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,001
Probability of flipping heads after three attempts
The answer by Henry +1 (and others as well) is much simpler. However, the method below is more general. If the problem is changed slightly, for instance that the probability of a coin landing heads becomes dependent on the number of coins being flipped, then the simple answer does not work anymore. I would model this with a Markov chain. Giving a matrix to get from state $i$ to state $j$ (let the $n$-th state mean "there are still $n$ coins left"): $$M_{i,j} = \begin{bmatrix} \frac{1}{8} & \frac{3}{8} & \frac{3}{8} & \frac{1}{8} \\ 0 & \frac{1}{4} & \frac{2}{4} & \frac{1}{4} \\ 0 & 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}$$ and solve for 3 turns (that is you compute $M^3$) which answer is $$(M_{i,j})^3 = \begin{bmatrix} \frac{1}{512} & \frac{21}{512} & \frac{147}{512} & \color{red}{\frac{343}{512}} \\ 0 & \frac{1}{64} & \frac{14}{64} & \frac{49}{64} \\ 0 & 0 & \frac{1}{8} & \frac{7}{8} \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}$$ Another related problem (for the interested) is to compute the expected number of turns. To do this you can equate the expectations for the number of steps neccesary in the $x$-th state by means of the other $0$-th to $x$-th state. E.g. $$\begin{array}{} E[T_3] &=& \frac{1}{8} (E[T_3]+1) &+&\frac{3}{8} (E[T_2]+1) &+&\frac{3}{8} (E[T_1]+1) &+& \frac{1}{8} (1)\\ E[T_2] &=& &&\frac{1}{4} (E[T_2]+1) &+&\frac{2}{4} (E[T_1]+1) &+& \frac{1}{4} (1)\\ E[T_1] &=& &&&&\frac{1}{2} (E[T_1]+1)&+& \frac{1}{2} (1) \end{array}$$ Which can be solved as a problem with 3 linear equations and 3 unknowns. This variant of your question is similar to the frog problem. (I imagine that the simpler method by Henry to compute the probability to still be in the game after $n$ turns with $m$ coins as $P(turns>n) = 1-\left(1- {1}/{2^n} \right)^m$ allows an alternative computation of the expectation. And to do it without Wolfram Alphha you would have to split it up into different terms. $P(turns>n;m=3) = 8^{-n} - 3 \times 4^{-n} + 3 \times 2^{-n} $ where the sums of the individual terms can be solved as sums of geometric series )
Probability of flipping heads after three attempts
The answer by Henry +1 (and others as well) is much simpler. However, the method below is more general. If the problem is changed slightly, for instance that the probability of a coin landing heads be
Probability of flipping heads after three attempts The answer by Henry +1 (and others as well) is much simpler. However, the method below is more general. If the problem is changed slightly, for instance that the probability of a coin landing heads becomes dependent on the number of coins being flipped, then the simple answer does not work anymore. I would model this with a Markov chain. Giving a matrix to get from state $i$ to state $j$ (let the $n$-th state mean "there are still $n$ coins left"): $$M_{i,j} = \begin{bmatrix} \frac{1}{8} & \frac{3}{8} & \frac{3}{8} & \frac{1}{8} \\ 0 & \frac{1}{4} & \frac{2}{4} & \frac{1}{4} \\ 0 & 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}$$ and solve for 3 turns (that is you compute $M^3$) which answer is $$(M_{i,j})^3 = \begin{bmatrix} \frac{1}{512} & \frac{21}{512} & \frac{147}{512} & \color{red}{\frac{343}{512}} \\ 0 & \frac{1}{64} & \frac{14}{64} & \frac{49}{64} \\ 0 & 0 & \frac{1}{8} & \frac{7}{8} \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}$$ Another related problem (for the interested) is to compute the expected number of turns. To do this you can equate the expectations for the number of steps neccesary in the $x$-th state by means of the other $0$-th to $x$-th state. E.g. $$\begin{array}{} E[T_3] &=& \frac{1}{8} (E[T_3]+1) &+&\frac{3}{8} (E[T_2]+1) &+&\frac{3}{8} (E[T_1]+1) &+& \frac{1}{8} (1)\\ E[T_2] &=& &&\frac{1}{4} (E[T_2]+1) &+&\frac{2}{4} (E[T_1]+1) &+& \frac{1}{4} (1)\\ E[T_1] &=& &&&&\frac{1}{2} (E[T_1]+1)&+& \frac{1}{2} (1) \end{array}$$ Which can be solved as a problem with 3 linear equations and 3 unknowns. This variant of your question is similar to the frog problem. (I imagine that the simpler method by Henry to compute the probability to still be in the game after $n$ turns with $m$ coins as $P(turns>n) = 1-\left(1- {1}/{2^n} \right)^m$ allows an alternative computation of the expectation. And to do it without Wolfram Alphha you would have to split it up into different terms. $P(turns>n;m=3) = 8^{-n} - 3 \times 4^{-n} + 3 \times 2^{-n} $ where the sums of the individual terms can be solved as sums of geometric series )
Probability of flipping heads after three attempts The answer by Henry +1 (and others as well) is much simpler. However, the method below is more general. If the problem is changed slightly, for instance that the probability of a coin landing heads be
18,002
Probability of flipping heads after three attempts
You can split the problem into two (independent) parts so it becomes easier to solve. Probability of flipping head for a coin after three attemps, the inverse of the probability of getting 3 tails in a row. $1-(\frac{1}{2}*\frac{1}{2}*\frac{1}{2})= \frac{7}{8}$ Probability of flipping all three coins after three attemps, it is the same as the probability of flipping head for a coin after three attemps (i.e. using the probability calculated before) happening three times in a row : $\frac{7}{8}*\frac{7}{8}*\frac{7}{8} = \frac{343}{512} $ ~= 67% Final Result: $\frac{343}{512}$
Probability of flipping heads after three attempts
You can split the problem into two (independent) parts so it becomes easier to solve. Probability of flipping head for a coin after three attemps, the inverse of the probability of getting 3 tails in
Probability of flipping heads after three attempts You can split the problem into two (independent) parts so it becomes easier to solve. Probability of flipping head for a coin after three attemps, the inverse of the probability of getting 3 tails in a row. $1-(\frac{1}{2}*\frac{1}{2}*\frac{1}{2})= \frac{7}{8}$ Probability of flipping all three coins after three attemps, it is the same as the probability of flipping head for a coin after three attemps (i.e. using the probability calculated before) happening three times in a row : $\frac{7}{8}*\frac{7}{8}*\frac{7}{8} = \frac{343}{512} $ ~= 67% Final Result: $\frac{343}{512}$
Probability of flipping heads after three attempts You can split the problem into two (independent) parts so it becomes easier to solve. Probability of flipping head for a coin after three attemps, the inverse of the probability of getting 3 tails in
18,003
Probability of flipping heads after three attempts
Okay, I think I've figured out the answer. Funny how typing everything out tends to clarify some incorrect assumptions at the same time. I believe that my second methodology is actually correct, but that the individual probabilities that I assigned to each case were incorrect. For example, I had assigned the probability of flipping one "heads" and two "tails" on the first attempt to be (1/2 * 1/2 * 1/2 = 1/8), but I don't think that's correct in this case, because HTT is the same as THT and TTH. So the probability for that is actually 3/8, as is the inverse case of HTT, THT, TTH. A similar concept exists for HH vs HT vs TT. HT is also TH, so that has a probability of 1/2, while HH and TT retain their assigned probability of 1/4. Given the above, the final formula is 1/8 + 3/16 + 3/32 + 3/32 + 3/128 + 1/512 + 3/128 + 3/256 + 1/64 = .57617 So you should expect that around 57.6% of the time you are able to get all heads in three attempts with three coins, without replacement.
Probability of flipping heads after three attempts
Okay, I think I've figured out the answer. Funny how typing everything out tends to clarify some incorrect assumptions at the same time. I believe that my second methodology is actually correct, but
Probability of flipping heads after three attempts Okay, I think I've figured out the answer. Funny how typing everything out tends to clarify some incorrect assumptions at the same time. I believe that my second methodology is actually correct, but that the individual probabilities that I assigned to each case were incorrect. For example, I had assigned the probability of flipping one "heads" and two "tails" on the first attempt to be (1/2 * 1/2 * 1/2 = 1/8), but I don't think that's correct in this case, because HTT is the same as THT and TTH. So the probability for that is actually 3/8, as is the inverse case of HTT, THT, TTH. A similar concept exists for HH vs HT vs TT. HT is also TH, so that has a probability of 1/2, while HH and TT retain their assigned probability of 1/4. Given the above, the final formula is 1/8 + 3/16 + 3/32 + 3/32 + 3/128 + 1/512 + 3/128 + 3/256 + 1/64 = .57617 So you should expect that around 57.6% of the time you are able to get all heads in three attempts with three coins, without replacement.
Probability of flipping heads after three attempts Okay, I think I've figured out the answer. Funny how typing everything out tends to clarify some incorrect assumptions at the same time. I believe that my second methodology is actually correct, but
18,004
Probability of flipping heads after three attempts
You can think about it as trying to flip heads with one coin with three attempts. After one attempt, the chance for H is 1/2. After two attempts (that is, you get T, and then H), the chance is 1/4. After three attempts (T, T, H), the chance is 1/8. Add it all up and the chance that you win this minigame is 7/8. In reverse, you lose by flipping T, T, T, with probability 1/8. As you have three coins, the actual game actually consists of three of these minigames, and you have to win all three of them to win the game. As the minigames are independent one another, you will have to calculate the probability of independent events, so the solution is just $\left(\frac{7}{8}\right)^3 = \frac{343}{512}$, very close to $\frac{2}{3}$ You can extend this game to n coins and m attempts of flipping all heads, and the probability of winning the game will be: $P_{n,m} = \left( \frac{2^m-1}{2^m} \right) ^ n$
Probability of flipping heads after three attempts
You can think about it as trying to flip heads with one coin with three attempts. After one attempt, the chance for H is 1/2. After two attempts (that is, you get T, and then H), the chance is 1/4. A
Probability of flipping heads after three attempts You can think about it as trying to flip heads with one coin with three attempts. After one attempt, the chance for H is 1/2. After two attempts (that is, you get T, and then H), the chance is 1/4. After three attempts (T, T, H), the chance is 1/8. Add it all up and the chance that you win this minigame is 7/8. In reverse, you lose by flipping T, T, T, with probability 1/8. As you have three coins, the actual game actually consists of three of these minigames, and you have to win all three of them to win the game. As the minigames are independent one another, you will have to calculate the probability of independent events, so the solution is just $\left(\frac{7}{8}\right)^3 = \frac{343}{512}$, very close to $\frac{2}{3}$ You can extend this game to n coins and m attempts of flipping all heads, and the probability of winning the game will be: $P_{n,m} = \left( \frac{2^m-1}{2^m} \right) ^ n$
Probability of flipping heads after three attempts You can think about it as trying to flip heads with one coin with three attempts. After one attempt, the chance for H is 1/2. After two attempts (that is, you get T, and then H), the chance is 1/4. A
18,005
Probability of flipping heads after three attempts
So there are 512 ways to get results when you toss 3 coins, that looks good. I think you're just missing a few nuances. It would help to the totals for each of the initial results (HHH, HHT, HTH, HTT, THH, THT, TTH, TTT) and make sure each one totals to 1/8th. For example you have to results for an initial throw of HHT: HHT, H = (1/16) HHT, T, H = (1/32) That only totals to 3/32 and it should be 4/32 or 1/8. You're missing the possibility that they throw HHT, T, T and never get all heads. Also your HTT results (4 through 9) are missing something. I think for the second throw you are considering only 3 results, HH, HT, and TT. There's a fourth result though, TH.
Probability of flipping heads after three attempts
So there are 512 ways to get results when you toss 3 coins, that looks good. I think you're just missing a few nuances. It would help to the totals for each of the initial results (HHH, HHT, HTH, HT
Probability of flipping heads after three attempts So there are 512 ways to get results when you toss 3 coins, that looks good. I think you're just missing a few nuances. It would help to the totals for each of the initial results (HHH, HHT, HTH, HTT, THH, THT, TTH, TTT) and make sure each one totals to 1/8th. For example you have to results for an initial throw of HHT: HHT, H = (1/16) HHT, T, H = (1/32) That only totals to 3/32 and it should be 4/32 or 1/8. You're missing the possibility that they throw HHT, T, T and never get all heads. Also your HTT results (4 through 9) are missing something. I think for the second throw you are considering only 3 results, HH, HT, and TT. There's a fourth result though, TH.
Probability of flipping heads after three attempts So there are 512 ways to get results when you toss 3 coins, that looks good. I think you're just missing a few nuances. It would help to the totals for each of the initial results (HHH, HHT, HTH, HT
18,006
Probability of flipping heads after three attempts
Rather than calculating it as stopping flipping a coin once that coin comes up heads, you should calculate the probability based on flipping each coin three times first, and then looking at whether any of the results were heads.
Probability of flipping heads after three attempts
Rather than calculating it as stopping flipping a coin once that coin comes up heads, you should calculate the probability based on flipping each coin three times first, and then looking at whether an
Probability of flipping heads after three attempts Rather than calculating it as stopping flipping a coin once that coin comes up heads, you should calculate the probability based on flipping each coin three times first, and then looking at whether any of the results were heads.
Probability of flipping heads after three attempts Rather than calculating it as stopping flipping a coin once that coin comes up heads, you should calculate the probability based on flipping each coin three times first, and then looking at whether an
18,007
Probability of flipping heads after three attempts
Unless I am missing something, this is a very basic problem. You are throwing 1 coin 3 times and looking for the probability they will all come up heads, correct? This is dictated by the binomial distribution. But simply, p(heads) on toss 1 = 0.5. Probability that toss 1 and toss 2 come up heads = 0.5*0.5 = 0.250. Probability that toss 1, 2, and 3 all come up heads = 0.5 * 0.5 * 0.5 = 0.125.
Probability of flipping heads after three attempts
Unless I am missing something, this is a very basic problem. You are throwing 1 coin 3 times and looking for the probability they will all come up heads, correct? This is dictated by the binomial dis
Probability of flipping heads after three attempts Unless I am missing something, this is a very basic problem. You are throwing 1 coin 3 times and looking for the probability they will all come up heads, correct? This is dictated by the binomial distribution. But simply, p(heads) on toss 1 = 0.5. Probability that toss 1 and toss 2 come up heads = 0.5*0.5 = 0.250. Probability that toss 1, 2, and 3 all come up heads = 0.5 * 0.5 * 0.5 = 0.125.
Probability of flipping heads after three attempts Unless I am missing something, this is a very basic problem. You are throwing 1 coin 3 times and looking for the probability they will all come up heads, correct? This is dictated by the binomial dis
18,008
Probability of flipping heads after three attempts
Even simpler. There are eight possible outcomes (HHH, HHT, HTH, THH, HTT, THT, TTH, TTT)and only one does not contain a heads. If you stop after one or two throws makes no difference.
Probability of flipping heads after three attempts
Even simpler. There are eight possible outcomes (HHH, HHT, HTH, THH, HTT, THT, TTH, TTT)and only one does not contain a heads. If you stop after one or two throws makes no difference.
Probability of flipping heads after three attempts Even simpler. There are eight possible outcomes (HHH, HHT, HTH, THH, HTT, THT, TTH, TTT)and only one does not contain a heads. If you stop after one or two throws makes no difference.
Probability of flipping heads after three attempts Even simpler. There are eight possible outcomes (HHH, HHT, HTH, THH, HTT, THT, TTH, TTT)and only one does not contain a heads. If you stop after one or two throws makes no difference.
18,009
Is there a simple way of detecting outliers?
There is no simple sound way to remove outliers. Outliers can be of two kinds: 1) Data entry errors. These are often the easiest to spot and always the easiest to deal with. If you can find the right data, correct it; if not, delete it. 2) Legitimate data that is unusual. This is much trickier. For bivariate data like yours, the outlier could be univariate or bivariate. a) Univariate. First, "unusual" depends on the distribution and the sample size. You give us the sample size of 350, but what is the distribution? It clearly isn't normal, since it's a relatively small integer. What is unusual under a Poisson would not be under a negative binomial. I'd kind of suspect a zero-inflated negative binomial relationship. But even when you have the distribution, the (possible) outliers will affect the parameters. You can look at "leave one out" distributions, where you check if data point q would be an outlier if the data had all points but q. Even then, though, what if there are multiple outliers? b) Bivariate. This is where neither variable's value is unusual in itself, but together they are odd. There is a possibly apocryphal report that the census once said there were 20,000 12 year old widows in the USA. 12 year olds aren't unusual, widows aren't either, but 12 year old widows are. Given all this, it might be simpler to report a robust measure of relationship.
Is there a simple way of detecting outliers?
There is no simple sound way to remove outliers. Outliers can be of two kinds: 1) Data entry errors. These are often the easiest to spot and always the easiest to deal with. If you can find the right
Is there a simple way of detecting outliers? There is no simple sound way to remove outliers. Outliers can be of two kinds: 1) Data entry errors. These are often the easiest to spot and always the easiest to deal with. If you can find the right data, correct it; if not, delete it. 2) Legitimate data that is unusual. This is much trickier. For bivariate data like yours, the outlier could be univariate or bivariate. a) Univariate. First, "unusual" depends on the distribution and the sample size. You give us the sample size of 350, but what is the distribution? It clearly isn't normal, since it's a relatively small integer. What is unusual under a Poisson would not be under a negative binomial. I'd kind of suspect a zero-inflated negative binomial relationship. But even when you have the distribution, the (possible) outliers will affect the parameters. You can look at "leave one out" distributions, where you check if data point q would be an outlier if the data had all points but q. Even then, though, what if there are multiple outliers? b) Bivariate. This is where neither variable's value is unusual in itself, but together they are odd. There is a possibly apocryphal report that the census once said there were 20,000 12 year old widows in the USA. 12 year olds aren't unusual, widows aren't either, but 12 year old widows are. Given all this, it might be simpler to report a robust measure of relationship.
Is there a simple way of detecting outliers? There is no simple sound way to remove outliers. Outliers can be of two kinds: 1) Data entry errors. These are often the easiest to spot and always the easiest to deal with. If you can find the right
18,010
Is there a simple way of detecting outliers?
I have done a lot of research on outliers, particularly when I worked on energy data validation at Oak Ridge from 1978 to 1980. There are formal tests for univariate outliers for normal data (e.g. Grubbs' test and Dixon's ratio test). There are tests for multivariate outliers and time series. The book by Barnett and Lewis on "Outliers in Statistical Data" is the bible on outliers and covers just about everything. When I was at Oak Ridge working on data validation we had large multivariate data sets. For univariate outliers, there is a direction for extremes (highly above the mean and highly below the mean). But for multivariate outliers there are many directions to look for outliers. Our philosophy was to consider what the intended use of the data is. If you are trying to estimate certain parameters such as a bivariate correlation or a regression coefficient then you want to look in the direction that provides the greatest effect on the parameter of interest. At that time I had read Mallows' unpublished paper on influence functions. The use of influence functions to detect outliers is covered in Gnanadesikan's multivariate analysis book. Of course, you can find it in Barnett and Lewis also. The influence function for a parameter is defined at points in the multivariate space of the observations and essentially measures the difference between the parameter estimate when the data point is included compared with when it is left out. You can do such estimates with each sample point but usually, you can derive a nice functional form for the influence function that gives insight and faster computation. For example in my paper in the American Journal of Mathematical and Management Science in 1982 "The Influence Function and Its Application to Data Validation" I show the analytic formula for the influence function for bivariate correlation and that the contours of constant influence are hyperbolae. So the contours show the direction in the plane where the influence function increases the fastest. In my paper, I show how we applied the influence function for bivariate correlation with the FPC Form 4 data on generation and consumption of energy. There is a clear high positive correlation between the two and we found a few outliers that were highly influential on the estimate of correlation. Further investigation showed that at least one of the points was in error and we were able to correct it. But an important point that I always mention when discussing outliers is that automatic rejection is wrong. The outlier is not always an error and sometimes it provides important information about the data. Valid data should not be removed just because it doesn't conform with our theory of reality. Whether or not it is difficult to do, the reason why the outlier occurred should always be investigated. I should mention that this is not the first time multivariate outliers have been discussed on this site. A search for outliers would probably lead to several questions where multivariate outliers have been discussed. I know that I have referenced my paper and these books before and given links to them. Also when outlier rejection is discussed many of us on this site have recommended against it especially if it is done based solely on a statistical test. Peter Huber often mentions robust estimation as an alternative to outlier rejection. The idea is that robust procedures will downweight the outliers reducing their effect on estimation without the heavy-handed step of rejecting them and using a non-robust estimator. The influence function was actually originally developed by Frank Hampel in his PhD dissertation in the early 1970s (1974 I think). His idea was actually to use influence functions to identify estimators that were not robust against outliers and to help develop robust estimators. Here is a link to a previous discussion on this topic where I mentioned some work of mine on detecting outliers in time series using influence functions.
Is there a simple way of detecting outliers?
I have done a lot of research on outliers, particularly when I worked on energy data validation at Oak Ridge from 1978 to 1980. There are formal tests for univariate outliers for normal data (e.g. Gru
Is there a simple way of detecting outliers? I have done a lot of research on outliers, particularly when I worked on energy data validation at Oak Ridge from 1978 to 1980. There are formal tests for univariate outliers for normal data (e.g. Grubbs' test and Dixon's ratio test). There are tests for multivariate outliers and time series. The book by Barnett and Lewis on "Outliers in Statistical Data" is the bible on outliers and covers just about everything. When I was at Oak Ridge working on data validation we had large multivariate data sets. For univariate outliers, there is a direction for extremes (highly above the mean and highly below the mean). But for multivariate outliers there are many directions to look for outliers. Our philosophy was to consider what the intended use of the data is. If you are trying to estimate certain parameters such as a bivariate correlation or a regression coefficient then you want to look in the direction that provides the greatest effect on the parameter of interest. At that time I had read Mallows' unpublished paper on influence functions. The use of influence functions to detect outliers is covered in Gnanadesikan's multivariate analysis book. Of course, you can find it in Barnett and Lewis also. The influence function for a parameter is defined at points in the multivariate space of the observations and essentially measures the difference between the parameter estimate when the data point is included compared with when it is left out. You can do such estimates with each sample point but usually, you can derive a nice functional form for the influence function that gives insight and faster computation. For example in my paper in the American Journal of Mathematical and Management Science in 1982 "The Influence Function and Its Application to Data Validation" I show the analytic formula for the influence function for bivariate correlation and that the contours of constant influence are hyperbolae. So the contours show the direction in the plane where the influence function increases the fastest. In my paper, I show how we applied the influence function for bivariate correlation with the FPC Form 4 data on generation and consumption of energy. There is a clear high positive correlation between the two and we found a few outliers that were highly influential on the estimate of correlation. Further investigation showed that at least one of the points was in error and we were able to correct it. But an important point that I always mention when discussing outliers is that automatic rejection is wrong. The outlier is not always an error and sometimes it provides important information about the data. Valid data should not be removed just because it doesn't conform with our theory of reality. Whether or not it is difficult to do, the reason why the outlier occurred should always be investigated. I should mention that this is not the first time multivariate outliers have been discussed on this site. A search for outliers would probably lead to several questions where multivariate outliers have been discussed. I know that I have referenced my paper and these books before and given links to them. Also when outlier rejection is discussed many of us on this site have recommended against it especially if it is done based solely on a statistical test. Peter Huber often mentions robust estimation as an alternative to outlier rejection. The idea is that robust procedures will downweight the outliers reducing their effect on estimation without the heavy-handed step of rejecting them and using a non-robust estimator. The influence function was actually originally developed by Frank Hampel in his PhD dissertation in the early 1970s (1974 I think). His idea was actually to use influence functions to identify estimators that were not robust against outliers and to help develop robust estimators. Here is a link to a previous discussion on this topic where I mentioned some work of mine on detecting outliers in time series using influence functions.
Is there a simple way of detecting outliers? I have done a lot of research on outliers, particularly when I worked on energy data validation at Oak Ridge from 1978 to 1980. There are formal tests for univariate outliers for normal data (e.g. Gru
18,011
Is there a simple way of detecting outliers?
Another simple approach to dealing with outliers is to use non-parametric statistics. Probably with your sample size a Spearman's rho would work well as an index of the correlation. (Note, though, that non-parametric, rank-order statistics do not help you much with non-linear relationships.) If you want to use a Pearson's r (a parametric statistic), and if you are not able to compute Cook's distance, you might use a standard rule of thumb that any data point that is more than 2.67 standard deviations (s.d.) from the mean, or 4.67 s.d. from the mean is an outlier or extreme, respectively. These are typical cutoff values for outliers and extreme data points that are used in one standard statistical analysis program (SPSS). Just because a data point is an outlier does not mean it is bad data to be discarded. You might compute your correlation with and without extreme points and go from there.
Is there a simple way of detecting outliers?
Another simple approach to dealing with outliers is to use non-parametric statistics. Probably with your sample size a Spearman's rho would work well as an index of the correlation. (Note, though, th
Is there a simple way of detecting outliers? Another simple approach to dealing with outliers is to use non-parametric statistics. Probably with your sample size a Spearman's rho would work well as an index of the correlation. (Note, though, that non-parametric, rank-order statistics do not help you much with non-linear relationships.) If you want to use a Pearson's r (a parametric statistic), and if you are not able to compute Cook's distance, you might use a standard rule of thumb that any data point that is more than 2.67 standard deviations (s.d.) from the mean, or 4.67 s.d. from the mean is an outlier or extreme, respectively. These are typical cutoff values for outliers and extreme data points that are used in one standard statistical analysis program (SPSS). Just because a data point is an outlier does not mean it is bad data to be discarded. You might compute your correlation with and without extreme points and go from there.
Is there a simple way of detecting outliers? Another simple approach to dealing with outliers is to use non-parametric statistics. Probably with your sample size a Spearman's rho would work well as an index of the correlation. (Note, though, th
18,012
Is there a simple way of detecting outliers?
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. You might want to try Cook's Distance. See the wikipedia article for suggested cutoffs. Also, if you are heading toward some regression model, then you may wish to try robust regression.
Is there a simple way of detecting outliers?
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.
Is there a simple way of detecting outliers? 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. You might want to try Cook's Distance. See the wikipedia article for suggested cutoffs. Also, if you are heading toward some regression model, then you may wish to try robust regression.
Is there a simple way of detecting outliers? 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,013
Is there a simple way of detecting outliers?
Firstly, don't remove atypical values unless you are sure that are out of the study! They may contain some important information (variability). You should drop them if it's obvious that the outlier is due to incorrectly entered or measured data. If you don't know the sampling method used to obtain your data, then you should identify atypical values and their effects as follows: Degree of abnormality: it is expected a 5% of the observations with standarized residuals ($e_i*$) > 2. If you have some more higher residuals you can suspect outliers. Degree of distance to the center gravity in the space of x's: $h_{ii}$ (leverage). When some $h_{ii}$ is very high you have an observation that may distort your model because is out of the range of your study. Degree of influence on the fitted model: Influential points are those which have enough weight to change your model. Then, cofficients of fitted model using all n observations are very different from coefficients of the fitted model using all points but not this observation $i$-th. Cook's distance or Cook's D is a commonly used estimate of the influence of a data point. : $DC_i=ei*^2·h_{ii}/[(1-h_{ii})·p]$ Possible solutions: Transforming variables and / or adding new variables to the model. For influential observations which are nothing but outliers, if not many, you can remove those individuals.
Is there a simple way of detecting outliers?
Firstly, don't remove atypical values unless you are sure that are out of the study! They may contain some important information (variability). You should drop them if it's obvious that the outlier is
Is there a simple way of detecting outliers? Firstly, don't remove atypical values unless you are sure that are out of the study! They may contain some important information (variability). You should drop them if it's obvious that the outlier is due to incorrectly entered or measured data. If you don't know the sampling method used to obtain your data, then you should identify atypical values and their effects as follows: Degree of abnormality: it is expected a 5% of the observations with standarized residuals ($e_i*$) > 2. If you have some more higher residuals you can suspect outliers. Degree of distance to the center gravity in the space of x's: $h_{ii}$ (leverage). When some $h_{ii}$ is very high you have an observation that may distort your model because is out of the range of your study. Degree of influence on the fitted model: Influential points are those which have enough weight to change your model. Then, cofficients of fitted model using all n observations are very different from coefficients of the fitted model using all points but not this observation $i$-th. Cook's distance or Cook's D is a commonly used estimate of the influence of a data point. : $DC_i=ei*^2·h_{ii}/[(1-h_{ii})·p]$ Possible solutions: Transforming variables and / or adding new variables to the model. For influential observations which are nothing but outliers, if not many, you can remove those individuals.
Is there a simple way of detecting outliers? Firstly, don't remove atypical values unless you are sure that are out of the study! They may contain some important information (variability). You should drop them if it's obvious that the outlier is
18,014
Is there a simple way of detecting outliers?
Distinguish identifying outliers (which many others have answered about) from removing them. The outliers may be the most interesting finding in your study. Some people may eat fast food often and be much more physically active than most others. Why? Launching an initiative to figure that out may be the most important outcome of your study. Outliers are unusual. That could be because of an error in data collection or recording, in which case removing from analysis might make sense. Or it could be due to some other reason that is worth tracking down! Don't remove the most interesting data in your study just because the values are unusual!
Is there a simple way of detecting outliers?
Distinguish identifying outliers (which many others have answered about) from removing them. The outliers may be the most interesting finding in your study. Some people may eat fast food often and be
Is there a simple way of detecting outliers? Distinguish identifying outliers (which many others have answered about) from removing them. The outliers may be the most interesting finding in your study. Some people may eat fast food often and be much more physically active than most others. Why? Launching an initiative to figure that out may be the most important outcome of your study. Outliers are unusual. That could be because of an error in data collection or recording, in which case removing from analysis might make sense. Or it could be due to some other reason that is worth tracking down! Don't remove the most interesting data in your study just because the values are unusual!
Is there a simple way of detecting outliers? Distinguish identifying outliers (which many others have answered about) from removing them. The outliers may be the most interesting finding in your study. Some people may eat fast food often and be
18,015
Show average instead of median in boxplot [closed]
This code makes the boxplots then places a circle marking the mean for each box. You can use a different symbol by specifying the marker argument in the call to scatter. import numpy as np import pylab # 3 boxes data = [[np.random.rand(100)] for i in range(3)] pylab.boxplot(data) # mark the mean means = [np.mean(x) for x in data] pylab.scatter([1, 2, 3], means)
Show average instead of median in boxplot [closed]
This code makes the boxplots then places a circle marking the mean for each box. You can use a different symbol by specifying the marker argument in the call to scatter. import numpy as np import pyl
Show average instead of median in boxplot [closed] This code makes the boxplots then places a circle marking the mean for each box. You can use a different symbol by specifying the marker argument in the call to scatter. import numpy as np import pylab # 3 boxes data = [[np.random.rand(100)] for i in range(3)] pylab.boxplot(data) # mark the mean means = [np.mean(x) for x in data] pylab.scatter([1, 2, 3], means)
Show average instead of median in boxplot [closed] This code makes the boxplots then places a circle marking the mean for each box. You can use a different symbol by specifying the marker argument in the call to scatter. import numpy as np import pyl
18,016
Show average instead of median in boxplot [closed]
To answer your second question: Yes, I think it will be confusing to put the line at the mean instead of the median. The precise rules controlling the length of the 'whiskers' (if any) and treatment of outliers vary, but everyone keeps to Tukey's use of the box as displaying the median and lower and upper quartiles. For highly skew distributions, the mean could be outside the box, which would look very odd. Common usage is that the median goes with the interquartile range, while the mean goes with standard deviation (or standard error of the mean if you're interested in inference rather than data description). If you want to show the mean visually, i'd use a different symbol to display it to avoid confusion.
Show average instead of median in boxplot [closed]
To answer your second question: Yes, I think it will be confusing to put the line at the mean instead of the median. The precise rules controlling the length of the 'whiskers' (if any) and treatment o
Show average instead of median in boxplot [closed] To answer your second question: Yes, I think it will be confusing to put the line at the mean instead of the median. The precise rules controlling the length of the 'whiskers' (if any) and treatment of outliers vary, but everyone keeps to Tukey's use of the box as displaying the median and lower and upper quartiles. For highly skew distributions, the mean could be outside the box, which would look very odd. Common usage is that the median goes with the interquartile range, while the mean goes with standard deviation (or standard error of the mean if you're interested in inference rather than data description). If you want to show the mean visually, i'd use a different symbol to display it to avoid confusion.
Show average instead of median in boxplot [closed] To answer your second question: Yes, I think it will be confusing to put the line at the mean instead of the median. The precise rules controlling the length of the 'whiskers' (if any) and treatment o
18,017
Is the median preserved for any strictly monotonic mapping?
The conjecture is true and your disproof is flawed. The flaw in your steps occurs when you make a change-of-variables in the initial step but do not change the range of integration accordingly. While it is not the simplest method of proof (see here for a simpler approach using the CDF), you could construct a proof of this result using the density functions along the lines you are trying. If $g$ is strictly increasing and differentiable you have $g'(x) \geqslant 0$ for all $x \in\mathbb{R}$, which then gives: $$\begin{align} \int \limits_{-\infty}^{y_0} f_Y(y) \ dy &= \int \limits_{-\infty}^{g(x_0)} f_Y(y) \ dy \\[6pt] &= \int \limits_{-\infty}^{x_0} f_Y(g(x)) \cdot \frac{dy}{dx} \ dx \\[6pt] &= \int \limits_{-\infty}^{x_0} f_Y(g(x)) \cdot g'(x) \ dx \\[6pt] &= \int \limits_{-\infty}^{x_0} f_X(x) \ dx \\[12pt] &= \frac{1}{2}. \\[6pt] \end{align}$$ When proving this result, I would also recommend you tighten up your assertion that you can use increasing $g$ without a loss of generality. You need to make it clear why the decreasing case is analogous to the increasing case. This is related to the formula for transformation of random variables for monotonic transformations.
Is the median preserved for any strictly monotonic mapping?
The conjecture is true and your disproof is flawed. The flaw in your steps occurs when you make a change-of-variables in the initial step but do not change the range of integration accordingly. Whil
Is the median preserved for any strictly monotonic mapping? The conjecture is true and your disproof is flawed. The flaw in your steps occurs when you make a change-of-variables in the initial step but do not change the range of integration accordingly. While it is not the simplest method of proof (see here for a simpler approach using the CDF), you could construct a proof of this result using the density functions along the lines you are trying. If $g$ is strictly increasing and differentiable you have $g'(x) \geqslant 0$ for all $x \in\mathbb{R}$, which then gives: $$\begin{align} \int \limits_{-\infty}^{y_0} f_Y(y) \ dy &= \int \limits_{-\infty}^{g(x_0)} f_Y(y) \ dy \\[6pt] &= \int \limits_{-\infty}^{x_0} f_Y(g(x)) \cdot \frac{dy}{dx} \ dx \\[6pt] &= \int \limits_{-\infty}^{x_0} f_Y(g(x)) \cdot g'(x) \ dx \\[6pt] &= \int \limits_{-\infty}^{x_0} f_X(x) \ dx \\[12pt] &= \frac{1}{2}. \\[6pt] \end{align}$$ When proving this result, I would also recommend you tighten up your assertion that you can use increasing $g$ without a loss of generality. You need to make it clear why the decreasing case is analogous to the increasing case. This is related to the formula for transformation of random variables for monotonic transformations.
Is the median preserved for any strictly monotonic mapping? The conjecture is true and your disproof is flawed. The flaw in your steps occurs when you make a change-of-variables in the initial step but do not change the range of integration accordingly. Whil
18,018
Is the median preserved for any strictly monotonic mapping?
Here is a generalization. It is intended to reveal which properties of probability are involved in the result. It turns out that density functions are irrelevant. Any number $\mu$ determines two events relative to the random variable $X$: $\mathscr E^-_\mu(X): X \le \mu$ and $\mathscr E^+_\mu: X \ge \mu.$ Any (strictly) monotonic transformation $g$ either preserves these events or reverses them, in the sense that the two sets $g(E^{\pm}_\mu(X))$ are the two sets $E^{\pm}_{g(\mu)}(g(X)).$ This follows immediately from the definition of (strict) monotonicity as preserving equality and either preserving or reversing strict inequality. When $0\lt q \lt 1$ is a probability, it defines a nonempty set of numbers -- any one of which can be called the $q^{\text{th}}$ quantile of $X$ -- consisting of all $\mu_q$ for which $\Pr(E^-_{\mu_q}(X)) \ge q$ and $\Pr(E^+_{\mu_q}(X)) \ge 1-q.$ (Proof: start with a very large number $\alpha$ and decrease it as long as $\Pr(E^-_{\alpha}(X)) \ge q$. Start with a very small number $\beta$ and increase it as long as $\Pr(E^+_{\beta}(X))\ge 1-q.$ If $\alpha \gt \beta,$ there exists $\gamma$ strictly between $\alpha$ and $\beta$ that, by construction, satisfies $\Pr(E^-_{\gamma}(X)) \lt q$ (because $\gamma \lt \alpha$) and $\Pr(E^+_{\gamma}(X)) \lt 1-q$ (because $\gamma \gt \beta$). But then $$1 = \Pr(\mathbb R) = \Pr(E^-_{\gamma}(X)\cup E^+_{\gamma}(X)) \lt \Pr(E^-_{\gamma}(X)) + \Pr(E^+_{\gamma}(X)) \lt q + 1-q = 1,$$ a contradiction. Notice how this constructive demonstration relies only on two simple probability axioms and a basic property of real numbers.) The $q$ quantiles of $X$ are defined to be the interval $[\alpha,\beta],$ which we have seen is nonempty. As a matter of temporary notation, denote such a set by $X[q].$ Putting these two observations together, we conclude that any strictly monotonically increasing transformation $g$ maps quantiles to quantiles (that is, $g(X[q]) \subseteq g(X)[q]$ for all $q\in(0,1)$) while a strictly monotonically decreasing transformation maps the $q$ quantiles into the $1-q$ quantiles (that is, $g(X[q])\subseteq g(X)[1-q]$). (As @Ilmari Karonen kindly points out in comments, $g$ is guaranteed to preserve quantiles when it is continuous, for then it will have an inverse that maps quantiles back into quantiles.) Applying this to the case $q=1/2=1-q$ shows that $g$ preserves medians as sets. When the median is unique (a singleton set), the median of $g(X)$ therefore is $g$ applied to the median of $X.$ You may wish to show that when $X$ has a density function defined in a neighborhood of its $q$ quantile and is not identically zero in any such neighborhood, it has a unique $q$ quantile: that is, $X[q]$ is a singleton.
Is the median preserved for any strictly monotonic mapping?
Here is a generalization. It is intended to reveal which properties of probability are involved in the result. It turns out that density functions are irrelevant. Any number $\mu$ determines two ev
Is the median preserved for any strictly monotonic mapping? Here is a generalization. It is intended to reveal which properties of probability are involved in the result. It turns out that density functions are irrelevant. Any number $\mu$ determines two events relative to the random variable $X$: $\mathscr E^-_\mu(X): X \le \mu$ and $\mathscr E^+_\mu: X \ge \mu.$ Any (strictly) monotonic transformation $g$ either preserves these events or reverses them, in the sense that the two sets $g(E^{\pm}_\mu(X))$ are the two sets $E^{\pm}_{g(\mu)}(g(X)).$ This follows immediately from the definition of (strict) monotonicity as preserving equality and either preserving or reversing strict inequality. When $0\lt q \lt 1$ is a probability, it defines a nonempty set of numbers -- any one of which can be called the $q^{\text{th}}$ quantile of $X$ -- consisting of all $\mu_q$ for which $\Pr(E^-_{\mu_q}(X)) \ge q$ and $\Pr(E^+_{\mu_q}(X)) \ge 1-q.$ (Proof: start with a very large number $\alpha$ and decrease it as long as $\Pr(E^-_{\alpha}(X)) \ge q$. Start with a very small number $\beta$ and increase it as long as $\Pr(E^+_{\beta}(X))\ge 1-q.$ If $\alpha \gt \beta,$ there exists $\gamma$ strictly between $\alpha$ and $\beta$ that, by construction, satisfies $\Pr(E^-_{\gamma}(X)) \lt q$ (because $\gamma \lt \alpha$) and $\Pr(E^+_{\gamma}(X)) \lt 1-q$ (because $\gamma \gt \beta$). But then $$1 = \Pr(\mathbb R) = \Pr(E^-_{\gamma}(X)\cup E^+_{\gamma}(X)) \lt \Pr(E^-_{\gamma}(X)) + \Pr(E^+_{\gamma}(X)) \lt q + 1-q = 1,$$ a contradiction. Notice how this constructive demonstration relies only on two simple probability axioms and a basic property of real numbers.) The $q$ quantiles of $X$ are defined to be the interval $[\alpha,\beta],$ which we have seen is nonempty. As a matter of temporary notation, denote such a set by $X[q].$ Putting these two observations together, we conclude that any strictly monotonically increasing transformation $g$ maps quantiles to quantiles (that is, $g(X[q]) \subseteq g(X)[q]$ for all $q\in(0,1)$) while a strictly monotonically decreasing transformation maps the $q$ quantiles into the $1-q$ quantiles (that is, $g(X[q])\subseteq g(X)[1-q]$). (As @Ilmari Karonen kindly points out in comments, $g$ is guaranteed to preserve quantiles when it is continuous, for then it will have an inverse that maps quantiles back into quantiles.) Applying this to the case $q=1/2=1-q$ shows that $g$ preserves medians as sets. When the median is unique (a singleton set), the median of $g(X)$ therefore is $g$ applied to the median of $X.$ You may wish to show that when $X$ has a density function defined in a neighborhood of its $q$ quantile and is not identically zero in any such neighborhood, it has a unique $q$ quantile: that is, $X[q]$ is a singleton.
Is the median preserved for any strictly monotonic mapping? Here is a generalization. It is intended to reveal which properties of probability are involved in the result. It turns out that density functions are irrelevant. Any number $\mu$ determines two ev
18,019
Is the median preserved for any strictly monotonic mapping?
By definition, $m$ is a median of the random variable $X$ if and only if $$\mathrm{Pr}[X ≤ m] ≥ \tfrac12 \text{ and } \mathrm{Pr}[X ≥ m] ≥ \tfrac12.$$ (Note that, in general, $X$ may have multiple medians if there is an interval of values satisfying the definition, and that it's possible for either or both probabilities to be strictly greater than $\tfrac12$ if $\mathrm{Pr}[X = m] > 0$.) Also by definition, a function $g: \mathbb R \to \mathbb R$ is monotone increasing if and only if $$a ≤ b \implies g(a) ≤ g(b)$$ for all $a,b \in \mathbb R$. (A function $g$ is called strictly monotone increasing if $a < b \implies g(a) < g(b)$, but we don't actually need this stronger property here.) Now, let $m$ be a median of $X$ and let $g$ be monotone increasing. Then $X ≤ m \implies g(X) ≤ g(m)$ (and $X ≥ m \implies g(X) ≥ g(m)$), and thus $$\begin{aligned} \mathrm{Pr}[g(X) ≤ g(m)] ≥ \mathrm{Pr}[X ≤ m] &≥ \tfrac12 \text{ and } \\ \mathrm{Pr}[g(X) ≥ g(m)] ≥ \mathrm{Pr}[X ≥ m] &≥ \tfrac12. \end{aligned}$$ In other words, if $m$ is a median of $X$ and $g$ is monotone increasing, then $g(m)$ is a median of $g(X)$. Ps. Note that the result above holds for any real-valued random variable $X$ and any monotone increasing function $g$, even if the medians of $X$ and/or $g(X)$ are not uniquely defined. However, it only guarantees that $g(m)$ is some median of $g(X)$, but not that any particular rule for picking a "canonical" median $m$ for $X$ — such always taking the low end, high end or the midpoint of the interval of possible medians — will necessarily yield $g(m)$ when applied to the distribution of $g(X)$. Also, if the function $g$ is discontinuous, $g(X)$ may have multiple medians even if $X$ does not, while if $g$ is not strictly increasing, $X$ may have multiple medians even if $g(X)$ does not. And if $g$ is not strictly increasing, then it's also possible for $g(m)$ to be a median of $g(X)$ even if $m$ is not a median of $X$. In particular, even if we define $\operatorname{median}[X]$ to be the set of all medians of $X$, the most we can say in general is that $g(\operatorname{median}[X]) \subseteq \operatorname{median}[g(X)]$. Pps. The result above can also be straightforwardly generalized to arbitrary quantiles by defining $m$ to be a $p$-quantile of $X$ (for some $p \in [0,1]$) if and only if $$\mathrm{Pr}[X ≤ m] ≥ p \text{ and } \mathrm{Pr}[X ≥ m] ≥ 1-p$$ and using essentially the same proof to show that, if $g$ is monotone increasing, then $g(m)$ is a $p$-quantile of $g(X)$.
Is the median preserved for any strictly monotonic mapping?
By definition, $m$ is a median of the random variable $X$ if and only if $$\mathrm{Pr}[X ≤ m] ≥ \tfrac12 \text{ and } \mathrm{Pr}[X ≥ m] ≥ \tfrac12.$$ (Note that, in general, $X$ may have multiple med
Is the median preserved for any strictly monotonic mapping? By definition, $m$ is a median of the random variable $X$ if and only if $$\mathrm{Pr}[X ≤ m] ≥ \tfrac12 \text{ and } \mathrm{Pr}[X ≥ m] ≥ \tfrac12.$$ (Note that, in general, $X$ may have multiple medians if there is an interval of values satisfying the definition, and that it's possible for either or both probabilities to be strictly greater than $\tfrac12$ if $\mathrm{Pr}[X = m] > 0$.) Also by definition, a function $g: \mathbb R \to \mathbb R$ is monotone increasing if and only if $$a ≤ b \implies g(a) ≤ g(b)$$ for all $a,b \in \mathbb R$. (A function $g$ is called strictly monotone increasing if $a < b \implies g(a) < g(b)$, but we don't actually need this stronger property here.) Now, let $m$ be a median of $X$ and let $g$ be monotone increasing. Then $X ≤ m \implies g(X) ≤ g(m)$ (and $X ≥ m \implies g(X) ≥ g(m)$), and thus $$\begin{aligned} \mathrm{Pr}[g(X) ≤ g(m)] ≥ \mathrm{Pr}[X ≤ m] &≥ \tfrac12 \text{ and } \\ \mathrm{Pr}[g(X) ≥ g(m)] ≥ \mathrm{Pr}[X ≥ m] &≥ \tfrac12. \end{aligned}$$ In other words, if $m$ is a median of $X$ and $g$ is monotone increasing, then $g(m)$ is a median of $g(X)$. Ps. Note that the result above holds for any real-valued random variable $X$ and any monotone increasing function $g$, even if the medians of $X$ and/or $g(X)$ are not uniquely defined. However, it only guarantees that $g(m)$ is some median of $g(X)$, but not that any particular rule for picking a "canonical" median $m$ for $X$ — such always taking the low end, high end or the midpoint of the interval of possible medians — will necessarily yield $g(m)$ when applied to the distribution of $g(X)$. Also, if the function $g$ is discontinuous, $g(X)$ may have multiple medians even if $X$ does not, while if $g$ is not strictly increasing, $X$ may have multiple medians even if $g(X)$ does not. And if $g$ is not strictly increasing, then it's also possible for $g(m)$ to be a median of $g(X)$ even if $m$ is not a median of $X$. In particular, even if we define $\operatorname{median}[X]$ to be the set of all medians of $X$, the most we can say in general is that $g(\operatorname{median}[X]) \subseteq \operatorname{median}[g(X)]$. Pps. The result above can also be straightforwardly generalized to arbitrary quantiles by defining $m$ to be a $p$-quantile of $X$ (for some $p \in [0,1]$) if and only if $$\mathrm{Pr}[X ≤ m] ≥ p \text{ and } \mathrm{Pr}[X ≥ m] ≥ 1-p$$ and using essentially the same proof to show that, if $g$ is monotone increasing, then $g(m)$ is a $p$-quantile of $g(X)$.
Is the median preserved for any strictly monotonic mapping? By definition, $m$ is a median of the random variable $X$ if and only if $$\mathrm{Pr}[X ≤ m] ≥ \tfrac12 \text{ and } \mathrm{Pr}[X ≥ m] ≥ \tfrac12.$$ (Note that, in general, $X$ may have multiple med
18,020
Is the median preserved for any strictly monotonic mapping?
The claim is obviously true for a discrete variable (i.e. we consider a probability distribution over a finite number of events): given a set $A$, the median is a number $a_0$ such that $\sum_{\{a: a \leq a_0\}}p(a)=\sum_{\{a: a \geq a_0\}}p(a)$. Clearly, $\sum_{\{g(a): g(a)\leq g(a_0)\}}p(g(a))=\sum_{\{a: a\leq a_0\}}p(a)$, and $\sum_{\{g(a): g(a) \geq g(a_0)\}}p(g(a))=\sum_{\{a: a \geq a_0\}}p(a)$, so $\sum_{\{g(a): g(a)\leq g(a_0)\}}p(g(a))= \sum_{\{g(a): g(a) \geq g(a_0)\}}p(g(a))$ We can then extend it to the continuous case by taking Reimann sums: partition the domain into a finite number of intervals, find the probability density of the interval, and multiply by the size of the interval. Then we let the lengths of the intervals go to zero. When we transform an interval by $g$, we multiply the length of the interval by $g'$, and divide the probability density by $g'$, so the total probability mass is unchanged. This is a bit handwavy, since we need to take this "in the limit" for $g'$ to be constant over the interval, but the basic concept should be reasonably intuitive. The error in your logic is that you essentially only changed the probability density, and ignored that since each interval will be scaled, the overall domain is also scaled.
Is the median preserved for any strictly monotonic mapping?
The claim is obviously true for a discrete variable (i.e. we consider a probability distribution over a finite number of events): given a set $A$, the median is a number $a_0$ such that $\sum_{\{a: a
Is the median preserved for any strictly monotonic mapping? The claim is obviously true for a discrete variable (i.e. we consider a probability distribution over a finite number of events): given a set $A$, the median is a number $a_0$ such that $\sum_{\{a: a \leq a_0\}}p(a)=\sum_{\{a: a \geq a_0\}}p(a)$. Clearly, $\sum_{\{g(a): g(a)\leq g(a_0)\}}p(g(a))=\sum_{\{a: a\leq a_0\}}p(a)$, and $\sum_{\{g(a): g(a) \geq g(a_0)\}}p(g(a))=\sum_{\{a: a \geq a_0\}}p(a)$, so $\sum_{\{g(a): g(a)\leq g(a_0)\}}p(g(a))= \sum_{\{g(a): g(a) \geq g(a_0)\}}p(g(a))$ We can then extend it to the continuous case by taking Reimann sums: partition the domain into a finite number of intervals, find the probability density of the interval, and multiply by the size of the interval. Then we let the lengths of the intervals go to zero. When we transform an interval by $g$, we multiply the length of the interval by $g'$, and divide the probability density by $g'$, so the total probability mass is unchanged. This is a bit handwavy, since we need to take this "in the limit" for $g'$ to be constant over the interval, but the basic concept should be reasonably intuitive. The error in your logic is that you essentially only changed the probability density, and ignored that since each interval will be scaled, the overall domain is also scaled.
Is the median preserved for any strictly monotonic mapping? The claim is obviously true for a discrete variable (i.e. we consider a probability distribution over a finite number of events): given a set $A$, the median is a number $a_0$ such that $\sum_{\{a: a
18,021
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
Dichotomizing a continuous covariate is ill-advised, as has been noted by other users. One strategy I employ is to rescale the predictor to something more reasonable. 1 mmHg may not be a very meaningful scale on which to interpret changes in BP. But, if you rescale the predictor so that a difference of 1 unit represents say a difference 10 mmHg then things become a little easier to digest and the odds ratio will be more appreciable and have the following interpretation For every 10 mmHg increase in blood pressure, the odds of MI increases by a factor of $\exp(\beta)$.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
Dichotomizing a continuous covariate is ill-advised, as has been noted by other users. One strategy I employ is to rescale the predictor to something more reasonable. 1 mmHg may not be a very meaning
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation Dichotomizing a continuous covariate is ill-advised, as has been noted by other users. One strategy I employ is to rescale the predictor to something more reasonable. 1 mmHg may not be a very meaningful scale on which to interpret changes in BP. But, if you rescale the predictor so that a difference of 1 unit represents say a difference 10 mmHg then things become a little easier to digest and the odds ratio will be more appreciable and have the following interpretation For every 10 mmHg increase in blood pressure, the odds of MI increases by a factor of $\exp(\beta)$.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation Dichotomizing a continuous covariate is ill-advised, as has been noted by other users. One strategy I employ is to rescale the predictor to something more reasonable. 1 mmHg may not be a very meaning
18,022
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
Similar to EdM's answer, a marginal effects plot is a useful way to showcase the relationship between a clinical measurement and outcome while holding other variables constant. These plots are helpful because they show the relationship between the predictor and outcome, so if the outcome is nonlinear, physicians can easily see this and interpret it appropriately. Here is an example from Frank Harrell's book Regression Modeling Strategies One concern with dichotomizing the blood pressure variable and doing inference is that you've assumed that all patients with blood pressure below 150 mmHg have the same risk due to their blood pressure, which I don't believe is true. I don't think there is any biology behind the assumption that once a patient's blood pressure rises above 150mmHg they magically become at higher risk of a heart attack. It's more likely that small increases in blood pressure lead to small increases in risk. Incorrect assumptions like this can invalidate the inference because the model is no longer correct. Incorrect models will lead to invalid inferences and incorrect p-values, so it's essential we define the model to best fit what is biologically plausible. This means treating blood pressure as continuous instead of dichotomizing.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
Similar to EdM's answer, a marginal effects plot is a useful way to showcase the relationship between a clinical measurement and outcome while holding other variables constant. These plots are helpful
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation Similar to EdM's answer, a marginal effects plot is a useful way to showcase the relationship between a clinical measurement and outcome while holding other variables constant. These plots are helpful because they show the relationship between the predictor and outcome, so if the outcome is nonlinear, physicians can easily see this and interpret it appropriately. Here is an example from Frank Harrell's book Regression Modeling Strategies One concern with dichotomizing the blood pressure variable and doing inference is that you've assumed that all patients with blood pressure below 150 mmHg have the same risk due to their blood pressure, which I don't believe is true. I don't think there is any biology behind the assumption that once a patient's blood pressure rises above 150mmHg they magically become at higher risk of a heart attack. It's more likely that small increases in blood pressure lead to small increases in risk. Incorrect assumptions like this can invalidate the inference because the model is no longer correct. Incorrect models will lead to invalid inferences and incorrect p-values, so it's essential we define the model to best fit what is biologically plausible. This means treating blood pressure as continuous instead of dichotomizing.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation Similar to EdM's answer, a marginal effects plot is a useful way to showcase the relationship between a clinical measurement and outcome while holding other variables constant. These plots are helpful
18,023
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
For digestibility, use examples from representative situations: in your example, maybe comparing risks at BP of 160 versus BP of 120. For an approach that can take into account the multiple predictors typically important in clinical studies, use a nomogram. It provides a graphical tool to show how predictor values affect outcomes. The rms package in R provides tools for constructing nomograms from fitted regression models. This particular approach that you propose: The doctor therefore does a ROC analysis to see at what value the sensitivity and specificity of blood pressure is highest to predict a heart attack. He notices this is at 150 mmHg... He regresses again, with heart attacks and the new dichotomized BP above or below 150 mmHg and gets an OR of 5 is ill-advised for reasons besides the general issues of dichotomization that you acknowledge. For one, use of sensitivity and specificity tends to involve a hidden assumption that false-positive and false-negative classifications have the same costs. For another, once you use the data to set the cutoff, the assumptions underlying p-value and confidence-interval calculations no longer hold.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
For digestibility, use examples from representative situations: in your example, maybe comparing risks at BP of 160 versus BP of 120. For an approach that can take into account the multiple predictors
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation For digestibility, use examples from representative situations: in your example, maybe comparing risks at BP of 160 versus BP of 120. For an approach that can take into account the multiple predictors typically important in clinical studies, use a nomogram. It provides a graphical tool to show how predictor values affect outcomes. The rms package in R provides tools for constructing nomograms from fitted regression models. This particular approach that you propose: The doctor therefore does a ROC analysis to see at what value the sensitivity and specificity of blood pressure is highest to predict a heart attack. He notices this is at 150 mmHg... He regresses again, with heart attacks and the new dichotomized BP above or below 150 mmHg and gets an OR of 5 is ill-advised for reasons besides the general issues of dichotomization that you acknowledge. For one, use of sensitivity and specificity tends to involve a hidden assumption that false-positive and false-negative classifications have the same costs. For another, once you use the data to set the cutoff, the assumptions underlying p-value and confidence-interval calculations no longer hold.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation For digestibility, use examples from representative situations: in your example, maybe comparing risks at BP of 160 versus BP of 120. For an approach that can take into account the multiple predictors
18,024
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
Another issue is that the relationship between the IV and the DV (here, BP and heart attack risk) might not be linear. I would think this sort of nonlinearity would be quite common in medical fields. Indeed, this is sometimes given as a reason for categorizing the continuous variable (albeit into more than two categories). But this isn't good. A better method is to use a spline of the IV.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation
Another issue is that the relationship between the IV and the DV (here, BP and heart attack risk) might not be linear. I would think this sort of nonlinearity would be quite common in medical fields.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation Another issue is that the relationship between the IV and the DV (here, BP and heart attack risk) might not be linear. I would think this sort of nonlinearity would be quite common in medical fields. Indeed, this is sometimes given as a reason for categorizing the continuous variable (albeit into more than two categories). But this isn't good. A better method is to use a spline of the IV.
Dichotomizing continuous variables at their optimal cut-off for clinical interpretation Another issue is that the relationship between the IV and the DV (here, BP and heart attack risk) might not be linear. I would think this sort of nonlinearity would be quite common in medical fields.
18,025
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
Suppose, as an easy counter example, that the probability $P(A)$ of $A$ is $1$, regardless of the value of $C$. Then, if we take the incorrect equation, we get: $P(A | B) = P(A | B, C) + P(A | B, \neg C) = 1 + 1 = 2$ That obviously can't be correct, a probably cannot be greater than $1$. This helps to build the intuition that you should assign a weight to each of the two cases proportional to how likely that case is, which results in the first (correct) equation.. That brings you closer to your first equation, but the weights are not completely right. See A. Rex' comment for the correct weights.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
Suppose, as an easy counter example, that the probability $P(A)$ of $A$ is $1$, regardless of the value of $C$. Then, if we take the incorrect equation, we get: $P(A | B) = P(A | B, C) + P(A | B, \neg
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? Suppose, as an easy counter example, that the probability $P(A)$ of $A$ is $1$, regardless of the value of $C$. Then, if we take the incorrect equation, we get: $P(A | B) = P(A | B, C) + P(A | B, \neg C) = 1 + 1 = 2$ That obviously can't be correct, a probably cannot be greater than $1$. This helps to build the intuition that you should assign a weight to each of the two cases proportional to how likely that case is, which results in the first (correct) equation.. That brings you closer to your first equation, but the weights are not completely right. See A. Rex' comment for the correct weights.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? Suppose, as an easy counter example, that the probability $P(A)$ of $A$ is $1$, regardless of the value of $C$. Then, if we take the incorrect equation, we get: $P(A | B) = P(A | B, C) + P(A | B, \neg
18,026
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
Dennis's answer has a great counter-example, disproving the wrong equation. This answer seeks to explain why the following equation is right: $$P(A|B) = P(A|C,B) P(C|B) + P(A|\neg C,B) P(\neg C|B).$$ As every term is conditioned on $B$, we can replace the entire probability space by $B$ and drop the $B$ term. This gives us: $$P(A) = P(A|C) P(C) + P(A|\neg C) P(\neg C).$$ Then you are asking why this equation has the $P(C)$ and $P(\neg C)$ terms in it. The reason is that $P(A|C) P(C)$ is the portion of $A$ in $C$ and $P(A|\neg C) P(\neg C)$ is the portion of $A$ in $\neg C$ and the two add up to $A$. See diagram. On the other hand $P(A|C)$ is the proportion of $C$ containing $A$ and $P(A|\neg C)$ is the proportion of $\neg C$ containing $A$ - these are proportions of different regions so they don't have common denominators so adding them is meaningless.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
Dennis's answer has a great counter-example, disproving the wrong equation. This answer seeks to explain why the following equation is right: $$P(A|B) = P(A|C,B) P(C|B) + P(A|\neg C,B) P(\neg C|B).$$
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? Dennis's answer has a great counter-example, disproving the wrong equation. This answer seeks to explain why the following equation is right: $$P(A|B) = P(A|C,B) P(C|B) + P(A|\neg C,B) P(\neg C|B).$$ As every term is conditioned on $B$, we can replace the entire probability space by $B$ and drop the $B$ term. This gives us: $$P(A) = P(A|C) P(C) + P(A|\neg C) P(\neg C).$$ Then you are asking why this equation has the $P(C)$ and $P(\neg C)$ terms in it. The reason is that $P(A|C) P(C)$ is the portion of $A$ in $C$ and $P(A|\neg C) P(\neg C)$ is the portion of $A$ in $\neg C$ and the two add up to $A$. See diagram. On the other hand $P(A|C)$ is the proportion of $C$ containing $A$ and $P(A|\neg C)$ is the proportion of $\neg C$ containing $A$ - these are proportions of different regions so they don't have common denominators so adding them is meaningless.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? Dennis's answer has a great counter-example, disproving the wrong equation. This answer seeks to explain why the following equation is right: $$P(A|B) = P(A|C,B) P(C|B) + P(A|\neg C,B) P(\neg C|B).$$
18,027
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
I know you've already received two great answers to your question, but I just wanted to point out how you can turn the idea behind your intuition into the correct equation. First, remember that $P(X \mid Y) = \dfrac{P(X \cap Y)}{P(Y)}$ and equivalently $P(X \cap Y) = P(X \mid Y)P(Y)$. To avoid making mistakes, we will use the first equation in the previous paragraph to eliminate all conditional probabilities, then keep rewriting expressions involving intersections and unions of events, then use the second equation in the previous paragraph to re-introduce the conditionals at the end. Thus, we start with: $$P(A \mid B) = \dfrac{P(A \cap B)}{P(B)}$$ We will keep rewriting the right-hand side until we get the desired equation. The casework in your intuition expands the event $A$ into $(A \cap C) \cup (A \cap \neg C)$, resulting in $$P(A \mid B) = \dfrac{P(((A \cap C) \cup (A \cap \neg C)) \cap B)}{P(B)}$$ As with sets, the intersection distributes over the union: $$P(A \mid B) = \dfrac{P((A \cap B \cap C) \cup (A \cap B \cap \neg C))}{P(B)}$$ Since the two events being unioned in the numerator are mutually exclusive (since $C$ and $\neg C$ cannot both happen), we can use the sum rule: $$P(A \mid B) = \dfrac{P(A \cap B \cap C)}{P(B)} + \dfrac{P(A \cap B \cap \neg C)}{P(B)}$$ We now see that $P(A \mid B) = P(A \cap C \mid B) + P(A \cap \neg C \mid B)$; thus, you can use the sum rule on the event on the event of interest (the "left" side of the conditional bar) if you keep the given event (the "right" side) the same. This can be used as a general rule for other equality proofs as well. We re-introduce the desired conditionals using the second equation in the second paragraph: $$P(A \cap (B \cap C)) = P(A \mid B \cap C)P(B \cap C)$$ and similarly for $\neg C$. We plug this into our equation for $P(A \mid B)$ as: $$P(A \mid B) = \dfrac{P(A \mid B \cap C)P(B \cap C)}{P(B)} + \dfrac{P(A \mid B \cap \neg C)P(B \cap \neg C)}{P(B)}$$ Noting that $\dfrac{P(B \cap C)}{P(B)} = P(C \mid B)$ (and similarly for $\neg C$), we finally get $$P(A \mid B) = P(A \mid B \cap C)P(C \mid B) + P(A \mid B \cap \neg C)P(\neg C \mid B)$$ Which is the correct equation (albeit with slightly different notation), including the fix A. Rex pointed out. Note that $P(A \cap C \mid B)$ turned into $P(A \mid B \cap C)P(C \mid B)$. This mirrors the equation $P(A \cap C) = P(A \mid C)P(C)$ by adding the $B$ condition to not only $P(A \cap C)$ and $P(A \mid C)$, but also $P(C)$ as well. I think if you are to use familiar rules on conditioned probabilities, you need to add the condition to all probabilities in the rule. And if there's any doubt whether that idea works for a particular situation, you can always expand out the conditionals to check, as I did for this answer.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
I know you've already received two great answers to your question, but I just wanted to point out how you can turn the idea behind your intuition into the correct equation. First, remember that $P(X \
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? I know you've already received two great answers to your question, but I just wanted to point out how you can turn the idea behind your intuition into the correct equation. First, remember that $P(X \mid Y) = \dfrac{P(X \cap Y)}{P(Y)}$ and equivalently $P(X \cap Y) = P(X \mid Y)P(Y)$. To avoid making mistakes, we will use the first equation in the previous paragraph to eliminate all conditional probabilities, then keep rewriting expressions involving intersections and unions of events, then use the second equation in the previous paragraph to re-introduce the conditionals at the end. Thus, we start with: $$P(A \mid B) = \dfrac{P(A \cap B)}{P(B)}$$ We will keep rewriting the right-hand side until we get the desired equation. The casework in your intuition expands the event $A$ into $(A \cap C) \cup (A \cap \neg C)$, resulting in $$P(A \mid B) = \dfrac{P(((A \cap C) \cup (A \cap \neg C)) \cap B)}{P(B)}$$ As with sets, the intersection distributes over the union: $$P(A \mid B) = \dfrac{P((A \cap B \cap C) \cup (A \cap B \cap \neg C))}{P(B)}$$ Since the two events being unioned in the numerator are mutually exclusive (since $C$ and $\neg C$ cannot both happen), we can use the sum rule: $$P(A \mid B) = \dfrac{P(A \cap B \cap C)}{P(B)} + \dfrac{P(A \cap B \cap \neg C)}{P(B)}$$ We now see that $P(A \mid B) = P(A \cap C \mid B) + P(A \cap \neg C \mid B)$; thus, you can use the sum rule on the event on the event of interest (the "left" side of the conditional bar) if you keep the given event (the "right" side) the same. This can be used as a general rule for other equality proofs as well. We re-introduce the desired conditionals using the second equation in the second paragraph: $$P(A \cap (B \cap C)) = P(A \mid B \cap C)P(B \cap C)$$ and similarly for $\neg C$. We plug this into our equation for $P(A \mid B)$ as: $$P(A \mid B) = \dfrac{P(A \mid B \cap C)P(B \cap C)}{P(B)} + \dfrac{P(A \mid B \cap \neg C)P(B \cap \neg C)}{P(B)}$$ Noting that $\dfrac{P(B \cap C)}{P(B)} = P(C \mid B)$ (and similarly for $\neg C$), we finally get $$P(A \mid B) = P(A \mid B \cap C)P(C \mid B) + P(A \mid B \cap \neg C)P(\neg C \mid B)$$ Which is the correct equation (albeit with slightly different notation), including the fix A. Rex pointed out. Note that $P(A \cap C \mid B)$ turned into $P(A \mid B \cap C)P(C \mid B)$. This mirrors the equation $P(A \cap C) = P(A \mid C)P(C)$ by adding the $B$ condition to not only $P(A \cap C)$ and $P(A \mid C)$, but also $P(C)$ as well. I think if you are to use familiar rules on conditioned probabilities, you need to add the condition to all probabilities in the rule. And if there's any doubt whether that idea works for a particular situation, you can always expand out the conditionals to check, as I did for this answer.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? I know you've already received two great answers to your question, but I just wanted to point out how you can turn the idea behind your intuition into the correct equation. First, remember that $P(X \
18,028
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
Probabilities are ratios; the probability of A given B is how often A happens within the space of B. For instance, $P(\text{rain|March})$ is the number of rainy days in March divided by the number of total days in March. When dealing with fractions, it makes sense to split up numerators. For instance, \begin{align} P(\text{rain or snow|March}) &= \frac{(\text{number of rainy or snowy days in March})}{(\text{total number of days in March})} \\[7pt] &= \frac{(\text{number of rainy days in March})}{(\text{total number of days in March)}} + \\[4pt] &\qquad \frac{\text{(number of snowy days in March)}}{(\text{total number of days in March)}} \\[7pt] &= P(\text{rain|March})+P(\text{snow|March}) \end{align} This of course assumes that "snow" and "rain" are mutually exclusive. It does not, however, make sense to split up denominators. So if you have $P(\text{rain|February or March})$, that is equal to $$\frac{(\text{number of rainy days in February and March})}{(\text{total number of days in February and March})}.$$ But that is not equal to $$\frac{(\text{number of rainy days in February})}{(\text{total number of days in February})} + \frac{(\text{number of rainy days in March)}}{(\text{total number of days in March)}}.$$ If you're having trouble seeing that, you can try out some numbers. Suppose there are 10 rainy days in February and 8 in March. Then we have $$\frac{(\text{number of rainy days in February and March})}{(\text{total number of days in February and March)}} = (10+8)/(28+31) = 29.5\% $$ and \begin{align} \frac{(\text{number of rainy days in February})}{(\text{total number of days in February)}} + \frac{(\text{number of rainy days in March)}}{(\text{total number of days in March)}} &= (10/28)+(8/31) \\ &= 35.7\% + 25.8\% \\ &= 61.5\% \end{align} The first number, 29.5%, is the average of 35.7% and 25.8% (with the second number weighted slightly more because there is are more days in March). When you say $P(A|B)=P(A|B,C)+P(A|B,¬C)$ you're saying that $\frac{x_1+x_2}{y_1+y_2} = \frac{x_1}{y_1}+\frac{x_2}{y_2}$, which is false.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
Probabilities are ratios; the probability of A given B is how often A happens within the space of B. For instance, $P(\text{rain|March})$ is the number of rainy days in March divided by the number of
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? Probabilities are ratios; the probability of A given B is how often A happens within the space of B. For instance, $P(\text{rain|March})$ is the number of rainy days in March divided by the number of total days in March. When dealing with fractions, it makes sense to split up numerators. For instance, \begin{align} P(\text{rain or snow|March}) &= \frac{(\text{number of rainy or snowy days in March})}{(\text{total number of days in March})} \\[7pt] &= \frac{(\text{number of rainy days in March})}{(\text{total number of days in March)}} + \\[4pt] &\qquad \frac{\text{(number of snowy days in March)}}{(\text{total number of days in March)}} \\[7pt] &= P(\text{rain|March})+P(\text{snow|March}) \end{align} This of course assumes that "snow" and "rain" are mutually exclusive. It does not, however, make sense to split up denominators. So if you have $P(\text{rain|February or March})$, that is equal to $$\frac{(\text{number of rainy days in February and March})}{(\text{total number of days in February and March})}.$$ But that is not equal to $$\frac{(\text{number of rainy days in February})}{(\text{total number of days in February})} + \frac{(\text{number of rainy days in March)}}{(\text{total number of days in March)}}.$$ If you're having trouble seeing that, you can try out some numbers. Suppose there are 10 rainy days in February and 8 in March. Then we have $$\frac{(\text{number of rainy days in February and March})}{(\text{total number of days in February and March)}} = (10+8)/(28+31) = 29.5\% $$ and \begin{align} \frac{(\text{number of rainy days in February})}{(\text{total number of days in February)}} + \frac{(\text{number of rainy days in March)}}{(\text{total number of days in March)}} &= (10/28)+(8/31) \\ &= 35.7\% + 25.8\% \\ &= 61.5\% \end{align} The first number, 29.5%, is the average of 35.7% and 25.8% (with the second number weighted slightly more because there is are more days in March). When you say $P(A|B)=P(A|B,C)+P(A|B,¬C)$ you're saying that $\frac{x_1+x_2}{y_1+y_2} = \frac{x_1}{y_1}+\frac{x_2}{y_2}$, which is false.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? Probabilities are ratios; the probability of A given B is how often A happens within the space of B. For instance, $P(\text{rain|March})$ is the number of rainy days in March divided by the number of
18,029
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
If I go to Spain, I can get sunburnt. $$P(sunburnt | Spain)=0.2$$ This tells me nothing about getting sunburnt if not going to Spain, let's say $$P(sunburnt|\neg Spain)=0.1$$ This year I'm going to Spain, so $$P(sunburnt)=0.2$$ Letting $B=\Omega$, this is, $P(B)=1$, your intuition would imply $$P(A)=P(A|C)+P(A|\neg C)$$ which by the previous argument, isn't neccesarily true.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$?
If I go to Spain, I can get sunburnt. $$P(sunburnt | Spain)=0.2$$ This tells me nothing about getting sunburnt if not going to Spain, let's say $$P(sunburnt|\neg Spain)=0.1$$ This year I'm going to Sp
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? If I go to Spain, I can get sunburnt. $$P(sunburnt | Spain)=0.2$$ This tells me nothing about getting sunburnt if not going to Spain, let's say $$P(sunburnt|\neg Spain)=0.1$$ This year I'm going to Spain, so $$P(sunburnt)=0.2$$ Letting $B=\Omega$, this is, $P(B)=1$, your intuition would imply $$P(A)=P(A|C)+P(A|\neg C)$$ which by the previous argument, isn't neccesarily true.
Why $P(A|B) \neq P(A | B,C) + P(A | B, \neg C)$? If I go to Spain, I can get sunburnt. $$P(sunburnt | Spain)=0.2$$ This tells me nothing about getting sunburnt if not going to Spain, let's say $$P(sunburnt|\neg Spain)=0.1$$ This year I'm going to Sp
18,030
What is an example of perfect multicollinearity?
Here is an example with 3 variables, $y$, $x_1$ and $x_2$, related by the equation $$ y = x_1 + x_2 + \varepsilon $$ where $\varepsilon \sim N(0,1)$ The particular data are y x1 x2 1 4.520866 1 2 2 6.849811 2 4 3 6.539804 3 6 So it is evident that $x_2$ is a multiple of $x_1$ hence we have perfect collinearity. We can write the model as $$ Y = X \beta + \varepsilon$$ where: $$ Y = \begin{bmatrix}4.52 \\6.85 \\6.54\end{bmatrix}$$ $$ X = \begin{bmatrix}1 & 1 & 2\\1 & 2 & 4 \\1 & 3 & 6\end{bmatrix}$$ So we have $$ XX' = \begin{bmatrix}1 & 1 & 2\\1 & 2 & 4 \\1 & 3 & 6\end{bmatrix} \begin{bmatrix}1 & 1 & 1\\1 & 2 & 3 \\2 & 4 & 6\end{bmatrix} = \begin{bmatrix}6 & 11 & 16\\11 & 21 & 31 \\16 & 31 & 46\end{bmatrix} $$ Now we calculate the determinant of $XX'$ : $$ \det XX' = 6\begin{vmatrix}21 & 31 \\31 & 46\end{vmatrix} - 11 \begin{vmatrix}11 & 31 \\16 & 46\end{vmatrix} + 16\begin{vmatrix}11 & 21 \\16 & 31\end{vmatrix}= 0$$ In R we can show this as follows: > x1 <- c(1,2,3) create x2, a multiple of x1 > x2 <- x1*2 create y, a linear combination of x1, x2 and some randomness > y <- x1 + x2 + rnorm(3,0,1) observe that > summary(m0 <- lm(y~x1+x2)) fails to estimate a value for the x2 coefficient: Coefficients: (1 not defined because of singularities) Estimate Std. Error t value Pr(>|t|) (Intercept) 3.9512 1.6457 2.401 0.251 x1 1.0095 0.7618 1.325 0.412 x2 NA NA NA NA Residual standard error: 0.02583 on 1 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 0.9999 F-statistic: 2.981e+04 on 1 and 1 DF, p-value: 0.003687 The model matrix $X$ is: > (X <- model.matrix(m0)) (Intercept) x1 x2 1 1 1 2 2 1 2 4 3 1 3 6 So $XX'$ is > (XXdash <- X %*% t(X)) 1 2 3 1 6 11 16 2 11 21 31 3 16 31 46 which is not invertible, as shown by > solve(XXdash) Error in solve.default(XXdash) : Lapack routine dgesv: system is exactly singular: U[3,3] = 0 Or: > det(XXdash) [1] 0
What is an example of perfect multicollinearity?
Here is an example with 3 variables, $y$, $x_1$ and $x_2$, related by the equation $$ y = x_1 + x_2 + \varepsilon $$ where $\varepsilon \sim N(0,1)$ The particular data are y x1 x2 1 4.520866
What is an example of perfect multicollinearity? Here is an example with 3 variables, $y$, $x_1$ and $x_2$, related by the equation $$ y = x_1 + x_2 + \varepsilon $$ where $\varepsilon \sim N(0,1)$ The particular data are y x1 x2 1 4.520866 1 2 2 6.849811 2 4 3 6.539804 3 6 So it is evident that $x_2$ is a multiple of $x_1$ hence we have perfect collinearity. We can write the model as $$ Y = X \beta + \varepsilon$$ where: $$ Y = \begin{bmatrix}4.52 \\6.85 \\6.54\end{bmatrix}$$ $$ X = \begin{bmatrix}1 & 1 & 2\\1 & 2 & 4 \\1 & 3 & 6\end{bmatrix}$$ So we have $$ XX' = \begin{bmatrix}1 & 1 & 2\\1 & 2 & 4 \\1 & 3 & 6\end{bmatrix} \begin{bmatrix}1 & 1 & 1\\1 & 2 & 3 \\2 & 4 & 6\end{bmatrix} = \begin{bmatrix}6 & 11 & 16\\11 & 21 & 31 \\16 & 31 & 46\end{bmatrix} $$ Now we calculate the determinant of $XX'$ : $$ \det XX' = 6\begin{vmatrix}21 & 31 \\31 & 46\end{vmatrix} - 11 \begin{vmatrix}11 & 31 \\16 & 46\end{vmatrix} + 16\begin{vmatrix}11 & 21 \\16 & 31\end{vmatrix}= 0$$ In R we can show this as follows: > x1 <- c(1,2,3) create x2, a multiple of x1 > x2 <- x1*2 create y, a linear combination of x1, x2 and some randomness > y <- x1 + x2 + rnorm(3,0,1) observe that > summary(m0 <- lm(y~x1+x2)) fails to estimate a value for the x2 coefficient: Coefficients: (1 not defined because of singularities) Estimate Std. Error t value Pr(>|t|) (Intercept) 3.9512 1.6457 2.401 0.251 x1 1.0095 0.7618 1.325 0.412 x2 NA NA NA NA Residual standard error: 0.02583 on 1 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 0.9999 F-statistic: 2.981e+04 on 1 and 1 DF, p-value: 0.003687 The model matrix $X$ is: > (X <- model.matrix(m0)) (Intercept) x1 x2 1 1 1 2 2 1 2 4 3 1 3 6 So $XX'$ is > (XXdash <- X %*% t(X)) 1 2 3 1 6 11 16 2 11 21 31 3 16 31 46 which is not invertible, as shown by > solve(XXdash) Error in solve.default(XXdash) : Lapack routine dgesv: system is exactly singular: U[3,3] = 0 Or: > det(XXdash) [1] 0
What is an example of perfect multicollinearity? Here is an example with 3 variables, $y$, $x_1$ and $x_2$, related by the equation $$ y = x_1 + x_2 + \varepsilon $$ where $\varepsilon \sim N(0,1)$ The particular data are y x1 x2 1 4.520866
18,031
What is an example of perfect multicollinearity?
Here are a couple of fairly common scenarios producing perfect multicollinearity, i.e. situations in which the columns of the design matrix are linearly dependent. Recall from linear algebra that this means there is a linear combination of columns of the design matrix (whose coefficients are not all zero) which equals zero. I have included some practical examples to help explain why this pitfall strikes so often — I have encountered almost all of them! One variable is a multiple of another, regardless of whether there is an intercept term: perhaps because you have recorded the same variable twice using different units (e.g. "length in centimetres" is precisely 100 times larger than "length in metres") or because you have recorded a variable once as a raw number and once as a proportion or percentage, when the denominator is fixed (e.g. "area of petri dish colonized" and "percentage of petri dish colonized" will be exact multiples of each other if the area of each petri dish is the same). We have collinearity because if $w_i = ax_i$ where $w$ and $x$ are variables (columns of your design matrix) and $a$ is a scalar constant, then $1(\vec w) - a(\vec x)$ is a linear combination of variables that is equal to zero. There is an intercept term and one variable differs from another by a constant: this will happen if you center a variable ($w_i = x_i - \bar x$) and include both raw $x$ and centered $w$ in your regression. It will also happen if your variables are measured in different unit systems that differ by a constant, e.g. if $w$ is "temperature in kelvin" and $x$ as "temperature in °C" then $w_i = x_i + 273.15$. If we regard the intercept term as a variable that is always $1$ (represented as a column of ones, $\vec 1_n$, in the design matrix) then having $w_i = x_i + k$ for some constant $k$ means that $1(\vec w) - 1(\vec x) - k(\vec 1_n)$ is a linear combination of the $w$, $x$ and $1$ columns of the design matrix that equals zero. There is an intercept term and one variable is given by an affine transformation of another: i.e. you have variables $w$ and $x$, related by $w_i = ax_i + b$ where $a$ and $b$ are constants. For instance this happens if you standardize a variable as $z_i = \frac{x_i - \bar x}{s_x}$ and include both raw $x$ and standardized $z$ variables in your regression. It also happens if you record $w$ as "temperature in °F" and $x$ as "temperature in °C", since those unit systems do not share a common zero but are related by $w_i = 1.8x_i + 32$. Or in a business context, suppose there is fixed cost $b$ (e.g. covering delivery) for each order, as well as a cost $\$a$ per unit sold; then if $\$w_i$ is the cost of order $i$ and $x_i$ is the number of units ordered, we have $w_i = ax_i + b$. The linear combination of interest is $1(\vec w) - a(\vec x) - b(\vec 1_n) = \vec 0$. Note that if $a=1$, then (3) includes (2) as a special case; if $b=0$, then (3) includes (1) as a special case. There is an intercept term and the sum of several variables is fixed (e.g. in the famous "dummy variable trap"): for example if you have "percentage of satisfied customers", "percentage of dissatisfied customers" and "percentage of customers neither satisfied nor dissatisfied" then these three variables will always (barring rounding error) sum to 100. One of these variables — or alternatively, the intercept term — needs to be dropped from the regression to prevent collinearity. The "dummy variable trap" occurs when you use indicator variables (more commonly but less usefully called "dummies") for every possible level of a categorical variable. For instance, suppose vases are produced in red, green or blue color schemes. If you recorded the categorical variable "color" by three indicator variables (red, green and blue would be binary variables, stored as 1 for "yes" and 0 for "no") then for each vase only one of the variables would be a one, and hence red + green + blue = 1. Since there is a vector of ones for the intercept term, the linear combination 1(red) + 1(green) + 1(blue) - 1(1) = 0. The usual remedy here is either to drop the intercept, or drop one of the indicators (e.g. leave out red) which becomes a baseline or reference level. In this case, the regression coefficient for green would indicate the change in the mean response associated with switching from a red vase to a green one, holding other explanatory variables constant. There are at least two subsets of variables, each having a fixed sum, regardless of whether there is an intercept term: suppose the vases in (4) were produced in three sizes, and the categorical variable for size was stored as three additional indicator variables. We would havelarge + medium + small = 1. Then we have the linear combination 1(large) + 1(medium) + 1(small) - 1(red) - 1(green) - 1(blue) = 0, even when there is no intercept term. The two subsets need not share the same sum, e.g. if we have explanatory variables $u, v, w, x$ such that every $u_i + v_i = k_1$ and $x_i + y_i = k_2$ then $k_2(\vec u) + k_2(\vec v) - k_1(\vec w) - k_1(\vec x) = \vec 0$. One variable is defined as a linear combination of several other variables: for instance, if you record the length $l$, width $w$ and perimeter $p$ of each rectangle, then $p_i = 2l_i + 2w_i$ so we have the linear combination $1(\vec p) - 2(\vec l) - 2(\vec w) = \vec 0$. An example with an intercept term: suppose a mail-order business has two product lines, and we record that order $i$ consisted of $u_i$ of the first product at unit cost $\$a$ and $v_i$ of the second at unit cost $\$b$, with fixed delivery charge $\$c$. If we also include the order cost $\$x$ as an explanatory variable, then $x_i = a u_i + b v_i + c$ and so $1(\vec x) - a(\vec u) - b(\vec v) -c(\vec 1_n) = \vec 0$. This is an obvious generalization of (3). It also gives us a different way of thinking about (4): once we know all bar one of the subset of variables whose sum is fixed, then the remaining one is their complement so can be expressed as a linear combination of them and their sum. If we know 50% of customers were satisfied and 20% were dissatisfied, then 100% - 50% - 20% = 30% must be neither satisfied nor dissatisfied; if we know the vase is not red (red=0) and it is green (green=1) then we know it is not blue (blue = 1(1) - 1(red) - 1(green) = 1 - 0 - 1 = 0). One variable is constant and zero, regardless of whether there is an intercept term: in an observational study, a variable will be constant if your sample does not exhibit sufficient (any!) variation. There may be variation in the population that is not captured in your sample, e.g. if there is a very common modal value: perhaps your sample size is too small and was therefore unlikely to include any values that differed from the mode, or your measurements were insufficiently accurate to detect small variations from the mode. Alternatively, there may be theoretical reasons for the lack of variation, particularly if you are studying a sub-population. In a study of new-build properties in Los Angeles, it would not be surprising that every data point has AgeOfProperty = 0 and State = California! In an experimental study, you may have measured an independent variable that is under experimental control. Should one of your explanatory variables $x$ be both constant and zero, then we have immediately that the linear combination $1(\vec x)$ (with coefficient zero for any other variables) is $\vec 0$. There is an intercept term and at least one variable is constant: if $x$ is constant so that each $x_i = k \neq 0$, then the linear combination $1(\vec x) - k(\vec 1_n) = \vec 0$. At least two variables are constant, regardless of whether there is an intercept term: if each $w_i = k_1 \neq 0$ and $x_i = k_2 \neq 0$, then the linear combination $k_2(\vec w) - k_1(\vec x) = \vec 0$. Number of columns of design matrix, $k$, exceeds number of rows, $n$: even when there is no conceptual relationship between your variables, it is mathematically necessitated that the columns of your design matrix will be linearly dependent when $k > n$. It simply isn't possible to have $k$ linearly independent vectors in a space with a number of dimensions lower than $k$: for instance, while you can draw two independent vectors on a sheet of paper (a two-dimensional plane, $\mathbb R^2$) any further vector drawn on the page must lie within their span, and hence be a linear combination of them. Note that an intercept term contributes a column of ones to the design matrix, so counts as one of your $k$ columns. (This scenario is often called the "large $p$, small $n$" problem: see also this related CV question.) Data examples with R code Each example gives a design matrix $X$, the matrix $X'X$ (note this is always square and symmetrical) and $\det (X'X)$. Note that if $X'X$ is singular (zero determinant, hence not invertible) then we cannot estimate $\hat \beta = (X'X)^{-1}X'y$. The condition that $X'X$ be non-singular is equivalent to the condition that $X$ has full rank so its columns are linearly independent: see this Math SE question, or this one and its converse. (1) One column is multiple of another # x2 = 2 * x1 # Note no intercept term (column of 1s) is needed X <- matrix(c(2, 4, 1, 2, 3, 6, 2, 4), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 4 #[2,] 1 2 #[3,] 3 6 #[4,] 2 4 t(X) %*% X # [,1] [,2] #[1,] 18 36 #[2,] 36 72 round(det(t(X) %*% X), digits = 9) #0 (2) Intercept term and one variable differs from another by constant # x1 represents intercept term # x3 = x2 + 2 X <- matrix(c(1, 2, 4, 1, 1, 3, 1, 3, 5, 1, 0, 2), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 4 #[2,] 1 1 3 #[3,] 1 3 5 #[4,] 1 0 2 t(X) %*% X # [,1] [,2] [,3] #[1,] 4 6 14 #[2,] 6 14 26 #[3,] 14 26 54 round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, cols now linearly independent # x2 = x1 + 2 with no intercept column X <- matrix(c(2, 4, 1, 3, 3, 5, 0, 2), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 4 #[2,] 1 3 #[3,] 3 5 #[4,] 0 2 t(X) %*% X # [,1] [,2] #[1,] 14 26 #[2,] 26 54 # Can you see how this matrix is related to the previous one, and why? round(det(t(X) %*% X), digits = 9) #80 # Non-zero determinant so X'X is invertible (3) Intercept term and one variable is affine transformation of another # x1 represents intercept term # x3 = 2*x2 - 3 X <- matrix(c(1, 2, 1, 1, 1, -1, 1, 3, 3, 1, 0, -3), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 1 #[2,] 1 1 -1 #[3,] 1 3 3 #[4,] 1 0 -3 t(X) %*% X # [,1] [,2] [,3] #[1,] 4 6 0 #[2,] 6 14 10 #[3,] 0 10 20 round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, cols now linearly independent # x2 = 2*x1 - 3 with no intercept column X <- matrix(c(2, 1, 1, -1, 3, 3, 0, -3), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 1 #[2,] 1 -1 #[3,] 3 3 #[4,] 0 -3 t(X) %*% X # [,1] [,2] #[1,] 14 10 #[2,] 10 20 # Can you see how this matrix is related to the previous one, and why? round(det(t(X) %*% X), digits = 9) #180 # Non-zero determinant so X'X is invertible (4) Intercept term and sum of several variables is fixed # x1 represents intercept term # x2 + x3 = 10 X <- matrix(c(1, 2, 8, 1, 1, 9, 1, 3, 7, 1, 0, 10), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 8 #[2,] 1 1 9 #[3,] 1 3 7 #[4,] 1 0 10 t(X) %*% X # [,1] [,2] [,3] #[1,] 4 6 34 #[2,] 6 14 46 #[3,] 34 46 294 round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, then columns now linearly independent # x1 + x2 = 10 with no intercept column X <- matrix(c(2, 8, 1, 9, 3, 7, 0, 10), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 8 #[2,] 1 9 #[3,] 3 7 #[4,] 0 10 t(X) %*% X # [,1] [,2] #[1,] 14 46 #[2,] 46 294 # Can you see how this matrix is related to the previous one, and why? round(det(t(X) %*% X), digits = 9) #2000 # Non-zero determinant so X'X is invertible (4a) Intercept term with dummy variable trap # x1 represents intercept term # x2 + x3 + x4 = 1 X <- matrix(c(1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0), ncol = 4, byrow=TRUE) X # [,1] [,2] [,3] [,4] #[1,] 1 0 0 1 #[2,] 1 1 0 0 #[3,] 1 0 1 0 #[4,] 1 1 0 0 #[5,] 1 0 1 0 t(X) %*% X # [,1] [,2] [,3] [,4] #[1,] 5 2 2 1 #[2,] 2 2 0 0 #[3,] 2 0 2 0 #[4,] 1 0 0 1 # This matrix has a very natural interpretation - can you work it out? round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, then columns now linearly independent # x1 + x2 + x3 = 1 with no intercept column X <- matrix(c(0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 0 0 1 #[2,] 1 0 0 #[3,] 0 1 0 #[4,] 1 0 0 #[5,] 0 1 0 t(X) %*% X # [,1] [,2] [,3] #[1,] 2 0 0 #[2,] 0 2 0 #[3,] 0 0 1 # Can you see how this matrix is related to the previous one? round(det(t(X) %*% X), digits = 9) #4 # Non-zero determinant so X'X is invertible (5) Two subsets of variables with fixed sum # No intercept term needed # x1 + x2 = 1 # x3 + x4 = 1 X <- matrix(c(0,1,0,1,1,0,0,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,1,0), ncol = 4, byrow=TRUE) X # [,1] [,2] [,3] [,4] #[1,] 0 1 0 1 #[2,] 1 0 0 1 #[3,] 0 1 1 0 #[4,] 1 0 0 1 #[5,] 1 0 1 0 #[6,] 0 1 1 0 t(X) %*% X # [,1] [,2] [,3] [,4] #[1,] 3 0 1 2 #[2,] 0 3 2 1 #[3,] 1 2 3 0 #[4,] 2 1 0 3 # This matrix has a very natural interpretation - can you work it out? round(det(t(X) %*% X), digits = 9) #0 (6) One variable is linear combination of others # No intercept term # x3 = x1 + 2*x2 X <- matrix(c(1,1,3,0,2,4,2,1,4,3,1,5,1,2,5), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 1 3 #[2,] 0 2 4 #[3,] 2 1 4 #[4,] 3 1 5 #[5,] 1 2 5 t(X) %*% X # [,1] [,2] [,3] #[1,] 15 8 31 #[2,] 8 11 30 #[3,] 31 30 91 round(det(t(X) %*% X), digits = 9) #0 (7) One variable is constant and zero # No intercept term # x3 = 0 X <- matrix(c(1,1,0,0,2,0,2,1,0,3,1,0,1,2,0), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 1 0 #[2,] 0 2 0 #[3,] 2 1 0 #[4,] 3 1 0 #[5,] 1 2 0 t(X) %*% X # [,1] [,2] [,3] #[1,] 15 8 0 #[2,] 8 11 0 #[3,] 0 0 0 round(det(t(X) %*% X), digits = 9) #0 (8) Intercept term and one constant variable # x1 is intercept term, x3 = 5 X <- matrix(c(1,1,5,1,2,5,1,1,5,1,1,5,1,2,5), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 1 5 #[2,] 1 2 5 #[3,] 1 1 5 #[4,] 1 1 5 #[5,] 1 2 5 t(X) %*% X # [,1] [,2] [,3] #[1,] 5 7 25 #[2,] 7 11 35 #[3,] 25 35 125 round(det(t(X) %*% X), digits = 9) #0 (9) Two constant variables # No intercept term, x2 = 2, x3 = 5 X <- matrix(c(1,2,5,2,2,5,1,2,5,1,2,5,2,2,5), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 5 #[2,] 2 2 5 #[3,] 1 2 5 #[4,] 1 2 5 #[5,] 2 2 5 t(X) %*% X # [,1] [,2] [,3] #[1,] 11 14 35 #[2,] 14 20 50 #[3,] 35 50 125 round(det(t(X) %*% X), digits = 9) #0 (10) $k > n$ # Design matrix has 4 columns but only 3 rows X <- matrix(c(1,1,1,1,1,2,4,8,1,3,9,27), ncol = 4, byrow=TRUE) X # [,1] [,2] [,3] [,4] #[1,] 1 1 1 1 #[2,] 1 2 4 8 #[3,] 1 3 9 27 t(X) %*% X # [,1] [,2] [,3] [,4] #[1,] 3 6 14 36 #[2,] 6 14 36 98 #[3,] 14 36 98 276 #[4,] 36 98 276 794 round(det(t(X) %*% X), digits = 9) #0
What is an example of perfect multicollinearity?
Here are a couple of fairly common scenarios producing perfect multicollinearity, i.e. situations in which the columns of the design matrix are linearly dependent. Recall from linear algebra that this
What is an example of perfect multicollinearity? Here are a couple of fairly common scenarios producing perfect multicollinearity, i.e. situations in which the columns of the design matrix are linearly dependent. Recall from linear algebra that this means there is a linear combination of columns of the design matrix (whose coefficients are not all zero) which equals zero. I have included some practical examples to help explain why this pitfall strikes so often — I have encountered almost all of them! One variable is a multiple of another, regardless of whether there is an intercept term: perhaps because you have recorded the same variable twice using different units (e.g. "length in centimetres" is precisely 100 times larger than "length in metres") or because you have recorded a variable once as a raw number and once as a proportion or percentage, when the denominator is fixed (e.g. "area of petri dish colonized" and "percentage of petri dish colonized" will be exact multiples of each other if the area of each petri dish is the same). We have collinearity because if $w_i = ax_i$ where $w$ and $x$ are variables (columns of your design matrix) and $a$ is a scalar constant, then $1(\vec w) - a(\vec x)$ is a linear combination of variables that is equal to zero. There is an intercept term and one variable differs from another by a constant: this will happen if you center a variable ($w_i = x_i - \bar x$) and include both raw $x$ and centered $w$ in your regression. It will also happen if your variables are measured in different unit systems that differ by a constant, e.g. if $w$ is "temperature in kelvin" and $x$ as "temperature in °C" then $w_i = x_i + 273.15$. If we regard the intercept term as a variable that is always $1$ (represented as a column of ones, $\vec 1_n$, in the design matrix) then having $w_i = x_i + k$ for some constant $k$ means that $1(\vec w) - 1(\vec x) - k(\vec 1_n)$ is a linear combination of the $w$, $x$ and $1$ columns of the design matrix that equals zero. There is an intercept term and one variable is given by an affine transformation of another: i.e. you have variables $w$ and $x$, related by $w_i = ax_i + b$ where $a$ and $b$ are constants. For instance this happens if you standardize a variable as $z_i = \frac{x_i - \bar x}{s_x}$ and include both raw $x$ and standardized $z$ variables in your regression. It also happens if you record $w$ as "temperature in °F" and $x$ as "temperature in °C", since those unit systems do not share a common zero but are related by $w_i = 1.8x_i + 32$. Or in a business context, suppose there is fixed cost $b$ (e.g. covering delivery) for each order, as well as a cost $\$a$ per unit sold; then if $\$w_i$ is the cost of order $i$ and $x_i$ is the number of units ordered, we have $w_i = ax_i + b$. The linear combination of interest is $1(\vec w) - a(\vec x) - b(\vec 1_n) = \vec 0$. Note that if $a=1$, then (3) includes (2) as a special case; if $b=0$, then (3) includes (1) as a special case. There is an intercept term and the sum of several variables is fixed (e.g. in the famous "dummy variable trap"): for example if you have "percentage of satisfied customers", "percentage of dissatisfied customers" and "percentage of customers neither satisfied nor dissatisfied" then these three variables will always (barring rounding error) sum to 100. One of these variables — or alternatively, the intercept term — needs to be dropped from the regression to prevent collinearity. The "dummy variable trap" occurs when you use indicator variables (more commonly but less usefully called "dummies") for every possible level of a categorical variable. For instance, suppose vases are produced in red, green or blue color schemes. If you recorded the categorical variable "color" by three indicator variables (red, green and blue would be binary variables, stored as 1 for "yes" and 0 for "no") then for each vase only one of the variables would be a one, and hence red + green + blue = 1. Since there is a vector of ones for the intercept term, the linear combination 1(red) + 1(green) + 1(blue) - 1(1) = 0. The usual remedy here is either to drop the intercept, or drop one of the indicators (e.g. leave out red) which becomes a baseline or reference level. In this case, the regression coefficient for green would indicate the change in the mean response associated with switching from a red vase to a green one, holding other explanatory variables constant. There are at least two subsets of variables, each having a fixed sum, regardless of whether there is an intercept term: suppose the vases in (4) were produced in three sizes, and the categorical variable for size was stored as three additional indicator variables. We would havelarge + medium + small = 1. Then we have the linear combination 1(large) + 1(medium) + 1(small) - 1(red) - 1(green) - 1(blue) = 0, even when there is no intercept term. The two subsets need not share the same sum, e.g. if we have explanatory variables $u, v, w, x$ such that every $u_i + v_i = k_1$ and $x_i + y_i = k_2$ then $k_2(\vec u) + k_2(\vec v) - k_1(\vec w) - k_1(\vec x) = \vec 0$. One variable is defined as a linear combination of several other variables: for instance, if you record the length $l$, width $w$ and perimeter $p$ of each rectangle, then $p_i = 2l_i + 2w_i$ so we have the linear combination $1(\vec p) - 2(\vec l) - 2(\vec w) = \vec 0$. An example with an intercept term: suppose a mail-order business has two product lines, and we record that order $i$ consisted of $u_i$ of the first product at unit cost $\$a$ and $v_i$ of the second at unit cost $\$b$, with fixed delivery charge $\$c$. If we also include the order cost $\$x$ as an explanatory variable, then $x_i = a u_i + b v_i + c$ and so $1(\vec x) - a(\vec u) - b(\vec v) -c(\vec 1_n) = \vec 0$. This is an obvious generalization of (3). It also gives us a different way of thinking about (4): once we know all bar one of the subset of variables whose sum is fixed, then the remaining one is their complement so can be expressed as a linear combination of them and their sum. If we know 50% of customers were satisfied and 20% were dissatisfied, then 100% - 50% - 20% = 30% must be neither satisfied nor dissatisfied; if we know the vase is not red (red=0) and it is green (green=1) then we know it is not blue (blue = 1(1) - 1(red) - 1(green) = 1 - 0 - 1 = 0). One variable is constant and zero, regardless of whether there is an intercept term: in an observational study, a variable will be constant if your sample does not exhibit sufficient (any!) variation. There may be variation in the population that is not captured in your sample, e.g. if there is a very common modal value: perhaps your sample size is too small and was therefore unlikely to include any values that differed from the mode, or your measurements were insufficiently accurate to detect small variations from the mode. Alternatively, there may be theoretical reasons for the lack of variation, particularly if you are studying a sub-population. In a study of new-build properties in Los Angeles, it would not be surprising that every data point has AgeOfProperty = 0 and State = California! In an experimental study, you may have measured an independent variable that is under experimental control. Should one of your explanatory variables $x$ be both constant and zero, then we have immediately that the linear combination $1(\vec x)$ (with coefficient zero for any other variables) is $\vec 0$. There is an intercept term and at least one variable is constant: if $x$ is constant so that each $x_i = k \neq 0$, then the linear combination $1(\vec x) - k(\vec 1_n) = \vec 0$. At least two variables are constant, regardless of whether there is an intercept term: if each $w_i = k_1 \neq 0$ and $x_i = k_2 \neq 0$, then the linear combination $k_2(\vec w) - k_1(\vec x) = \vec 0$. Number of columns of design matrix, $k$, exceeds number of rows, $n$: even when there is no conceptual relationship between your variables, it is mathematically necessitated that the columns of your design matrix will be linearly dependent when $k > n$. It simply isn't possible to have $k$ linearly independent vectors in a space with a number of dimensions lower than $k$: for instance, while you can draw two independent vectors on a sheet of paper (a two-dimensional plane, $\mathbb R^2$) any further vector drawn on the page must lie within their span, and hence be a linear combination of them. Note that an intercept term contributes a column of ones to the design matrix, so counts as one of your $k$ columns. (This scenario is often called the "large $p$, small $n$" problem: see also this related CV question.) Data examples with R code Each example gives a design matrix $X$, the matrix $X'X$ (note this is always square and symmetrical) and $\det (X'X)$. Note that if $X'X$ is singular (zero determinant, hence not invertible) then we cannot estimate $\hat \beta = (X'X)^{-1}X'y$. The condition that $X'X$ be non-singular is equivalent to the condition that $X$ has full rank so its columns are linearly independent: see this Math SE question, or this one and its converse. (1) One column is multiple of another # x2 = 2 * x1 # Note no intercept term (column of 1s) is needed X <- matrix(c(2, 4, 1, 2, 3, 6, 2, 4), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 4 #[2,] 1 2 #[3,] 3 6 #[4,] 2 4 t(X) %*% X # [,1] [,2] #[1,] 18 36 #[2,] 36 72 round(det(t(X) %*% X), digits = 9) #0 (2) Intercept term and one variable differs from another by constant # x1 represents intercept term # x3 = x2 + 2 X <- matrix(c(1, 2, 4, 1, 1, 3, 1, 3, 5, 1, 0, 2), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 4 #[2,] 1 1 3 #[3,] 1 3 5 #[4,] 1 0 2 t(X) %*% X # [,1] [,2] [,3] #[1,] 4 6 14 #[2,] 6 14 26 #[3,] 14 26 54 round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, cols now linearly independent # x2 = x1 + 2 with no intercept column X <- matrix(c(2, 4, 1, 3, 3, 5, 0, 2), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 4 #[2,] 1 3 #[3,] 3 5 #[4,] 0 2 t(X) %*% X # [,1] [,2] #[1,] 14 26 #[2,] 26 54 # Can you see how this matrix is related to the previous one, and why? round(det(t(X) %*% X), digits = 9) #80 # Non-zero determinant so X'X is invertible (3) Intercept term and one variable is affine transformation of another # x1 represents intercept term # x3 = 2*x2 - 3 X <- matrix(c(1, 2, 1, 1, 1, -1, 1, 3, 3, 1, 0, -3), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 1 #[2,] 1 1 -1 #[3,] 1 3 3 #[4,] 1 0 -3 t(X) %*% X # [,1] [,2] [,3] #[1,] 4 6 0 #[2,] 6 14 10 #[3,] 0 10 20 round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, cols now linearly independent # x2 = 2*x1 - 3 with no intercept column X <- matrix(c(2, 1, 1, -1, 3, 3, 0, -3), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 1 #[2,] 1 -1 #[3,] 3 3 #[4,] 0 -3 t(X) %*% X # [,1] [,2] #[1,] 14 10 #[2,] 10 20 # Can you see how this matrix is related to the previous one, and why? round(det(t(X) %*% X), digits = 9) #180 # Non-zero determinant so X'X is invertible (4) Intercept term and sum of several variables is fixed # x1 represents intercept term # x2 + x3 = 10 X <- matrix(c(1, 2, 8, 1, 1, 9, 1, 3, 7, 1, 0, 10), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 8 #[2,] 1 1 9 #[3,] 1 3 7 #[4,] 1 0 10 t(X) %*% X # [,1] [,2] [,3] #[1,] 4 6 34 #[2,] 6 14 46 #[3,] 34 46 294 round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, then columns now linearly independent # x1 + x2 = 10 with no intercept column X <- matrix(c(2, 8, 1, 9, 3, 7, 0, 10), ncol = 2, byrow=TRUE) X # [,1] [,2] #[1,] 2 8 #[2,] 1 9 #[3,] 3 7 #[4,] 0 10 t(X) %*% X # [,1] [,2] #[1,] 14 46 #[2,] 46 294 # Can you see how this matrix is related to the previous one, and why? round(det(t(X) %*% X), digits = 9) #2000 # Non-zero determinant so X'X is invertible (4a) Intercept term with dummy variable trap # x1 represents intercept term # x2 + x3 + x4 = 1 X <- matrix(c(1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0), ncol = 4, byrow=TRUE) X # [,1] [,2] [,3] [,4] #[1,] 1 0 0 1 #[2,] 1 1 0 0 #[3,] 1 0 1 0 #[4,] 1 1 0 0 #[5,] 1 0 1 0 t(X) %*% X # [,1] [,2] [,3] [,4] #[1,] 5 2 2 1 #[2,] 2 2 0 0 #[3,] 2 0 2 0 #[4,] 1 0 0 1 # This matrix has a very natural interpretation - can you work it out? round(det(t(X) %*% X), digits = 9) #0 # NB if we drop the intercept, then columns now linearly independent # x1 + x2 + x3 = 1 with no intercept column X <- matrix(c(0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 0 0 1 #[2,] 1 0 0 #[3,] 0 1 0 #[4,] 1 0 0 #[5,] 0 1 0 t(X) %*% X # [,1] [,2] [,3] #[1,] 2 0 0 #[2,] 0 2 0 #[3,] 0 0 1 # Can you see how this matrix is related to the previous one? round(det(t(X) %*% X), digits = 9) #4 # Non-zero determinant so X'X is invertible (5) Two subsets of variables with fixed sum # No intercept term needed # x1 + x2 = 1 # x3 + x4 = 1 X <- matrix(c(0,1,0,1,1,0,0,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,1,0), ncol = 4, byrow=TRUE) X # [,1] [,2] [,3] [,4] #[1,] 0 1 0 1 #[2,] 1 0 0 1 #[3,] 0 1 1 0 #[4,] 1 0 0 1 #[5,] 1 0 1 0 #[6,] 0 1 1 0 t(X) %*% X # [,1] [,2] [,3] [,4] #[1,] 3 0 1 2 #[2,] 0 3 2 1 #[3,] 1 2 3 0 #[4,] 2 1 0 3 # This matrix has a very natural interpretation - can you work it out? round(det(t(X) %*% X), digits = 9) #0 (6) One variable is linear combination of others # No intercept term # x3 = x1 + 2*x2 X <- matrix(c(1,1,3,0,2,4,2,1,4,3,1,5,1,2,5), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 1 3 #[2,] 0 2 4 #[3,] 2 1 4 #[4,] 3 1 5 #[5,] 1 2 5 t(X) %*% X # [,1] [,2] [,3] #[1,] 15 8 31 #[2,] 8 11 30 #[3,] 31 30 91 round(det(t(X) %*% X), digits = 9) #0 (7) One variable is constant and zero # No intercept term # x3 = 0 X <- matrix(c(1,1,0,0,2,0,2,1,0,3,1,0,1,2,0), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 1 0 #[2,] 0 2 0 #[3,] 2 1 0 #[4,] 3 1 0 #[5,] 1 2 0 t(X) %*% X # [,1] [,2] [,3] #[1,] 15 8 0 #[2,] 8 11 0 #[3,] 0 0 0 round(det(t(X) %*% X), digits = 9) #0 (8) Intercept term and one constant variable # x1 is intercept term, x3 = 5 X <- matrix(c(1,1,5,1,2,5,1,1,5,1,1,5,1,2,5), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 1 5 #[2,] 1 2 5 #[3,] 1 1 5 #[4,] 1 1 5 #[5,] 1 2 5 t(X) %*% X # [,1] [,2] [,3] #[1,] 5 7 25 #[2,] 7 11 35 #[3,] 25 35 125 round(det(t(X) %*% X), digits = 9) #0 (9) Two constant variables # No intercept term, x2 = 2, x3 = 5 X <- matrix(c(1,2,5,2,2,5,1,2,5,1,2,5,2,2,5), ncol = 3, byrow=TRUE) X # [,1] [,2] [,3] #[1,] 1 2 5 #[2,] 2 2 5 #[3,] 1 2 5 #[4,] 1 2 5 #[5,] 2 2 5 t(X) %*% X # [,1] [,2] [,3] #[1,] 11 14 35 #[2,] 14 20 50 #[3,] 35 50 125 round(det(t(X) %*% X), digits = 9) #0 (10) $k > n$ # Design matrix has 4 columns but only 3 rows X <- matrix(c(1,1,1,1,1,2,4,8,1,3,9,27), ncol = 4, byrow=TRUE) X # [,1] [,2] [,3] [,4] #[1,] 1 1 1 1 #[2,] 1 2 4 8 #[3,] 1 3 9 27 t(X) %*% X # [,1] [,2] [,3] [,4] #[1,] 3 6 14 36 #[2,] 6 14 36 98 #[3,] 14 36 98 276 #[4,] 36 98 276 794 round(det(t(X) %*% X), digits = 9) #0
What is an example of perfect multicollinearity? Here are a couple of fairly common scenarios producing perfect multicollinearity, i.e. situations in which the columns of the design matrix are linearly dependent. Recall from linear algebra that this
18,032
What is an example of perfect multicollinearity?
Some trivial examples to help intuition: $\mathbf{x_1}$ is height in centimeters. $\mathbf{x_2}$ is height in meters. Then: $\mathbf{x_1} = 100 \mathbf{x_2}$, and your design matrix $X$ will not have linearly independent columns. $\mathbf{x_1} = \mathbf{1}$ (i.e. you include a constant in your regression), $\mathbf{x_2}$ is temperature in fahrenheit, and $\mathbf{x_3}$ is temperature in celsius. Then: $\mathbf{x_2} = \frac{9}{5}\mathbf{x_3} + 32 \mathbf{x_1}$, and your design matrix $X$ will not have linearly independent columns. Everyone starts school at age 5, $\mathbf{x_1} = \mathbf{1}$ (i.e. constant value of 1 across all observations), $\mathbf{x_2}$ is years of schooling, $\mathbf{x_3}$ is age, and no one has left school. Then: $\mathbf{x_2} = \mathbf{x_3} - 5\mathbf{x_1}$, and your design matrix $X$ will not have linearly independent columns. There a multitude of ways such that one column of data will be a linear function of your other data. Some of them are obvious (eg. meters vs. centimeters) while others can be more subtle (eg. age and years of schooling for younger children). Notational notes: Let $\mathbf{x_1}$ denote the first column of $X$, $\mathbf{x_2}$ the second column etc..., and $\mathbf{1}$ denotes a vector of ones, which is what's included in the design matrix X if you include a constant in your regression.
What is an example of perfect multicollinearity?
Some trivial examples to help intuition: $\mathbf{x_1}$ is height in centimeters. $\mathbf{x_2}$ is height in meters. Then: $\mathbf{x_1} = 100 \mathbf{x_2}$, and your design matrix $X$ will not hav
What is an example of perfect multicollinearity? Some trivial examples to help intuition: $\mathbf{x_1}$ is height in centimeters. $\mathbf{x_2}$ is height in meters. Then: $\mathbf{x_1} = 100 \mathbf{x_2}$, and your design matrix $X$ will not have linearly independent columns. $\mathbf{x_1} = \mathbf{1}$ (i.e. you include a constant in your regression), $\mathbf{x_2}$ is temperature in fahrenheit, and $\mathbf{x_3}$ is temperature in celsius. Then: $\mathbf{x_2} = \frac{9}{5}\mathbf{x_3} + 32 \mathbf{x_1}$, and your design matrix $X$ will not have linearly independent columns. Everyone starts school at age 5, $\mathbf{x_1} = \mathbf{1}$ (i.e. constant value of 1 across all observations), $\mathbf{x_2}$ is years of schooling, $\mathbf{x_3}$ is age, and no one has left school. Then: $\mathbf{x_2} = \mathbf{x_3} - 5\mathbf{x_1}$, and your design matrix $X$ will not have linearly independent columns. There a multitude of ways such that one column of data will be a linear function of your other data. Some of them are obvious (eg. meters vs. centimeters) while others can be more subtle (eg. age and years of schooling for younger children). Notational notes: Let $\mathbf{x_1}$ denote the first column of $X$, $\mathbf{x_2}$ the second column etc..., and $\mathbf{1}$ denotes a vector of ones, which is what's included in the design matrix X if you include a constant in your regression.
What is an example of perfect multicollinearity? Some trivial examples to help intuition: $\mathbf{x_1}$ is height in centimeters. $\mathbf{x_2}$ is height in meters. Then: $\mathbf{x_1} = 100 \mathbf{x_2}$, and your design matrix $X$ will not hav
18,033
Random forest regression not predicting higher than training data
As it has been mentioned already in previous answers, random forest for regression / regression trees doesn't produce expected predictions for data points beyond the scope of training data range because they cannot extrapolate (well). A regression tree consists of a hierarchy of nodes, where each node specifies a test to be carried out on an attribute value and each leaf (terminal) node specifies a rule to calculate a predicted output. In your case the testing observation flow through the trees to leaf nodes stating, e.g., "if x > 335, then y = 15", which are then averaged by random forest. Here is an R script visualizing the situation with both random forest and linear regression. In random forest's case, predictions are constant for testing data points that are either below the lowest training data x-value or above the highest training data x-value. library(datasets) library(randomForest) library(ggplot2) library(ggthemes) # Import mtcars (Motor Trend Car Road Tests) dataset data(mtcars) # Define training data train_data = data.frame( x = mtcars$hp, # Gross horsepower y = mtcars$qsec) # 1/4 mile time # Train random forest model for regression random_forest <- randomForest(x = matrix(train_data$x), y = matrix(train_data$y), ntree = 20) # Train linear regression model using ordinary least squares (OLS) estimator linear_regr <- lm(y ~ x, train_data) # Create testing data test_data = data.frame(x = seq(0, 400)) # Predict targets for testing data points test_data$y_predicted_rf <- predict(random_forest, matrix(test_data$x)) test_data$y_predicted_linreg <- predict(linear_regr, test_data) # Visualize ggplot2::ggplot() + # Training data points ggplot2::geom_point(data = train_data, size = 2, ggplot2::aes(x = x, y = y, color = "Training data")) + # Random forest predictions ggplot2::geom_line(data = test_data, size = 2, alpha = 0.7, ggplot2::aes(x = x, y = y_predicted_rf, color = "Predicted with random forest")) + # Linear regression predictions ggplot2::geom_line(data = test_data, size = 2, alpha = 0.7, ggplot2::aes(x = x, y = y_predicted_linreg, color = "Predicted with linear regression")) + # Hide legend title, change legend location and add axis labels ggplot2::theme(legend.title = element_blank(), legend.position = "bottom") + labs(y = "1/4 mile time", x = "Gross horsepower") + ggthemes::scale_colour_colorblind()
Random forest regression not predicting higher than training data
As it has been mentioned already in previous answers, random forest for regression / regression trees doesn't produce expected predictions for data points beyond the scope of training data range becau
Random forest regression not predicting higher than training data As it has been mentioned already in previous answers, random forest for regression / regression trees doesn't produce expected predictions for data points beyond the scope of training data range because they cannot extrapolate (well). A regression tree consists of a hierarchy of nodes, where each node specifies a test to be carried out on an attribute value and each leaf (terminal) node specifies a rule to calculate a predicted output. In your case the testing observation flow through the trees to leaf nodes stating, e.g., "if x > 335, then y = 15", which are then averaged by random forest. Here is an R script visualizing the situation with both random forest and linear regression. In random forest's case, predictions are constant for testing data points that are either below the lowest training data x-value or above the highest training data x-value. library(datasets) library(randomForest) library(ggplot2) library(ggthemes) # Import mtcars (Motor Trend Car Road Tests) dataset data(mtcars) # Define training data train_data = data.frame( x = mtcars$hp, # Gross horsepower y = mtcars$qsec) # 1/4 mile time # Train random forest model for regression random_forest <- randomForest(x = matrix(train_data$x), y = matrix(train_data$y), ntree = 20) # Train linear regression model using ordinary least squares (OLS) estimator linear_regr <- lm(y ~ x, train_data) # Create testing data test_data = data.frame(x = seq(0, 400)) # Predict targets for testing data points test_data$y_predicted_rf <- predict(random_forest, matrix(test_data$x)) test_data$y_predicted_linreg <- predict(linear_regr, test_data) # Visualize ggplot2::ggplot() + # Training data points ggplot2::geom_point(data = train_data, size = 2, ggplot2::aes(x = x, y = y, color = "Training data")) + # Random forest predictions ggplot2::geom_line(data = test_data, size = 2, alpha = 0.7, ggplot2::aes(x = x, y = y_predicted_rf, color = "Predicted with random forest")) + # Linear regression predictions ggplot2::geom_line(data = test_data, size = 2, alpha = 0.7, ggplot2::aes(x = x, y = y_predicted_linreg, color = "Predicted with linear regression")) + # Hide legend title, change legend location and add axis labels ggplot2::theme(legend.title = element_blank(), legend.position = "bottom") + labs(y = "1/4 mile time", x = "Gross horsepower") + ggthemes::scale_colour_colorblind()
Random forest regression not predicting higher than training data As it has been mentioned already in previous answers, random forest for regression / regression trees doesn't produce expected predictions for data points beyond the scope of training data range becau
18,034
Random forest regression not predicting higher than training data
There's no way to a Random Forest to extrapolate like an OLS do. The reason is simple: the predictions from a Random Forest are done through averaging the results obtained in several trees. The trees themselves output the mean value of the samples in each terminal node, the leaves. It's impossible for the result to be outside the range of the training data, because the average is always inside the range of its constituents. In other words, it's impossible for an average to be bigger (or lower) than every sample, and Random Forests regressions are based on averaging.
Random forest regression not predicting higher than training data
There's no way to a Random Forest to extrapolate like an OLS do. The reason is simple: the predictions from a Random Forest are done through averaging the results obtained in several trees. The trees
Random forest regression not predicting higher than training data There's no way to a Random Forest to extrapolate like an OLS do. The reason is simple: the predictions from a Random Forest are done through averaging the results obtained in several trees. The trees themselves output the mean value of the samples in each terminal node, the leaves. It's impossible for the result to be outside the range of the training data, because the average is always inside the range of its constituents. In other words, it's impossible for an average to be bigger (or lower) than every sample, and Random Forests regressions are based on averaging.
Random forest regression not predicting higher than training data There's no way to a Random Forest to extrapolate like an OLS do. The reason is simple: the predictions from a Random Forest are done through averaging the results obtained in several trees. The trees
18,035
Random forest regression not predicting higher than training data
Decision Trees / Random Forrest cannot extrapolate outside of the training data. And although OLS can do this, such predictions should be looked at with caution; as the identified pattern may not continue outside of the observed range.
Random forest regression not predicting higher than training data
Decision Trees / Random Forrest cannot extrapolate outside of the training data. And although OLS can do this, such predictions should be looked at with caution; as the identified pattern may not cont
Random forest regression not predicting higher than training data Decision Trees / Random Forrest cannot extrapolate outside of the training data. And although OLS can do this, such predictions should be looked at with caution; as the identified pattern may not continue outside of the observed range.
Random forest regression not predicting higher than training data Decision Trees / Random Forrest cannot extrapolate outside of the training data. And although OLS can do this, such predictions should be looked at with caution; as the identified pattern may not cont
18,036
Does the assumption of Normal errors imply that Y is also Normal?
The standard OLS model is $Y = X \beta + \varepsilon$ with $\varepsilon \sim \mathcal N(\vec 0, \sigma^2 I_n)$ for a fixed $X \in \mathbb R^{n \times p}$. This does indeed mean that $Y|\{X, \beta, \sigma^2\} \sim \mathcal N(X\beta, \sigma^2 I_n)$, although this is a consequence of our assumption on the distribution of $\varepsilon$, rather than actually being the assumption. Also keep in mind that I'm talking about the conditional distribution of $Y$, not the marginal distribution of $Y$. I'm focusing on the conditional distribution because I think that's what you're really asking about. I think the part that is confusing is that this doesn't mean that a histogram of $Y$ will look normal. We are saying that the entire vector $Y$ is a single draw from a multivariate normal distribution where each element has a potentially different mean $E(Y_i|X_i) = X_i^T\beta$. This is not the same as being an iid normal sample. The errors $\varepsilon$ actually are an iid sample so a histogram of them would look normal (and that's why we do a QQ plot of the residuals, not the response). Here's an example: suppose we are measuring height $H$ for a sample of 6th graders and 12th graders. Our model is $H_i = \beta_0 + \beta_1I(\text{12th grader}) + \varepsilon_i$ with $\varepsilon_i \sim \ \text{iid} \ \mathcal N(0, \sigma^2)$. If we look at a histogram of the $H_i$ we'll probably see a bimodal distribution, with one peak for 6th graders and one peak for 12th graders, but that doesn't represent a violation of our assumptions.
Does the assumption of Normal errors imply that Y is also Normal?
The standard OLS model is $Y = X \beta + \varepsilon$ with $\varepsilon \sim \mathcal N(\vec 0, \sigma^2 I_n)$ for a fixed $X \in \mathbb R^{n \times p}$. This does indeed mean that $Y|\{X, \beta, \s
Does the assumption of Normal errors imply that Y is also Normal? The standard OLS model is $Y = X \beta + \varepsilon$ with $\varepsilon \sim \mathcal N(\vec 0, \sigma^2 I_n)$ for a fixed $X \in \mathbb R^{n \times p}$. This does indeed mean that $Y|\{X, \beta, \sigma^2\} \sim \mathcal N(X\beta, \sigma^2 I_n)$, although this is a consequence of our assumption on the distribution of $\varepsilon$, rather than actually being the assumption. Also keep in mind that I'm talking about the conditional distribution of $Y$, not the marginal distribution of $Y$. I'm focusing on the conditional distribution because I think that's what you're really asking about. I think the part that is confusing is that this doesn't mean that a histogram of $Y$ will look normal. We are saying that the entire vector $Y$ is a single draw from a multivariate normal distribution where each element has a potentially different mean $E(Y_i|X_i) = X_i^T\beta$. This is not the same as being an iid normal sample. The errors $\varepsilon$ actually are an iid sample so a histogram of them would look normal (and that's why we do a QQ plot of the residuals, not the response). Here's an example: suppose we are measuring height $H$ for a sample of 6th graders and 12th graders. Our model is $H_i = \beta_0 + \beta_1I(\text{12th grader}) + \varepsilon_i$ with $\varepsilon_i \sim \ \text{iid} \ \mathcal N(0, \sigma^2)$. If we look at a histogram of the $H_i$ we'll probably see a bimodal distribution, with one peak for 6th graders and one peak for 12th graders, but that doesn't represent a violation of our assumptions.
Does the assumption of Normal errors imply that Y is also Normal? The standard OLS model is $Y = X \beta + \varepsilon$ with $\varepsilon \sim \mathcal N(\vec 0, \sigma^2 I_n)$ for a fixed $X \in \mathbb R^{n \times p}$. This does indeed mean that $Y|\{X, \beta, \s
18,037
Does the assumption of Normal errors imply that Y is also Normal?
Therefore, if we assume that the error term is Normally distributed, doesn't that imply that the response is also Normally distributed? Not even remotely. The way I remember this is that the residuals are normal conditional on the deterministic portion of the model. Here's a demonstration of what that looks like in practice. I start by randomly generating some data. Then I define an outcome which is a linear function of the predictors and estimate a model. N <- 100 x1 <- rbeta(N, shape1=2, shape2=10) x2 <- rbeta(N, shape1=10, shape2=2) x <- c(x1,x2) plot(density(x, from=0, to=1)) y <- 1+10*x+rnorm(2*N, sd=1) model<-lm(y~x) Let's take a look at what these residuals look like. I suspect that they should be normally distributed, since the outcome y had iid normal noise added to it. And indeed that is the case. plot(density(model$residuals), main="Model residuals", lwd=2) s <- seq(-5,20, len=1000) lines(s, dnorm(s), col="red") plot(density(y), main="KDE of y", lwd=2) lines(s, dnorm(s, mean=mean(y), sd=sd(y)), col="red") Checking the distribution of y, however, we can see that it's definitely not normal! I've overlaid the density function with the same mean and variance as y, but it's obviously a terrible fit! The reason that this happened in this case is that the input data is not even remotely normal. Nothing about this regression model requires normality except in the residuals -- not in the independent variable, and not in the dependent variable.
Does the assumption of Normal errors imply that Y is also Normal?
Therefore, if we assume that the error term is Normally distributed, doesn't that imply that the response is also Normally distributed? Not even remotely. The way I remember this is that the residual
Does the assumption of Normal errors imply that Y is also Normal? Therefore, if we assume that the error term is Normally distributed, doesn't that imply that the response is also Normally distributed? Not even remotely. The way I remember this is that the residuals are normal conditional on the deterministic portion of the model. Here's a demonstration of what that looks like in practice. I start by randomly generating some data. Then I define an outcome which is a linear function of the predictors and estimate a model. N <- 100 x1 <- rbeta(N, shape1=2, shape2=10) x2 <- rbeta(N, shape1=10, shape2=2) x <- c(x1,x2) plot(density(x, from=0, to=1)) y <- 1+10*x+rnorm(2*N, sd=1) model<-lm(y~x) Let's take a look at what these residuals look like. I suspect that they should be normally distributed, since the outcome y had iid normal noise added to it. And indeed that is the case. plot(density(model$residuals), main="Model residuals", lwd=2) s <- seq(-5,20, len=1000) lines(s, dnorm(s), col="red") plot(density(y), main="KDE of y", lwd=2) lines(s, dnorm(s, mean=mean(y), sd=sd(y)), col="red") Checking the distribution of y, however, we can see that it's definitely not normal! I've overlaid the density function with the same mean and variance as y, but it's obviously a terrible fit! The reason that this happened in this case is that the input data is not even remotely normal. Nothing about this regression model requires normality except in the residuals -- not in the independent variable, and not in the dependent variable.
Does the assumption of Normal errors imply that Y is also Normal? Therefore, if we assume that the error term is Normally distributed, doesn't that imply that the response is also Normally distributed? Not even remotely. The way I remember this is that the residual
18,038
Does the assumption of Normal errors imply that Y is also Normal?
No, it doesn't. For example, suppose we have a model predicting the weight of Olympic athletes. While weight could well be normally distributed among athletes in each sport, it won't be among all athletes - it might not even be unimodal.
Does the assumption of Normal errors imply that Y is also Normal?
No, it doesn't. For example, suppose we have a model predicting the weight of Olympic athletes. While weight could well be normally distributed among athletes in each sport, it won't be among all ath
Does the assumption of Normal errors imply that Y is also Normal? No, it doesn't. For example, suppose we have a model predicting the weight of Olympic athletes. While weight could well be normally distributed among athletes in each sport, it won't be among all athletes - it might not even be unimodal.
Does the assumption of Normal errors imply that Y is also Normal? No, it doesn't. For example, suppose we have a model predicting the weight of Olympic athletes. While weight could well be normally distributed among athletes in each sport, it won't be among all ath
18,039
VC dimension of a rectangle
tl;dr: You've got the definition of VC dimension incorrect. The VC dimension of rectangles is the cardinality of the maximum set of points that can be shattered by a rectangle. The VC dimension of rectangles is 4 because there exists a set of 4 points that can be shattered by a rectangle and any set of 5 points can not be shattered by a rectangle. So, while it's true that a rectangle cannot shatter a set of four collinear points with alternate positive and negative, the VC-dimension is still 4 because there exists one configuration of 4 points which can be shattered.
VC dimension of a rectangle
tl;dr: You've got the definition of VC dimension incorrect. The VC dimension of rectangles is the cardinality of the maximum set of points that can be shattered by a rectangle. The VC dimension of rec
VC dimension of a rectangle tl;dr: You've got the definition of VC dimension incorrect. The VC dimension of rectangles is the cardinality of the maximum set of points that can be shattered by a rectangle. The VC dimension of rectangles is 4 because there exists a set of 4 points that can be shattered by a rectangle and any set of 5 points can not be shattered by a rectangle. So, while it's true that a rectangle cannot shatter a set of four collinear points with alternate positive and negative, the VC-dimension is still 4 because there exists one configuration of 4 points which can be shattered.
VC dimension of a rectangle tl;dr: You've got the definition of VC dimension incorrect. The VC dimension of rectangles is the cardinality of the maximum set of points that can be shattered by a rectangle. The VC dimension of rec
18,040
VC dimension of a rectangle
The VC dimension of an algorithm is that maximum number of points such that there exists some layout of the points such that for all labelings of those points, the algorithm makes no errors And indeed, there is a layout of four points (as a diamond) such that a rectangle can divide any set of positive points from the others. That there exists a layout of four points where the rectangle will fail is irrelevant. Here's a writeup with a diagram.
VC dimension of a rectangle
The VC dimension of an algorithm is that maximum number of points such that there exists some layout of the points such that for all labelings of those points, the algorithm makes no errors And ind
VC dimension of a rectangle The VC dimension of an algorithm is that maximum number of points such that there exists some layout of the points such that for all labelings of those points, the algorithm makes no errors And indeed, there is a layout of four points (as a diamond) such that a rectangle can divide any set of positive points from the others. That there exists a layout of four points where the rectangle will fail is irrelevant. Here's a writeup with a diagram.
VC dimension of a rectangle The VC dimension of an algorithm is that maximum number of points such that there exists some layout of the points such that for all labelings of those points, the algorithm makes no errors And ind
18,041
VC dimension of a rectangle
Consider it like a game between you and an opponent. You choose the location of points and the opponent label them anyway he likes. If he wins by finding a labeling that can not be shattered, then the VC dimension is less than the number of points but if you win the VC dimension is equal or greater than the number of points. In your question, you are not forced to select that arrangement, you can find a better arrangement of points, which let you win.
VC dimension of a rectangle
Consider it like a game between you and an opponent. You choose the location of points and the opponent label them anyway he likes. If he wins by finding a labeling that can not be shattered, then t
VC dimension of a rectangle Consider it like a game between you and an opponent. You choose the location of points and the opponent label them anyway he likes. If he wins by finding a labeling that can not be shattered, then the VC dimension is less than the number of points but if you win the VC dimension is equal or greater than the number of points. In your question, you are not forced to select that arrangement, you can find a better arrangement of points, which let you win.
VC dimension of a rectangle Consider it like a game between you and an opponent. You choose the location of points and the opponent label them anyway he likes. If he wins by finding a labeling that can not be shattered, then t
18,042
What does truncated distribution mean?
To truncate a distribution is to restrict its values to an interval and re-normalize the density so that the integral over that range is 1. So, to truncate the $N(\mu, \sigma^{2})$ distribution to an interval $(a,b)$ would be to generate a random variable that has density $$ p_{a,b}(x) = \frac{ \phi_{\mu, \sigma^{2}}(x) }{ \int_{a}^{b} \phi_{\mu, \sigma^{2}}(y) dy } \cdot \mathcal{I} \{ x \in (a,b) \} $$ where $\phi_{\mu, \sigma^{2}}(x)$ is the $N(\mu, \sigma^2)$ density. You could sample from this density in a number of ways. One way (the simplest way I can think of) to do this would be to generate $N(\mu, \sigma^2)$ values and throw out the ones that fall outside of the $(a,b)$ interval, as you mentioned. So, yes, those two bullets you listed would accomplish the same goal. Also, you are right that the empirical density (or histogram) of variables from this distribution would not extend to $\pm \infty$. It would be restricted to $(a,b)$, of course.
What does truncated distribution mean?
To truncate a distribution is to restrict its values to an interval and re-normalize the density so that the integral over that range is 1. So, to truncate the $N(\mu, \sigma^{2})$ distribution to an
What does truncated distribution mean? To truncate a distribution is to restrict its values to an interval and re-normalize the density so that the integral over that range is 1. So, to truncate the $N(\mu, \sigma^{2})$ distribution to an interval $(a,b)$ would be to generate a random variable that has density $$ p_{a,b}(x) = \frac{ \phi_{\mu, \sigma^{2}}(x) }{ \int_{a}^{b} \phi_{\mu, \sigma^{2}}(y) dy } \cdot \mathcal{I} \{ x \in (a,b) \} $$ where $\phi_{\mu, \sigma^{2}}(x)$ is the $N(\mu, \sigma^2)$ density. You could sample from this density in a number of ways. One way (the simplest way I can think of) to do this would be to generate $N(\mu, \sigma^2)$ values and throw out the ones that fall outside of the $(a,b)$ interval, as you mentioned. So, yes, those two bullets you listed would accomplish the same goal. Also, you are right that the empirical density (or histogram) of variables from this distribution would not extend to $\pm \infty$. It would be restricted to $(a,b)$, of course.
What does truncated distribution mean? To truncate a distribution is to restrict its values to an interval and re-normalize the density so that the integral over that range is 1. So, to truncate the $N(\mu, \sigma^{2})$ distribution to an
18,043
What does truncated distribution mean?
Simulating from the normal $\mathcal{N}(\mu,\sigma^2)$ distribution until the outcome falls within an interval $(a,b)$ is fine when the probability $$ \varrho = \int_a^b \varphi_{\mu,\sigma^2}(x)\,\text{d} x $$ is large enough. If it is too small, this procedure is too costly since the average number of draws for one acceptance is $1/\varrho$. As described in Monte Carlo Statistical Methods (Chapter 2, Example 2.2), as well as in my arXiv paper, a more efficient way to simulate this truncated normal is to use an accept-reject method based on an exponential $\mathcal{E}(\alpha)$ distribution. Consider, without loss of generality, the case $\mu = 0$ and $\sigma = 1$. When $b=+\infty$, a potential instrumental distribution is the translated exponential distribution, $\mathcal{E} (\alpha,{ a})$, with density $$ g_{\alpha}(z) = \alpha e^{- \alpha(z - {a})} \; \mathbb{I}_{z \geq {a }} \;. $$ The ratio $$ p_{a,\infty}(z)/g_{\alpha}(z) \propto e^{- \alpha(z - a )}e^{-z^{2}/2} $$ is then bounded by $\exp(\alpha^{2}/2 - \alpha{a })$ if $\alpha > a$ and by $\exp(- a^{2}/2)$ otherwise. The corresponding (upper) bound is $$ \begin{cases} 1/\alpha \; \exp (\alpha^{2}/2 - \alpha{a }) & \hbox{if } \alpha > a , \cr 1/\alpha \; \exp (- a^{2}/2) & \hbox{otherwise.} \cr \end{cases} $$ The first expression is minimized by \begin{equation} \alpha^{*} = \frac{1}{2}a + \frac{1}{2} \sqrt{a^2 + 4}\;,\qquad (1) \end{equation} whereas $\tilde\alpha = a $ minimizes the second bound. The optimal choice of $\alpha$ is therefore (1).
What does truncated distribution mean?
Simulating from the normal $\mathcal{N}(\mu,\sigma^2)$ distribution until the outcome falls within an interval $(a,b)$ is fine when the probability $$ \varrho = \int_a^b \varphi_{\mu,\sigma^2}(x)\,\t
What does truncated distribution mean? Simulating from the normal $\mathcal{N}(\mu,\sigma^2)$ distribution until the outcome falls within an interval $(a,b)$ is fine when the probability $$ \varrho = \int_a^b \varphi_{\mu,\sigma^2}(x)\,\text{d} x $$ is large enough. If it is too small, this procedure is too costly since the average number of draws for one acceptance is $1/\varrho$. As described in Monte Carlo Statistical Methods (Chapter 2, Example 2.2), as well as in my arXiv paper, a more efficient way to simulate this truncated normal is to use an accept-reject method based on an exponential $\mathcal{E}(\alpha)$ distribution. Consider, without loss of generality, the case $\mu = 0$ and $\sigma = 1$. When $b=+\infty$, a potential instrumental distribution is the translated exponential distribution, $\mathcal{E} (\alpha,{ a})$, with density $$ g_{\alpha}(z) = \alpha e^{- \alpha(z - {a})} \; \mathbb{I}_{z \geq {a }} \;. $$ The ratio $$ p_{a,\infty}(z)/g_{\alpha}(z) \propto e^{- \alpha(z - a )}e^{-z^{2}/2} $$ is then bounded by $\exp(\alpha^{2}/2 - \alpha{a })$ if $\alpha > a$ and by $\exp(- a^{2}/2)$ otherwise. The corresponding (upper) bound is $$ \begin{cases} 1/\alpha \; \exp (\alpha^{2}/2 - \alpha{a }) & \hbox{if } \alpha > a , \cr 1/\alpha \; \exp (- a^{2}/2) & \hbox{otherwise.} \cr \end{cases} $$ The first expression is minimized by \begin{equation} \alpha^{*} = \frac{1}{2}a + \frac{1}{2} \sqrt{a^2 + 4}\;,\qquad (1) \end{equation} whereas $\tilde\alpha = a $ minimizes the second bound. The optimal choice of $\alpha$ is therefore (1).
What does truncated distribution mean? Simulating from the normal $\mathcal{N}(\mu,\sigma^2)$ distribution until the outcome falls within an interval $(a,b)$ is fine when the probability $$ \varrho = \int_a^b \varphi_{\mu,\sigma^2}(x)\,\t
18,044
What does truncated distribution mean?
Sample from a Normal distribution but ignore all the random values falling outside the specified range before simulations. This method is correct, but, as mentionned by @Xi'an in his answer, it would take a long time when the range is small (more precisely, when its measure is small under the normal distribution). As any other distribution, one could use the inversion method $F^{-1}(U)$ (also called inverse transform sampling), where $F$ is the (cumulative function of the) distribution of interest and $U\sim\text{Unif}(0,1)$. When $F$ is the distribution obtained by truncating some distribution $G$ on some interval $(a,b)$, this is equivalent to sample $G^{-1}(U)$ with $U\sim\text{Unif}\bigl(G(a),G(b)\bigr)$. However, and this is already mentionned by @Xi'an's in a comment, for some situations the inversion method requires a very precise evaluation of the quantile function $G^{-1}$, and I would add it also requires a fast computation of $G^{-1}$. When $G$ is a normal distribution, the evaluation of $G^{-1}$ is rather slow, and it is not highly precise for values of $a$ and $b$ outside the "range" of $G$. Simulate a truncated distribution using importance sampling A possibility is to use importance sampling. Consider the case of the standard Gaussian distribution ${\cal N}(0,1)$. Forget the previous notations, now let $G$ be the Cauchy distribution. The two above mentionned requirements are fulfilled for $G$ : one simply has $\boxed{G(q)=\frac{\arctan(q)}{\pi}+\frac12}$ and $\boxed{G^{-1}(q)=\tan\bigl(\pi(q-\frac12)\bigr)}$. Therefore, the truncated Cauchy distribution is easy to sample by the inversion method and it is a good choice of the instrumental variable for importance sampling of the truncated normal distribution. After a bit of simplifications, sampling $U\sim\text{Unif}\bigl(G(a),G(b)\bigr)$ and taking $G^{-1}(U)$ is equivalent to take $\tan(U')$ with $U'\sim\text{Unif}\bigl(\arctan(a),\arctan(b)\bigr)$: a <- 1 b <- 5 nsims <- 10^5 sims <- tan(runif(nsims, atan(a), atan(b))) Now one has to calculate the weight for each sampled value $x_i$, defined as the ratio $\phi(x)/g(x)$ of the two densities up to normalization, hence we can take $$ w(x) = \exp(-x^2/2)(1+x^2), $$ but it could be safer to take the log-weights: log_w <- -sims^2/2 + log1p(sims^2) w <- exp(log_w) # unnormalized weights w <- w/sum(w) The weighted sample $(x_i,w(x_i))$ allows to estimate the measure of every interval $[u,v]$ under the target distribution, by summing the weights of each sampled value falling inside the interval: u <- 2; v<- 4 sum(w[sims>u & sims<v]) ## [1] 0.1418 This provides an estimate of the target cumulative function. We can quickly get and plot it with the spatsat package: F <- spatstat::ewcdf(sims,w) # estimated F: curve(F(x), from=a-0.1, to=b+0.1) # true F: curve((pnorm(x)-pnorm(a))/(pnorm(b)-pnorm(a)), add=TRUE, col="red") # approximate probability of u<x<v: F(v)-F(u) ## [1] 0.1418 Of course, the sample $(x_i)$ is definitely not a sample of the target distribution, but of the instrumental Cauchy distribution, and one gets a sample of the target distribution by performing weighted resampling, for instance using the multinomial sampling: msample <- rmultinom(1, nsims, w)[,1] resims <- rep(sims, times=msample) hist(resims) mean(resims>u & resims<v) ## [1] 0.1446 Another method: fast inverse transform sampling Olver and Townsend developed a sampling method for a broad class of continuous distribution. It is implemented in the chebfun2 library for Matlab as well as the ApproxFun library for Julia. I have recently discovered this library and it sounds very promising (not only for random sampling). Basically this is the inversion method but using powerful approximations of the cdf and the inverse cdf. The input is the target density function up to normalization. The sample is simply generated by the following code: using ApproxFun f = Fun(x -> exp(-x.^2./2), [1,5]); nsims = 10^5; x = sample(f,nsims); As checked below, it yields an estimated measure of the interval $[2,4]$ close to the one previously obtained by importance sampling: sum((x.>2) & (x.<4))/nsims ## 0.14191
What does truncated distribution mean?
Sample from a Normal distribution but ignore all the random values falling outside the specified range before simulations. This method is correct, but, as mentionned by @Xi'an in his answer, it wou
What does truncated distribution mean? Sample from a Normal distribution but ignore all the random values falling outside the specified range before simulations. This method is correct, but, as mentionned by @Xi'an in his answer, it would take a long time when the range is small (more precisely, when its measure is small under the normal distribution). As any other distribution, one could use the inversion method $F^{-1}(U)$ (also called inverse transform sampling), where $F$ is the (cumulative function of the) distribution of interest and $U\sim\text{Unif}(0,1)$. When $F$ is the distribution obtained by truncating some distribution $G$ on some interval $(a,b)$, this is equivalent to sample $G^{-1}(U)$ with $U\sim\text{Unif}\bigl(G(a),G(b)\bigr)$. However, and this is already mentionned by @Xi'an's in a comment, for some situations the inversion method requires a very precise evaluation of the quantile function $G^{-1}$, and I would add it also requires a fast computation of $G^{-1}$. When $G$ is a normal distribution, the evaluation of $G^{-1}$ is rather slow, and it is not highly precise for values of $a$ and $b$ outside the "range" of $G$. Simulate a truncated distribution using importance sampling A possibility is to use importance sampling. Consider the case of the standard Gaussian distribution ${\cal N}(0,1)$. Forget the previous notations, now let $G$ be the Cauchy distribution. The two above mentionned requirements are fulfilled for $G$ : one simply has $\boxed{G(q)=\frac{\arctan(q)}{\pi}+\frac12}$ and $\boxed{G^{-1}(q)=\tan\bigl(\pi(q-\frac12)\bigr)}$. Therefore, the truncated Cauchy distribution is easy to sample by the inversion method and it is a good choice of the instrumental variable for importance sampling of the truncated normal distribution. After a bit of simplifications, sampling $U\sim\text{Unif}\bigl(G(a),G(b)\bigr)$ and taking $G^{-1}(U)$ is equivalent to take $\tan(U')$ with $U'\sim\text{Unif}\bigl(\arctan(a),\arctan(b)\bigr)$: a <- 1 b <- 5 nsims <- 10^5 sims <- tan(runif(nsims, atan(a), atan(b))) Now one has to calculate the weight for each sampled value $x_i$, defined as the ratio $\phi(x)/g(x)$ of the two densities up to normalization, hence we can take $$ w(x) = \exp(-x^2/2)(1+x^2), $$ but it could be safer to take the log-weights: log_w <- -sims^2/2 + log1p(sims^2) w <- exp(log_w) # unnormalized weights w <- w/sum(w) The weighted sample $(x_i,w(x_i))$ allows to estimate the measure of every interval $[u,v]$ under the target distribution, by summing the weights of each sampled value falling inside the interval: u <- 2; v<- 4 sum(w[sims>u & sims<v]) ## [1] 0.1418 This provides an estimate of the target cumulative function. We can quickly get and plot it with the spatsat package: F <- spatstat::ewcdf(sims,w) # estimated F: curve(F(x), from=a-0.1, to=b+0.1) # true F: curve((pnorm(x)-pnorm(a))/(pnorm(b)-pnorm(a)), add=TRUE, col="red") # approximate probability of u<x<v: F(v)-F(u) ## [1] 0.1418 Of course, the sample $(x_i)$ is definitely not a sample of the target distribution, but of the instrumental Cauchy distribution, and one gets a sample of the target distribution by performing weighted resampling, for instance using the multinomial sampling: msample <- rmultinom(1, nsims, w)[,1] resims <- rep(sims, times=msample) hist(resims) mean(resims>u & resims<v) ## [1] 0.1446 Another method: fast inverse transform sampling Olver and Townsend developed a sampling method for a broad class of continuous distribution. It is implemented in the chebfun2 library for Matlab as well as the ApproxFun library for Julia. I have recently discovered this library and it sounds very promising (not only for random sampling). Basically this is the inversion method but using powerful approximations of the cdf and the inverse cdf. The input is the target density function up to normalization. The sample is simply generated by the following code: using ApproxFun f = Fun(x -> exp(-x.^2./2), [1,5]); nsims = 10^5; x = sample(f,nsims); As checked below, it yields an estimated measure of the interval $[2,4]$ close to the one previously obtained by importance sampling: sum((x.>2) & (x.<4))/nsims ## 0.14191
What does truncated distribution mean? Sample from a Normal distribution but ignore all the random values falling outside the specified range before simulations. This method is correct, but, as mentionned by @Xi'an in his answer, it wou
18,045
How to choose a confidence level?
In addition to Tim's great answer, there are even within a field different reasons for particular confidence intervals. In a clinical trial for hairspray, for example, you would want to be very confident your treatment wasn't likely to kill anyone, say 99.99%, but you'd be perfectly fine with a 75% confidence interval that your hairspray makes hair stay straight. In general, confidence intervals should be used in such a fashion that you're comfortable with the uncertainty, but also not so strict they lower the power of your study into irrelevance. A 90% confidence interval means when repeating the sampling you would expect that one time in ten intervals generate will not include the true value. Based on what you're researching, is that acceptable? On the other hand, if you prefer a 99% confidence interval, is your sample size sufficient that your interval isn't going to be uselessly large? (Hopefully you're deciding the CI level before doing the study, right?) In my experience (in the social sciences) and from what I've seen of my wife's (in the biological sciences), while there are CI/significance sort-of-standards in various fields and various specific cases, it's not uncommon for the majority of debate over a topic be whether you appropriately set your CI interval or significance level. I've been in meetings where a statistician patiently explained to a client that while they may like a 99% two sided confidence interval, for their data to ever show significance they would have to increase their sample tenfold; and I've been in meetings where clients ask why none of their data shows a significant difference, where we patiently explain to them it's because they chose a high interval - or the reverse, everything is significant because a lower interval was requested. When you publish a paper, it's not uncommon for three reviewers to have three different opinions of your CI level, if it's not on the high end for your discipline. What I suggest is to read some of the major papers in your field (as close to your specific topic as possible) and see what they use; combine that with your comfort level and sample size; and then be prepared to defend what you choose with that information at hand. Unless you're in a field with very strict rules - clinical trials I suspect are the only ones that are really that strict, at least from what I've seen - you'll not get anything better. (And if there are strict rules, I'd expect the major papers in your field to follow it!)
How to choose a confidence level?
In addition to Tim's great answer, there are even within a field different reasons for particular confidence intervals. In a clinical trial for hairspray, for example, you would want to be very confi
How to choose a confidence level? In addition to Tim's great answer, there are even within a field different reasons for particular confidence intervals. In a clinical trial for hairspray, for example, you would want to be very confident your treatment wasn't likely to kill anyone, say 99.99%, but you'd be perfectly fine with a 75% confidence interval that your hairspray makes hair stay straight. In general, confidence intervals should be used in such a fashion that you're comfortable with the uncertainty, but also not so strict they lower the power of your study into irrelevance. A 90% confidence interval means when repeating the sampling you would expect that one time in ten intervals generate will not include the true value. Based on what you're researching, is that acceptable? On the other hand, if you prefer a 99% confidence interval, is your sample size sufficient that your interval isn't going to be uselessly large? (Hopefully you're deciding the CI level before doing the study, right?) In my experience (in the social sciences) and from what I've seen of my wife's (in the biological sciences), while there are CI/significance sort-of-standards in various fields and various specific cases, it's not uncommon for the majority of debate over a topic be whether you appropriately set your CI interval or significance level. I've been in meetings where a statistician patiently explained to a client that while they may like a 99% two sided confidence interval, for their data to ever show significance they would have to increase their sample tenfold; and I've been in meetings where clients ask why none of their data shows a significant difference, where we patiently explain to them it's because they chose a high interval - or the reverse, everything is significant because a lower interval was requested. When you publish a paper, it's not uncommon for three reviewers to have three different opinions of your CI level, if it's not on the high end for your discipline. What I suggest is to read some of the major papers in your field (as close to your specific topic as possible) and see what they use; combine that with your comfort level and sample size; and then be prepared to defend what you choose with that information at hand. Unless you're in a field with very strict rules - clinical trials I suspect are the only ones that are really that strict, at least from what I've seen - you'll not get anything better. (And if there are strict rules, I'd expect the major papers in your field to follow it!)
How to choose a confidence level? In addition to Tim's great answer, there are even within a field different reasons for particular confidence intervals. In a clinical trial for hairspray, for example, you would want to be very confi
18,046
How to choose a confidence level?
Choosing a confidence interval range is a subjective decision. You could choose literally any confidence interval: 50%, 90%, 99,999%... etc. It is about how much confidence do you want to have. Probably the most commonly used are 95% CI. As about interpretation and the link you provided... These kinds of interpretations are oversimplifications. Correlation is a good example, because in different contexts different values could be considered as "strong" or "weak" correlation, take a look at some random example from the web: I once asked a chemist who was calibrating a laboratory instrument to a standard what value of the correlation coefficient she was looking for. “0.9 is too low. You need at least 0.98 or 0.99.” She got the number from a government guidance document. I once asked an engineer who was conducting a regression analysis of a treatment process what value of the correlation coefficient he was looking for. “Anything between 0.6 and 0.8 is acceptable.” His college professor told him this. I once asked a biologist who was conducting an ANOVA of the size of field mice living in contaminated versus pristine soils what value of the correlation coefficient he was looking for. He didn’t know, but his cutoff was 0.2 based on the smallest size difference his model could detect with the number of samples he had. So sorry, but there are no shortcuts... To get a better feeling what Confidence Intervals are you could read more on them e.g. here, here, or here.
How to choose a confidence level?
Choosing a confidence interval range is a subjective decision. You could choose literally any confidence interval: 50%, 90%, 99,999%... etc. It is about how much confidence do you want to have. Probab
How to choose a confidence level? Choosing a confidence interval range is a subjective decision. You could choose literally any confidence interval: 50%, 90%, 99,999%... etc. It is about how much confidence do you want to have. Probably the most commonly used are 95% CI. As about interpretation and the link you provided... These kinds of interpretations are oversimplifications. Correlation is a good example, because in different contexts different values could be considered as "strong" or "weak" correlation, take a look at some random example from the web: I once asked a chemist who was calibrating a laboratory instrument to a standard what value of the correlation coefficient she was looking for. “0.9 is too low. You need at least 0.98 or 0.99.” She got the number from a government guidance document. I once asked an engineer who was conducting a regression analysis of a treatment process what value of the correlation coefficient he was looking for. “Anything between 0.6 and 0.8 is acceptable.” His college professor told him this. I once asked a biologist who was conducting an ANOVA of the size of field mice living in contaminated versus pristine soils what value of the correlation coefficient he was looking for. He didn’t know, but his cutoff was 0.2 based on the smallest size difference his model could detect with the number of samples he had. So sorry, but there are no shortcuts... To get a better feeling what Confidence Intervals are you could read more on them e.g. here, here, or here.
How to choose a confidence level? Choosing a confidence interval range is a subjective decision. You could choose literally any confidence interval: 50%, 90%, 99,999%... etc. It is about how much confidence do you want to have. Probab
18,047
How to choose a confidence level?
Although, generally the confidence levels are left to the discretion of the analyst, there are cases when they are set by laws and regulations. I'll give you two examples. In banking supervision you must use 99% confidence level when computing certain risks, see p.2 in this Basel regulation. FDA may instruct to use certain confidence levels for drug and device testing in their statistical methodologies. Overall, it's a good practice to consult the expert in your field to find out what are the accepted practices and regulations concerning confidence levels.
How to choose a confidence level?
Although, generally the confidence levels are left to the discretion of the analyst, there are cases when they are set by laws and regulations. I'll give you two examples. In banking supervision you m
How to choose a confidence level? Although, generally the confidence levels are left to the discretion of the analyst, there are cases when they are set by laws and regulations. I'll give you two examples. In banking supervision you must use 99% confidence level when computing certain risks, see p.2 in this Basel regulation. FDA may instruct to use certain confidence levels for drug and device testing in their statistical methodologies. Overall, it's a good practice to consult the expert in your field to find out what are the accepted practices and regulations concerning confidence levels.
How to choose a confidence level? Although, generally the confidence levels are left to the discretion of the analyst, there are cases when they are set by laws and regulations. I'll give you two examples. In banking supervision you m
18,048
Expectation of the product of iid random variables
First, let's establish the correct identity. When $X_1, \ldots, X_N$ are independent variables with finite expectations $\mu_i=X_i,$ then by laws of conditional expectation, $$E\left[\prod_{i=1}^N X_i\right] =E\left[X_N E\left[\prod_{i=1}^{N-1} X_i \mid X_{N}\right]\right] = E\left[X_N \prod_{i=1}^{N-1} \mu_i\right] = \mu_N\prod_{i=1}^{N-1} \mu_i= \prod_{i=1}^N \mu_i$$ gives a proof by mathematical induction (beginning with the base case $N=1$ where $$E\left[\prod_{i=1}^N X_i\right] = E\left[X_1\right] = \mu_1 = \prod_{i=1}^N \mu_i$$ is trivially true). Now, let's find an explanation for the simulation results. The pairing argument in the question is an interesting one, because it shows that when multiplications by $(1-a)$ and $(1+a)$ occur in equal numbers (approximately $N/2$ each), the net product is $(1-a^2)^{N/2}\approx \exp(-Na^2/2).$ This suggests that when $N$ is sufficiently large, it's nearly certain that the product will be tiny--certainly less than the common mean of $1.$ The reason this is not a paradox is that there will be a vanishingly small--but still positive--probability of yielding a whopping big number on the order of $(1+a)^N \approx \exp(aN).$ This rare chance of a huge product balances out all the tiny products, keeping the mean at $1.$ It is not easy to analyze the product of many Normal variables. Instead, we may gain insight from a simpler case. Let $Y_1, Y_2, \ldots,$ be a sequence of independent Rademacher variables: that is, each of these has a $1/2$ chance of being either $1$ or $-1.$ Pick some number $0 \lt a \lt 1$ and define $X_i = 1 + aY_i,$ so that each $X_i$ has equal chances of being $1\pm a.$ Clearly $E[X_i] = 1 = \mu_i$ for all $i.$ Consider the product of the first $N$ of these $X_i.$ Suppose, in a simulation, that $k$ of these values equal $1-a$ and (therefore) the remaining $N-k$ of them equal $1+a.$ The product then is $(1-a)^k(1+a)^{N-k}.$ How small must $k$ be for this product to exceed $1$? Given $N$ and $a,$ we must solve the inequality $$(1-a)^k(1+a)^{N-k} \ge 1$$ for $k.$ By taking logarithms, this is equivalent to $$k \le N \frac{\log(1+a)}{\log(1+a) - \log(1-a)}.$$ Because each $X_i$ has equal and independent chances of being $1\pm a,$ the distribution of $k$ is Binomial$(N, 1/2),$ which even for moderate sizes of $N$ ($N \ge 10$ is fine) is nicely approximated by a Normal$(N/2, \sqrt{N}/2)$ distribution. Thus, the chance that the product is $1$ or greater will be close to the value of the standard Normal distribution at $Z$ (the tail area under the Bell Curve left of $Z$) where $$Z = \frac{N \frac{\log(1+a)}{\log(1+a) - \log(1-a)} - \frac{N}{2}}{\sqrt{N}/2} = \text{constant}\times \sqrt{N}.$$ You can see where this is going! As $N$ grows large, $Z$ is pushed further out to the left, making it less and less likely to observe any product greater than $1$ in a simulation. In the question, where the standard deviation is $0.2,$ the value $a=0.2$ will closely reproduce the simulation behavior. In this case the constant is $$\text{constant} = \frac{2\log(1+a)}{\log(1+a)-\log(1-a)} - 1 = -0.100\ldots$$ Taking $N=2\times 10^6,$ for instance, as in the question, compute $Z \approx -142.$ The chance that $k$ is small enough to produce a value this negative is less than $10^{-10000}.$ You can't even represent that in double precision floats. It would take far more than the age of the universe to create a simulation that had the remotest chance of producing such an imbalance between the $1+a$ and $1-a$ values that the product exceeds $1.$ In short, for all practical purposes, when $N$ is sufficiently large ($N \gg 5000$ will do when $a=1/5$), you will never observe a value above $1$ in this simulation, even though the mean of the product is $1.$
Expectation of the product of iid random variables
First, let's establish the correct identity. When $X_1, \ldots, X_N$ are independent variables with finite expectations $\mu_i=X_i,$ then by laws of conditional expectation, $$E\left[\prod_{i=1}^N X_i
Expectation of the product of iid random variables First, let's establish the correct identity. When $X_1, \ldots, X_N$ are independent variables with finite expectations $\mu_i=X_i,$ then by laws of conditional expectation, $$E\left[\prod_{i=1}^N X_i\right] =E\left[X_N E\left[\prod_{i=1}^{N-1} X_i \mid X_{N}\right]\right] = E\left[X_N \prod_{i=1}^{N-1} \mu_i\right] = \mu_N\prod_{i=1}^{N-1} \mu_i= \prod_{i=1}^N \mu_i$$ gives a proof by mathematical induction (beginning with the base case $N=1$ where $$E\left[\prod_{i=1}^N X_i\right] = E\left[X_1\right] = \mu_1 = \prod_{i=1}^N \mu_i$$ is trivially true). Now, let's find an explanation for the simulation results. The pairing argument in the question is an interesting one, because it shows that when multiplications by $(1-a)$ and $(1+a)$ occur in equal numbers (approximately $N/2$ each), the net product is $(1-a^2)^{N/2}\approx \exp(-Na^2/2).$ This suggests that when $N$ is sufficiently large, it's nearly certain that the product will be tiny--certainly less than the common mean of $1.$ The reason this is not a paradox is that there will be a vanishingly small--but still positive--probability of yielding a whopping big number on the order of $(1+a)^N \approx \exp(aN).$ This rare chance of a huge product balances out all the tiny products, keeping the mean at $1.$ It is not easy to analyze the product of many Normal variables. Instead, we may gain insight from a simpler case. Let $Y_1, Y_2, \ldots,$ be a sequence of independent Rademacher variables: that is, each of these has a $1/2$ chance of being either $1$ or $-1.$ Pick some number $0 \lt a \lt 1$ and define $X_i = 1 + aY_i,$ so that each $X_i$ has equal chances of being $1\pm a.$ Clearly $E[X_i] = 1 = \mu_i$ for all $i.$ Consider the product of the first $N$ of these $X_i.$ Suppose, in a simulation, that $k$ of these values equal $1-a$ and (therefore) the remaining $N-k$ of them equal $1+a.$ The product then is $(1-a)^k(1+a)^{N-k}.$ How small must $k$ be for this product to exceed $1$? Given $N$ and $a,$ we must solve the inequality $$(1-a)^k(1+a)^{N-k} \ge 1$$ for $k.$ By taking logarithms, this is equivalent to $$k \le N \frac{\log(1+a)}{\log(1+a) - \log(1-a)}.$$ Because each $X_i$ has equal and independent chances of being $1\pm a,$ the distribution of $k$ is Binomial$(N, 1/2),$ which even for moderate sizes of $N$ ($N \ge 10$ is fine) is nicely approximated by a Normal$(N/2, \sqrt{N}/2)$ distribution. Thus, the chance that the product is $1$ or greater will be close to the value of the standard Normal distribution at $Z$ (the tail area under the Bell Curve left of $Z$) where $$Z = \frac{N \frac{\log(1+a)}{\log(1+a) - \log(1-a)} - \frac{N}{2}}{\sqrt{N}/2} = \text{constant}\times \sqrt{N}.$$ You can see where this is going! As $N$ grows large, $Z$ is pushed further out to the left, making it less and less likely to observe any product greater than $1$ in a simulation. In the question, where the standard deviation is $0.2,$ the value $a=0.2$ will closely reproduce the simulation behavior. In this case the constant is $$\text{constant} = \frac{2\log(1+a)}{\log(1+a)-\log(1-a)} - 1 = -0.100\ldots$$ Taking $N=2\times 10^6,$ for instance, as in the question, compute $Z \approx -142.$ The chance that $k$ is small enough to produce a value this negative is less than $10^{-10000}.$ You can't even represent that in double precision floats. It would take far more than the age of the universe to create a simulation that had the remotest chance of producing such an imbalance between the $1+a$ and $1-a$ values that the product exceeds $1.$ In short, for all practical purposes, when $N$ is sufficiently large ($N \gg 5000$ will do when $a=1/5$), you will never observe a value above $1$ in this simulation, even though the mean of the product is $1.$
Expectation of the product of iid random variables First, let's establish the correct identity. When $X_1, \ldots, X_N$ are independent variables with finite expectations $\mu_i=X_i,$ then by laws of conditional expectation, $$E\left[\prod_{i=1}^N X_i
18,049
Expectation of the product of iid random variables
As an addendum to @whuber's explanation, consider that \begin{align} \prod_{i=1}^N \vert X_i\vert &= \exp\{ \sum\nolimits_{i=1}^N \overbrace{\ln \vert X_i\vert}^{Y_i} \}\\ &= \exp\{ \sum\nolimits_{i=1}^N Y_i \}\\ &= \exp\{ \sum\nolimits_{i=1}^N (Y_i - \tilde \mu)+N\tilde\mu\}\qquad\qquad\mathbb \ \ E[Y_i]=\tilde\mu\\ &= \exp\left\{\frac{\tilde\sigma\sqrt{N}}{\sqrt{N}\tilde\sigma} \sum\nolimits_{i=1}^N (Y_i - \tilde \mu)+N\tilde\mu\right\}\qquad\text{var}(Y_i)=\tilde\sigma^2\\ &\approx \exp\{\tilde\sigma\sqrt{N}\zeta+N\tilde\mu\}\qquad\quad\qquad\qquad\zeta\sim\mathcal N(0,1)\\ \end{align} which shows that the expression tends to behave more and more erratically as $N$ increases. (For $|\mu|$ large enough, $\tilde \mu\approx\log|\mu|$.) Note that $$\xi=\exp\{\tilde\sigma\sqrt{N}\zeta+N\tilde\mu\}$$ is a log-normal $\mathcal L\mathcal N(N\tilde\mu,N\tilde\sigma^2)$ random variable with $$\mathbb E[\xi]=\exp\{N\tilde\mu+N\tilde\sigma^2/2)\qquad \text{var}(\xi)=[\exp\{N\tilde\sigma^2/2\}-1]\exp\{2N\tilde\mu+N\tilde\sigma^2\}$$ As a last remark, not quite related with the spirit of the question, while $$\prod_{i=1}^NX_i$$ is indeed an unbiased estimator of $\mu^N$, a more efficient estimator based on the $N$ rv's $X_i$ would be $$\mathbb E\left[\prod_{i=1}^NX_i\Big\vert\bar X_N\right]$$ thanks to the Rao-Blackwell theorem. I however do not see an easy way out for computing this conditional expectation (which should be a polynomial of degree $N$ in $\bar X_N$). But since $\bar X_N$ is minimal sufficient and complete there exists a single (UMVU) estimator.
Expectation of the product of iid random variables
As an addendum to @whuber's explanation, consider that \begin{align} \prod_{i=1}^N \vert X_i\vert &= \exp\{ \sum\nolimits_{i=1}^N \overbrace{\ln \vert X_i\vert}^{Y_i} \}\\ &= \exp\{ \sum\nolimits_{i=1
Expectation of the product of iid random variables As an addendum to @whuber's explanation, consider that \begin{align} \prod_{i=1}^N \vert X_i\vert &= \exp\{ \sum\nolimits_{i=1}^N \overbrace{\ln \vert X_i\vert}^{Y_i} \}\\ &= \exp\{ \sum\nolimits_{i=1}^N Y_i \}\\ &= \exp\{ \sum\nolimits_{i=1}^N (Y_i - \tilde \mu)+N\tilde\mu\}\qquad\qquad\mathbb \ \ E[Y_i]=\tilde\mu\\ &= \exp\left\{\frac{\tilde\sigma\sqrt{N}}{\sqrt{N}\tilde\sigma} \sum\nolimits_{i=1}^N (Y_i - \tilde \mu)+N\tilde\mu\right\}\qquad\text{var}(Y_i)=\tilde\sigma^2\\ &\approx \exp\{\tilde\sigma\sqrt{N}\zeta+N\tilde\mu\}\qquad\quad\qquad\qquad\zeta\sim\mathcal N(0,1)\\ \end{align} which shows that the expression tends to behave more and more erratically as $N$ increases. (For $|\mu|$ large enough, $\tilde \mu\approx\log|\mu|$.) Note that $$\xi=\exp\{\tilde\sigma\sqrt{N}\zeta+N\tilde\mu\}$$ is a log-normal $\mathcal L\mathcal N(N\tilde\mu,N\tilde\sigma^2)$ random variable with $$\mathbb E[\xi]=\exp\{N\tilde\mu+N\tilde\sigma^2/2)\qquad \text{var}(\xi)=[\exp\{N\tilde\sigma^2/2\}-1]\exp\{2N\tilde\mu+N\tilde\sigma^2\}$$ As a last remark, not quite related with the spirit of the question, while $$\prod_{i=1}^NX_i$$ is indeed an unbiased estimator of $\mu^N$, a more efficient estimator based on the $N$ rv's $X_i$ would be $$\mathbb E\left[\prod_{i=1}^NX_i\Big\vert\bar X_N\right]$$ thanks to the Rao-Blackwell theorem. I however do not see an easy way out for computing this conditional expectation (which should be a polynomial of degree $N$ in $\bar X_N$). But since $\bar X_N$ is minimal sufficient and complete there exists a single (UMVU) estimator.
Expectation of the product of iid random variables As an addendum to @whuber's explanation, consider that \begin{align} \prod_{i=1}^N \vert X_i\vert &= \exp\{ \sum\nolimits_{i=1}^N \overbrace{\ln \vert X_i\vert}^{Y_i} \}\\ &= \exp\{ \sum\nolimits_{i=1
18,050
Expectation of the product of iid random variables
There are several things to note here. Multiplying lots of numbers in computer leads to rounding errors, especially if these numbers vary in magnitude, i.e. small numbers are multiplied by large numbers. You need to sample the $\prod X_i$, not $X_i$. In simulations you rely on law of large numbers. However the bigger the variance of the random variable you sample, the slower the convergence. To see the point 3 let us calculate the variance of $\prod X_i$: $$ Var(\prod X_i) = E(\prod X_i)^2 - (E\prod X_i)^2 = (EX_i^2)^N - (EX_i)^N. $$ For normal variable $N(\mu, \sigma^2)$ this expression turns into: $$ (\sigma^2+\mu^2)^N-\mu^N \approx N\sigma^2 $$ if $\mu=1$. So the variance scales with $N$. So here is an example in R which showcases this: > set.seed(666) > prod_sample <- sapply(1:1000, function(x)prod(rnorm(100, mean = 1, sd = sqrt(0.2)))) > quantile(prod_sample) 0% 25% 50% 75% 100% -3.001294e+00 -5.287966e-07 5.889490e-11 2.814698e-06 7.951951e+01 > mean(prod_sample) [1] 0.1500762 This is for $N=100$ and the product is sampled 1000 times. If we chose $N=3$, then the result is more aligned with the expectations: > prod_sample <- sapply(1:1000, function(x)prod(rnorm(3, mean = 1, sd = sqrt(0.2)))) > quantile(prod_sample) 0% 25% 50% 75% 100% -0.9823311 0.4047946 0.7918063 1.3744908 5.5923739 > > mean(prod_sample) [1] 1.000404
Expectation of the product of iid random variables
There are several things to note here. Multiplying lots of numbers in computer leads to rounding errors, especially if these numbers vary in magnitude, i.e. small numbers are multiplied by large numb
Expectation of the product of iid random variables There are several things to note here. Multiplying lots of numbers in computer leads to rounding errors, especially if these numbers vary in magnitude, i.e. small numbers are multiplied by large numbers. You need to sample the $\prod X_i$, not $X_i$. In simulations you rely on law of large numbers. However the bigger the variance of the random variable you sample, the slower the convergence. To see the point 3 let us calculate the variance of $\prod X_i$: $$ Var(\prod X_i) = E(\prod X_i)^2 - (E\prod X_i)^2 = (EX_i^2)^N - (EX_i)^N. $$ For normal variable $N(\mu, \sigma^2)$ this expression turns into: $$ (\sigma^2+\mu^2)^N-\mu^N \approx N\sigma^2 $$ if $\mu=1$. So the variance scales with $N$. So here is an example in R which showcases this: > set.seed(666) > prod_sample <- sapply(1:1000, function(x)prod(rnorm(100, mean = 1, sd = sqrt(0.2)))) > quantile(prod_sample) 0% 25% 50% 75% 100% -3.001294e+00 -5.287966e-07 5.889490e-11 2.814698e-06 7.951951e+01 > mean(prod_sample) [1] 0.1500762 This is for $N=100$ and the product is sampled 1000 times. If we chose $N=3$, then the result is more aligned with the expectations: > prod_sample <- sapply(1:1000, function(x)prod(rnorm(3, mean = 1, sd = sqrt(0.2)))) > quantile(prod_sample) 0% 25% 50% 75% 100% -0.9823311 0.4047946 0.7918063 1.3744908 5.5923739 > > mean(prod_sample) [1] 1.000404
Expectation of the product of iid random variables There are several things to note here. Multiplying lots of numbers in computer leads to rounding errors, especially if these numbers vary in magnitude, i.e. small numbers are multiplied by large numb
18,051
What if path c isn't significant, but paths a and b are? Indirect effect in mediation
Your approach to testing mediation appears to conform to the "causal steps approach" described in the classic methods paper by Baron & Kenny (1986). This approach to mediation entails the following steps: Test whether X and Y are significantly associated (the c path); if they are not, stop the analysis; if they are... Test whether X and M are significantly associated (the a path); if they are not, stop the analysis; if they are... Test whether M and Y are significantly associated after controlling for X (the b path); if they are not, stop the analysis; if they are... Compare the direct of effect of X (the c' path--predicting Y from X after controlling for M) to the total effect of X (the c path from Step 1). If c' is closer to zero than c, and non-significant, the research concludes that M completely mediates the association between X and Y. But if c' is still significant, the researcher concludes that M is only a "partial" mediator of X's influence on Y. I emphasize the difference between direct (c') and total effects (c) because though you wrote... Can we claim that X has an indirect effect but not a direct effect on Y?? I think what you are actually concerned about is the legitimacy of claiming that X has an indirect, but not a total effect on Y. The Short Answer Yes, it is legitimate to conclude that M mediates the association between X and Y even if the total effect (c) is not significant. The causal steps approach, though historically popular, has been widely replaced by methods of testing for mediation that are more statistically powerful, make fewer assumptions of the data, and are more logically coherent. Hayes (2013) has a wonderfully accessible and thorough explanation of the many limitations of the causal steps approach in his book. Check out other more rigorous approaches, including the bootstrapping (MacKinnon et al., 2004) and Monte Carlo (Preacher & Selig, 2012) methods. Both methods estimate a confidence interval of the indirect effect itself (the ab path)--how they do so differs between methods--and then you examine the confidence interval to see whether 0 is a plausible value. They are both pretty easy to implement in your own research, regardless of which statistical analysis software you use. The Longer Answer Yes, it is legitimate to conclude that M mediates the association between X and Y even if the total effect (c) is not significant. In fact, there is a relatively large consensus among statisticians that the total effect (c) should not be used as a 'gatekeeper' for tests of mediation (e.g., Hayes, 2009; Shrout & Bolger, 2002) for a few reasons: The causal steps approach attempts to statistically evaluate the presence of mediation without ever actually directly evaluating the indirect effect (the ab path, or c-c' if you prefer). This seems illogical, especially given that there are numerous easy ways to estimate/test the indirect effect directly. The causal steps approach is contingent on multiple significance tests. Sometimes significance tests work as they should, but they can be derailed when assumptions of inferential tests are not met, and/or when inferential tests are underpowered (I think this is what John was getting at in his comment on your question). Thus, mediation could be really happening in a given model, but the total effect (c) could be non-significant simply because the sample size is small, or assumptions for the test of the total effect have not been met. And because the causal steps approach is contingent on the outcome of two other significance tests, it makes the causal steps approach one of the least powerful tests of mediation (Preacher & Selig, 2008). The total effect (c) is understood as the sum of the direct effect (c') and all indirect effects (ab(1) , ab(2)...). Pretend the influence of X on Y is fully mediated (i.e., c' is 0) by two variables, M1 and M2. But further pretend that the indirect effect of X on Y through M1 is positive, whereas the indirect effect through M2 is negative, and the two indirect effects are comparable in magnitude. Summing these two indirect effects would give you a total effect (c) of zero, and yet, if you adopted the causal steps approach, you would not only miss one "real" mediation, but two. Alternatives that I would recommend to the causal steps approach to testing mediation include the bootstrapping (MacKinnon et al., 2004) and Monte Carlo (Preacher & Selig, 2012) methods. The Bootstrapping method involves taking a superficially large number of random samples with replacement (e.g., 5000) of the same sample size from your own data, estimating the indirect effect (the ab path) in each sample, ordering those estimates from lowest to highest, and then define a confidence interval for the bootstrapped indirect effect as within some range of percentiles (e.g., 2.5th and 97.5th for a 95% confidence interval). Bootstrapping macros for indirect effects are available for statistical analysis software like SPSS and SAS, packages are available for R, and other programs (e.g., Mplus) have bootstrapping capabilities already built-in. The Monte Carlo method is a nice alternative when you don't have the original data, or in cases when bootstrapping isn't possible. All you need are the parameter estimates for the a and b paths, each path's variance, and the covariance between the two paths (often, but not always 0). With these statistical values, you can then simulate a superficially large distribution (e.g., 20,000) of ab values, and like the bootstrapping approach, order them from lowest to highest and define a confidence interval. Though you could program your own Monte Carlo mediation calculator, Kris Preacher has a nice one that is freely available to use on his website (see Preacher & Selig, 2012, for accompanying paper) For both approaches, you would examine the confidence interval to see if it contains a value of 0; if not, you could conclude that you have a significance indirect effect. References Baron, R. M., & Kenny, D. A. (1986). The moderator-mediator variable distinction in social psychological research: Conceptual, strategic, and statistical considerations. Journal of Personality and Social Psychology, 51, 1173-1182. Hayes, A. F. (2013). Introduction to mediation, moderation, and conditional process analysis: A regression-based approach. New York, NY: Guilford. Hayes, A. F. (2009). Beyond Baron and Kenny: Statistical mediation analysis in the new millennium. Communication Monographs, 76 408-420. MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect effect: Distribution of the product and resampling methods. Multivariate Behavioral Research, 39, 99-128. Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6, 77-98. Shrout, P. E., & Bolger, N. (2002). Mediation in experimental and nonexperimental studies: New procedures and recommendations. Psychological Methods, 7, 422-445.
What if path c isn't significant, but paths a and b are? Indirect effect in mediation
Your approach to testing mediation appears to conform to the "causal steps approach" described in the classic methods paper by Baron & Kenny (1986). This approach to mediation entails the following st
What if path c isn't significant, but paths a and b are? Indirect effect in mediation Your approach to testing mediation appears to conform to the "causal steps approach" described in the classic methods paper by Baron & Kenny (1986). This approach to mediation entails the following steps: Test whether X and Y are significantly associated (the c path); if they are not, stop the analysis; if they are... Test whether X and M are significantly associated (the a path); if they are not, stop the analysis; if they are... Test whether M and Y are significantly associated after controlling for X (the b path); if they are not, stop the analysis; if they are... Compare the direct of effect of X (the c' path--predicting Y from X after controlling for M) to the total effect of X (the c path from Step 1). If c' is closer to zero than c, and non-significant, the research concludes that M completely mediates the association between X and Y. But if c' is still significant, the researcher concludes that M is only a "partial" mediator of X's influence on Y. I emphasize the difference between direct (c') and total effects (c) because though you wrote... Can we claim that X has an indirect effect but not a direct effect on Y?? I think what you are actually concerned about is the legitimacy of claiming that X has an indirect, but not a total effect on Y. The Short Answer Yes, it is legitimate to conclude that M mediates the association between X and Y even if the total effect (c) is not significant. The causal steps approach, though historically popular, has been widely replaced by methods of testing for mediation that are more statistically powerful, make fewer assumptions of the data, and are more logically coherent. Hayes (2013) has a wonderfully accessible and thorough explanation of the many limitations of the causal steps approach in his book. Check out other more rigorous approaches, including the bootstrapping (MacKinnon et al., 2004) and Monte Carlo (Preacher & Selig, 2012) methods. Both methods estimate a confidence interval of the indirect effect itself (the ab path)--how they do so differs between methods--and then you examine the confidence interval to see whether 0 is a plausible value. They are both pretty easy to implement in your own research, regardless of which statistical analysis software you use. The Longer Answer Yes, it is legitimate to conclude that M mediates the association between X and Y even if the total effect (c) is not significant. In fact, there is a relatively large consensus among statisticians that the total effect (c) should not be used as a 'gatekeeper' for tests of mediation (e.g., Hayes, 2009; Shrout & Bolger, 2002) for a few reasons: The causal steps approach attempts to statistically evaluate the presence of mediation without ever actually directly evaluating the indirect effect (the ab path, or c-c' if you prefer). This seems illogical, especially given that there are numerous easy ways to estimate/test the indirect effect directly. The causal steps approach is contingent on multiple significance tests. Sometimes significance tests work as they should, but they can be derailed when assumptions of inferential tests are not met, and/or when inferential tests are underpowered (I think this is what John was getting at in his comment on your question). Thus, mediation could be really happening in a given model, but the total effect (c) could be non-significant simply because the sample size is small, or assumptions for the test of the total effect have not been met. And because the causal steps approach is contingent on the outcome of two other significance tests, it makes the causal steps approach one of the least powerful tests of mediation (Preacher & Selig, 2008). The total effect (c) is understood as the sum of the direct effect (c') and all indirect effects (ab(1) , ab(2)...). Pretend the influence of X on Y is fully mediated (i.e., c' is 0) by two variables, M1 and M2. But further pretend that the indirect effect of X on Y through M1 is positive, whereas the indirect effect through M2 is negative, and the two indirect effects are comparable in magnitude. Summing these two indirect effects would give you a total effect (c) of zero, and yet, if you adopted the causal steps approach, you would not only miss one "real" mediation, but two. Alternatives that I would recommend to the causal steps approach to testing mediation include the bootstrapping (MacKinnon et al., 2004) and Monte Carlo (Preacher & Selig, 2012) methods. The Bootstrapping method involves taking a superficially large number of random samples with replacement (e.g., 5000) of the same sample size from your own data, estimating the indirect effect (the ab path) in each sample, ordering those estimates from lowest to highest, and then define a confidence interval for the bootstrapped indirect effect as within some range of percentiles (e.g., 2.5th and 97.5th for a 95% confidence interval). Bootstrapping macros for indirect effects are available for statistical analysis software like SPSS and SAS, packages are available for R, and other programs (e.g., Mplus) have bootstrapping capabilities already built-in. The Monte Carlo method is a nice alternative when you don't have the original data, or in cases when bootstrapping isn't possible. All you need are the parameter estimates for the a and b paths, each path's variance, and the covariance between the two paths (often, but not always 0). With these statistical values, you can then simulate a superficially large distribution (e.g., 20,000) of ab values, and like the bootstrapping approach, order them from lowest to highest and define a confidence interval. Though you could program your own Monte Carlo mediation calculator, Kris Preacher has a nice one that is freely available to use on his website (see Preacher & Selig, 2012, for accompanying paper) For both approaches, you would examine the confidence interval to see if it contains a value of 0; if not, you could conclude that you have a significance indirect effect. References Baron, R. M., & Kenny, D. A. (1986). The moderator-mediator variable distinction in social psychological research: Conceptual, strategic, and statistical considerations. Journal of Personality and Social Psychology, 51, 1173-1182. Hayes, A. F. (2013). Introduction to mediation, moderation, and conditional process analysis: A regression-based approach. New York, NY: Guilford. Hayes, A. F. (2009). Beyond Baron and Kenny: Statistical mediation analysis in the new millennium. Communication Monographs, 76 408-420. MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect effect: Distribution of the product and resampling methods. Multivariate Behavioral Research, 39, 99-128. Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6, 77-98. Shrout, P. E., & Bolger, N. (2002). Mediation in experimental and nonexperimental studies: New procedures and recommendations. Psychological Methods, 7, 422-445.
What if path c isn't significant, but paths a and b are? Indirect effect in mediation Your approach to testing mediation appears to conform to the "causal steps approach" described in the classic methods paper by Baron & Kenny (1986). This approach to mediation entails the following st
18,052
What if path c isn't significant, but paths a and b are? Indirect effect in mediation
I agree with the jsakaluk's answer, and I would like to add more relevant information. Baron and Kenny's (1986) method of testing mediation has been extensively applied, but there are many papers discussing severe limitations of this approach, which broadly include: 1) Not directly testing the significance of an indirect effect 2) Low statistical power 3) Inability to accommodate models with inconsistent mediation *Note: see Memon, Cheah, Ramayah, Ting, and Chuah (2018) for an overview. Considering these limitations, a new typology of mediation was developed by Zhao, Lynch and Chen (2010). As of Oct 2019, it has over 5,000 citations, so it is gaining greater popularity. As a brief summary, and taking a three-variable causal model as an example, thee types of mediation exist. Complementary mediation: Mediated effect (a x b) and direct effect (c) both exist and point at the same direction. Competitive mediation: Mediated effect (a x b) and direct effect (c) both exist and point in opposite directions. Indirect-only mediation: Mediated effect (a x b) exists, but no direct effect (c). Further, two non-mediation types were proposed: Direct-only non-mediation: Direct effect (c) exists, but no indirect effect. No-effect non-mediation: Nether direct effect (c), nor indirect effect exists. Thus, the OP's case would be classed as Indirect only mediation as mediated effect exists but the direct effect (c') is non-significant. References Memon, M. A., Cheah, J., Ramayah, T., Ting, H., & Chuah, F. (2018). Mediation Analysis Issues and Recommendations. Journal of Applied Structural Equation Modeling, 2(1), 1-9. Zhao, X., Lynch Jr, J. G., & Chen, Q. (2010). Reconsidering Baron and Kenny: Myths and truths about mediation analysis. Journal of Consumer Research, 37(2), 197-206.
What if path c isn't significant, but paths a and b are? Indirect effect in mediation
I agree with the jsakaluk's answer, and I would like to add more relevant information. Baron and Kenny's (1986) method of testing mediation has been extensively applied, but there are many papers dis
What if path c isn't significant, but paths a and b are? Indirect effect in mediation I agree with the jsakaluk's answer, and I would like to add more relevant information. Baron and Kenny's (1986) method of testing mediation has been extensively applied, but there are many papers discussing severe limitations of this approach, which broadly include: 1) Not directly testing the significance of an indirect effect 2) Low statistical power 3) Inability to accommodate models with inconsistent mediation *Note: see Memon, Cheah, Ramayah, Ting, and Chuah (2018) for an overview. Considering these limitations, a new typology of mediation was developed by Zhao, Lynch and Chen (2010). As of Oct 2019, it has over 5,000 citations, so it is gaining greater popularity. As a brief summary, and taking a three-variable causal model as an example, thee types of mediation exist. Complementary mediation: Mediated effect (a x b) and direct effect (c) both exist and point at the same direction. Competitive mediation: Mediated effect (a x b) and direct effect (c) both exist and point in opposite directions. Indirect-only mediation: Mediated effect (a x b) exists, but no direct effect (c). Further, two non-mediation types were proposed: Direct-only non-mediation: Direct effect (c) exists, but no indirect effect. No-effect non-mediation: Nether direct effect (c), nor indirect effect exists. Thus, the OP's case would be classed as Indirect only mediation as mediated effect exists but the direct effect (c') is non-significant. References Memon, M. A., Cheah, J., Ramayah, T., Ting, H., & Chuah, F. (2018). Mediation Analysis Issues and Recommendations. Journal of Applied Structural Equation Modeling, 2(1), 1-9. Zhao, X., Lynch Jr, J. G., & Chen, Q. (2010). Reconsidering Baron and Kenny: Myths and truths about mediation analysis. Journal of Consumer Research, 37(2), 197-206.
What if path c isn't significant, but paths a and b are? Indirect effect in mediation I agree with the jsakaluk's answer, and I would like to add more relevant information. Baron and Kenny's (1986) method of testing mediation has been extensively applied, but there are many papers dis
18,053
What if path c isn't significant, but paths a and b are? Indirect effect in mediation
Okay, I think I might have found a good answer. I took a look at David Kenny's webinar, which introduces this case as inconsistent mediation. The reason why path c is not significantly different from 0 is that the product of a and b has a sign different from that of c'. In an example Kenny gives, stress leads to an decrease in mood (c' is negative); whereas exercise as a mediator between stress and mood is positively correlated to both (ab is positive). Since c = c' + ab, when the absolute values of c' and ab are close, c could be close to 0. Kenny notes in the webinar that contemporary view considers testing of c and c' not quite essential; the mediation effect is mainly displayed through ab.
What if path c isn't significant, but paths a and b are? Indirect effect in mediation
Okay, I think I might have found a good answer. I took a look at David Kenny's webinar, which introduces this case as inconsistent mediation. The reason why path c is not significantly different from
What if path c isn't significant, but paths a and b are? Indirect effect in mediation Okay, I think I might have found a good answer. I took a look at David Kenny's webinar, which introduces this case as inconsistent mediation. The reason why path c is not significantly different from 0 is that the product of a and b has a sign different from that of c'. In an example Kenny gives, stress leads to an decrease in mood (c' is negative); whereas exercise as a mediator between stress and mood is positively correlated to both (ab is positive). Since c = c' + ab, when the absolute values of c' and ab are close, c could be close to 0. Kenny notes in the webinar that contemporary view considers testing of c and c' not quite essential; the mediation effect is mainly displayed through ab.
What if path c isn't significant, but paths a and b are? Indirect effect in mediation Okay, I think I might have found a good answer. I took a look at David Kenny's webinar, which introduces this case as inconsistent mediation. The reason why path c is not significantly different from
18,054
What does average of word2vec vector mean?
You can think of it in terms of physical analogy. You can take a flat surface, like a table, and arrange 30 balls on it. Then you can cut legs from the table and replace it with a single leg. In order to figure out where to put this leg you need to find center of mass of all 30 balls on the table. Assuming that each ball has the same size and weight than center of mass would be average position of all balls. In the picture above, in the first example with 3 objects, you can see that center of mass much closer to the two objects that form small cluster. The same idea with word vectors. Each word is an object and sentence (or tweet) is just a set of these objects. If many vectors from the tweet close to each other in space than the overall average will be close to this cluster and would be a good representation of the tweet. One remark is that taking average can be the same as just summing vectors, because in most cases you will use cosine similarity for finding close vectors. And with cosine similarity, dividing vector by $n$ is the same as multiplying it by $1/n$ which is a scalar and scale of the vector doesn't matter if you measure distance using angles.
What does average of word2vec vector mean?
You can think of it in terms of physical analogy. You can take a flat surface, like a table, and arrange 30 balls on it. Then you can cut legs from the table and replace it with a single leg. In order
What does average of word2vec vector mean? You can think of it in terms of physical analogy. You can take a flat surface, like a table, and arrange 30 balls on it. Then you can cut legs from the table and replace it with a single leg. In order to figure out where to put this leg you need to find center of mass of all 30 balls on the table. Assuming that each ball has the same size and weight than center of mass would be average position of all balls. In the picture above, in the first example with 3 objects, you can see that center of mass much closer to the two objects that form small cluster. The same idea with word vectors. Each word is an object and sentence (or tweet) is just a set of these objects. If many vectors from the tweet close to each other in space than the overall average will be close to this cluster and would be a good representation of the tweet. One remark is that taking average can be the same as just summing vectors, because in most cases you will use cosine similarity for finding close vectors. And with cosine similarity, dividing vector by $n$ is the same as multiplying it by $1/n$ which is a scalar and scale of the vector doesn't matter if you measure distance using angles.
What does average of word2vec vector mean? You can think of it in terms of physical analogy. You can take a flat surface, like a table, and arrange 30 balls on it. Then you can cut legs from the table and replace it with a single leg. In order
18,055
What does average of word2vec vector mean?
This means that embedding of all words are averaged, and thus we get a 1D vector of features corresponding to each tweet. This data format is what typical machine learning models expect, so in a sense it is convenient. However, this should be done very carefully because averaging does not take care of word order. For example: our president is a good leader he will not fail our president is not a good leader he will fail Have the same words, and therefore will have same average word embedding, but the tweets have very different meaning. Edit: To address this issue, one might look into: Sentence-BERT https://github.com/UKPLab/sentence-transformers and https://arxiv.org/abs/1908.10084 Here is quick illustration with the above example: from sentence_transformers import SentenceTransformer import numpy as np def cosine_similarity(sentence_embeddings, ind_a, ind_b): s = sentence_embeddings return np.dot(s[ind_a], s[ind_b]) / (np.linalg.norm(s[ind_a]) * np.linalg.norm(s[ind_b])) model = SentenceTransformer('bert-base-nli-mean-tokens') s0 = "our president is a good leader he will not fail" s1 = "our president is not a good leader he will fail" s2 = "our president is a good leader" s3 = "our president will succeed" sentences = [s0, s1, s2, s3] sentence_embeddings = model.encode(sentences) s = sentence_embeddings print(f"{s0} <--> {s1}: {cosine_similarity(sentence_embeddings, 0, 1)}") print(f"{s0} <--> {s2}: {cosine_similarity(sentence_embeddings, 0, 2)}") print(f"{s0} <--> {s3}: {cosine_similarity(sentence_embeddings, 0, 3)}") Result: our president is a good leader he will not fail <--> our president is not a good leader he will fail: 0.46340954303741455 our president is a good leader he will not fail <--> our president is a good leader: 0.8822922110557556 our president is a good leader he will not fail <--> our president will succeed: 0.7640182971954346
What does average of word2vec vector mean?
This means that embedding of all words are averaged, and thus we get a 1D vector of features corresponding to each tweet. This data format is what typical machine learning models expect, so in a sense
What does average of word2vec vector mean? This means that embedding of all words are averaged, and thus we get a 1D vector of features corresponding to each tweet. This data format is what typical machine learning models expect, so in a sense it is convenient. However, this should be done very carefully because averaging does not take care of word order. For example: our president is a good leader he will not fail our president is not a good leader he will fail Have the same words, and therefore will have same average word embedding, but the tweets have very different meaning. Edit: To address this issue, one might look into: Sentence-BERT https://github.com/UKPLab/sentence-transformers and https://arxiv.org/abs/1908.10084 Here is quick illustration with the above example: from sentence_transformers import SentenceTransformer import numpy as np def cosine_similarity(sentence_embeddings, ind_a, ind_b): s = sentence_embeddings return np.dot(s[ind_a], s[ind_b]) / (np.linalg.norm(s[ind_a]) * np.linalg.norm(s[ind_b])) model = SentenceTransformer('bert-base-nli-mean-tokens') s0 = "our president is a good leader he will not fail" s1 = "our president is not a good leader he will fail" s2 = "our president is a good leader" s3 = "our president will succeed" sentences = [s0, s1, s2, s3] sentence_embeddings = model.encode(sentences) s = sentence_embeddings print(f"{s0} <--> {s1}: {cosine_similarity(sentence_embeddings, 0, 1)}") print(f"{s0} <--> {s2}: {cosine_similarity(sentence_embeddings, 0, 2)}") print(f"{s0} <--> {s3}: {cosine_similarity(sentence_embeddings, 0, 3)}") Result: our president is a good leader he will not fail <--> our president is not a good leader he will fail: 0.46340954303741455 our president is a good leader he will not fail <--> our president is a good leader: 0.8822922110557556 our president is a good leader he will not fail <--> our president will succeed: 0.7640182971954346
What does average of word2vec vector mean? This means that embedding of all words are averaged, and thus we get a 1D vector of features corresponding to each tweet. This data format is what typical machine learning models expect, so in a sense
18,056
What does average of word2vec vector mean?
You have a tweet $T$, which is composed of words $w_1,w_2,\cdots,w_n$. Each word has a word2vec embedding $u_{w_1},u_{w_2},..,u_{w_n}$. So you define the tweet embedding as: $u_T:=\frac{1}{n}\sum_{i=1}^nu_{w_i}$.
What does average of word2vec vector mean?
You have a tweet $T$, which is composed of words $w_1,w_2,\cdots,w_n$. Each word has a word2vec embedding $u_{w_1},u_{w_2},..,u_{w_n}$. So you define the tweet embedding as: $u_T:=\frac{1}{n}\sum_{i=1
What does average of word2vec vector mean? You have a tweet $T$, which is composed of words $w_1,w_2,\cdots,w_n$. Each word has a word2vec embedding $u_{w_1},u_{w_2},..,u_{w_n}$. So you define the tweet embedding as: $u_T:=\frac{1}{n}\sum_{i=1}^nu_{w_i}$.
What does average of word2vec vector mean? You have a tweet $T$, which is composed of words $w_1,w_2,\cdots,w_n$. Each word has a word2vec embedding $u_{w_1},u_{w_2},..,u_{w_n}$. So you define the tweet embedding as: $u_T:=\frac{1}{n}\sum_{i=1
18,057
Expected number of times to roll a die until each side has appeared 3 times
Suppose all $d=6$ sides have equal chances. Let's generalize and find the expected number of rolls needed until side $1$ has appeared $n_1$ times, side $2$ has appeared $n_2$ times, ..., and side $d$ has appeared $n_d$ times. Because the identities of the sides do not matter (they all have equal chances), the description of this objective can be condensed: let us suppose that $i_0$ sides don't have to appear at all, $i_1$ of the sides need to appear just once, ..., and $i_n$ of the sides have to appear $n=\max(n_1,n_2,\ldots,n_d)$ times. Let $$\mathbf{i}=(i_0,i_1,\ldots,i_n)$$ designate this situation and write $$e(\mathbf{i})$$ for the expected number of rolls. The question asks for $e(0,0,0,6)$: $i_3 = 6$ indicates all six sides need to be seen three times each. An easy recurrence is available. At the next roll, the side that appears corresponds to one of the $i_j$: that is, either we didn't need to see it, or we needed to see it once, ..., or we needed to see it $n$ more times. $j$ is the number of times we needed to see it. When $j=0$, we didn't need to see it and nothing changes. This happens with probability $i_0/d$. When $j \gt 0$ then we did need to see this side. Now there is one less side that needs to seen $j$ times and one more side that needs to be seen $j-1$ times. Thus, $i_j$ becomes $i_j-1$ and $i_{j-1}$ becomes $i_j+1$. Let this operation on the components of $\mathbf{i}$ be designated $\mathbf{i}\cdot j$, so that $$\mathbf{i}\cdot j = (\color{gray}{i_0, \ldots, i_{j-2}}, i_{j-1}+1, i_j-1, \color{gray}{i_{j+1},\ldots, i_n}).$$ This happens with probability $i_j/d$. We merely have to count this die roll and use recursion to tell us how many more rolls are expected. By the laws of expectation and total probability, $$e(\mathbf{i}) = 1 + \frac{i_0}{d}e(\mathbf{i}) + \sum_{j=1}^n \frac{i_j}{d}e(\mathbf{i}\cdot j)$$ (Let's understand that whenever $i_j=0$, the corresponding term in the sum is zero.) If $i_0=d$, we are done and $e(\mathbf{i}) =0$. Otherwise we may solve for $e(\mathbf{i})$, giving the desired recursive formula $$e(\mathbf{i}) = \frac{d + i_1 e(\mathbf{i}\cdot 1) + \cdots + i_n e(\mathbf{i}\cdot n)}{d - i_0}.\tag{1}$$ Notice that $$|\mathbf{i}| = 0(i_0) + 1(i_1) + \cdots + n(i_n)$$ is the total number of events we wish to see. The operation $\cdot j$ reduces that quantity by one for any $j\gt 0$ provided $i_j \gt 0$, which is always the case. Therefore this recursion terminates at a depth of precisely $|\mathbf{i}|$ (equal to $3(6) = 18$ in the question). Moreover (as is not difficult to check) the number of possibilities at each recursion depth in this question is small (never exceeding $8$). Consequently, this is an efficient method, at least when the combinatorial possibilities are not too numerous and we memoize the intermediate results (so that no value of $e$ is calculated more than once). I compute that $$e(0,0,0,6) = \frac{2\,286\,878\,604\,508\,883}{69\,984\,000\,000\,000}\approx 32.677.$$ That seemed awfully small to me, so I ran a simulation (using R). After over three million rolls of the dice, this game had been played to its completion over 100,000 times, with an average length of $32.669$. The standard error of that estimate is $0.027$: the difference between this average and the theoretical value is insignificant, confirming the accuracy of the theoretical value. The distribution of lengths may be of interest. (Obviously it must begin at $18$, the minimum number of rolls needed to collect all six sides three times each.) # Specify the problem d <- 6 # Number of faces k <- 3 # Number of times to see each N <- 3.26772e6 # Number of rolls # Simulate many rolls set.seed(17) x <- sample(1:d, N, replace=TRUE) # Use these rolls to play the game repeatedly. totals <- sapply(1:d, function(i) cumsum(x==i)) n <- 0 base <- rep(0, d) i.last <- 0 n.list <- list() for (i in 1:N) { if (min(totals[i, ] - base) >= k) { base <- totals[i, ] n <- n+1 n.list[[n]] <- i - i.last i.last <- i } } # Summarize the results sim <- unlist(n.list) mean(sim) sd(sim) / sqrt(length(sim)) length(sim) hist(sim, main="Simulation results", xlab="Number of rolls", freq=FALSE, breaks=0:max(sim)) Implementation Although the recursive calculation of $e$ is simple, it presents some challenges in some computing environments. Chief among these is storing the values of $e(\mathbf{i})$ as they are computed. This is essential, for otherwise each value will be (redundantly) computed a very large number of times. However, the storage potentially needed for an array indexed by $\mathbf{i}$ could be enormous. Ideally, only values of $\mathbf{i}$ that are actually encountered during the computation should be stored. This calls for a kind of associative array. To illustrate, here is working R code. The comments describe the creation of a simple "AA" (associative array) class for storing intermediate results. Vectors $\mathbf{i}$ are converted to strings and those are used to index into a list E that will hold all the values. The $\mathbf{i}\cdot j$ operation is implemented as %.%. These preliminaries enable the recursive function $e$ to be defined rather simply in a way that parallels the mathematical notation. In particular, the line x <- (d + sum(sapply(1:n, function(i) j[i+1]*e.(j %.% i))))/(d - j[1]) is directly comparable to the formula $(1)$ above. Note that all indexes have been increased by $1$ because R starts indexing its arrays at $1$ rather than $0$. Timing shows it takes $0.01$ seconds to compute e(c(0,0,0,6)); its value is 32.6771634160506 Accumulated floating point roundoff error has destroyed the last two digits (which should be 68 rather than 06). e <- function(i) { # # Create a data structure to "memoize" the values. # `[[<-.AA` <- function(x, i, value) { class(x) <- NULL x[[paste(i, collapse=",")]] <- value class(x) <- "AA" x } `[[.AA` <- function(x, i) { class(x) <- NULL x[[paste(i, collapse=",")]] } E <- list() class(E) <- "AA" # # Define the "." operation. # `%.%` <- function(i, j) { i[j+1] <- i[j+1]-1 i[j] <- i[j] + 1 return(i) } # # Define a recursive version of this function. # e. <- function(j) { # # Detect initial conditions and return initial values. # if (min(j) < 0 || sum(j[-1])==0) return(0) # # Look up the value (if it has already been computed). # x <- E[[j]] if (!is.null(x)) return(x) # # Compute the value (for the first and only time). # d <- sum(j) n <- length(j) - 1 x <- (d + sum(sapply(1:n, function(i) j[i+1]*e.(j %.% i))))/(d - j[1]) # # Store the value for later re-use. # E[[j]] <<- x return(x) } # # Do the calculation. # e.(i) } e(c(0,0,0,6)) Finally, here is the original Mathematica implementation that produced the exact answer. The memoization is accomplished via the idiomatic e[i_] := e[i] = ... expression, eliminating almost all the R preliminaries. Internally, though, the two programs are doing the same things in the same way. shift[j_, x_List] /; Length[x] >= j >= 2 := Module[{i = x}, i[[j - 1]] = i[[j - 1]] + 1; i[[j]] = i[[j]] - 1; i]; e[i_] := e[i] = With[{i0 = First@i, d = Plus @@ i}, (d + Sum[If[i[[k]] > 0, i[[k]] e[shift[k, i]], 0], {k, 2, Length[i]}])/(d - i0)]; e[{x_, y__}] /; Plus[y] == 0 := e[{x, y}] = 0 e[{0, 0, 0, 6}] $\frac{2286878604508883}{69984000000000}$
Expected number of times to roll a die until each side has appeared 3 times
Suppose all $d=6$ sides have equal chances. Let's generalize and find the expected number of rolls needed until side $1$ has appeared $n_1$ times, side $2$ has appeared $n_2$ times, ..., and side $d$
Expected number of times to roll a die until each side has appeared 3 times Suppose all $d=6$ sides have equal chances. Let's generalize and find the expected number of rolls needed until side $1$ has appeared $n_1$ times, side $2$ has appeared $n_2$ times, ..., and side $d$ has appeared $n_d$ times. Because the identities of the sides do not matter (they all have equal chances), the description of this objective can be condensed: let us suppose that $i_0$ sides don't have to appear at all, $i_1$ of the sides need to appear just once, ..., and $i_n$ of the sides have to appear $n=\max(n_1,n_2,\ldots,n_d)$ times. Let $$\mathbf{i}=(i_0,i_1,\ldots,i_n)$$ designate this situation and write $$e(\mathbf{i})$$ for the expected number of rolls. The question asks for $e(0,0,0,6)$: $i_3 = 6$ indicates all six sides need to be seen three times each. An easy recurrence is available. At the next roll, the side that appears corresponds to one of the $i_j$: that is, either we didn't need to see it, or we needed to see it once, ..., or we needed to see it $n$ more times. $j$ is the number of times we needed to see it. When $j=0$, we didn't need to see it and nothing changes. This happens with probability $i_0/d$. When $j \gt 0$ then we did need to see this side. Now there is one less side that needs to seen $j$ times and one more side that needs to be seen $j-1$ times. Thus, $i_j$ becomes $i_j-1$ and $i_{j-1}$ becomes $i_j+1$. Let this operation on the components of $\mathbf{i}$ be designated $\mathbf{i}\cdot j$, so that $$\mathbf{i}\cdot j = (\color{gray}{i_0, \ldots, i_{j-2}}, i_{j-1}+1, i_j-1, \color{gray}{i_{j+1},\ldots, i_n}).$$ This happens with probability $i_j/d$. We merely have to count this die roll and use recursion to tell us how many more rolls are expected. By the laws of expectation and total probability, $$e(\mathbf{i}) = 1 + \frac{i_0}{d}e(\mathbf{i}) + \sum_{j=1}^n \frac{i_j}{d}e(\mathbf{i}\cdot j)$$ (Let's understand that whenever $i_j=0$, the corresponding term in the sum is zero.) If $i_0=d$, we are done and $e(\mathbf{i}) =0$. Otherwise we may solve for $e(\mathbf{i})$, giving the desired recursive formula $$e(\mathbf{i}) = \frac{d + i_1 e(\mathbf{i}\cdot 1) + \cdots + i_n e(\mathbf{i}\cdot n)}{d - i_0}.\tag{1}$$ Notice that $$|\mathbf{i}| = 0(i_0) + 1(i_1) + \cdots + n(i_n)$$ is the total number of events we wish to see. The operation $\cdot j$ reduces that quantity by one for any $j\gt 0$ provided $i_j \gt 0$, which is always the case. Therefore this recursion terminates at a depth of precisely $|\mathbf{i}|$ (equal to $3(6) = 18$ in the question). Moreover (as is not difficult to check) the number of possibilities at each recursion depth in this question is small (never exceeding $8$). Consequently, this is an efficient method, at least when the combinatorial possibilities are not too numerous and we memoize the intermediate results (so that no value of $e$ is calculated more than once). I compute that $$e(0,0,0,6) = \frac{2\,286\,878\,604\,508\,883}{69\,984\,000\,000\,000}\approx 32.677.$$ That seemed awfully small to me, so I ran a simulation (using R). After over three million rolls of the dice, this game had been played to its completion over 100,000 times, with an average length of $32.669$. The standard error of that estimate is $0.027$: the difference between this average and the theoretical value is insignificant, confirming the accuracy of the theoretical value. The distribution of lengths may be of interest. (Obviously it must begin at $18$, the minimum number of rolls needed to collect all six sides three times each.) # Specify the problem d <- 6 # Number of faces k <- 3 # Number of times to see each N <- 3.26772e6 # Number of rolls # Simulate many rolls set.seed(17) x <- sample(1:d, N, replace=TRUE) # Use these rolls to play the game repeatedly. totals <- sapply(1:d, function(i) cumsum(x==i)) n <- 0 base <- rep(0, d) i.last <- 0 n.list <- list() for (i in 1:N) { if (min(totals[i, ] - base) >= k) { base <- totals[i, ] n <- n+1 n.list[[n]] <- i - i.last i.last <- i } } # Summarize the results sim <- unlist(n.list) mean(sim) sd(sim) / sqrt(length(sim)) length(sim) hist(sim, main="Simulation results", xlab="Number of rolls", freq=FALSE, breaks=0:max(sim)) Implementation Although the recursive calculation of $e$ is simple, it presents some challenges in some computing environments. Chief among these is storing the values of $e(\mathbf{i})$ as they are computed. This is essential, for otherwise each value will be (redundantly) computed a very large number of times. However, the storage potentially needed for an array indexed by $\mathbf{i}$ could be enormous. Ideally, only values of $\mathbf{i}$ that are actually encountered during the computation should be stored. This calls for a kind of associative array. To illustrate, here is working R code. The comments describe the creation of a simple "AA" (associative array) class for storing intermediate results. Vectors $\mathbf{i}$ are converted to strings and those are used to index into a list E that will hold all the values. The $\mathbf{i}\cdot j$ operation is implemented as %.%. These preliminaries enable the recursive function $e$ to be defined rather simply in a way that parallels the mathematical notation. In particular, the line x <- (d + sum(sapply(1:n, function(i) j[i+1]*e.(j %.% i))))/(d - j[1]) is directly comparable to the formula $(1)$ above. Note that all indexes have been increased by $1$ because R starts indexing its arrays at $1$ rather than $0$. Timing shows it takes $0.01$ seconds to compute e(c(0,0,0,6)); its value is 32.6771634160506 Accumulated floating point roundoff error has destroyed the last two digits (which should be 68 rather than 06). e <- function(i) { # # Create a data structure to "memoize" the values. # `[[<-.AA` <- function(x, i, value) { class(x) <- NULL x[[paste(i, collapse=",")]] <- value class(x) <- "AA" x } `[[.AA` <- function(x, i) { class(x) <- NULL x[[paste(i, collapse=",")]] } E <- list() class(E) <- "AA" # # Define the "." operation. # `%.%` <- function(i, j) { i[j+1] <- i[j+1]-1 i[j] <- i[j] + 1 return(i) } # # Define a recursive version of this function. # e. <- function(j) { # # Detect initial conditions and return initial values. # if (min(j) < 0 || sum(j[-1])==0) return(0) # # Look up the value (if it has already been computed). # x <- E[[j]] if (!is.null(x)) return(x) # # Compute the value (for the first and only time). # d <- sum(j) n <- length(j) - 1 x <- (d + sum(sapply(1:n, function(i) j[i+1]*e.(j %.% i))))/(d - j[1]) # # Store the value for later re-use. # E[[j]] <<- x return(x) } # # Do the calculation. # e.(i) } e(c(0,0,0,6)) Finally, here is the original Mathematica implementation that produced the exact answer. The memoization is accomplished via the idiomatic e[i_] := e[i] = ... expression, eliminating almost all the R preliminaries. Internally, though, the two programs are doing the same things in the same way. shift[j_, x_List] /; Length[x] >= j >= 2 := Module[{i = x}, i[[j - 1]] = i[[j - 1]] + 1; i[[j]] = i[[j]] - 1; i]; e[i_] := e[i] = With[{i0 = First@i, d = Plus @@ i}, (d + Sum[If[i[[k]] > 0, i[[k]] e[shift[k, i]], 0], {k, 2, Length[i]}])/(d - i0)]; e[{x_, y__}] /; Plus[y] == 0 := e[{x, y}] = 0 e[{0, 0, 0, 6}] $\frac{2286878604508883}{69984000000000}$
Expected number of times to roll a die until each side has appeared 3 times Suppose all $d=6$ sides have equal chances. Let's generalize and find the expected number of rolls needed until side $1$ has appeared $n_1$ times, side $2$ has appeared $n_2$ times, ..., and side $d$
18,058
Expected number of times to roll a die until each side has appeared 3 times
The original version of this question started life by asking: how many rolls are needed until each side has appeared 3 times Of course, that is a question that does not have an answer as @JuhoKokkala commented above: the answer is a random variable with a distribution that needs to be found. The question was then modified to ask: "What is the expected number of rolls." The answer below seeks to answer the original question posed: how to find the distribution of the number of rolls, without using simulation, and just using conceptually simple techniques any New Zealand student with a computer could implement $\rightarrow$ Why not? The problem reduces to a 1-liner. Distribution of the number of rolls required ... such that each side appears 3 times We roll a die $n$ times. Let $X_i$ denote the number of times side $i$ of the die appears, where $i \in \{1, \dots, 6\}$. Then, the joint pmf of $(X_1, X_2,\dots, X_6)$ is $\text{Multinomial}(n,\frac16)$ i.e.: $$P\left(X_1=x_1,\ldots ,X_6=x_6\right) \; = \; \frac{n! }{ x_1! \cdots x_6!} \; \frac{1}{6^n} \quad \text{ subject to: } \quad \sum _{i=1}^6 x_i=n$$ Let: $\quad N = \min\big\{n: \; {X_i \geq 3 \; \forall_i } \big\}. \;$ Then the cdf of $N$ is: $\quad P(N \leq n) \; = \; P\big(X_{\forall_i} \geq 3 \; \big| \; n\big) $ i.e. To find the cdf $P(N \leq n)$, simply calculate for each value of $n = \{18, 19, 20,\dots\}$: $$P(X_1 \geq3, \dots , X_6 \geq 3) \quad \text{ where } \quad (X_1, \dots, X_6) \sim \text{Multinomial}(n,\frac16)$$ Here, for example, is Mathematica code that does this, as $n$ increases from 18 to say 60. It is basically a one-liner: cdf = ParallelTable[ Probability[x1 >= 3 && x2 >= 3 && x3 >= 3 && x4 >= 3 && x5 >= 3 && x6 >= 3, {x1, x2, x3, x4, x5, x6} \[Distributed] MultinomialDistribution[n, Table[1/6, 6]]], {n, 18, 60}] ... which yields the exact cdf as $n$ increases: $$\begin{array}{cc} 18 & \frac{14889875}{11019960576} \\ 19 & \frac{282907625}{44079842304} \\ 20 & \frac{3111983875}{176319369216} \\ 21 & \frac{116840849125}{3173748645888} \\ 22 & \frac{3283142988125}{50779978334208} \\ 23 & \frac{61483465418375}{609359740010496} \\ \vdots & \vdots\\ \\ \end{array}$$ Here is a plot of the cdf $P(N\leq n)$, as a function of $n$: $ $ To derive the pmf $P(N=n)$, simply first difference the cdf: Of course, the distribution has no upper bound, but we can readily solve here for as many values as practically required. The approach is general and should work just as well for any desired combination of sides required.
Expected number of times to roll a die until each side has appeared 3 times
The original version of this question started life by asking: how many rolls are needed until each side has appeared 3 times Of course, that is a question that does not have an answer as @JuhoKokkal
Expected number of times to roll a die until each side has appeared 3 times The original version of this question started life by asking: how many rolls are needed until each side has appeared 3 times Of course, that is a question that does not have an answer as @JuhoKokkala commented above: the answer is a random variable with a distribution that needs to be found. The question was then modified to ask: "What is the expected number of rolls." The answer below seeks to answer the original question posed: how to find the distribution of the number of rolls, without using simulation, and just using conceptually simple techniques any New Zealand student with a computer could implement $\rightarrow$ Why not? The problem reduces to a 1-liner. Distribution of the number of rolls required ... such that each side appears 3 times We roll a die $n$ times. Let $X_i$ denote the number of times side $i$ of the die appears, where $i \in \{1, \dots, 6\}$. Then, the joint pmf of $(X_1, X_2,\dots, X_6)$ is $\text{Multinomial}(n,\frac16)$ i.e.: $$P\left(X_1=x_1,\ldots ,X_6=x_6\right) \; = \; \frac{n! }{ x_1! \cdots x_6!} \; \frac{1}{6^n} \quad \text{ subject to: } \quad \sum _{i=1}^6 x_i=n$$ Let: $\quad N = \min\big\{n: \; {X_i \geq 3 \; \forall_i } \big\}. \;$ Then the cdf of $N$ is: $\quad P(N \leq n) \; = \; P\big(X_{\forall_i} \geq 3 \; \big| \; n\big) $ i.e. To find the cdf $P(N \leq n)$, simply calculate for each value of $n = \{18, 19, 20,\dots\}$: $$P(X_1 \geq3, \dots , X_6 \geq 3) \quad \text{ where } \quad (X_1, \dots, X_6) \sim \text{Multinomial}(n,\frac16)$$ Here, for example, is Mathematica code that does this, as $n$ increases from 18 to say 60. It is basically a one-liner: cdf = ParallelTable[ Probability[x1 >= 3 && x2 >= 3 && x3 >= 3 && x4 >= 3 && x5 >= 3 && x6 >= 3, {x1, x2, x3, x4, x5, x6} \[Distributed] MultinomialDistribution[n, Table[1/6, 6]]], {n, 18, 60}] ... which yields the exact cdf as $n$ increases: $$\begin{array}{cc} 18 & \frac{14889875}{11019960576} \\ 19 & \frac{282907625}{44079842304} \\ 20 & \frac{3111983875}{176319369216} \\ 21 & \frac{116840849125}{3173748645888} \\ 22 & \frac{3283142988125}{50779978334208} \\ 23 & \frac{61483465418375}{609359740010496} \\ \vdots & \vdots\\ \\ \end{array}$$ Here is a plot of the cdf $P(N\leq n)$, as a function of $n$: $ $ To derive the pmf $P(N=n)$, simply first difference the cdf: Of course, the distribution has no upper bound, but we can readily solve here for as many values as practically required. The approach is general and should work just as well for any desired combination of sides required.
Expected number of times to roll a die until each side has appeared 3 times The original version of this question started life by asking: how many rolls are needed until each side has appeared 3 times Of course, that is a question that does not have an answer as @JuhoKokkal
18,059
Alternative graphics to "handle bar" plots
Thanks for all you answers. For completeness I thought I should include what I usually do. I tend to do a combination of the suggestions given: dots, boxplots (when n is large), and se (or sd) ranges. (Removed by moderator because the site hosting the image no longer appears to work correctly.) From the dot plot, it is clear that data is far more spread out the "handle bar" plots suggest. In fact, there is a negative value in A3! I've made this answer a CW so I don't gain rep
Alternative graphics to "handle bar" plots
Thanks for all you answers. For completeness I thought I should include what I usually do. I tend to do a combination of the suggestions given: dots, boxplots (when n is large), and se (or sd) ranges.
Alternative graphics to "handle bar" plots Thanks for all you answers. For completeness I thought I should include what I usually do. I tend to do a combination of the suggestions given: dots, boxplots (when n is large), and se (or sd) ranges. (Removed by moderator because the site hosting the image no longer appears to work correctly.) From the dot plot, it is clear that data is far more spread out the "handle bar" plots suggest. In fact, there is a negative value in A3! I've made this answer a CW so I don't gain rep
Alternative graphics to "handle bar" plots Thanks for all you answers. For completeness I thought I should include what I usually do. I tend to do a combination of the suggestions given: dots, boxplots (when n is large), and se (or sd) ranges.
18,060
Alternative graphics to "handle bar" plots
Frank Harrell's (most excellent) keynote entitled "Information Allergy" at useR! last month showed alternatives to these: rather than hiding the raw data via the aggregation the bars provide, the raw data is also shown as dots (or points). "Why hide the data?" was Frank's comment. Given alpa blending, that strikes as a most sensible suggestion (and the whole talk most full of good, and important, nuggets).
Alternative graphics to "handle bar" plots
Frank Harrell's (most excellent) keynote entitled "Information Allergy" at useR! last month showed alternatives to these: rather than hiding the raw data via the aggregation the bars provide, the raw
Alternative graphics to "handle bar" plots Frank Harrell's (most excellent) keynote entitled "Information Allergy" at useR! last month showed alternatives to these: rather than hiding the raw data via the aggregation the bars provide, the raw data is also shown as dots (or points). "Why hide the data?" was Frank's comment. Given alpa blending, that strikes as a most sensible suggestion (and the whole talk most full of good, and important, nuggets).
Alternative graphics to "handle bar" plots Frank Harrell's (most excellent) keynote entitled "Information Allergy" at useR! last month showed alternatives to these: rather than hiding the raw data via the aggregation the bars provide, the raw
18,061
Alternative graphics to "handle bar" plots
From a psychological perspective, I advocate plotting the data plus your uncertainty about the data. Thus, in a plot like you show, I would never bother with extending the bars all the way to zero, which only serves to minimize the eye's ability to distinguish differences in the range of the data. Additionally, I'm frankly anti-bargraph; bar graphs map two variables to the same aesthetic attribute (x-axis location), which can cause confusion. A better approach is to avoid redundant aesthetic mapping by mapping one variable to the x-axis and another variable to another aesthetic attribute (eg. point shape or color or both). Finally, in your plot above, you only include error bars above the value, which hinders one's ability to compare the intervals of uncertainty relative to bars above and below the value. Here's how I would plot the data (via the ggplot2 package). Note that I add lines connecting points in the same series; some argue that this is only appropriate when the series across which the lines are connected are numeric (as seems to be in this case), however as long as there is any reasonable ordinal relationship among the levels of the x-axis variable, I think connecting lines are useful for helping the eye associate points across the x-axis. This can become particularly useful for detecting interactions, which really stand out with lines. library(ggplot2) a = data.frame(names,prevs,se) a$let = substr(a$names,1,1) a$num = substr(a$names,2,2) ggplot(data = a)+ layer( geom = 'point' , mapping = aes( x = num , y = prevs , colour = let , shape = let ) )+ layer( geom = 'line' , mapping = aes( x = num , y = prevs , colour = let , linetype = let , group = let ) )+ layer( geom = 'errorbar' , mapping = aes( x = num , ymin = prevs-se , ymax = prevs+se , colour = let ) , alpha = .5 , width = .5 )
Alternative graphics to "handle bar" plots
From a psychological perspective, I advocate plotting the data plus your uncertainty about the data. Thus, in a plot like you show, I would never bother with extending the bars all the way to zero, wh
Alternative graphics to "handle bar" plots From a psychological perspective, I advocate plotting the data plus your uncertainty about the data. Thus, in a plot like you show, I would never bother with extending the bars all the way to zero, which only serves to minimize the eye's ability to distinguish differences in the range of the data. Additionally, I'm frankly anti-bargraph; bar graphs map two variables to the same aesthetic attribute (x-axis location), which can cause confusion. A better approach is to avoid redundant aesthetic mapping by mapping one variable to the x-axis and another variable to another aesthetic attribute (eg. point shape or color or both). Finally, in your plot above, you only include error bars above the value, which hinders one's ability to compare the intervals of uncertainty relative to bars above and below the value. Here's how I would plot the data (via the ggplot2 package). Note that I add lines connecting points in the same series; some argue that this is only appropriate when the series across which the lines are connected are numeric (as seems to be in this case), however as long as there is any reasonable ordinal relationship among the levels of the x-axis variable, I think connecting lines are useful for helping the eye associate points across the x-axis. This can become particularly useful for detecting interactions, which really stand out with lines. library(ggplot2) a = data.frame(names,prevs,se) a$let = substr(a$names,1,1) a$num = substr(a$names,2,2) ggplot(data = a)+ layer( geom = 'point' , mapping = aes( x = num , y = prevs , colour = let , shape = let ) )+ layer( geom = 'line' , mapping = aes( x = num , y = prevs , colour = let , linetype = let , group = let ) )+ layer( geom = 'errorbar' , mapping = aes( x = num , ymin = prevs-se , ymax = prevs+se , colour = let ) , alpha = .5 , width = .5 )
Alternative graphics to "handle bar" plots From a psychological perspective, I advocate plotting the data plus your uncertainty about the data. Thus, in a plot like you show, I would never bother with extending the bars all the way to zero, wh
18,062
Alternative graphics to "handle bar" plots
I'm curious at to why you don't like these plots. I use them all the time. Without wanting to state the blooming obvious, they allow you to compare the means of different groups and see if their 95% CIs overlap (i.e., true mean likely to be different). It's important to get a balance of simplicity and information for different purposes, I guess. But when I use these plots I am saying- "these two groups are different from each other in some important way" [or not]. Seems pretty great to me, but I'd be interested to hear counter-examples. I suppose implicit in the use of the plot is that the data do not have a bizzare distribution which renders the mean invalid or misleading.
Alternative graphics to "handle bar" plots
I'm curious at to why you don't like these plots. I use them all the time. Without wanting to state the blooming obvious, they allow you to compare the means of different groups and see if their 95% C
Alternative graphics to "handle bar" plots I'm curious at to why you don't like these plots. I use them all the time. Without wanting to state the blooming obvious, they allow you to compare the means of different groups and see if their 95% CIs overlap (i.e., true mean likely to be different). It's important to get a balance of simplicity and information for different purposes, I guess. But when I use these plots I am saying- "these two groups are different from each other in some important way" [or not]. Seems pretty great to me, but I'd be interested to hear counter-examples. I suppose implicit in the use of the plot is that the data do not have a bizzare distribution which renders the mean invalid or misleading.
Alternative graphics to "handle bar" plots I'm curious at to why you don't like these plots. I use them all the time. Without wanting to state the blooming obvious, they allow you to compare the means of different groups and see if their 95% C
18,063
Alternative graphics to "handle bar" plots
I would use boxplots here; clean, meaningful, nonparametric... Or vioplot if the distribution is more interesting.
Alternative graphics to "handle bar" plots
I would use boxplots here; clean, meaningful, nonparametric... Or vioplot if the distribution is more interesting.
Alternative graphics to "handle bar" plots I would use boxplots here; clean, meaningful, nonparametric... Or vioplot if the distribution is more interesting.
Alternative graphics to "handle bar" plots I would use boxplots here; clean, meaningful, nonparametric... Or vioplot if the distribution is more interesting.
18,064
Alternative graphics to "handle bar" plots
If the data are rates: that is number of successes divided by number of trials, then a very elegant method is a funnel plot. For example, see this (apologies if the link requires a subscription--let me know and I'll find another). It may be possible to adapt it to other types of data, but I haven't seen any examples. UPDATE: Here's a link to an example which doesn't require a subscription (and has a good explanation for how they might be used): http://understandinguncertainty.org/fertility They can be used for non-rate data, by simply plotting mean against standard error, however they may lose some of their simplicity. The wikipedia article is not great, as it only discusses their use in meta-analyses. I'd argue they could be useful in many other contexts.
Alternative graphics to "handle bar" plots
If the data are rates: that is number of successes divided by number of trials, then a very elegant method is a funnel plot. For example, see this (apologies if the link requires a subscription--let m
Alternative graphics to "handle bar" plots If the data are rates: that is number of successes divided by number of trials, then a very elegant method is a funnel plot. For example, see this (apologies if the link requires a subscription--let me know and I'll find another). It may be possible to adapt it to other types of data, but I haven't seen any examples. UPDATE: Here's a link to an example which doesn't require a subscription (and has a good explanation for how they might be used): http://understandinguncertainty.org/fertility They can be used for non-rate data, by simply plotting mean against standard error, however they may lose some of their simplicity. The wikipedia article is not great, as it only discusses their use in meta-analyses. I'd argue they could be useful in many other contexts.
Alternative graphics to "handle bar" plots If the data are rates: that is number of successes divided by number of trials, then a very elegant method is a funnel plot. For example, see this (apologies if the link requires a subscription--let m
18,065
Alternative graphics to "handle bar" plots
Simplifying @csgillespie's terrific code from above: qplot( data=a, x=num, y=prevs, colour=let, shape=let, group=let, ymin=prevs-se, ymax=prevs+se, position=position_dodge(width=0.25), geom=c("point", "line", "errorbar") )
Alternative graphics to "handle bar" plots
Simplifying @csgillespie's terrific code from above: qplot( data=a, x=num, y=prevs, colour=let, shape=let, group=let, ymin=prevs-se, ymax=prevs+se, position=positio
Alternative graphics to "handle bar" plots Simplifying @csgillespie's terrific code from above: qplot( data=a, x=num, y=prevs, colour=let, shape=let, group=let, ymin=prevs-se, ymax=prevs+se, position=position_dodge(width=0.25), geom=c("point", "line", "errorbar") )
Alternative graphics to "handle bar" plots Simplifying @csgillespie's terrific code from above: qplot( data=a, x=num, y=prevs, colour=let, shape=let, group=let, ymin=prevs-se, ymax=prevs+se, position=positio
18,066
Alternative graphics to "handle bar" plots
I prefer geom_pointrange to errorbar and think the lines are distracting rather than helpful. Here is version that I find much cleaner than the @James or @csgillespie version: qplot( data=a, x=num, y=prevs, colour=let, ymin=prevs-se, ymax=prevs+se, position=position_dodge(width=0.25), geom=c("pointrange"), size=I(2) )
Alternative graphics to "handle bar" plots
I prefer geom_pointrange to errorbar and think the lines are distracting rather than helpful. Here is version that I find much cleaner than the @James or @csgillespie version: qplot( data=a, x=num
Alternative graphics to "handle bar" plots I prefer geom_pointrange to errorbar and think the lines are distracting rather than helpful. Here is version that I find much cleaner than the @James or @csgillespie version: qplot( data=a, x=num, y=prevs, colour=let, ymin=prevs-se, ymax=prevs+se, position=position_dodge(width=0.25), geom=c("pointrange"), size=I(2) )
Alternative graphics to "handle bar" plots I prefer geom_pointrange to errorbar and think the lines are distracting rather than helpful. Here is version that I find much cleaner than the @James or @csgillespie version: qplot( data=a, x=num
18,067
At the end of the day, what do you do with Bayesian Estimates?
First of all, Frequentist methods also provide a distribution over possible answers. It is just that we do not call them distributions because of a philosophical point. Frequentists consider parameters of a distribution as a fixed quantity. It is not allowed to be random; therefore, you cannot talk about distributions over parameters in a meaningful way. In frequentist methods, we estimate confidence intervals which can be thought of as distributions if we are letting go of the philosophical details. But in Bayesian methods the fixed parameters are allowed to be random; therefore, we talk about the (prior and posterior) distributions over the parameters. Second, it is not always the case that only a single value is used at the end. Many applications require us to use the entire posterior distributions in subsequent analysis. In fact, to derive a suitable point estimate, full distribution is required. A well known example is risk minimization. Another example is model identification in natural sciences in the presence of significant uncertainties. Third, Bayesian inference has many benefits over a frequentist analysis (not just the one that you metion): Ease of interpretation: It is hard to understand what a confidence interval is and why it is not a probability distributions. The reason is simply a philosophical one as I have explained above briefly. The probability distributions in Bayesian inference are easier to understand becuase that is how we typically tend to think in uncertain situations. Ease of implementation: It is easier to get Bayesian probability distributions than frequentist confidence intervals. Frequentist analysis requires us to identify a sampling distribution which is very difficult for many real world applications. Assumptions of the model are explicit in Bayesian inference: For example, many frequentist analyses assume asymptotic Normality for computing the confidence interval. But no such assumptions are required for Bayesian inference. Moreover, the assumptions made in Bayesian inference are more explicit. Prior information: Most importantly, Bayesian inference allows us to incorporate prior knowledge into the analyses in a relatively simple manner. In frequentist methods, regularization is used to incorporate prior information which is very difficult to do in many problems. It is not to say that incorporation of prior information is easy in Bayesian analysis; but it is easier than that in frequentist analysis. Edit: A particularly good example of ease-of-interpretation of Bayesian methods is their use in probabilistic machine learning (ML). There are several method developed in ML literature with the backdrop of Bayesian ideas. For example, relevance vector machines (RVMs), Gaussian processes (GPs). As Richard hardy pointed, this answer gives the reasons why someone would want to use Bayesian analysis. There are good reasons to use frequentist analysis also. In general, frequentist methods are computationally more efficient. I would suggest reading first 3-4 chapters of 'Statistical Decision Theory and Bayesian Analysis' by James Berger which gives a balanced view on this issue but with an emphasis on Bayesian practice. To elaborate on the use of entire distribution rather a point estimate to make a decision in risk minimization, a simple example follows. Suppose you have to choose between different parameters of a process to make a decision, and the cost of choosing wrong parameters is $L(\hat{\theta},\theta)$ where $\hat{\theta}$ is the parameter estimate and $\theta$ is assumed to be true parameter. Now given the posterior distribution $p(\hat{\theta}|D)$ (where $D$ denotes observations)we can minimize expected loss which is $\int L(\hat{\theta},\theta)p(\hat{\theta}|D)d\hat{\theta}$. This expected loss can be minimized for every value of $\theta$ and the $\theta$ value with minimum expected loss can be used for decision making. This will result in a point estimate; but the value of the point estimate depends upon the loss function. Based on a comment by Alexis, here is why frequentist confidence intervals are harder to interpret. Confidence intervals are (as Alexis has pointed out): A plausible range of estimates for a parameter given a Type I error rate. One naturally asks where does this possible range come from. The frequentist answer is that it comes from the sampling distribution. But then the question is we only observe one sample? The frequentist answer is we infer what other samples could have been observed based on the likelihood function. But if we are inferring other samples based on likelihood function, those samples should have a probability distribution over them, and, consequently, the confidence interval should be interpreted as a probability distribution. But for the philosophical reason mentioned above, this last extension of probability distribution to confidence interval is not allowed. Compare this to a Bayesian statement: A 95% credible-region means that the true parameter lies in this region with 95% probability. A side note on philosophical differences between Bayesian and frequentist theory (based on a comment by ): In frequentist theory probability of an event is relative frequencies of that event over a large number of repeated trials of the experiment in question. Therefore, the parameters of a distribution are fixed because they stay the same in all the repetitions of the experiment. In Bayesian theory, the probabilities are degrees of belief in that an event would occur for in a single trial of the experiment in question. The problem with frequentist definition of probability is that it cannot be used to define probabilities in many real world applications. As an example, try to define the probability that I am typing this answer an android smartphone. Frequentist would say that the probability is either $0$ or $1$. While the Bayesian definition allows you to choose an appropriate number between $0$ and $1$.
At the end of the day, what do you do with Bayesian Estimates?
First of all, Frequentist methods also provide a distribution over possible answers. It is just that we do not call them distributions because of a philosophical point. Frequentists consider parameter
At the end of the day, what do you do with Bayesian Estimates? First of all, Frequentist methods also provide a distribution over possible answers. It is just that we do not call them distributions because of a philosophical point. Frequentists consider parameters of a distribution as a fixed quantity. It is not allowed to be random; therefore, you cannot talk about distributions over parameters in a meaningful way. In frequentist methods, we estimate confidence intervals which can be thought of as distributions if we are letting go of the philosophical details. But in Bayesian methods the fixed parameters are allowed to be random; therefore, we talk about the (prior and posterior) distributions over the parameters. Second, it is not always the case that only a single value is used at the end. Many applications require us to use the entire posterior distributions in subsequent analysis. In fact, to derive a suitable point estimate, full distribution is required. A well known example is risk minimization. Another example is model identification in natural sciences in the presence of significant uncertainties. Third, Bayesian inference has many benefits over a frequentist analysis (not just the one that you metion): Ease of interpretation: It is hard to understand what a confidence interval is and why it is not a probability distributions. The reason is simply a philosophical one as I have explained above briefly. The probability distributions in Bayesian inference are easier to understand becuase that is how we typically tend to think in uncertain situations. Ease of implementation: It is easier to get Bayesian probability distributions than frequentist confidence intervals. Frequentist analysis requires us to identify a sampling distribution which is very difficult for many real world applications. Assumptions of the model are explicit in Bayesian inference: For example, many frequentist analyses assume asymptotic Normality for computing the confidence interval. But no such assumptions are required for Bayesian inference. Moreover, the assumptions made in Bayesian inference are more explicit. Prior information: Most importantly, Bayesian inference allows us to incorporate prior knowledge into the analyses in a relatively simple manner. In frequentist methods, regularization is used to incorporate prior information which is very difficult to do in many problems. It is not to say that incorporation of prior information is easy in Bayesian analysis; but it is easier than that in frequentist analysis. Edit: A particularly good example of ease-of-interpretation of Bayesian methods is their use in probabilistic machine learning (ML). There are several method developed in ML literature with the backdrop of Bayesian ideas. For example, relevance vector machines (RVMs), Gaussian processes (GPs). As Richard hardy pointed, this answer gives the reasons why someone would want to use Bayesian analysis. There are good reasons to use frequentist analysis also. In general, frequentist methods are computationally more efficient. I would suggest reading first 3-4 chapters of 'Statistical Decision Theory and Bayesian Analysis' by James Berger which gives a balanced view on this issue but with an emphasis on Bayesian practice. To elaborate on the use of entire distribution rather a point estimate to make a decision in risk minimization, a simple example follows. Suppose you have to choose between different parameters of a process to make a decision, and the cost of choosing wrong parameters is $L(\hat{\theta},\theta)$ where $\hat{\theta}$ is the parameter estimate and $\theta$ is assumed to be true parameter. Now given the posterior distribution $p(\hat{\theta}|D)$ (where $D$ denotes observations)we can minimize expected loss which is $\int L(\hat{\theta},\theta)p(\hat{\theta}|D)d\hat{\theta}$. This expected loss can be minimized for every value of $\theta$ and the $\theta$ value with minimum expected loss can be used for decision making. This will result in a point estimate; but the value of the point estimate depends upon the loss function. Based on a comment by Alexis, here is why frequentist confidence intervals are harder to interpret. Confidence intervals are (as Alexis has pointed out): A plausible range of estimates for a parameter given a Type I error rate. One naturally asks where does this possible range come from. The frequentist answer is that it comes from the sampling distribution. But then the question is we only observe one sample? The frequentist answer is we infer what other samples could have been observed based on the likelihood function. But if we are inferring other samples based on likelihood function, those samples should have a probability distribution over them, and, consequently, the confidence interval should be interpreted as a probability distribution. But for the philosophical reason mentioned above, this last extension of probability distribution to confidence interval is not allowed. Compare this to a Bayesian statement: A 95% credible-region means that the true parameter lies in this region with 95% probability. A side note on philosophical differences between Bayesian and frequentist theory (based on a comment by ): In frequentist theory probability of an event is relative frequencies of that event over a large number of repeated trials of the experiment in question. Therefore, the parameters of a distribution are fixed because they stay the same in all the repetitions of the experiment. In Bayesian theory, the probabilities are degrees of belief in that an event would occur for in a single trial of the experiment in question. The problem with frequentist definition of probability is that it cannot be used to define probabilities in many real world applications. As an example, try to define the probability that I am typing this answer an android smartphone. Frequentist would say that the probability is either $0$ or $1$. While the Bayesian definition allows you to choose an appropriate number between $0$ and $1$.
At the end of the day, what do you do with Bayesian Estimates? First of all, Frequentist methods also provide a distribution over possible answers. It is just that we do not call them distributions because of a philosophical point. Frequentists consider parameter
18,068
At the end of the day, what do you do with Bayesian Estimates?
I can't give a de jure benefit of Bayesianism, but I can offer some examples of how I find Bayesianism beneficial as compared to frequentism. That the results of a Bayesian analysis is a posterior distribution and not a point estimate allows the analyst to perform some very straightforward calculations in order to perform decision analysis. As I explain here, the posterior can be used to estimate the expected loss of any decision (assuming a cost function is specified) simply by taking averages of samples obtained via MCMC techniques. This assumes one has a good model readily available (perhaps a benefit, perhaps a detriment depending on where you stand) but I can't underscore just how simple the calculations can be. From some of the points you make in your post, it sounds like you're caught on the fact that people still want a single number (the expectation of the posterior, for example, or the MAP of the parameters). The sample mean implies a particular cost function (the sample mean for example minimizes the sum of squared errors). But, if you wanted some other cost structure, then with Bayesianism you're free to use an estimator which caters to your needs, as I do in the link above.
At the end of the day, what do you do with Bayesian Estimates?
I can't give a de jure benefit of Bayesianism, but I can offer some examples of how I find Bayesianism beneficial as compared to frequentism. That the results of a Bayesian analysis is a posterior dis
At the end of the day, what do you do with Bayesian Estimates? I can't give a de jure benefit of Bayesianism, but I can offer some examples of how I find Bayesianism beneficial as compared to frequentism. That the results of a Bayesian analysis is a posterior distribution and not a point estimate allows the analyst to perform some very straightforward calculations in order to perform decision analysis. As I explain here, the posterior can be used to estimate the expected loss of any decision (assuming a cost function is specified) simply by taking averages of samples obtained via MCMC techniques. This assumes one has a good model readily available (perhaps a benefit, perhaps a detriment depending on where you stand) but I can't underscore just how simple the calculations can be. From some of the points you make in your post, it sounds like you're caught on the fact that people still want a single number (the expectation of the posterior, for example, or the MAP of the parameters). The sample mean implies a particular cost function (the sample mean for example minimizes the sum of squared errors). But, if you wanted some other cost structure, then with Bayesianism you're free to use an estimator which caters to your needs, as I do in the link above.
At the end of the day, what do you do with Bayesian Estimates? I can't give a de jure benefit of Bayesianism, but I can offer some examples of how I find Bayesianism beneficial as compared to frequentism. That the results of a Bayesian analysis is a posterior dis
18,069
At the end of the day, what do you do with Bayesian Estimates?
There isn't an answer to your question. It is true that there are circumstances where a Bayesian solution is intrinsically preferable to a Frequentist solution. The reverse is also true. The main benefit of a Bayesian model is that it updates and improves your beliefs about the world. Other than that, the two systems are not comparable. They solve different questions. A posterior distribution, if you really are using your real priors, should become your new prior. It becomes your default understanding of the world with respect to the parameters and future data. If you are using it in analysis for a third party, then it should be specified by their prior distributions and not yours. You are not updating your beliefs. All three main methods of constructing estimators, the method of maximum likelihood, Frequency-based estimators such as the minimum variance unbiased estimator, and Bayesian estimators are optimal estimators. They are optimal under different criteria. If you woke up one morning and assuming that one or more categories of estimation were not foreclosed by the nature of the problem, and needed a point estimate, then the solution is to answer what you mean when you say a point is optimal. You should answer a variety of questions. Who needs the point? Why do they need the point? What happens to that third party if you choose the wrong point? Does it actually need to be a point? Could an interval or a distribution do as good or a better job? I think there is another difference that you might be missing. A Frequentist interval or point is working in the sample space. The distributions that are implicit or explicit in the process, such as the sampling distribution of Student's t statistic, are not distributions of beliefs. For statistics, they are the long-run distribution that you would expect to see while collecting samples over the sample space. They represent possible, but maybe forever unrealized, outcomes that could happen. The Bayesian prior and posterior distributions are distributions of beliefs about parameters. They are not distributions that can happen. They happen only in the mind. Change your priors and you change your posterior. Even the Bayesian predictive distribution, which also intrinsically minimizes the K-L divergence between the prediction and nature, can never happen. It is just the weighted sum of the possible distributions that could happen over the posterior or prior. The posterior is the Bayesian conclusion. Getting a point requires adding additional criteria that are then imposed on the posterior, prior, or predictive distributions. There are many good reasons to use a Bayesian solution. In some cases, it is the only permissible solution. The very same thing can be said about non-Bayesian tools too. If you look at the opportunity costs of your model, what school of estimation should you use?
At the end of the day, what do you do with Bayesian Estimates?
There isn't an answer to your question. It is true that there are circumstances where a Bayesian solution is intrinsically preferable to a Frequentist solution. The reverse is also true. The main ben
At the end of the day, what do you do with Bayesian Estimates? There isn't an answer to your question. It is true that there are circumstances where a Bayesian solution is intrinsically preferable to a Frequentist solution. The reverse is also true. The main benefit of a Bayesian model is that it updates and improves your beliefs about the world. Other than that, the two systems are not comparable. They solve different questions. A posterior distribution, if you really are using your real priors, should become your new prior. It becomes your default understanding of the world with respect to the parameters and future data. If you are using it in analysis for a third party, then it should be specified by their prior distributions and not yours. You are not updating your beliefs. All three main methods of constructing estimators, the method of maximum likelihood, Frequency-based estimators such as the minimum variance unbiased estimator, and Bayesian estimators are optimal estimators. They are optimal under different criteria. If you woke up one morning and assuming that one or more categories of estimation were not foreclosed by the nature of the problem, and needed a point estimate, then the solution is to answer what you mean when you say a point is optimal. You should answer a variety of questions. Who needs the point? Why do they need the point? What happens to that third party if you choose the wrong point? Does it actually need to be a point? Could an interval or a distribution do as good or a better job? I think there is another difference that you might be missing. A Frequentist interval or point is working in the sample space. The distributions that are implicit or explicit in the process, such as the sampling distribution of Student's t statistic, are not distributions of beliefs. For statistics, they are the long-run distribution that you would expect to see while collecting samples over the sample space. They represent possible, but maybe forever unrealized, outcomes that could happen. The Bayesian prior and posterior distributions are distributions of beliefs about parameters. They are not distributions that can happen. They happen only in the mind. Change your priors and you change your posterior. Even the Bayesian predictive distribution, which also intrinsically minimizes the K-L divergence between the prediction and nature, can never happen. It is just the weighted sum of the possible distributions that could happen over the posterior or prior. The posterior is the Bayesian conclusion. Getting a point requires adding additional criteria that are then imposed on the posterior, prior, or predictive distributions. There are many good reasons to use a Bayesian solution. In some cases, it is the only permissible solution. The very same thing can be said about non-Bayesian tools too. If you look at the opportunity costs of your model, what school of estimation should you use?
At the end of the day, what do you do with Bayesian Estimates? There isn't an answer to your question. It is true that there are circumstances where a Bayesian solution is intrinsically preferable to a Frequentist solution. The reverse is also true. The main ben
18,070
At the end of the day, what do you do with Bayesian Estimates?
Suppose your prior distribution is that a coin may be biased so it has success probability $\theta$ near $1/3.$ Specifically, you consider that $\theta\sim\mathsf{Beta}(2,4),$ so that $E(\theta)=1/3,$ $P(\theta < 1/2) = 0.8125,$ $P(0.0527 <\theta < 0.716) = 0.96,$ and $\theta$ has density function $f(\theta) = K\theta^{2-1}(1-\theta)^{4-1},$ where $K$ is the norming constant. [Computations in R.] pbeta(.5, 2,4) [1] 0.8125 qbeta(c(.025,.975),2,4) [1] 0.05274495 0.71641794 Then you are allowed to toss the coin $n = 30$ times, obtaining $x = 9$ heads. Thus, your likelihood function is $g(x|\theta) \propto \theta^9(1-\theta)^{21},$ where the symbol $\propto$ indicates that the norming constant has been omitted. Finally, by Bayes' Theorem, the posterior distribution is $$g(\theta|x) \propto f(\theta)\times g(x|\theta)\\ \propto \theta^{2-1}(1-\theta)^{4-1} \times \theta^9(1-\theta)^{21}\\ \propto \theta^{11-1}(1-\theta)^{25-1}.$$ where we recognize the last line as the kernel (density without norming constant) of $\mathsf{Beta}(11,25).$ Thus the posterior mean of $\theta$ is $E(\theta|x)=11/36= 0.3056,$ slightly smaller than the prior $E(\theta) = 0.333$ because you have information from your 30 tosses. Also, a 95% posterior credible interval for $\theta$ is $(0.169, 0.463).$ qbeta(c(.025,.975),11,25) [1] 0.1685172 0.4630446 The posterior distribution has information from your initial hunch that the coin may be biased towards Tails and also the results of your thirty-toss experiment with the coin. The interpretation of this Bayesian interval estimate differs from the 'long run' interpretation of a frequentist confidence interval. Because the prior and likelihood both describe the particular coin at hand, we can say that the interval $(0.169, 0.463)$ also applies to the coin at hand. In particular we are pretty sure the coin is not fair.
At the end of the day, what do you do with Bayesian Estimates?
Suppose your prior distribution is that a coin may be biased so it has success probability $\theta$ near $1/3.$ Specifically, you consider that $\theta\sim\mathsf{Beta}(2,4),$ so that $E(\theta)=1/3,$
At the end of the day, what do you do with Bayesian Estimates? Suppose your prior distribution is that a coin may be biased so it has success probability $\theta$ near $1/3.$ Specifically, you consider that $\theta\sim\mathsf{Beta}(2,4),$ so that $E(\theta)=1/3,$ $P(\theta < 1/2) = 0.8125,$ $P(0.0527 <\theta < 0.716) = 0.96,$ and $\theta$ has density function $f(\theta) = K\theta^{2-1}(1-\theta)^{4-1},$ where $K$ is the norming constant. [Computations in R.] pbeta(.5, 2,4) [1] 0.8125 qbeta(c(.025,.975),2,4) [1] 0.05274495 0.71641794 Then you are allowed to toss the coin $n = 30$ times, obtaining $x = 9$ heads. Thus, your likelihood function is $g(x|\theta) \propto \theta^9(1-\theta)^{21},$ where the symbol $\propto$ indicates that the norming constant has been omitted. Finally, by Bayes' Theorem, the posterior distribution is $$g(\theta|x) \propto f(\theta)\times g(x|\theta)\\ \propto \theta^{2-1}(1-\theta)^{4-1} \times \theta^9(1-\theta)^{21}\\ \propto \theta^{11-1}(1-\theta)^{25-1}.$$ where we recognize the last line as the kernel (density without norming constant) of $\mathsf{Beta}(11,25).$ Thus the posterior mean of $\theta$ is $E(\theta|x)=11/36= 0.3056,$ slightly smaller than the prior $E(\theta) = 0.333$ because you have information from your 30 tosses. Also, a 95% posterior credible interval for $\theta$ is $(0.169, 0.463).$ qbeta(c(.025,.975),11,25) [1] 0.1685172 0.4630446 The posterior distribution has information from your initial hunch that the coin may be biased towards Tails and also the results of your thirty-toss experiment with the coin. The interpretation of this Bayesian interval estimate differs from the 'long run' interpretation of a frequentist confidence interval. Because the prior and likelihood both describe the particular coin at hand, we can say that the interval $(0.169, 0.463)$ also applies to the coin at hand. In particular we are pretty sure the coin is not fair.
At the end of the day, what do you do with Bayesian Estimates? Suppose your prior distribution is that a coin may be biased so it has success probability $\theta$ near $1/3.$ Specifically, you consider that $\theta\sim\mathsf{Beta}(2,4),$ so that $E(\theta)=1/3,$
18,071
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate]
If I understood the question correctly - you might want to use a "conditional density plot". Such a plot provides a smoothed overview of how a categorical variable changes across various levels of continuous numerical variable. Example For a real-world example here is the distribution of Sepal Width across 3 different species in the iris dataset: cdplot(Species ~ Sepal.Width, data=iris) Interpretation These plots represent smoothed proportions of each category within various levels of the continuous variable. In order to interpret them you should look across at the x-axis and see how the different proportions for each category (represented by different colors) change with the different values of the numerical variable. For example consider the picture above: it is quite easy to see that when sepal width reaches 3.5 or above you are most likely dealing with setosa type of flower. At sepal width 2.0 the versicolor dominates. And at 3.0 there are about 20% setosa, 35% versicolor and 45% virginica (judging by eye according to the scales on the y-axis on the right.) For another discussion about interpretation of such plots consider reading answers in this question: Interpretation of conditional density plots Your case Of course in your case you would have 2 categories on the y-axis. So the final picture would look closer to this example: set.seed(14) presence <- factor(rbinom(20, 1, 0.5)) presence [1] 0 1 1 1 1 1 1 0 0 0 1 0 0 1 1 1 0 1 1 1 Levels: 0 1 pressure <- runif(20, 1000, 1035) pressure [1] 1012.282 1014.687 1021.619 1024.159 1026.247 1021.663 1013.469 1018.317 1024.054 1002.747 1028.396 1004.806 1033.906 1022.898 1033.127 1004.378 1019.386 1016.432 1030.160 1021.567 cdplot(presence ~ pressure) Interpretation stays the same, except you will be dealing with a binary categorical variable. In this particular case the plot would suggest that the presence (1, light grey area) is increasing with increasing values of pressure (x-axis).
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate]
If I understood the question correctly - you might want to use a "conditional density plot". Such a plot provides a smoothed overview of how a categorical variable changes across various levels of con
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate] If I understood the question correctly - you might want to use a "conditional density plot". Such a plot provides a smoothed overview of how a categorical variable changes across various levels of continuous numerical variable. Example For a real-world example here is the distribution of Sepal Width across 3 different species in the iris dataset: cdplot(Species ~ Sepal.Width, data=iris) Interpretation These plots represent smoothed proportions of each category within various levels of the continuous variable. In order to interpret them you should look across at the x-axis and see how the different proportions for each category (represented by different colors) change with the different values of the numerical variable. For example consider the picture above: it is quite easy to see that when sepal width reaches 3.5 or above you are most likely dealing with setosa type of flower. At sepal width 2.0 the versicolor dominates. And at 3.0 there are about 20% setosa, 35% versicolor and 45% virginica (judging by eye according to the scales on the y-axis on the right.) For another discussion about interpretation of such plots consider reading answers in this question: Interpretation of conditional density plots Your case Of course in your case you would have 2 categories on the y-axis. So the final picture would look closer to this example: set.seed(14) presence <- factor(rbinom(20, 1, 0.5)) presence [1] 0 1 1 1 1 1 1 0 0 0 1 0 0 1 1 1 0 1 1 1 Levels: 0 1 pressure <- runif(20, 1000, 1035) pressure [1] 1012.282 1014.687 1021.619 1024.159 1026.247 1021.663 1013.469 1018.317 1024.054 1002.747 1028.396 1004.806 1033.906 1022.898 1033.127 1004.378 1019.386 1016.432 1030.160 1021.567 cdplot(presence ~ pressure) Interpretation stays the same, except you will be dealing with a binary categorical variable. In this particular case the plot would suggest that the presence (1, light grey area) is increasing with increasing values of pressure (x-axis).
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate] If I understood the question correctly - you might want to use a "conditional density plot". Such a plot provides a smoothed overview of how a categorical variable changes across various levels of con
18,072
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate]
Much better to turn your plot around: put presence on the horizontal and pressure on the vertical axis. Then plot pressure as a dotplot. If overplotting is an issue, jitter the dots horizontally. If you want to emphasize the distribution and/or summary statistics, overlay a boxplot or a beanplot. Of course you can plot these horizontally, too, if you insist, but for just two groups, one usually sees the vertical versions below. library(beanplot) set.seed(1) n_per_group <- 30 pressure <- data.frame(F=rnorm(n_per_group,1000,20),T=rnorm(n_per_group,1000,20)) boxplot(pressure,outline=FALSE,ylim=range(pressure),xaxt="n",col="gray", xlab="Presence",ylab="Pressure (hPa)") axis(1,c(1,2),c("FALSE","TRUE")) points(as.vector(cbind(runif(n_per_group,.7,1.3),runif(n_per_group,1.7,2.3))), unlist(pressure),pch=19) beanplot(pressure,what=c(0,1,0,0),col="gray",xaxt="n",xlab="Presence",ylab="Pressure (hPa)") axis(1,c(1,2),c("FALSE","TRUE")) points(as.vector(cbind(runif(n_per_group,.7,1.3),runif(n_per_group,1.7,2.3))), unlist(pressure),pch=19)
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate]
Much better to turn your plot around: put presence on the horizontal and pressure on the vertical axis. Then plot pressure as a dotplot. If overplotting is an issue, jitter the dots horizontally. If y
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate] Much better to turn your plot around: put presence on the horizontal and pressure on the vertical axis. Then plot pressure as a dotplot. If overplotting is an issue, jitter the dots horizontally. If you want to emphasize the distribution and/or summary statistics, overlay a boxplot or a beanplot. Of course you can plot these horizontally, too, if you insist, but for just two groups, one usually sees the vertical versions below. library(beanplot) set.seed(1) n_per_group <- 30 pressure <- data.frame(F=rnorm(n_per_group,1000,20),T=rnorm(n_per_group,1000,20)) boxplot(pressure,outline=FALSE,ylim=range(pressure),xaxt="n",col="gray", xlab="Presence",ylab="Pressure (hPa)") axis(1,c(1,2),c("FALSE","TRUE")) points(as.vector(cbind(runif(n_per_group,.7,1.3),runif(n_per_group,1.7,2.3))), unlist(pressure),pch=19) beanplot(pressure,what=c(0,1,0,0),col="gray",xaxt="n",xlab="Presence",ylab="Pressure (hPa)") axis(1,c(1,2),c("FALSE","TRUE")) points(as.vector(cbind(runif(n_per_group,.7,1.3),runif(n_per_group,1.7,2.3))), unlist(pressure),pch=19)
How to plot binary (presence/absence - 1/0) data against continuous variables [duplicate] Much better to turn your plot around: put presence on the horizontal and pressure on the vertical axis. Then plot pressure as a dotplot. If overplotting is an issue, jitter the dots horizontally. If y
18,073
a general measure of data-set imbalance
You could use the Shannon entropy to measure balance. On a data set of $n$ instances, if you have $k$ classes of size $c_i$ you can compute entropy as follows: $$ H = -\sum_{ i = 1}^k \frac{c_i}{n} \log{ \frac{c_i}{n}}. $$ This is equal to: $0$ when there is one single class. In other words, it tends to $0$ when your data set is very unbalanced $\log{k}$ when all your classes are balanced of the same size $\frac{n}{k}$ Therefore, you could use the following measure of Balance for a data set: $$ \mbox{Balance} = \frac{H}{\log{k}} = \frac{-\sum_{ i = 1}^k \frac{c_i}{n} \log{ \frac{c_i}{n}}. } {\log{k}} $$ which is equal to: $0$ for an unbalanced data set $1$ for a balanced data set
a general measure of data-set imbalance
You could use the Shannon entropy to measure balance. On a data set of $n$ instances, if you have $k$ classes of size $c_i$ you can compute entropy as follows: $$ H = -\sum_{ i = 1}^k \frac{c_i}{n} \l
a general measure of data-set imbalance You could use the Shannon entropy to measure balance. On a data set of $n$ instances, if you have $k$ classes of size $c_i$ you can compute entropy as follows: $$ H = -\sum_{ i = 1}^k \frac{c_i}{n} \log{ \frac{c_i}{n}}. $$ This is equal to: $0$ when there is one single class. In other words, it tends to $0$ when your data set is very unbalanced $\log{k}$ when all your classes are balanced of the same size $\frac{n}{k}$ Therefore, you could use the following measure of Balance for a data set: $$ \mbox{Balance} = \frac{H}{\log{k}} = \frac{-\sum_{ i = 1}^k \frac{c_i}{n} \log{ \frac{c_i}{n}}. } {\log{k}} $$ which is equal to: $0$ for an unbalanced data set $1$ for a balanced data set
a general measure of data-set imbalance You could use the Shannon entropy to measure balance. On a data set of $n$ instances, if you have $k$ classes of size $c_i$ you can compute entropy as follows: $$ H = -\sum_{ i = 1}^k \frac{c_i}{n} \l
18,074
a general measure of data-set imbalance
Based on the answer of Simone, I wrote this short python code to calculate balance, which works very well for me. def balance(seq): from collections import Counter from numpy import log n = len(seq) classes = [(clas,float(count)) for clas,count in Counter(seq).items()] k = len(classes) H = -sum([ (count/n) * log((count/n)) for clas,count in classes]) #shannon entropy return H/log(k) Thank you very much!
a general measure of data-set imbalance
Based on the answer of Simone, I wrote this short python code to calculate balance, which works very well for me. def balance(seq): from collections import Counter from numpy import log
a general measure of data-set imbalance Based on the answer of Simone, I wrote this short python code to calculate balance, which works very well for me. def balance(seq): from collections import Counter from numpy import log n = len(seq) classes = [(clas,float(count)) for clas,count in Counter(seq).items()] k = len(classes) H = -sum([ (count/n) * log((count/n)) for clas,count in classes]) #shannon entropy return H/log(k) Thank you very much!
a general measure of data-set imbalance Based on the answer of Simone, I wrote this short python code to calculate balance, which works very well for me. def balance(seq): from collections import Counter from numpy import log
18,075
a general measure of data-set imbalance
I had the same problem and looked for some metrics to measure the degree of unbalance in my datasets, but I did not find any. Then, I created one that varies between 0 (perfectly balanced, the number of samples in all categories is the same) and 1 (extremely badly balanced, when the number of samples in all classes, except for one, is 1 and the rest of samples belong to a single class) The formula is: $$imbalance = \frac{Max_{samples} - Min_{samples}}{Total_{samples} - nclass}$$ Examples: For a balanced case $Max_{samples} = Min_{samples}$, then $imbalance =0$ For a three class case ($nclass=3$) having 500, 300 and 100 samples each, we have: $Max_{samples}=500$, $Min_{samples}=100$, and $Total_{samples} = 900$, then $imbalance = (500-100)/(900-3) = 0.446$ In an extreme three classes case, we have 500, 1 and 1 samples in each class, then $Max_{samples}=500$, $Min_{samples}=1$ and $Total_{samples} =502$, then $imbalance = (500-1)/(502-3) = 1$
a general measure of data-set imbalance
I had the same problem and looked for some metrics to measure the degree of unbalance in my datasets, but I did not find any. Then, I created one that varies between 0 (perfectly balanced, the number
a general measure of data-set imbalance I had the same problem and looked for some metrics to measure the degree of unbalance in my datasets, but I did not find any. Then, I created one that varies between 0 (perfectly balanced, the number of samples in all categories is the same) and 1 (extremely badly balanced, when the number of samples in all classes, except for one, is 1 and the rest of samples belong to a single class) The formula is: $$imbalance = \frac{Max_{samples} - Min_{samples}}{Total_{samples} - nclass}$$ Examples: For a balanced case $Max_{samples} = Min_{samples}$, then $imbalance =0$ For a three class case ($nclass=3$) having 500, 300 and 100 samples each, we have: $Max_{samples}=500$, $Min_{samples}=100$, and $Total_{samples} = 900$, then $imbalance = (500-100)/(900-3) = 0.446$ In an extreme three classes case, we have 500, 1 and 1 samples in each class, then $Max_{samples}=500$, $Min_{samples}=1$ and $Total_{samples} =502$, then $imbalance = (500-1)/(502-3) = 1$
a general measure of data-set imbalance I had the same problem and looked for some metrics to measure the degree of unbalance in my datasets, but I did not find any. Then, I created one that varies between 0 (perfectly balanced, the number
18,076
How to obtain p-values of coefficients from bootstrap regression?
Just another variant that is somewhat simplistic but I think deliver the message without explicitly using the library boot that may confuse some people with the syntax it uses. We have a linear model: $y = X \beta + \epsilon$, $\quad \epsilon \sim N(0,\sigma^2)$ The following is a parametric bootstrap for that linear model, that means that we do not resample our original data but actually we generate new data from our fitted model. Additionally we assume that the bootstrapped distribution of the regression coefficient $\beta$ is symmetric and that is translation invariant. (Very roughly speaking that we can move the axis of it with affecting its properties) The idea behind is that the fluctuations in the $\beta$ 's are due to $\epsilon$ and therefore with enough samples they should provide a good approximation of the true distribution of $\beta$ 's. As before we test again $H_0 : 0 = \beta_j$ and we defined our p-values as "the probability, given a null hypothesis for the probability distribution of the data, that the outcome would be as extreme as, or more extreme than, the observed outcome" (where the observed outcomes in this case are the $\beta$ 's we got for our original model). So here goes: # Sample Size N <- 2^12; # Linear Model to Boostrap Model2Boot <- lm( mpg ~ wt + disp, mtcars) # Values of the model coefficients Betas <- coefficients(Model2Boot) # Number of coefficents to test against M <- length(Betas) # Matrix of M columns to hold Bootstraping results BtStrpRes <- matrix( rep(0,M*N), ncol=M) for (i in 1:N) { # Simulate data N times from the model we assume be true # and save the resulting coefficient in the i-th row of BtStrpRes BtStrpRes[i,] <-coefficients(lm(unlist(simulate(Model2Boot)) ~wt + disp, mtcars)) } #Get the p-values for coefficient P_val1 <-mean( abs(BtStrpRes[,1] - mean(BtStrpRes[,1]) )> abs( Betas[1])) P_val2 <-mean( abs(BtStrpRes[,2] - mean(BtStrpRes[,2]) )> abs( Betas[2])) P_val3 <-mean( abs(BtStrpRes[,3] - mean(BtStrpRes[,3]) )> abs( Betas[3])) #and some parametric bootstrap confidence intervals (2.5%, 97.5%) ConfInt1 <- quantile(BtStrpRes[,1], c(.025, 0.975)) ConfInt2 <- quantile(BtStrpRes[,2], c(.025, 0.975)) ConfInt3 <- quantile(BtStrpRes[,3], c(.025, 0.975)) As mentioned the whole idea is that you have the bootstrapped distribution of $\beta$ 's approximates their true one. (Clearly this code is optimized for speed but for readability. :) )
How to obtain p-values of coefficients from bootstrap regression?
Just another variant that is somewhat simplistic but I think deliver the message without explicitly using the library boot that may confuse some people with the syntax it uses. We have a linear model
How to obtain p-values of coefficients from bootstrap regression? Just another variant that is somewhat simplistic but I think deliver the message without explicitly using the library boot that may confuse some people with the syntax it uses. We have a linear model: $y = X \beta + \epsilon$, $\quad \epsilon \sim N(0,\sigma^2)$ The following is a parametric bootstrap for that linear model, that means that we do not resample our original data but actually we generate new data from our fitted model. Additionally we assume that the bootstrapped distribution of the regression coefficient $\beta$ is symmetric and that is translation invariant. (Very roughly speaking that we can move the axis of it with affecting its properties) The idea behind is that the fluctuations in the $\beta$ 's are due to $\epsilon$ and therefore with enough samples they should provide a good approximation of the true distribution of $\beta$ 's. As before we test again $H_0 : 0 = \beta_j$ and we defined our p-values as "the probability, given a null hypothesis for the probability distribution of the data, that the outcome would be as extreme as, or more extreme than, the observed outcome" (where the observed outcomes in this case are the $\beta$ 's we got for our original model). So here goes: # Sample Size N <- 2^12; # Linear Model to Boostrap Model2Boot <- lm( mpg ~ wt + disp, mtcars) # Values of the model coefficients Betas <- coefficients(Model2Boot) # Number of coefficents to test against M <- length(Betas) # Matrix of M columns to hold Bootstraping results BtStrpRes <- matrix( rep(0,M*N), ncol=M) for (i in 1:N) { # Simulate data N times from the model we assume be true # and save the resulting coefficient in the i-th row of BtStrpRes BtStrpRes[i,] <-coefficients(lm(unlist(simulate(Model2Boot)) ~wt + disp, mtcars)) } #Get the p-values for coefficient P_val1 <-mean( abs(BtStrpRes[,1] - mean(BtStrpRes[,1]) )> abs( Betas[1])) P_val2 <-mean( abs(BtStrpRes[,2] - mean(BtStrpRes[,2]) )> abs( Betas[2])) P_val3 <-mean( abs(BtStrpRes[,3] - mean(BtStrpRes[,3]) )> abs( Betas[3])) #and some parametric bootstrap confidence intervals (2.5%, 97.5%) ConfInt1 <- quantile(BtStrpRes[,1], c(.025, 0.975)) ConfInt2 <- quantile(BtStrpRes[,2], c(.025, 0.975)) ConfInt3 <- quantile(BtStrpRes[,3], c(.025, 0.975)) As mentioned the whole idea is that you have the bootstrapped distribution of $\beta$ 's approximates their true one. (Clearly this code is optimized for speed but for readability. :) )
How to obtain p-values of coefficients from bootstrap regression? Just another variant that is somewhat simplistic but I think deliver the message without explicitly using the library boot that may confuse some people with the syntax it uses. We have a linear model
18,077
How to obtain p-values of coefficients from bootstrap regression?
The community and @BrianDiggs may correct me if I am wrong, but I believe you can get a p-value for your problem as follows. A p-value for a two sided test is defined as $$2*\text{min}[P(X \le x|H_0),P(X \ge x|H_0)]$$ So if you order the bootstrapped coefficients by size and then determine the proportions larger and smaller zero, the minimum proportion times two should give you a p-value. I normally use the following function in such a situation: twosidep<-function(data){ p1<-sum(data>0)/length(data) p2<-sum(data<0)/length(data) p<-min(p1,p2)*2 return(p) }
How to obtain p-values of coefficients from bootstrap regression?
The community and @BrianDiggs may correct me if I am wrong, but I believe you can get a p-value for your problem as follows. A p-value for a two sided test is defined as $$2*\text{min}[P(X \le x|H_0),
How to obtain p-values of coefficients from bootstrap regression? The community and @BrianDiggs may correct me if I am wrong, but I believe you can get a p-value for your problem as follows. A p-value for a two sided test is defined as $$2*\text{min}[P(X \le x|H_0),P(X \ge x|H_0)]$$ So if you order the bootstrapped coefficients by size and then determine the proportions larger and smaller zero, the minimum proportion times two should give you a p-value. I normally use the following function in such a situation: twosidep<-function(data){ p1<-sum(data>0)/length(data) p2<-sum(data<0)/length(data) p<-min(p1,p2)*2 return(p) }
How to obtain p-values of coefficients from bootstrap regression? The community and @BrianDiggs may correct me if I am wrong, but I believe you can get a p-value for your problem as follows. A p-value for a two sided test is defined as $$2*\text{min}[P(X \le x|H_0),
18,078
How to obtain p-values of coefficients from bootstrap regression?
The bootstrap can be used to compute $p$-values, but it would need a substantial change to your code. As I am not familiar with R I can only give you a reference in which you can look up what you would need to do: chapter 4 of (Davison and Hinkley 1997). Davison, A.C. and Hinkley, D.V. 1997. Bootstrap methods and their application. Cambridge: Cambridge University Press.
How to obtain p-values of coefficients from bootstrap regression?
The bootstrap can be used to compute $p$-values, but it would need a substantial change to your code. As I am not familiar with R I can only give you a reference in which you can look up what you woul
How to obtain p-values of coefficients from bootstrap regression? The bootstrap can be used to compute $p$-values, but it would need a substantial change to your code. As I am not familiar with R I can only give you a reference in which you can look up what you would need to do: chapter 4 of (Davison and Hinkley 1997). Davison, A.C. and Hinkley, D.V. 1997. Bootstrap methods and their application. Cambridge: Cambridge University Press.
How to obtain p-values of coefficients from bootstrap regression? The bootstrap can be used to compute $p$-values, but it would need a substantial change to your code. As I am not familiar with R I can only give you a reference in which you can look up what you woul
18,079
Random forest is overfitting
I think you are using wrong tool; if your whole X is equivalent to the index, you are basically having some sampled function $f:\mathbb{R}\rightarrow\mathbb{R}$ and trying to extrapolate it. Machine learning is all about interpolating history, so it is not surprising that it scores spectacular fail in this case. What you need is a time series analysis (i.e. extracting trend, analysing spectrum and autoregressing or HMMing the rest) or physics (i.e. thinking if there is an ODE that may produce such output and trying to fit its parameters via conserved quantities).
Random forest is overfitting
I think you are using wrong tool; if your whole X is equivalent to the index, you are basically having some sampled function $f:\mathbb{R}\rightarrow\mathbb{R}$ and trying to extrapolate it. Machine l
Random forest is overfitting I think you are using wrong tool; if your whole X is equivalent to the index, you are basically having some sampled function $f:\mathbb{R}\rightarrow\mathbb{R}$ and trying to extrapolate it. Machine learning is all about interpolating history, so it is not surprising that it scores spectacular fail in this case. What you need is a time series analysis (i.e. extracting trend, analysing spectrum and autoregressing or HMMing the rest) or physics (i.e. thinking if there is an ODE that may produce such output and trying to fit its parameters via conserved quantities).
Random forest is overfitting I think you are using wrong tool; if your whole X is equivalent to the index, you are basically having some sampled function $f:\mathbb{R}\rightarrow\mathbb{R}$ and trying to extrapolate it. Machine l
18,080
Random forest is overfitting
The biggest problem is that regression trees (and algorithms based on them like random forests) predict piecewise constant functions, giving a constant value for inputs falling under each leaf. This means that when extrapolating outside their training domain, they just predict the same value as they would for the nearest point at which they had training data. @mbq is correct that there are specialized tools for learning time series that would probably be better than general machine learning techniques. However, random forests are particularly bad for this example, and there other general ML techniques would probably perform much better than what you are seeing. SVMs with nonlinear kernels are one option that comes to mind. Since your function has periodic structure, this also suggests working the frequency domain, using Fourier components or wavelets.
Random forest is overfitting
The biggest problem is that regression trees (and algorithms based on them like random forests) predict piecewise constant functions, giving a constant value for inputs falling under each leaf. This m
Random forest is overfitting The biggest problem is that regression trees (and algorithms based on them like random forests) predict piecewise constant functions, giving a constant value for inputs falling under each leaf. This means that when extrapolating outside their training domain, they just predict the same value as they would for the nearest point at which they had training data. @mbq is correct that there are specialized tools for learning time series that would probably be better than general machine learning techniques. However, random forests are particularly bad for this example, and there other general ML techniques would probably perform much better than what you are seeing. SVMs with nonlinear kernels are one option that comes to mind. Since your function has periodic structure, this also suggests working the frequency domain, using Fourier components or wavelets.
Random forest is overfitting The biggest problem is that regression trees (and algorithms based on them like random forests) predict piecewise constant functions, giving a constant value for inputs falling under each leaf. This m
18,081
Random forest is overfitting
This is a textbook example for data over-fitting, the model does very well on trained data but collapses on any new test data. This is one of the strategies to address this: Make a ten fold cross validation of the training data to optimize the parameters. Step 1. Create a MSE minimizing function using the NM optimization. An example could be seen here: http://glowingpython.blogspot.de/2011/05/curve-fitting-using-fmin.html Step 2. Within this minimization function, the objective is to reduce the MSE. In order to do this, create a ten-fold split of the data where a new model is learned on 9 folds and tested on the 10th fold. This process is repeated ten times, to obtain the MSE on each fold. The aggregated MSE is returned as the result of the objective. Step 3. The fmin in python will do the iterations for you. Check which hyper parameters are necessary to be fine tuned (n_estimators, max_features etc.) and pass them to the fmin. The result will be the best hyper-parameters which will reduce the possibility of over-fitting.
Random forest is overfitting
This is a textbook example for data over-fitting, the model does very well on trained data but collapses on any new test data. This is one of the strategies to address this: Make a ten fold cross val
Random forest is overfitting This is a textbook example for data over-fitting, the model does very well on trained data but collapses on any new test data. This is one of the strategies to address this: Make a ten fold cross validation of the training data to optimize the parameters. Step 1. Create a MSE minimizing function using the NM optimization. An example could be seen here: http://glowingpython.blogspot.de/2011/05/curve-fitting-using-fmin.html Step 2. Within this minimization function, the objective is to reduce the MSE. In order to do this, create a ten-fold split of the data where a new model is learned on 9 folds and tested on the 10th fold. This process is repeated ten times, to obtain the MSE on each fold. The aggregated MSE is returned as the result of the objective. Step 3. The fmin in python will do the iterations for you. Check which hyper parameters are necessary to be fine tuned (n_estimators, max_features etc.) and pass them to the fmin. The result will be the best hyper-parameters which will reduce the possibility of over-fitting.
Random forest is overfitting This is a textbook example for data over-fitting, the model does very well on trained data but collapses on any new test data. This is one of the strategies to address this: Make a ten fold cross val
18,082
Random forest is overfitting
Some suggestions: Tune your parameters using a rolling window approach (your model must be optimized to predict the next values in the time series, not to predict values among the ones supplied) Try other models (even simpler ones, with the right feature selection and feature engineering strategies, might prove better suited to your problem) Try to learn optimal transformations of the target variable (tune this too, there's a negative linear/exponential tendency, you may be able to estimate it) Spectral analysis perhaps The maxima/minima are equally spaced it seems. Learn where they are given your features (no operator input, make an algorithm discover it to remove bias) and add this as a feature. Also engineer a feature nearest maximum. Dunno, it might work, or perhaps not, you can only know if you test it :)
Random forest is overfitting
Some suggestions: Tune your parameters using a rolling window approach (your model must be optimized to predict the next values in the time series, not to predict values among the ones supplied) Try
Random forest is overfitting Some suggestions: Tune your parameters using a rolling window approach (your model must be optimized to predict the next values in the time series, not to predict values among the ones supplied) Try other models (even simpler ones, with the right feature selection and feature engineering strategies, might prove better suited to your problem) Try to learn optimal transformations of the target variable (tune this too, there's a negative linear/exponential tendency, you may be able to estimate it) Spectral analysis perhaps The maxima/minima are equally spaced it seems. Learn where they are given your features (no operator input, make an algorithm discover it to remove bias) and add this as a feature. Also engineer a feature nearest maximum. Dunno, it might work, or perhaps not, you can only know if you test it :)
Random forest is overfitting Some suggestions: Tune your parameters using a rolling window approach (your model must be optimized to predict the next values in the time series, not to predict values among the ones supplied) Try
18,083
Random forest is overfitting
This is an interesting problem. Your data suggests some regularity (periodic $x^2$ like functions) but has sharp peaks at transitions. All this suggests a slightly complex model. I would model these data by a succession of $x_2$ functions parametrized by a coefficient and a displacement parameter.
Random forest is overfitting
This is an interesting problem. Your data suggests some regularity (periodic $x^2$ like functions) but has sharp peaks at transitions. All this suggests a slightly complex model. I would model these d
Random forest is overfitting This is an interesting problem. Your data suggests some regularity (periodic $x^2$ like functions) but has sharp peaks at transitions. All this suggests a slightly complex model. I would model these data by a succession of $x_2$ functions parametrized by a coefficient and a displacement parameter.
Random forest is overfitting This is an interesting problem. Your data suggests some regularity (periodic $x^2$ like functions) but has sharp peaks at transitions. All this suggests a slightly complex model. I would model these d
18,084
Random forest is overfitting
After reading above post , I want to give another different answer. For tree based models, such as random forest, they can't extrapolate the value beyond the training set. So, I don't think it is an over fitting problem, but an wrong modeling strategy. So, what can we do for time series prediction with tree model? The possible way is to combine it with linear regression: first, detrend the time series (or modeling trend with linear regression), then modeling the residual with trees (residuals are bounded, so tree models can handle it). Besides, there is a tree model combined with linear regression can extrapolate, called cubist, it does linear regression on the leaf.
Random forest is overfitting
After reading above post , I want to give another different answer. For tree based models, such as random forest, they can't extrapolate the value beyond the training set. So, I don't think it is an o
Random forest is overfitting After reading above post , I want to give another different answer. For tree based models, such as random forest, they can't extrapolate the value beyond the training set. So, I don't think it is an over fitting problem, but an wrong modeling strategy. So, what can we do for time series prediction with tree model? The possible way is to combine it with linear regression: first, detrend the time series (or modeling trend with linear regression), then modeling the residual with trees (residuals are bounded, so tree models can handle it). Besides, there is a tree model combined with linear regression can extrapolate, called cubist, it does linear regression on the leaf.
Random forest is overfitting After reading above post , I want to give another different answer. For tree based models, such as random forest, they can't extrapolate the value beyond the training set. So, I don't think it is an o
18,085
Random forest is overfitting
If you simply want to predict within the bounds of the graph, then simply randomizing the observations before splitting the data set should solve the problem. It then becomes an interpolation problem from the extrapolation one as shown.
Random forest is overfitting
If you simply want to predict within the bounds of the graph, then simply randomizing the observations before splitting the data set should solve the problem. It then becomes an interpolation problem
Random forest is overfitting If you simply want to predict within the bounds of the graph, then simply randomizing the observations before splitting the data set should solve the problem. It then becomes an interpolation problem from the extrapolation one as shown.
Random forest is overfitting If you simply want to predict within the bounds of the graph, then simply randomizing the observations before splitting the data set should solve the problem. It then becomes an interpolation problem
18,086
Why applying model selection using AIC gives me non-significant p-values for the variables
AIC and its variants are closer to variations on $R^2$ then on p-values of each regressor. More precisely, they are penalized versions of the log-likelihood. You don't want to test differences of AIC using chi-squared. You could test differences of the log-likelihood using chi-squared (if the models are nested). For AIC, lower is better (in most implementations of it, anyway). No further adjustment needed. You really want to avoid automated model selection methods, if you possibly can. If you must use one, try LASSO or LAR.
Why applying model selection using AIC gives me non-significant p-values for the variables
AIC and its variants are closer to variations on $R^2$ then on p-values of each regressor. More precisely, they are penalized versions of the log-likelihood. You don't want to test differences of AIC
Why applying model selection using AIC gives me non-significant p-values for the variables AIC and its variants are closer to variations on $R^2$ then on p-values of each regressor. More precisely, they are penalized versions of the log-likelihood. You don't want to test differences of AIC using chi-squared. You could test differences of the log-likelihood using chi-squared (if the models are nested). For AIC, lower is better (in most implementations of it, anyway). No further adjustment needed. You really want to avoid automated model selection methods, if you possibly can. If you must use one, try LASSO or LAR.
Why applying model selection using AIC gives me non-significant p-values for the variables AIC and its variants are closer to variations on $R^2$ then on p-values of each regressor. More precisely, they are penalized versions of the log-likelihood. You don't want to test differences of AIC
18,087
Why applying model selection using AIC gives me non-significant p-values for the variables
In fact using AIC for single-variable-at-a-time stepwise selection is (at least asymptotically) equivalent to stepwise selection using a cut-off for p-values of about 15.7%. (This is quite simple to show - the AIC for the larger model will be smaller if it reduces the log-likelihood by more than the penalty for the extra parameter of 2; this corresponds to choosing the larger model if the p-value in a Wald chi-square is smaller than the tail area of a $\chi^2_1$ beyond 2 ... which is 15.7%) So it's hardly surprising if you compare it with using some smaller cutoff for p-values that sometimes it includes variables with higher p-values than that cutoff.
Why applying model selection using AIC gives me non-significant p-values for the variables
In fact using AIC for single-variable-at-a-time stepwise selection is (at least asymptotically) equivalent to stepwise selection using a cut-off for p-values of about 15.7%. (This is quite simple to s
Why applying model selection using AIC gives me non-significant p-values for the variables In fact using AIC for single-variable-at-a-time stepwise selection is (at least asymptotically) equivalent to stepwise selection using a cut-off for p-values of about 15.7%. (This is quite simple to show - the AIC for the larger model will be smaller if it reduces the log-likelihood by more than the penalty for the extra parameter of 2; this corresponds to choosing the larger model if the p-value in a Wald chi-square is smaller than the tail area of a $\chi^2_1$ beyond 2 ... which is 15.7%) So it's hardly surprising if you compare it with using some smaller cutoff for p-values that sometimes it includes variables with higher p-values than that cutoff.
Why applying model selection using AIC gives me non-significant p-values for the variables In fact using AIC for single-variable-at-a-time stepwise selection is (at least asymptotically) equivalent to stepwise selection using a cut-off for p-values of about 15.7%. (This is quite simple to s
18,088
Why applying model selection using AIC gives me non-significant p-values for the variables
Note that neither p-values or AIC were designed for stepwise model selection, in fact the assumptions underlying both (but different assumptions) are violated after the first step in a stepwise regression. As @PeterFlom mentioned, LASSO and/or LAR are better alternatives if you feel the need for automated model selection. Those methods pull the estimates that are large by chance (which stepwise rewards for chance) back towards 0 and so tends to be less biased than stepwise (and the remaining bias tends to be more conservative). A big issue with AIC that is often overlooked is the size of the difference in AIC values, it is all to common to see "lower is better" and stop there (and automated proceedures just emphasise this). If you are comparing 2 models and they have very different AIC values, then there is a clear preference for the model with the lower AIC, but often we will have 2 (or more) models with AIC values that are close to each other, in this case using only the model with the lowest AIC value will miss out on valuable information (and infering things about terms that are in or not in this model but differ in the other similar models will be meaningless or worse). Information from outside the data itself (such as how hard/expensive) it is to collect the set of predictor variables) may make a model with slightly higher AIC more desirable to use without much loss in quality. Another approach is to use a weighted average of the similar models (this will probably result in similar final predictions to the penalized methods like ridge regression or lasso, but the thought process leading to the model might aid in understanding).
Why applying model selection using AIC gives me non-significant p-values for the variables
Note that neither p-values or AIC were designed for stepwise model selection, in fact the assumptions underlying both (but different assumptions) are violated after the first step in a stepwise regres
Why applying model selection using AIC gives me non-significant p-values for the variables Note that neither p-values or AIC were designed for stepwise model selection, in fact the assumptions underlying both (but different assumptions) are violated after the first step in a stepwise regression. As @PeterFlom mentioned, LASSO and/or LAR are better alternatives if you feel the need for automated model selection. Those methods pull the estimates that are large by chance (which stepwise rewards for chance) back towards 0 and so tends to be less biased than stepwise (and the remaining bias tends to be more conservative). A big issue with AIC that is often overlooked is the size of the difference in AIC values, it is all to common to see "lower is better" and stop there (and automated proceedures just emphasise this). If you are comparing 2 models and they have very different AIC values, then there is a clear preference for the model with the lower AIC, but often we will have 2 (or more) models with AIC values that are close to each other, in this case using only the model with the lowest AIC value will miss out on valuable information (and infering things about terms that are in or not in this model but differ in the other similar models will be meaningless or worse). Information from outside the data itself (such as how hard/expensive) it is to collect the set of predictor variables) may make a model with slightly higher AIC more desirable to use without much loss in quality. Another approach is to use a weighted average of the similar models (this will probably result in similar final predictions to the penalized methods like ridge regression or lasso, but the thought process leading to the model might aid in understanding).
Why applying model selection using AIC gives me non-significant p-values for the variables Note that neither p-values or AIC were designed for stepwise model selection, in fact the assumptions underlying both (but different assumptions) are violated after the first step in a stepwise regres
18,089
Why applying model selection using AIC gives me non-significant p-values for the variables
My experience with the AIC is that if variables appear non-significant, but still appear in the model with the smallest AIC, those turn out to be possible confounders. I suggest you check for confounding. Removing such non-significant variables hshould change the magnetude of some remaining estimaated coefficients by more than 25%.
Why applying model selection using AIC gives me non-significant p-values for the variables
My experience with the AIC is that if variables appear non-significant, but still appear in the model with the smallest AIC, those turn out to be possible confounders. I suggest you check for confoun
Why applying model selection using AIC gives me non-significant p-values for the variables My experience with the AIC is that if variables appear non-significant, but still appear in the model with the smallest AIC, those turn out to be possible confounders. I suggest you check for confounding. Removing such non-significant variables hshould change the magnetude of some remaining estimaated coefficients by more than 25%.
Why applying model selection using AIC gives me non-significant p-values for the variables My experience with the AIC is that if variables appear non-significant, but still appear in the model with the smallest AIC, those turn out to be possible confounders. I suggest you check for confoun
18,090
Why applying model selection using AIC gives me non-significant p-values for the variables
I think the best model selection is by using MuMIn package. This will be onestep result and you don't have to look for the lowest AIC values. Example: d<-read.csv("datasource") library(MuMIn) fit<-glm(y~x1+x2+x3+x4,family=poisson,data=d) get.models(dredge(fit,rank="AIC"))[1]
Why applying model selection using AIC gives me non-significant p-values for the variables
I think the best model selection is by using MuMIn package. This will be onestep result and you don't have to look for the lowest AIC values. Example: d<-read.csv("datasource") library(MuMIn) fit<-g
Why applying model selection using AIC gives me non-significant p-values for the variables I think the best model selection is by using MuMIn package. This will be onestep result and you don't have to look for the lowest AIC values. Example: d<-read.csv("datasource") library(MuMIn) fit<-glm(y~x1+x2+x3+x4,family=poisson,data=d) get.models(dredge(fit,rank="AIC"))[1]
Why applying model selection using AIC gives me non-significant p-values for the variables I think the best model selection is by using MuMIn package. This will be onestep result and you don't have to look for the lowest AIC values. Example: d<-read.csv("datasource") library(MuMIn) fit<-g
18,091
Boosted decision trees in python? [closed]
Updated Answer The landscape has changed a lot and the answer is clear nowadays: scikit-learn is the library in python and has several great algorithms for boosted decision trees the "best" boosted decision tree in python is the XGBoost implementation. Update 1 Meanwhile, there is also LightGBM, which seems to be equally good or even better then XGBoost
Boosted decision trees in python? [closed]
Updated Answer The landscape has changed a lot and the answer is clear nowadays: scikit-learn is the library in python and has several great algorithms for boosted decision trees the "best" boosted d
Boosted decision trees in python? [closed] Updated Answer The landscape has changed a lot and the answer is clear nowadays: scikit-learn is the library in python and has several great algorithms for boosted decision trees the "best" boosted decision tree in python is the XGBoost implementation. Update 1 Meanwhile, there is also LightGBM, which seems to be equally good or even better then XGBoost
Boosted decision trees in python? [closed] Updated Answer The landscape has changed a lot and the answer is clear nowadays: scikit-learn is the library in python and has several great algorithms for boosted decision trees the "best" boosted d
18,092
Boosted decision trees in python? [closed]
My first look would be at Orange, which is a fully-featured app for ML, with a backend in Python. See e.g. orngEnsemble. Other promising projects are mlpy and the scikit.learn. I know that PyCV include several boosting procedures, but apparently not for CART. Take also a look at MLboost
Boosted decision trees in python? [closed]
My first look would be at Orange, which is a fully-featured app for ML, with a backend in Python. See e.g. orngEnsemble. Other promising projects are mlpy and the scikit.learn. I know that PyCV includ
Boosted decision trees in python? [closed] My first look would be at Orange, which is a fully-featured app for ML, with a backend in Python. See e.g. orngEnsemble. Other promising projects are mlpy and the scikit.learn. I know that PyCV include several boosting procedures, but apparently not for CART. Take also a look at MLboost
Boosted decision trees in python? [closed] My first look would be at Orange, which is a fully-featured app for ML, with a backend in Python. See e.g. orngEnsemble. Other promising projects are mlpy and the scikit.learn. I know that PyCV includ
18,093
Boosted decision trees in python? [closed]
You can use R decision tree library using Rpy(http://rpy.sourceforge.net/). Also check the article "building decision trees using python"(http://onlamp.com/pub/a/python/2...). there is also http://opencv.willowgarage.com/documentation/index.html http://research.engineering.wustl.edu/~amohan/
Boosted decision trees in python? [closed]
You can use R decision tree library using Rpy(http://rpy.sourceforge.net/). Also check the article "building decision trees using python"(http://onlamp.com/pub/a/python/2...). there is also http://ope
Boosted decision trees in python? [closed] You can use R decision tree library using Rpy(http://rpy.sourceforge.net/). Also check the article "building decision trees using python"(http://onlamp.com/pub/a/python/2...). there is also http://opencv.willowgarage.com/documentation/index.html http://research.engineering.wustl.edu/~amohan/
Boosted decision trees in python? [closed] You can use R decision tree library using Rpy(http://rpy.sourceforge.net/). Also check the article "building decision trees using python"(http://onlamp.com/pub/a/python/2...). there is also http://ope
18,094
Boosted decision trees in python? [closed]
I had good success with the tree-based learners in Milk: Machine Learning Toolkit for Python. It seems to be under active development, but the documentation was a bit sparse when I was using it. The test suite (github.com/luispedro/milk/blob/master/tests/test_adaboost.py) contains a "boosted stump" though, which could get you going pretty quickly: import numpy as np import milk.supervised.tree import milk.supervised.adaboost def test_learner(): from milksets import wine learner = milk.supervised.adaboost.boost_learner(milk.supervised.tree.stump_learner()) features, labels = wine.load() features = features[labels < 2] labels = labels[labels < 2] == 0 labels = labels.astype(int) model = learner.train(features, labels) train_out = np.array(map(model.apply, features)) assert (train_out == labels).mean() > .9
Boosted decision trees in python? [closed]
I had good success with the tree-based learners in Milk: Machine Learning Toolkit for Python. It seems to be under active development, but the documentation was a bit sparse when I was using it. The
Boosted decision trees in python? [closed] I had good success with the tree-based learners in Milk: Machine Learning Toolkit for Python. It seems to be under active development, but the documentation was a bit sparse when I was using it. The test suite (github.com/luispedro/milk/blob/master/tests/test_adaboost.py) contains a "boosted stump" though, which could get you going pretty quickly: import numpy as np import milk.supervised.tree import milk.supervised.adaboost def test_learner(): from milksets import wine learner = milk.supervised.adaboost.boost_learner(milk.supervised.tree.stump_learner()) features, labels = wine.load() features = features[labels < 2] labels = labels[labels < 2] == 0 labels = labels.astype(int) model = learner.train(features, labels) train_out = np.array(map(model.apply, features)) assert (train_out == labels).mean() > .9
Boosted decision trees in python? [closed] I had good success with the tree-based learners in Milk: Machine Learning Toolkit for Python. It seems to be under active development, but the documentation was a bit sparse when I was using it. The
18,095
Boosted decision trees in python? [closed]
The scikit-learn now has good regression (and classification) trees and random forests implementations. However, boosted tree still isn't included. People are working on it, but it takes a while to get an efficient implementation. Disclaimer: I am a scikit-learn developer.
Boosted decision trees in python? [closed]
The scikit-learn now has good regression (and classification) trees and random forests implementations. However, boosted tree still isn't included. People are working on it, but it takes a while to ge
Boosted decision trees in python? [closed] The scikit-learn now has good regression (and classification) trees and random forests implementations. However, boosted tree still isn't included. People are working on it, but it takes a while to get an efficient implementation. Disclaimer: I am a scikit-learn developer.
Boosted decision trees in python? [closed] The scikit-learn now has good regression (and classification) trees and random forests implementations. However, boosted tree still isn't included. People are working on it, but it takes a while to ge
18,096
Boosted decision trees in python? [closed]
JBoost is an awesome library. It is definitely not written in Python, however It is somewhat language agnostic, because it can be executed from the command line and such so it can be "driven" from Python. I've used it in the past and liked it a lot, particularly the visualization stuff.
Boosted decision trees in python? [closed]
JBoost is an awesome library. It is definitely not written in Python, however It is somewhat language agnostic, because it can be executed from the command line and such so it can be "driven" from Pyt
Boosted decision trees in python? [closed] JBoost is an awesome library. It is definitely not written in Python, however It is somewhat language agnostic, because it can be executed from the command line and such so it can be "driven" from Python. I've used it in the past and liked it a lot, particularly the visualization stuff.
Boosted decision trees in python? [closed] JBoost is an awesome library. It is definitely not written in Python, however It is somewhat language agnostic, because it can be executed from the command line and such so it can be "driven" from Pyt
18,097
Boosted decision trees in python? [closed]
I have the same issue right now: I code in Python daily, use R once in a while, and need a good boosted regression tree algorithm. While there are lots of great Python packages for advanced analytics, my searching has not found a good offering for this particular algorithm. So, the route I think I'll be taking in coming weeks is to use the GBM package in R. There is a good paper showing practical issues with using it that can be found here. Importantly, the GBM package was basically used "off the shelf" to win the 2009 KDD Cup. So, I'll probably do all of my pre and post modeling in Python and use RPy to go back and forth with R/GBM.
Boosted decision trees in python? [closed]
I have the same issue right now: I code in Python daily, use R once in a while, and need a good boosted regression tree algorithm. While there are lots of great Python packages for advanced analytics,
Boosted decision trees in python? [closed] I have the same issue right now: I code in Python daily, use R once in a while, and need a good boosted regression tree algorithm. While there are lots of great Python packages for advanced analytics, my searching has not found a good offering for this particular algorithm. So, the route I think I'll be taking in coming weeks is to use the GBM package in R. There is a good paper showing practical issues with using it that can be found here. Importantly, the GBM package was basically used "off the shelf" to win the 2009 KDD Cup. So, I'll probably do all of my pre and post modeling in Python and use RPy to go back and forth with R/GBM.
Boosted decision trees in python? [closed] I have the same issue right now: I code in Python daily, use R once in a while, and need a good boosted regression tree algorithm. While there are lots of great Python packages for advanced analytics,
18,098
Boosted decision trees in python? [closed]
I have experienced the similar situation with you, I find Orange is hard to tune (maybe it is my problem). In the end, I used Peter Norivig's code for his famous book, in there he provided a well written code framework for tree, all you need is to add boosting in it. This way, you can code anything you like.
Boosted decision trees in python? [closed]
I have experienced the similar situation with you, I find Orange is hard to tune (maybe it is my problem). In the end, I used Peter Norivig's code for his famous book, in there he provided a well writ
Boosted decision trees in python? [closed] I have experienced the similar situation with you, I find Orange is hard to tune (maybe it is my problem). In the end, I used Peter Norivig's code for his famous book, in there he provided a well written code framework for tree, all you need is to add boosting in it. This way, you can code anything you like.
Boosted decision trees in python? [closed] I have experienced the similar situation with you, I find Orange is hard to tune (maybe it is my problem). In the end, I used Peter Norivig's code for his famous book, in there he provided a well writ
18,099
Boosted decision trees in python? [closed]
Decision Trees - Ada Boosting from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import AdaBoostClassifier from sklearn.metrics import accuracy_score Decision Trees with No Boosting clf_entropy_no_ada = DecisionTreeClassifier(criterion = "entropy", random_state = 100, max_depth=5, min_samples_leaf=5) clf_entropy_no_ada.fit(X_train, y_train) Decision Trees with Ada Boosting clf_entropy_ada = AdaBoostClassifier(base_estimator= clf_entropy_no_ada,n_estimators=400,learning_rate=1) clf_entropy_ada.fit(X_train, y_train) Fitting Models and calculating Accuracy y_predict_no_ada = clf_entropy_no_ada.predict(X_test) print ("Accuracy is ", accuracy_score(y_test,y_predict_no_ada)*100) y_predict_ada = clf_entropy_ada.predict(X_test) print ("Accuracy is ", accuracy_score(y_test,y_predict_ada)*100)
Boosted decision trees in python? [closed]
Decision Trees - Ada Boosting from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import AdaBoostClassifier from sklearn.metrics import accuracy_score Decision Trees with No Boostin
Boosted decision trees in python? [closed] Decision Trees - Ada Boosting from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import AdaBoostClassifier from sklearn.metrics import accuracy_score Decision Trees with No Boosting clf_entropy_no_ada = DecisionTreeClassifier(criterion = "entropy", random_state = 100, max_depth=5, min_samples_leaf=5) clf_entropy_no_ada.fit(X_train, y_train) Decision Trees with Ada Boosting clf_entropy_ada = AdaBoostClassifier(base_estimator= clf_entropy_no_ada,n_estimators=400,learning_rate=1) clf_entropy_ada.fit(X_train, y_train) Fitting Models and calculating Accuracy y_predict_no_ada = clf_entropy_no_ada.predict(X_test) print ("Accuracy is ", accuracy_score(y_test,y_predict_no_ada)*100) y_predict_ada = clf_entropy_ada.predict(X_test) print ("Accuracy is ", accuracy_score(y_test,y_predict_ada)*100)
Boosted decision trees in python? [closed] Decision Trees - Ada Boosting from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import AdaBoostClassifier from sklearn.metrics import accuracy_score Decision Trees with No Boostin
18,100
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity?
You may be interested in the Blackett Review of High Impact, Low Probability Risks that was undertaken for the UK Government Office for Science. Not a technically heavy document, it gives much attention to risk communication: see particularly the work of David Spiegelhalter, Cambridge University, who was a member of the Blackett panel. "The Norm Chronicles" is a good light read, and the micromort, a one in a million chance of death, useful for exploring low probability risks. Another vital consideration is the relationship between probability and impact: many HILP events can occur at different degrees of severity. Annex 7 of the Blackett Review sets out a typology of risk classes identified by Renn (2008): Damocles. Risk sources that have a very high potential for damage but a very low probability of occurrence. e.g. technological risks such as nuclear energy and large-scale chemical facilities. Cyclops. Events where the probability of occurrence is largely uncertain, but the maximum damage can be estimated. e.g. natural events, such as floods and earthquakes. Pythia. Highly uncertain risks, where the probability of occurrence, the extent of damage and the way in which the damage manifests itself is unknown due to high complexity. e.g. human interventions in ecosystems and the greenhouse effect. Pandora. Characterised by both uncertainty in probability of occurrence and the extent of damage, and high persistency, hence the large area that is demarcated in the diagram for this risk type. e.g. organic pollutants and endocrine disruptors. Cassandra. Paradoxical in that probability of occurrence and extent of damage are known, but there is no imminent societal concern because damage will only occur in the future. There is a high degree of delay between the initial event and the impact of the damage. e.g. anthropogenic climate change. Medusa. Low probability and low damage events, which due to specific characteristics nonetheless cause considerable concern for people. Often a large number of people are affected by these risks, but harmful results cannot be proven scientifically. e.g. mobile phone usage and electromagnetic fields. See Renn and Klinke, 2004 for more on how these were conceptualised - and named! Having suitable language to describe low probability events and communicate the inherent uncertainty (a big theme of Renn's classification) is important, as it's hard to estimate either probability or impact of HILP events empirically! And communication, especially to policy-makers, is a vital part of the skillset of a statistician or scientist. You may find some of the examples mentioned in the quotation above provide useful jumping-off points. All these areas — climate change, air pollution, nuclear safety, natural disasters — have specialised sub-fields dealing with risk assessment. More examples of monitored and quantified threats, like pandemics and terrorism, appear in the risk matrix of the UK National Risk Register, 2020, which again splits out impact and likelihood: Another example would be the impact hazard of near-Earth objects (NEOs). This is especially close to what you want as there's no doubt that, if unmitigated, the probability of a catastrophic event approaches one over time. The Torino Impact Hazard Scale tries to balance probability and likely effect. NASA's site on it doesn't contain much Wikipedia doesn't but gives a reference to Morrison et al. (2004) which may interest you. The scale originates with the work of Richard Binzel, e.g. Binzel (2000). While this scale applies to the risk presented by individual objects, you're more interested in the cumulative probability of a catastrophic impact in the long-term: this requires analysis of the geological record and of the current population of NEOs, corrected for observational bias (some types and sizes of object are more easily detected). Much of this material is set out in the Report of the Task Force on Potentially Hazardous Near Earth Objects by Atkinson et al. (2000). The task force was set up to advise the UK government, and provides the following cheerful table: If we view the probability of a Tunguska-scale event in any given year as $1$ in $250$, so that on average it would occur once in $250$ years, then the probability of the Earth lasting a millennium without such a strike is as low as $\left(\frac {249} {250}\right)^{1000}\approx 1.8\%$, which is well approximated as $\exp(-\frac{1000}{250})$ using the Poisson distribution, as @Ben's answer says. Although different fields face different problems and utilise different methods to estimate a heterogeneous bunch of (often highly uncertain) probabilities and impacts, there's an overarching bureaucratic approach to dealing with HILP events, into which Atkinson argues the NEO threat should be incorporated: Impacts from mid-sized Near Earth Objects are thus examples of an important class of events of low probability and high consequence. There are well established criteria for assessing whether such risks are to be considered tolerable, even though they may be expected to occur only on time-scales of thousands, tens of thousands or even hundreds of thousands of years. These criteria have been developed from experience by organisations like the British Health and Safety Executive to show when action should be taken to reduce the risks. Flood protection, the safety of nuclear power stations, the storage of dangerous chemicals or of nuclear waste are all examples of situations in which rare failures may have major consequences for life or the environment. Once the risk is assessed, plans can be made to reduce it from the intolerable to the lowest reasonably practical levels taking account of the costs involved. If a quarter of the world’s population were at risk from the impact of an object of 1 kilometre diameter, then according to current safety standards in use in the United Kingdom, the risk of such casualty levels, even if occurring on average once every 100,000 years, would significantly exceed a tolerable level. If such risks were the responsibility of an operator of an industrial plant or other activity, then that operator would be required to take steps to reduce the risk to levels that were deemed tolerable. One example of such guidance is the surprisingly readable report on The Tolerability of Risk from Nuclear Power Stations (1992 revision) from the UK Health and Safety Executive (HSE), commonly abbreviated to "TOR". TOR analyses what nuclear risks are acceptable by comparing other source of risk (as, rather infamously,* did the U.S. Rasmussen Report, WASH-1400) but also endeavoured "to consider the proposition that people feel greater aversion to death from radiation than from other causes, and that a major nuclear accident could have long term health effects." TOR's quantitative approach to decision-making about risk evolved into HSE's "R2P2" framework set out in Reducing risks, protecting people (2001). Something you'll often see in discussions of catastrophic risk is the F-N diagram, also known as Farmer's Diagram or Farmer Curve (after Frank Farmer of the UK Atomic Energy Authority and Imperial College London). Here $N$ is the number of fatalities and $F$ is the frequency, usually displayed logarithmically so events with very low probability, but potentially enormous consequences, can fit on the same scale as events which are orders of magnitude more probable but less lethal. The Health and Safety Executive Research Report 073: Transport fatal accidents and FN-curves, 1967-2001 has a good explanation and some example diagrams: What risk is to be deemed "tolerable"? One approach is to draw a "Farmer line", "limit line" or "criterion line" on the F-N diagram. The "Canvey criterion" and "Netherlands criterion" are commonly seen. The Canvey criterion is based on a major 1978-81 HSE study of the risks posed by the industrial installations on Canvey Island in the Thames estuary, where a $1$ in $5000$ chance per annum, i.e. annual probability of $2 \times 10^{-4}$, of a disaster causing $500$ fatalities was deemed politically "tolerable". This is plotted as the "Canvey point" on the F-N axes, and then extended on a risk-neutral basis. For example, the Canvey point is deemed equivalent to a probability of $10^{-4}$ of causing $1000$ fatalities, or $10^{-3}$ chance of $100$ fatalities. TOR notes this latter figure roughly corresponds to the $1$ in $1000$ per year threshold for breaches of "temporary safe refuges", mandated to protect offshore installation workers from fire or explosion following the Piper Alpha oil rig disaster, on the assumption of a hundred workers on a platform and that, conservatively, a breach would be fatal to all. On logarithmic axes this produces a "Canvey line" with slope $-1$, as shown in Fig. D1 of TOR ("ALARP" is "as low as reasonably practicable", the idea being that efforts should still be taken to reduce even tolerable risks, up to the point where the costs of doing so become prohibitive): HSE has been cautious about adopting limit lines in general, but R2P2 suggests a criterion ten times more conservative than the Canvey point: a $2 \times 10^{-4}$ annual probability of a disaster only causing fifty fatalities, instead of five hundred. Many publications show an "R2P2 line" through the R2P2 criterion, parallel to the Canvey line, but R2P2 doesn't specify a risk-neutral extension even if this sounds rational. In fact the Netherlands criterion is far more risk averse, with a slope of $-2$ indicating a particular aversion to high consequence incidents: if one catastrophic event would cause ten times as many fatalities as another, its tolerated probability is a hundred times lower. Farmer's original 1967 "boundary line as a criterion" had a slope of $-1.5$, but the horizontal axis was sieverts of iodine-131 released, not deaths.** HSE RR073 Fig. 4 compares various criteria with transport casualties, breaking out those train accident casualties which may have been prevented by upgrading the train protection system: A paper about landslide risk by Sim, Lee and Wong (2022) graphs many limit lines in use globally. More European criteria are shown in Trbojevic (2005) and Jonkman, van Gelder and Vriling (2003): both papers also survey a wider range of quantitative risk measures and regulatory approaches beyond the F-N curve. Rheinberger and Treich (2016) take an economic perspective on attitudes to catastrophic risk, again looking at many possible regulatory criteria, and examining closely the case for society being "catastrophe averse". If you're interested in microeconomics or behavioural economics (e.g. Kahneman and Tversky's prospect theory) you'll find their paper valuable, especially for its lengthy bibliography. Regulatory approaches based on limit lines on the F-N diagram aim to control the probability of disaster across the range of possible magnitudes of disasters, but don't limit the overall risk. We may identify several points on the F-N diagram representing credible accident scenarios at a nuclear power plant, whose individual probabilities are sufficiently low (for the harm each would cause) to be on the "tolerable" side of the limit line, yet feel this cluster of points collectively represents an intolerable risk. For that reason, and others, some prefer to use the complementary cumulative distribution function (CCDF) of the harm. This is calculated as one minus the CDF, and represents the probability the harm exceeds a given value. When examining catastrophic risks, the wide range of magnitudes and probabilities makes it conventional to plot on log-log axes, so superficially this resembles an F-N diagram. As the size of the consequences tends to infinity, the CDF tends to one, the CCDF to zero, and log CCDF to negative infinity. In the example below, I highlight the level of harm that's exceeded with probability $0.25$. This might measure fatalities, dose of radiation released, property damage, or some other consequence. Canadian nuclear regulators took the approach of setting safety limits at various points on the CCDF curve: Cox and Baybutt (1981) compare this to Farmer's limit-line criteria. See also chapters 7 and 10 of NUREG/CR-2040, a study of the implications of applying quantitative risk criteria in the licensing of nuclear power plants in the United States for the U.S. Nuclear Regulatory Commission (1981). Note that the probability of an industrial disaster tends towards one not just over time but also as the number of facilities increases. Jonkman et al. raise the point that each facility may meet risk tolerability criteria yet the national risk becomes intolerable. They propose setting a national limit, then subdividing it between facilities. NUREG/CR-2040 looks at this in Chapters 6 and 9. The authors distinguish risk criteria "per reactor-year" or "per site-year" for a specific plant, versus risk "per year" for the country as a whole. If national risk is to be limited to an agreed level, then site-specific risk criteria imposed to achieve this, the appropriate way to distribute risk across plants is not obvious due to the heterogeneity of sites. The authors suggest tolerating higher frequency of core melt accidents at older reactors (newer designs are expected to be safer, so arguably should face stricter criteria), or those in remote areas or with better mitigation systems (as a core melt at such sites should be harmful). The problem of the probability of catastrophe approaching $1$ in the long run can be solved by imposing risk criteria over long (even civilisational) time-scales then solving for the required annual criteria. One proposal examined in NUREG/CR-2040 (page 71) tries to restrict core melt frequencies on the basis of a 95% probability of no such accidents in the entire lifespan of the U.S. nuclear industry. Assuming we'll rely on fission technology for about three centuries with $300$ reactors active in an average year, then $100,000$ reactor-years seemed a reasonable guess. Write $\lambda_{\text{melt}}$ for the rate of core melts per reactor-year that needs to be achieved to limit the long-term risk to our tolerated level. Using the Poisson distribution, we solve $$ \exp\left(-\lambda_\text{melt} \times 10^5\right) = 0.95 \\ \implies \lambda_\text{melt} = - \frac{\ln 0.95}{10^5} \approx 5 \times 10^{-7} \text{ per reactor-year,}$$ so we require reactors that experience core melts at a rate no more frequent than once per two million years or so. Due to the Poisson approximation for rare events, we get a very similar answer if we solve the annual probability $p_\text{melt}$ at a given reactor, using the binomial distribution: $$\Pr(\text{0 core melts}) = (1 - p_\text{melt})^{100,000} = 0.95 \\ \implies p_\text{melt} = 1 - \sqrt[100,000]{0.95} \approx 5 \times 10^{-7}.$$ How can regulators establish the probability of a given magnitude of disaster at a particular installation is tolerably tiny? Conversely, how can scientists estimate the potential casualties from a "once in 200 years" earthquake or flood? Events so rare lie beyond empirical observation. For natural disasters we might extrapolate the F-N curve for observed events (see Sim et al., 2022) or model the physics of catastrophic scenarios coupled to a statistical model of how likely each scenario is (e.g. NASA's PAIR model for asteroid risk, Mathias et al, 2017). In engineering systems, particularly if hyper-reliability is needed, probabilistic risk assessment (PRA) can be used. For more on PRA in the nuclear industry, including fault tree analysis, the U.S. NRC website includes current practice and a historic overview, as does the Canadian Nuclear Safety Commission. An international comparison is Use and Development of Probabilistic Safety Assessments at Nuclear Facilities (2019) by the OECD's Nuclear Energy Agency. Footnotes $(*)$ The Rasmussen Report's executive summary dramatically compared nuclear risks to other man-made and natural risks, including Fig. 1 below, to emphasise that the additional risk to the U.S. population from a nuclear energy programme was negligible in comparison. It was criticised for failing to show the uncertainty of those risks, and ignoring harms other than fatalities (e.g. land contamination), particularly as later estimates of the probability of nuclear disaster were less optimistic. See Frank von Hippel's 1977 response in the Bulletin of the Atomic Scientists and, for a very readable historical overview, NUREG/KM-0010 (2016). $(**)$ Farmer's 1967 paper is available at pages 303-318 of the Proceedings on a symposium on the containment and siting of nuclear power plants held by the International Atomic Energy Agency in Vienna, 3-7 April, 1967. His colleague J. R. Beattie's paper on "Risks to the population and the individual from iodine releases" follows immediately as an appendix; Beattie converts Farmer's limit-line radiation releases into casualty figures, so the two papers together mark the genesis of the F-N boundary line approach. This is then followed by a lively symposium discussion. Regarding the slope of $-1.5$, Farmer explains "My final curve does not directly show an inverse relationship between hazard and consequence. I chose a steeper line which is entirely subjective." Farmer is wary of simplistically multiplying probabilities together, and due to lack of empirical data is especially cautious of claims the probability of catastrophe is low due to the improbability of passive safety measures being breached: "if credit of $1000$ or more is being claimed for a passive structure, can you really feel that the possibility of it being as effective as claimed is $999$ out of $1000$. I do not know how we test or ensure that certain conditions will obtain $999$ times out of $1000$, and if we cannot test it, I think we should not claim such high reliability". He prefers to focus on things like components (for which reliability data is available) and minimising the probability of an incident occurring in the first place. Some participants welcome Farmer's probabilistic approach, others prefer the "maximum credible accident" (nowadays evolved into the design-basis event): Farmer dislikes this approach due to the broad range of accidents one might subjectively deem "credible", and the most catastrophic, but plausible, nuclear accident would clearly violate any reasonable safety criteria even if the reactor was sited in a rural area. There's an interesting note of scepticism concerning low probability events from the French representative, F. de Vathaire: Applying the probability method consists of reasoning like actuaries in calculating insurance premiums, but it is questionable whether we have the right to apply insurance methods to nuclear hazard assessment. We must first of all possess sufficient knowledge of the probability of safety devices failing. ... I might add that the number of incidents which I have heard mentioned in France and other countries — incidents without serious radiological consequences, but which might have had them — is fairly impressive and suggests that the probability of failure under actual plant-operation conditions is fairly high, particularly due to human errors. On the other hand, it is large releases of fission products which constitute the only real safety problem and the corresponding probabilities are very low. What practical signification must be attached to events which occur only once every thousand or million years? Can they really be considered a possibility? NUREG/KM-0010 recounts an extreme example from the early days of probabilistic risk assessment in the nuclear industry: ...the AEC [Atomic Energy Commission] contracted with Research Planning Corporation in California to create realistic probability estimates for a severe reactor accident. The results were disappointing. While Research Planning’s calculations were good, they were underestimates. Research Planning estimated the probability of a catastrophic accident to be between $10^{-8}$ to $10^{-16}$ occurrences per year. If the $10^{-16}$ estimate were true, that would mean a reactor might operate $700,000$ times longer than the currently assumed age of the universe before experiencing a major accident. The numbers were impossibly optimistic, and the error band was distressingly large. As Dr. Wellock recalled, "the AEC wisely looked at this and recognized that probabilities were not going to solve [the problems with] this report." At this time, the AEC understood that the large error in the obtained probabilities could be attributed to the uncertainty in estimating common-cause accidents. Clearly we need caution if a tiny probability has been obtained from multiplying many failure probabilities together. Common-cause failures violate statistical independence and undermine reliability gains of redundancy. Jones (2012) gives an introduction to this topic in the context of the space industry, where NASA readopted PRA after the 1986 Challenger disaster. References Atkinson, H. H., Tickell, C. and Williams, D. A. (2000). Report of the Task Force on Potentially Hazardous Near Earth Objects. British National Space Centre. Beattie, J. R. (1967). Risks to the population and the individual from iodine releases. In Proceedings of a Symposium on the Containment and Siting of Nuclear Power Plants, Vienna, April 3–7, 318-324. IAEA. Binzel, R. P. (2000). The Torino impact hazard scale. Planetary and Space Science, 48(4), 297-303. Cox, D. C., and Baybutt, P. (1982). Limit lines for risk. Nuclear Technology, 57(3), 320-330. Farmer, F. R. (1967). Siting criteria: A new approach. In Proceedings of a Symposium on the Containment and Siting of Nuclear Power Plants, Vienna, April 3–7, 303-329. IAEA. Health and Safety Executive. (1992). The tolerability of risk from nuclear power stations (Revised Edition). HSE Books. ISBN 978-0118863681. Health and Safety Executive. (2001). [Reducing risks, protecting people: HSE's decision-making process] (https://www.hse.gov.uk/managing/theory/r2p2.pdf). HSE Books. ISBN 978-0717621514. Health and Safety Executive (2003). Research Report 073, Transport fatal accidents and FN-curves: 1967-2001. HSE Books. Jones, H. (2012, July). Common cause failures and ultra reliability. In 42nd International Conference on Environmental Systems (p. 3602). Jonkman, S. N., Van Gelder, P. H. A. J. M., & Vrijling, J. K. (2003). An overview of quantitative risk measures for loss of life and economic damage. Journal of hazardous materials, 99(1), 1-30. Mathias, D. L., Wheeler, L. F., and Dotson, J. L. (2017). A probabilistic asteroid impact risk model: assessment of sub-300 m impacts. Icarus, 289, 106-119. Morrison, D., Chapman, C. R., Steel, D., and Binzel R. P. (2004). Impacts and the Public: Communicating the Nature of the Impact Hazard. In Mitigation of Hazardous Comets and Asteroids, (M.J.S. Belton, T.H. Morgan, N.H. Samarasinha and D.K. Yeomans, Eds), Cambridge University Press. Renn, O. (2008). Risk Governance: Coping with Uncertainty in a Complex World. London: Earthscan. ISBN 978-1844072927. Renn, O., & Klinke, A. (2004). Systemic risks: a new challenge for risk management. EMBO reports, 5(S1), S41-S46. Rheinberger, C. M., and Treich, N. (2017). Attitudes toward catastrophe. Environmental and Resource Economics, 67, 609-636. Sim, K. B., Lee, M. L., & Wong, S. Y. (2022). A review of landslide acceptable risk and tolerable risk. Geoenvironmental Disasters, 9(1), 3. Spiegelhalter, D., & Blastland, M. (2013). The Norm chronicles: Stories and numbers about danger. Profile Books. ISBN 978-1846686207. [Various editions internationally with slightly different titles, e.g. "danger" replaced by "risk" or "danger and death".] Spiegelhalter, D. J. (2014). The power of the MicroMort. BJOG: An International Journal of Obstetrics & Gynaecology, 121(6), 662-663. Trbojevic, V. M. (2005). Risk criteria in EU. In: Advances in safety and reliability—proceedings of European safety and reliability conference ESREL 2005, vol 2, pp 1945–1952. U.S. Nuclear Regulatory Commission. (1981). A study of the implications of applying quantitative risk criteria in the licensing of nuclear power plants in the United States. USNRC NUREG/CR-2040. U.S. Nuclear Regulatory Commission. (2016). WASH-1400 — The Reactor Safety Study — The Introduction of Risk Assessment to the Regulation of Nuclear Reactors. USNRC NUREG/KM-0010. [See also errata available at https://www.nrc.gov/docs/ML1626/ML16264A431.pdf] Von Hippel, F. N. (1977). Looking back on the Rasmussen Report. Bulletin of the Atomic Scientists, 33(2), 42-47.
What theories, papers, or books examine low-probability events, particularly as the number of trials
You may be interested in the Blackett Review of High Impact, Low Probability Risks that was undertaken for the UK Government Office for Science. Not a technically heavy document, it gives much attenti
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity? You may be interested in the Blackett Review of High Impact, Low Probability Risks that was undertaken for the UK Government Office for Science. Not a technically heavy document, it gives much attention to risk communication: see particularly the work of David Spiegelhalter, Cambridge University, who was a member of the Blackett panel. "The Norm Chronicles" is a good light read, and the micromort, a one in a million chance of death, useful for exploring low probability risks. Another vital consideration is the relationship between probability and impact: many HILP events can occur at different degrees of severity. Annex 7 of the Blackett Review sets out a typology of risk classes identified by Renn (2008): Damocles. Risk sources that have a very high potential for damage but a very low probability of occurrence. e.g. technological risks such as nuclear energy and large-scale chemical facilities. Cyclops. Events where the probability of occurrence is largely uncertain, but the maximum damage can be estimated. e.g. natural events, such as floods and earthquakes. Pythia. Highly uncertain risks, where the probability of occurrence, the extent of damage and the way in which the damage manifests itself is unknown due to high complexity. e.g. human interventions in ecosystems and the greenhouse effect. Pandora. Characterised by both uncertainty in probability of occurrence and the extent of damage, and high persistency, hence the large area that is demarcated in the diagram for this risk type. e.g. organic pollutants and endocrine disruptors. Cassandra. Paradoxical in that probability of occurrence and extent of damage are known, but there is no imminent societal concern because damage will only occur in the future. There is a high degree of delay between the initial event and the impact of the damage. e.g. anthropogenic climate change. Medusa. Low probability and low damage events, which due to specific characteristics nonetheless cause considerable concern for people. Often a large number of people are affected by these risks, but harmful results cannot be proven scientifically. e.g. mobile phone usage and electromagnetic fields. See Renn and Klinke, 2004 for more on how these were conceptualised - and named! Having suitable language to describe low probability events and communicate the inherent uncertainty (a big theme of Renn's classification) is important, as it's hard to estimate either probability or impact of HILP events empirically! And communication, especially to policy-makers, is a vital part of the skillset of a statistician or scientist. You may find some of the examples mentioned in the quotation above provide useful jumping-off points. All these areas — climate change, air pollution, nuclear safety, natural disasters — have specialised sub-fields dealing with risk assessment. More examples of monitored and quantified threats, like pandemics and terrorism, appear in the risk matrix of the UK National Risk Register, 2020, which again splits out impact and likelihood: Another example would be the impact hazard of near-Earth objects (NEOs). This is especially close to what you want as there's no doubt that, if unmitigated, the probability of a catastrophic event approaches one over time. The Torino Impact Hazard Scale tries to balance probability and likely effect. NASA's site on it doesn't contain much Wikipedia doesn't but gives a reference to Morrison et al. (2004) which may interest you. The scale originates with the work of Richard Binzel, e.g. Binzel (2000). While this scale applies to the risk presented by individual objects, you're more interested in the cumulative probability of a catastrophic impact in the long-term: this requires analysis of the geological record and of the current population of NEOs, corrected for observational bias (some types and sizes of object are more easily detected). Much of this material is set out in the Report of the Task Force on Potentially Hazardous Near Earth Objects by Atkinson et al. (2000). The task force was set up to advise the UK government, and provides the following cheerful table: If we view the probability of a Tunguska-scale event in any given year as $1$ in $250$, so that on average it would occur once in $250$ years, then the probability of the Earth lasting a millennium without such a strike is as low as $\left(\frac {249} {250}\right)^{1000}\approx 1.8\%$, which is well approximated as $\exp(-\frac{1000}{250})$ using the Poisson distribution, as @Ben's answer says. Although different fields face different problems and utilise different methods to estimate a heterogeneous bunch of (often highly uncertain) probabilities and impacts, there's an overarching bureaucratic approach to dealing with HILP events, into which Atkinson argues the NEO threat should be incorporated: Impacts from mid-sized Near Earth Objects are thus examples of an important class of events of low probability and high consequence. There are well established criteria for assessing whether such risks are to be considered tolerable, even though they may be expected to occur only on time-scales of thousands, tens of thousands or even hundreds of thousands of years. These criteria have been developed from experience by organisations like the British Health and Safety Executive to show when action should be taken to reduce the risks. Flood protection, the safety of nuclear power stations, the storage of dangerous chemicals or of nuclear waste are all examples of situations in which rare failures may have major consequences for life or the environment. Once the risk is assessed, plans can be made to reduce it from the intolerable to the lowest reasonably practical levels taking account of the costs involved. If a quarter of the world’s population were at risk from the impact of an object of 1 kilometre diameter, then according to current safety standards in use in the United Kingdom, the risk of such casualty levels, even if occurring on average once every 100,000 years, would significantly exceed a tolerable level. If such risks were the responsibility of an operator of an industrial plant or other activity, then that operator would be required to take steps to reduce the risk to levels that were deemed tolerable. One example of such guidance is the surprisingly readable report on The Tolerability of Risk from Nuclear Power Stations (1992 revision) from the UK Health and Safety Executive (HSE), commonly abbreviated to "TOR". TOR analyses what nuclear risks are acceptable by comparing other source of risk (as, rather infamously,* did the U.S. Rasmussen Report, WASH-1400) but also endeavoured "to consider the proposition that people feel greater aversion to death from radiation than from other causes, and that a major nuclear accident could have long term health effects." TOR's quantitative approach to decision-making about risk evolved into HSE's "R2P2" framework set out in Reducing risks, protecting people (2001). Something you'll often see in discussions of catastrophic risk is the F-N diagram, also known as Farmer's Diagram or Farmer Curve (after Frank Farmer of the UK Atomic Energy Authority and Imperial College London). Here $N$ is the number of fatalities and $F$ is the frequency, usually displayed logarithmically so events with very low probability, but potentially enormous consequences, can fit on the same scale as events which are orders of magnitude more probable but less lethal. The Health and Safety Executive Research Report 073: Transport fatal accidents and FN-curves, 1967-2001 has a good explanation and some example diagrams: What risk is to be deemed "tolerable"? One approach is to draw a "Farmer line", "limit line" or "criterion line" on the F-N diagram. The "Canvey criterion" and "Netherlands criterion" are commonly seen. The Canvey criterion is based on a major 1978-81 HSE study of the risks posed by the industrial installations on Canvey Island in the Thames estuary, where a $1$ in $5000$ chance per annum, i.e. annual probability of $2 \times 10^{-4}$, of a disaster causing $500$ fatalities was deemed politically "tolerable". This is plotted as the "Canvey point" on the F-N axes, and then extended on a risk-neutral basis. For example, the Canvey point is deemed equivalent to a probability of $10^{-4}$ of causing $1000$ fatalities, or $10^{-3}$ chance of $100$ fatalities. TOR notes this latter figure roughly corresponds to the $1$ in $1000$ per year threshold for breaches of "temporary safe refuges", mandated to protect offshore installation workers from fire or explosion following the Piper Alpha oil rig disaster, on the assumption of a hundred workers on a platform and that, conservatively, a breach would be fatal to all. On logarithmic axes this produces a "Canvey line" with slope $-1$, as shown in Fig. D1 of TOR ("ALARP" is "as low as reasonably practicable", the idea being that efforts should still be taken to reduce even tolerable risks, up to the point where the costs of doing so become prohibitive): HSE has been cautious about adopting limit lines in general, but R2P2 suggests a criterion ten times more conservative than the Canvey point: a $2 \times 10^{-4}$ annual probability of a disaster only causing fifty fatalities, instead of five hundred. Many publications show an "R2P2 line" through the R2P2 criterion, parallel to the Canvey line, but R2P2 doesn't specify a risk-neutral extension even if this sounds rational. In fact the Netherlands criterion is far more risk averse, with a slope of $-2$ indicating a particular aversion to high consequence incidents: if one catastrophic event would cause ten times as many fatalities as another, its tolerated probability is a hundred times lower. Farmer's original 1967 "boundary line as a criterion" had a slope of $-1.5$, but the horizontal axis was sieverts of iodine-131 released, not deaths.** HSE RR073 Fig. 4 compares various criteria with transport casualties, breaking out those train accident casualties which may have been prevented by upgrading the train protection system: A paper about landslide risk by Sim, Lee and Wong (2022) graphs many limit lines in use globally. More European criteria are shown in Trbojevic (2005) and Jonkman, van Gelder and Vriling (2003): both papers also survey a wider range of quantitative risk measures and regulatory approaches beyond the F-N curve. Rheinberger and Treich (2016) take an economic perspective on attitudes to catastrophic risk, again looking at many possible regulatory criteria, and examining closely the case for society being "catastrophe averse". If you're interested in microeconomics or behavioural economics (e.g. Kahneman and Tversky's prospect theory) you'll find their paper valuable, especially for its lengthy bibliography. Regulatory approaches based on limit lines on the F-N diagram aim to control the probability of disaster across the range of possible magnitudes of disasters, but don't limit the overall risk. We may identify several points on the F-N diagram representing credible accident scenarios at a nuclear power plant, whose individual probabilities are sufficiently low (for the harm each would cause) to be on the "tolerable" side of the limit line, yet feel this cluster of points collectively represents an intolerable risk. For that reason, and others, some prefer to use the complementary cumulative distribution function (CCDF) of the harm. This is calculated as one minus the CDF, and represents the probability the harm exceeds a given value. When examining catastrophic risks, the wide range of magnitudes and probabilities makes it conventional to plot on log-log axes, so superficially this resembles an F-N diagram. As the size of the consequences tends to infinity, the CDF tends to one, the CCDF to zero, and log CCDF to negative infinity. In the example below, I highlight the level of harm that's exceeded with probability $0.25$. This might measure fatalities, dose of radiation released, property damage, or some other consequence. Canadian nuclear regulators took the approach of setting safety limits at various points on the CCDF curve: Cox and Baybutt (1981) compare this to Farmer's limit-line criteria. See also chapters 7 and 10 of NUREG/CR-2040, a study of the implications of applying quantitative risk criteria in the licensing of nuclear power plants in the United States for the U.S. Nuclear Regulatory Commission (1981). Note that the probability of an industrial disaster tends towards one not just over time but also as the number of facilities increases. Jonkman et al. raise the point that each facility may meet risk tolerability criteria yet the national risk becomes intolerable. They propose setting a national limit, then subdividing it between facilities. NUREG/CR-2040 looks at this in Chapters 6 and 9. The authors distinguish risk criteria "per reactor-year" or "per site-year" for a specific plant, versus risk "per year" for the country as a whole. If national risk is to be limited to an agreed level, then site-specific risk criteria imposed to achieve this, the appropriate way to distribute risk across plants is not obvious due to the heterogeneity of sites. The authors suggest tolerating higher frequency of core melt accidents at older reactors (newer designs are expected to be safer, so arguably should face stricter criteria), or those in remote areas or with better mitigation systems (as a core melt at such sites should be harmful). The problem of the probability of catastrophe approaching $1$ in the long run can be solved by imposing risk criteria over long (even civilisational) time-scales then solving for the required annual criteria. One proposal examined in NUREG/CR-2040 (page 71) tries to restrict core melt frequencies on the basis of a 95% probability of no such accidents in the entire lifespan of the U.S. nuclear industry. Assuming we'll rely on fission technology for about three centuries with $300$ reactors active in an average year, then $100,000$ reactor-years seemed a reasonable guess. Write $\lambda_{\text{melt}}$ for the rate of core melts per reactor-year that needs to be achieved to limit the long-term risk to our tolerated level. Using the Poisson distribution, we solve $$ \exp\left(-\lambda_\text{melt} \times 10^5\right) = 0.95 \\ \implies \lambda_\text{melt} = - \frac{\ln 0.95}{10^5} \approx 5 \times 10^{-7} \text{ per reactor-year,}$$ so we require reactors that experience core melts at a rate no more frequent than once per two million years or so. Due to the Poisson approximation for rare events, we get a very similar answer if we solve the annual probability $p_\text{melt}$ at a given reactor, using the binomial distribution: $$\Pr(\text{0 core melts}) = (1 - p_\text{melt})^{100,000} = 0.95 \\ \implies p_\text{melt} = 1 - \sqrt[100,000]{0.95} \approx 5 \times 10^{-7}.$$ How can regulators establish the probability of a given magnitude of disaster at a particular installation is tolerably tiny? Conversely, how can scientists estimate the potential casualties from a "once in 200 years" earthquake or flood? Events so rare lie beyond empirical observation. For natural disasters we might extrapolate the F-N curve for observed events (see Sim et al., 2022) or model the physics of catastrophic scenarios coupled to a statistical model of how likely each scenario is (e.g. NASA's PAIR model for asteroid risk, Mathias et al, 2017). In engineering systems, particularly if hyper-reliability is needed, probabilistic risk assessment (PRA) can be used. For more on PRA in the nuclear industry, including fault tree analysis, the U.S. NRC website includes current practice and a historic overview, as does the Canadian Nuclear Safety Commission. An international comparison is Use and Development of Probabilistic Safety Assessments at Nuclear Facilities (2019) by the OECD's Nuclear Energy Agency. Footnotes $(*)$ The Rasmussen Report's executive summary dramatically compared nuclear risks to other man-made and natural risks, including Fig. 1 below, to emphasise that the additional risk to the U.S. population from a nuclear energy programme was negligible in comparison. It was criticised for failing to show the uncertainty of those risks, and ignoring harms other than fatalities (e.g. land contamination), particularly as later estimates of the probability of nuclear disaster were less optimistic. See Frank von Hippel's 1977 response in the Bulletin of the Atomic Scientists and, for a very readable historical overview, NUREG/KM-0010 (2016). $(**)$ Farmer's 1967 paper is available at pages 303-318 of the Proceedings on a symposium on the containment and siting of nuclear power plants held by the International Atomic Energy Agency in Vienna, 3-7 April, 1967. His colleague J. R. Beattie's paper on "Risks to the population and the individual from iodine releases" follows immediately as an appendix; Beattie converts Farmer's limit-line radiation releases into casualty figures, so the two papers together mark the genesis of the F-N boundary line approach. This is then followed by a lively symposium discussion. Regarding the slope of $-1.5$, Farmer explains "My final curve does not directly show an inverse relationship between hazard and consequence. I chose a steeper line which is entirely subjective." Farmer is wary of simplistically multiplying probabilities together, and due to lack of empirical data is especially cautious of claims the probability of catastrophe is low due to the improbability of passive safety measures being breached: "if credit of $1000$ or more is being claimed for a passive structure, can you really feel that the possibility of it being as effective as claimed is $999$ out of $1000$. I do not know how we test or ensure that certain conditions will obtain $999$ times out of $1000$, and if we cannot test it, I think we should not claim such high reliability". He prefers to focus on things like components (for which reliability data is available) and minimising the probability of an incident occurring in the first place. Some participants welcome Farmer's probabilistic approach, others prefer the "maximum credible accident" (nowadays evolved into the design-basis event): Farmer dislikes this approach due to the broad range of accidents one might subjectively deem "credible", and the most catastrophic, but plausible, nuclear accident would clearly violate any reasonable safety criteria even if the reactor was sited in a rural area. There's an interesting note of scepticism concerning low probability events from the French representative, F. de Vathaire: Applying the probability method consists of reasoning like actuaries in calculating insurance premiums, but it is questionable whether we have the right to apply insurance methods to nuclear hazard assessment. We must first of all possess sufficient knowledge of the probability of safety devices failing. ... I might add that the number of incidents which I have heard mentioned in France and other countries — incidents without serious radiological consequences, but which might have had them — is fairly impressive and suggests that the probability of failure under actual plant-operation conditions is fairly high, particularly due to human errors. On the other hand, it is large releases of fission products which constitute the only real safety problem and the corresponding probabilities are very low. What practical signification must be attached to events which occur only once every thousand or million years? Can they really be considered a possibility? NUREG/KM-0010 recounts an extreme example from the early days of probabilistic risk assessment in the nuclear industry: ...the AEC [Atomic Energy Commission] contracted with Research Planning Corporation in California to create realistic probability estimates for a severe reactor accident. The results were disappointing. While Research Planning’s calculations were good, they were underestimates. Research Planning estimated the probability of a catastrophic accident to be between $10^{-8}$ to $10^{-16}$ occurrences per year. If the $10^{-16}$ estimate were true, that would mean a reactor might operate $700,000$ times longer than the currently assumed age of the universe before experiencing a major accident. The numbers were impossibly optimistic, and the error band was distressingly large. As Dr. Wellock recalled, "the AEC wisely looked at this and recognized that probabilities were not going to solve [the problems with] this report." At this time, the AEC understood that the large error in the obtained probabilities could be attributed to the uncertainty in estimating common-cause accidents. Clearly we need caution if a tiny probability has been obtained from multiplying many failure probabilities together. Common-cause failures violate statistical independence and undermine reliability gains of redundancy. Jones (2012) gives an introduction to this topic in the context of the space industry, where NASA readopted PRA after the 1986 Challenger disaster. References Atkinson, H. H., Tickell, C. and Williams, D. A. (2000). Report of the Task Force on Potentially Hazardous Near Earth Objects. British National Space Centre. Beattie, J. R. (1967). Risks to the population and the individual from iodine releases. In Proceedings of a Symposium on the Containment and Siting of Nuclear Power Plants, Vienna, April 3–7, 318-324. IAEA. Binzel, R. P. (2000). The Torino impact hazard scale. Planetary and Space Science, 48(4), 297-303. Cox, D. C., and Baybutt, P. (1982). Limit lines for risk. Nuclear Technology, 57(3), 320-330. Farmer, F. R. (1967). Siting criteria: A new approach. In Proceedings of a Symposium on the Containment and Siting of Nuclear Power Plants, Vienna, April 3–7, 303-329. IAEA. Health and Safety Executive. (1992). The tolerability of risk from nuclear power stations (Revised Edition). HSE Books. ISBN 978-0118863681. Health and Safety Executive. (2001). [Reducing risks, protecting people: HSE's decision-making process] (https://www.hse.gov.uk/managing/theory/r2p2.pdf). HSE Books. ISBN 978-0717621514. Health and Safety Executive (2003). Research Report 073, Transport fatal accidents and FN-curves: 1967-2001. HSE Books. Jones, H. (2012, July). Common cause failures and ultra reliability. In 42nd International Conference on Environmental Systems (p. 3602). Jonkman, S. N., Van Gelder, P. H. A. J. M., & Vrijling, J. K. (2003). An overview of quantitative risk measures for loss of life and economic damage. Journal of hazardous materials, 99(1), 1-30. Mathias, D. L., Wheeler, L. F., and Dotson, J. L. (2017). A probabilistic asteroid impact risk model: assessment of sub-300 m impacts. Icarus, 289, 106-119. Morrison, D., Chapman, C. R., Steel, D., and Binzel R. P. (2004). Impacts and the Public: Communicating the Nature of the Impact Hazard. In Mitigation of Hazardous Comets and Asteroids, (M.J.S. Belton, T.H. Morgan, N.H. Samarasinha and D.K. Yeomans, Eds), Cambridge University Press. Renn, O. (2008). Risk Governance: Coping with Uncertainty in a Complex World. London: Earthscan. ISBN 978-1844072927. Renn, O., & Klinke, A. (2004). Systemic risks: a new challenge for risk management. EMBO reports, 5(S1), S41-S46. Rheinberger, C. M., and Treich, N. (2017). Attitudes toward catastrophe. Environmental and Resource Economics, 67, 609-636. Sim, K. B., Lee, M. L., & Wong, S. Y. (2022). A review of landslide acceptable risk and tolerable risk. Geoenvironmental Disasters, 9(1), 3. Spiegelhalter, D., & Blastland, M. (2013). The Norm chronicles: Stories and numbers about danger. Profile Books. ISBN 978-1846686207. [Various editions internationally with slightly different titles, e.g. "danger" replaced by "risk" or "danger and death".] Spiegelhalter, D. J. (2014). The power of the MicroMort. BJOG: An International Journal of Obstetrics & Gynaecology, 121(6), 662-663. Trbojevic, V. M. (2005). Risk criteria in EU. In: Advances in safety and reliability—proceedings of European safety and reliability conference ESREL 2005, vol 2, pp 1945–1952. U.S. Nuclear Regulatory Commission. (1981). A study of the implications of applying quantitative risk criteria in the licensing of nuclear power plants in the United States. USNRC NUREG/CR-2040. U.S. Nuclear Regulatory Commission. (2016). WASH-1400 — The Reactor Safety Study — The Introduction of Risk Assessment to the Regulation of Nuclear Reactors. USNRC NUREG/KM-0010. [See also errata available at https://www.nrc.gov/docs/ML1626/ML16264A431.pdf] Von Hippel, F. N. (1977). Looking back on the Rasmussen Report. Bulletin of the Atomic Scientists, 33(2), 42-47.
What theories, papers, or books examine low-probability events, particularly as the number of trials You may be interested in the Blackett Review of High Impact, Low Probability Risks that was undertaken for the UK Government Office for Science. Not a technically heavy document, it gives much attenti