idx
int64
1
56k
question
stringlengths
15
155
answer
stringlengths
2
29.2k
question_cut
stringlengths
15
100
answer_cut
stringlengths
2
200
conversation
stringlengths
47
29.3k
conversation_cut
stringlengths
47
301
11,001
How do I check if my data fits an exponential distribution?
You can use a qq-plot, which is a graphical method for comparing two probability distributions by plotting their quantiles against each other. In R, there is no out-of-the-box qq-plot function for the exponential distribution specifically (at least among the base functions). However, you can use this: qqexp <- function(y, line=FALSE, ...) { y <- y[!is.na(y)] n <- length(y) x <- qexp(c(1:n)/(n+1)) m <- mean(y) if (any(range(y)<0)) stop("Data contains negative values") ylim <- c(0,max(y)) qqplot(x, y, xlab="Exponential plotting position",ylim=ylim,ylab="Ordered sample", ...) if (line) abline(0,m,lty=2) invisible() } While interpreting your results: If the two distributions being compared are similar, the points in the q-q plot will approximately lie on the line y = x. If the distributions are linearly related, the points in the q-q plot will approximately lie on a line, but not necessarily on the line y = x.
How do I check if my data fits an exponential distribution?
You can use a qq-plot, which is a graphical method for comparing two probability distributions by plotting their quantiles against each other. In R, there is no out-of-the-box qq-plot function for th
How do I check if my data fits an exponential distribution? You can use a qq-plot, which is a graphical method for comparing two probability distributions by plotting their quantiles against each other. In R, there is no out-of-the-box qq-plot function for the exponential distribution specifically (at least among the base functions). However, you can use this: qqexp <- function(y, line=FALSE, ...) { y <- y[!is.na(y)] n <- length(y) x <- qexp(c(1:n)/(n+1)) m <- mean(y) if (any(range(y)<0)) stop("Data contains negative values") ylim <- c(0,max(y)) qqplot(x, y, xlab="Exponential plotting position",ylim=ylim,ylab="Ordered sample", ...) if (line) abline(0,m,lty=2) invisible() } While interpreting your results: If the two distributions being compared are similar, the points in the q-q plot will approximately lie on the line y = x. If the distributions are linearly related, the points in the q-q plot will approximately lie on a line, but not necessarily on the line y = x.
How do I check if my data fits an exponential distribution? You can use a qq-plot, which is a graphical method for comparing two probability distributions by plotting their quantiles against each other. In R, there is no out-of-the-box qq-plot function for th
11,002
Explanation for unequal probabilities of numbers drawn in a lottery
You mentioned that odd-even pattern, so let's investigate that. Category Observed Expected # Expected odd 92 110 50% even 128 110 50% And test with just these two categories.... Chi squared equals 5.891 with 1 degrees of freedom. The two-tailed P value equals 0.0152 That would generally be considered significant This kind of result only happens fifteen times out of a thousand. Does that mean that we have a publishable result? The binomial test (more exact when there are two categories) gives p = 0.0062, also significant. There are several problems here. Firstly we chose to focus on one aspect of the data after we had collected it. We ignored others. For example, we could have tested for multiples of 3, or primes/non primes or ... many other choices are possible. Nearly all those other choices find "not significant". This is p-hacking the green jellybean fallacy, illustrated by xkcd. By subdividing or grouping data it is often possible to find a result that is significant. The proper response is to investigate further. If this is a real effect, it should become a stronger result with more data. If it just "green jellybeans" then it won't be repeatable. And (although not the same experiment) the German 6-aus-49 lottery has no odd-even pattern. Secondly we have a strong "prior": We inspect the machine and the balls and don't notice anything that seems amiss. We know from our general experience of such machines that they are usually quite fair. What would you estimate the probablity of the machine, or the operator, being substantially unfair, prior to the experiment? Clearly there is some judgement here, but suppose we say 0.001 (one in a thousand chance) Now, given this result, how likely is it that the machine is substantially unfair. Well, this will take you into Bayesian statistics. We would need to quantify "substantially unfair", but if an unfair machine will always give results like this [P(X²>5.891 | unfair)=1] then the probablity that the machine is unfair, given that we observe X²>5.891 is just 0.001/0.0152 =0.06. So we update our estimate of the machine being unfair from 0.001 to 0.06. We still think it rather unlikely that the machine is unfair.
Explanation for unequal probabilities of numbers drawn in a lottery
You mentioned that odd-even pattern, so let's investigate that. Category Observed Expected # Expected odd 92 110 50% even 128 110 50% And test with just these two categories.... Chi squa
Explanation for unequal probabilities of numbers drawn in a lottery You mentioned that odd-even pattern, so let's investigate that. Category Observed Expected # Expected odd 92 110 50% even 128 110 50% And test with just these two categories.... Chi squared equals 5.891 with 1 degrees of freedom. The two-tailed P value equals 0.0152 That would generally be considered significant This kind of result only happens fifteen times out of a thousand. Does that mean that we have a publishable result? The binomial test (more exact when there are two categories) gives p = 0.0062, also significant. There are several problems here. Firstly we chose to focus on one aspect of the data after we had collected it. We ignored others. For example, we could have tested for multiples of 3, or primes/non primes or ... many other choices are possible. Nearly all those other choices find "not significant". This is p-hacking the green jellybean fallacy, illustrated by xkcd. By subdividing or grouping data it is often possible to find a result that is significant. The proper response is to investigate further. If this is a real effect, it should become a stronger result with more data. If it just "green jellybeans" then it won't be repeatable. And (although not the same experiment) the German 6-aus-49 lottery has no odd-even pattern. Secondly we have a strong "prior": We inspect the machine and the balls and don't notice anything that seems amiss. We know from our general experience of such machines that they are usually quite fair. What would you estimate the probablity of the machine, or the operator, being substantially unfair, prior to the experiment? Clearly there is some judgement here, but suppose we say 0.001 (one in a thousand chance) Now, given this result, how likely is it that the machine is substantially unfair. Well, this will take you into Bayesian statistics. We would need to quantify "substantially unfair", but if an unfair machine will always give results like this [P(X²>5.891 | unfair)=1] then the probablity that the machine is unfair, given that we observe X²>5.891 is just 0.001/0.0152 =0.06. So we update our estimate of the machine being unfair from 0.001 to 0.06. We still think it rather unlikely that the machine is unfair.
Explanation for unequal probabilities of numbers drawn in a lottery You mentioned that odd-even pattern, so let's investigate that. Category Observed Expected # Expected odd 92 110 50% even 128 110 50% And test with just these two categories.... Chi squa
11,003
Explanation for unequal probabilities of numbers drawn in a lottery
To determine whether the results seem to indicate some shenanigans were afoot, we can test it! To begin, we need to specify what our null hypothesis is. I'll take the moment here to stress (as subsequent answers have pointed out in more detail) the importance of forming hypotheses before seeing the data we will use for testing this hypothesis. For example you observed that odd and lower-valued numbers appear more often, but our hypothesis should be formed prior to seeing the data. As such, it would be wrong to look at the data, note that odd numbers appear more often in the data, and then test that hypothesis based on the same data (as @Him points out, it's certainly reasonable to collect new data to test this hypothesis). Based on your writing, it seems like past data has made you believe that inconsistencies may be occurring, so a natural test would be whether the draws are from a (discrete) uniform distribution (the null hypothesis), or whether the draws are from some other distribution which would thus indicating bias towards certain numbers (the alternative hypothesis). A simple test of this hypothesis is a chi square test. Under the null hypothesis, each number has an equal chance of being drawn (i.e. for each draw, there is a $1/12$ chance that any given number is drawn -- subsequent answers have also shown how a chi square test can be used with different hypothesis such as odd/even difference). Under our null, we can calculate how many draws each number should have had by multiplying $1/12$ by the total number of draws for each number. The test essentially measures by how much the observed draws differ from the expected number of draws under the null. Using your observed numbers and performing this test (see code below), we find that the p-value is $p = 0.71$, and thus we fail to reject the null that the draws came from a fair process. Thus, we cannot conclude that the draws came from a biased sampling process. >obs = c(23,18,21,15,24,17,20,16,21,13,19,13) >p = rep(1/length(obs),length(obs)) >chisq.test(obs,p=p) Chi-squared test for given probabilities data: obs X-squared = 8, df = 11, p-value = 0.7133 As for the second part of the question, suppose we did conclude the draws came from unequal probabilities (which we did not). There are tons of plausible explanations for why this may be. To list two: A hustler with enough skill could probably easily make the process seem fair when it is not, either by cranking the machine in a consistent way that ensures the numbers that started at the bottom end at the bottom after they are done turning the lever, or by simply following the balls while he cranks it. You say it was from a real lottery, but did you actually observe this process? If not, then it's easy to say these were due to a fair lottery even if they were not.
Explanation for unequal probabilities of numbers drawn in a lottery
To determine whether the results seem to indicate some shenanigans were afoot, we can test it! To begin, we need to specify what our null hypothesis is. I'll take the moment here to stress (as subsequ
Explanation for unequal probabilities of numbers drawn in a lottery To determine whether the results seem to indicate some shenanigans were afoot, we can test it! To begin, we need to specify what our null hypothesis is. I'll take the moment here to stress (as subsequent answers have pointed out in more detail) the importance of forming hypotheses before seeing the data we will use for testing this hypothesis. For example you observed that odd and lower-valued numbers appear more often, but our hypothesis should be formed prior to seeing the data. As such, it would be wrong to look at the data, note that odd numbers appear more often in the data, and then test that hypothesis based on the same data (as @Him points out, it's certainly reasonable to collect new data to test this hypothesis). Based on your writing, it seems like past data has made you believe that inconsistencies may be occurring, so a natural test would be whether the draws are from a (discrete) uniform distribution (the null hypothesis), or whether the draws are from some other distribution which would thus indicating bias towards certain numbers (the alternative hypothesis). A simple test of this hypothesis is a chi square test. Under the null hypothesis, each number has an equal chance of being drawn (i.e. for each draw, there is a $1/12$ chance that any given number is drawn -- subsequent answers have also shown how a chi square test can be used with different hypothesis such as odd/even difference). Under our null, we can calculate how many draws each number should have had by multiplying $1/12$ by the total number of draws for each number. The test essentially measures by how much the observed draws differ from the expected number of draws under the null. Using your observed numbers and performing this test (see code below), we find that the p-value is $p = 0.71$, and thus we fail to reject the null that the draws came from a fair process. Thus, we cannot conclude that the draws came from a biased sampling process. >obs = c(23,18,21,15,24,17,20,16,21,13,19,13) >p = rep(1/length(obs),length(obs)) >chisq.test(obs,p=p) Chi-squared test for given probabilities data: obs X-squared = 8, df = 11, p-value = 0.7133 As for the second part of the question, suppose we did conclude the draws came from unequal probabilities (which we did not). There are tons of plausible explanations for why this may be. To list two: A hustler with enough skill could probably easily make the process seem fair when it is not, either by cranking the machine in a consistent way that ensures the numbers that started at the bottom end at the bottom after they are done turning the lever, or by simply following the balls while he cranks it. You say it was from a real lottery, but did you actually observe this process? If not, then it's easy to say these were due to a fair lottery even if they were not.
Explanation for unequal probabilities of numbers drawn in a lottery To determine whether the results seem to indicate some shenanigans were afoot, we can test it! To begin, we need to specify what our null hypothesis is. I'll take the moment here to stress (as subsequ
11,004
Explanation for unequal probabilities of numbers drawn in a lottery
Following @doubled's (+1) chi-squared test, a remaining question is whether 220 draws from the machine are enough to detect an actual small bias. Maybe the odd numbered balls are a bit heavier, lighter, or less round in such a way that they are slightly more likely to be be drawn. Maybe the true probability distribution is $(6,4,6,4, 6,4,6,4, 6,4,6,4)/60.$ What is the the probability a chi-squared test based on 220 draws would detect this bias in favor of odd numbers? Based on this distribution, one can simulate $m=100\,000$ sessions of 220 draws each, do the chi-squared test each time, and see what fraction of the $m$ sessions rejects the null hypothesis that draws are fair. This gives a good approximation of the power of the chi-squared test to detect the specified degree of unfairness. To begin, let's look at one such simulated session--which happens not to detect the unfairness (P-value > 5%). [Using R.] # one session set.seed(411) # for reproducibility pr = c(6,4,6,4, 6,4,6,4, 6,4,6,4)/60 x = sample(1:12, 220, rep=T, p = pr) TB = tabulate(x); TB [1] 23 11 17 20 20 16 19 19 20 17 21 17 chisq.test(TB)$p.val [1] 0.898677 Now, by simulating $m$ sessions of $n=220$ draws each, we see that we have just a little less than a 50:50 chance of detecting this level of unfairness. At the end of the simulation run vector pv has $m$ P-values, and mean(pv <= 0.05) gives the proportion of rejections. [The parameter nbins=12 of tabulate forces tabulate to give the correct tally, even if a session lacks some of the higher numbers.] # 100,000 sessions set.seed(2021) pr = c(6,4,6,4, 6,4,6,4, 6,4,6,4)/60 m = 10^5; pv = numeric(m) for(i in 1:m) { x = sample(1:12, 220, rep=T, p = pr) TB = tabulate(x, nbins=12) pv[i] = chisq.test(TB)$p.val } mean(pv <= 0.05) [1] 0.45349 Also, a run of the program with $n = 500$ draws per session [not shown] gives power almost 90%, and a run with $n=650$ gives power just above 95%. Note: In these simple cases, it is not necessary to do a simulation in order to approximate the power of a chi-squared test of $H_0: \mathrm{Fair}$ against alternative vector pr, using $n$ draws. The 5% critical value $c=19.6751$ has $P(Q > c|H_0) = 0.05.$ And the 'effect size' is $\lambda = n\sum\frac{(p_{ai} - 1/12)^2}{1/12} = 8.8.$ Then the exact power $0.4602$ is found using the chi-squared distribution with degrees $\nu = 12-1 = 11$ and noncentrality parameter $\lambda.$ c = qchisq(.95, 11); c [1] 19.67514 lam = 220*sum((pr-1/12)^2/(1/12)); lam [1] 8.8 1 - pchisq(c,11,lam) [1] 0.4602406 By contrast with $n = 650,$ we have $\lambda = 26$ and power $0.9574.$ lam = 650*sum((pr-1/12)^2/(1/12)); lam [1] 26 1 - pchisq(c,11,lam) [1] 0.9573635 Perhaps see this Q&A and its references.
Explanation for unequal probabilities of numbers drawn in a lottery
Following @doubled's (+1) chi-squared test, a remaining question is whether 220 draws from the machine are enough to detect an actual small bias. Maybe the odd numbered balls are a bit heavier, lighte
Explanation for unequal probabilities of numbers drawn in a lottery Following @doubled's (+1) chi-squared test, a remaining question is whether 220 draws from the machine are enough to detect an actual small bias. Maybe the odd numbered balls are a bit heavier, lighter, or less round in such a way that they are slightly more likely to be be drawn. Maybe the true probability distribution is $(6,4,6,4, 6,4,6,4, 6,4,6,4)/60.$ What is the the probability a chi-squared test based on 220 draws would detect this bias in favor of odd numbers? Based on this distribution, one can simulate $m=100\,000$ sessions of 220 draws each, do the chi-squared test each time, and see what fraction of the $m$ sessions rejects the null hypothesis that draws are fair. This gives a good approximation of the power of the chi-squared test to detect the specified degree of unfairness. To begin, let's look at one such simulated session--which happens not to detect the unfairness (P-value > 5%). [Using R.] # one session set.seed(411) # for reproducibility pr = c(6,4,6,4, 6,4,6,4, 6,4,6,4)/60 x = sample(1:12, 220, rep=T, p = pr) TB = tabulate(x); TB [1] 23 11 17 20 20 16 19 19 20 17 21 17 chisq.test(TB)$p.val [1] 0.898677 Now, by simulating $m$ sessions of $n=220$ draws each, we see that we have just a little less than a 50:50 chance of detecting this level of unfairness. At the end of the simulation run vector pv has $m$ P-values, and mean(pv <= 0.05) gives the proportion of rejections. [The parameter nbins=12 of tabulate forces tabulate to give the correct tally, even if a session lacks some of the higher numbers.] # 100,000 sessions set.seed(2021) pr = c(6,4,6,4, 6,4,6,4, 6,4,6,4)/60 m = 10^5; pv = numeric(m) for(i in 1:m) { x = sample(1:12, 220, rep=T, p = pr) TB = tabulate(x, nbins=12) pv[i] = chisq.test(TB)$p.val } mean(pv <= 0.05) [1] 0.45349 Also, a run of the program with $n = 500$ draws per session [not shown] gives power almost 90%, and a run with $n=650$ gives power just above 95%. Note: In these simple cases, it is not necessary to do a simulation in order to approximate the power of a chi-squared test of $H_0: \mathrm{Fair}$ against alternative vector pr, using $n$ draws. The 5% critical value $c=19.6751$ has $P(Q > c|H_0) = 0.05.$ And the 'effect size' is $\lambda = n\sum\frac{(p_{ai} - 1/12)^2}{1/12} = 8.8.$ Then the exact power $0.4602$ is found using the chi-squared distribution with degrees $\nu = 12-1 = 11$ and noncentrality parameter $\lambda.$ c = qchisq(.95, 11); c [1] 19.67514 lam = 220*sum((pr-1/12)^2/(1/12)); lam [1] 8.8 1 - pchisq(c,11,lam) [1] 0.4602406 By contrast with $n = 650,$ we have $\lambda = 26$ and power $0.9574.$ lam = 650*sum((pr-1/12)^2/(1/12)); lam [1] 26 1 - pchisq(c,11,lam) [1] 0.9573635 Perhaps see this Q&A and its references.
Explanation for unequal probabilities of numbers drawn in a lottery Following @doubled's (+1) chi-squared test, a remaining question is whether 220 draws from the machine are enough to detect an actual small bias. Maybe the odd numbered balls are a bit heavier, lighte
11,005
Explanation for unequal probabilities of numbers drawn in a lottery
As an addition to the other answers, let me offer you a visual way to inspect the differences between the expected and observed frequencies: A (hanging) rootogram, invented by John Tukey (see also Kleiber & Zeileis (2016)). In the figure below, the square roots of the expected counts are displayed as red dots. The square roots of the observed frequencies are hanging as histogram-like bars from these points. Therefore, if the expected and the observed frequencies are similar, the base of the bars all lie near zero. Bars for lower than expected frequencies lie above the zero line and vice versa. This plot makes it easy to see departures in either direction. In terms of interpretation, recall that for most values, the square root of a count will be less than one unit from its expected value. This is the case for all twelve numbers of your data. Hence, there is little evidence for a systematic departure from uniformity, as the other answers have already explained. The square root is useful here because it's a variance stabilizing function for the Poisson distribution. With $n=220, p=1/12$, the Poisson distribution is a reasonable approximation to the binomial. Finally, for fairly large $\lambda$s, the variance of the square root of a Poisson distribution will be around $1/4$ so the 68-95-99.7 rule suggests most values will lie within $2\times \sqrt{1/4} = 1$ of the mean. One could entertain the arcsine transformation for the binomial, but it virtually makes no difference in this case. On a separate note, please keep in mind that the usage of a formal hypothesis test could be dubious in such cases, if you only looked at the data because they made you suspicious (this is called HARKing: Hypothesizing after the results are known). In your case, you formed the hypothesis based on other data, which seems fine to me.
Explanation for unequal probabilities of numbers drawn in a lottery
As an addition to the other answers, let me offer you a visual way to inspect the differences between the expected and observed frequencies: A (hanging) rootogram, invented by John Tukey (see also Kle
Explanation for unequal probabilities of numbers drawn in a lottery As an addition to the other answers, let me offer you a visual way to inspect the differences between the expected and observed frequencies: A (hanging) rootogram, invented by John Tukey (see also Kleiber & Zeileis (2016)). In the figure below, the square roots of the expected counts are displayed as red dots. The square roots of the observed frequencies are hanging as histogram-like bars from these points. Therefore, if the expected and the observed frequencies are similar, the base of the bars all lie near zero. Bars for lower than expected frequencies lie above the zero line and vice versa. This plot makes it easy to see departures in either direction. In terms of interpretation, recall that for most values, the square root of a count will be less than one unit from its expected value. This is the case for all twelve numbers of your data. Hence, there is little evidence for a systematic departure from uniformity, as the other answers have already explained. The square root is useful here because it's a variance stabilizing function for the Poisson distribution. With $n=220, p=1/12$, the Poisson distribution is a reasonable approximation to the binomial. Finally, for fairly large $\lambda$s, the variance of the square root of a Poisson distribution will be around $1/4$ so the 68-95-99.7 rule suggests most values will lie within $2\times \sqrt{1/4} = 1$ of the mean. One could entertain the arcsine transformation for the binomial, but it virtually makes no difference in this case. On a separate note, please keep in mind that the usage of a formal hypothesis test could be dubious in such cases, if you only looked at the data because they made you suspicious (this is called HARKing: Hypothesizing after the results are known). In your case, you formed the hypothesis based on other data, which seems fine to me.
Explanation for unequal probabilities of numbers drawn in a lottery As an addition to the other answers, let me offer you a visual way to inspect the differences between the expected and observed frequencies: A (hanging) rootogram, invented by John Tukey (see also Kle
11,006
Explanation for unequal probabilities of numbers drawn in a lottery
I found that there was a correlation of -0.5109730443013045 between the number drawn and its frequency, and a p-value of 0.090274 for that correlation. For a binomial test for a number being odd or even, I got a p-value of 0.00621804354. When I adjusted the odd numbers for the difference in means (that is, added (even mean-odd mean) to the frequencies of odd numbers), I found a correlation of -0.753098254512706 for the numbers versus frequencies, for a p-value of 0.0047. As other answers have discussed, this is HARKing (hypothesizing after the results are known). There are lots of different patterns you could have noticed, so given any alpha, the probability that at least one has a p-value less than alpha is significantly greater than the probability for each one individually. Besides the possibility of cherry-picking the hypothesis to fit the data, there is the possibility of cherry-picking the data: if you see lots of lotteries, and only discuss the ones with unusual results, or you stop collecting data from a lottery once that data seems anomalous, and don't continue collecting data to see whether it reverts to the mean, the apparent p-value can misrepresent the true improbability of the results. 0.090274 is a large p-value in general, and in the context of HARKing, it's well within the range of what we could expect by chance. It's enough to draw attention to it, but not enough to come to a solid conclusion. 0.00621804354, on the other hand, is quite small. With it being less that one-eighth of the standard alpha of 0.05, a relevant question to ask is "Are there eight other hypotheses that would be as, or more, noticeable?" It's on the borderline (and keep in mind that you need to account for the bias that the pattern that you actually say feels more salient than ones that you didn't see). When you add in the fact that there are surely more than 161 lotteries, seeing a p-value of 1/161 hardly eliminates the possibility that this is due to just chance. The p-value of 0.0047, or 1/213, for the adjusted correlation is a bit lower, but it's also more contrived, so we need to adjust our "How many hypotheses are there that would be as, or more, noticeable?" number upwards. So it's enough that it would be understandable to investigate whether there's something causing a bias, but there's no way to know without empirical investigation, and sometimes things happen just by chance. That's the whole point of a lottery, after all. If you were to win a lottery, you probably wouldn't say "The p-value of me winning is less than 0.05, so obviously the lottery's rigged."
Explanation for unequal probabilities of numbers drawn in a lottery
I found that there was a correlation of -0.5109730443013045 between the number drawn and its frequency, and a p-value of 0.090274 for that correlation. For a binomial test for a number being odd or ev
Explanation for unequal probabilities of numbers drawn in a lottery I found that there was a correlation of -0.5109730443013045 between the number drawn and its frequency, and a p-value of 0.090274 for that correlation. For a binomial test for a number being odd or even, I got a p-value of 0.00621804354. When I adjusted the odd numbers for the difference in means (that is, added (even mean-odd mean) to the frequencies of odd numbers), I found a correlation of -0.753098254512706 for the numbers versus frequencies, for a p-value of 0.0047. As other answers have discussed, this is HARKing (hypothesizing after the results are known). There are lots of different patterns you could have noticed, so given any alpha, the probability that at least one has a p-value less than alpha is significantly greater than the probability for each one individually. Besides the possibility of cherry-picking the hypothesis to fit the data, there is the possibility of cherry-picking the data: if you see lots of lotteries, and only discuss the ones with unusual results, or you stop collecting data from a lottery once that data seems anomalous, and don't continue collecting data to see whether it reverts to the mean, the apparent p-value can misrepresent the true improbability of the results. 0.090274 is a large p-value in general, and in the context of HARKing, it's well within the range of what we could expect by chance. It's enough to draw attention to it, but not enough to come to a solid conclusion. 0.00621804354, on the other hand, is quite small. With it being less that one-eighth of the standard alpha of 0.05, a relevant question to ask is "Are there eight other hypotheses that would be as, or more, noticeable?" It's on the borderline (and keep in mind that you need to account for the bias that the pattern that you actually say feels more salient than ones that you didn't see). When you add in the fact that there are surely more than 161 lotteries, seeing a p-value of 1/161 hardly eliminates the possibility that this is due to just chance. The p-value of 0.0047, or 1/213, for the adjusted correlation is a bit lower, but it's also more contrived, so we need to adjust our "How many hypotheses are there that would be as, or more, noticeable?" number upwards. So it's enough that it would be understandable to investigate whether there's something causing a bias, but there's no way to know without empirical investigation, and sometimes things happen just by chance. That's the whole point of a lottery, after all. If you were to win a lottery, you probably wouldn't say "The p-value of me winning is less than 0.05, so obviously the lottery's rigged."
Explanation for unequal probabilities of numbers drawn in a lottery I found that there was a correlation of -0.5109730443013045 between the number drawn and its frequency, and a p-value of 0.090274 for that correlation. For a binomial test for a number being odd or ev
11,007
Reason for not shrinking the bias (intercept) term in regression
The Elements of Statistical Learning by Hastie et al. define ridge regression as follows (Section 3.4.1, equation 3.41): $$\hat \beta{}^\mathrm{ridge} = \underset{\beta}{\mathrm{argmin}}\left\{\sum_{i=1}^N(y_i - \beta_0 - \sum_{j=1}^p x_{ij}\beta_j)^2 + \lambda \sum_{j=1}^p \beta_j^2\right\},$$ i.e. explicitly exclude the intercept term $\beta_0$ from the ridge penalty. Then they write: [...] notice that the intercept $\beta_0$ has been left out of the penalty term. Penalization of the intercept would make the procedure depend on the origin chosen for $Y$; that is, adding a constant $c$ to each of the targets $y_i$ would not simply result in a shift of the predictions by the same amount $c$. Indeed, in the presence of the intercept term, adding $c$ to all $y_i$ will simply lead to $\beta_0$ increasing by $c$ as well and correspondingly all predicted values $\hat y_i$ will also increase by $c$. This is not true if the intercept is penalized: $\beta_0$ will have to increase by less than $c$. In fact, there are several nice and convenient properties of linear regression that depend on there being a proper (unpenalized) intercept term. E.g. the average value of $y_i$ and the average value of $\hat y_i$ are equal, and (consequently) the squared multiple correlation coefficient $R$ is equal to the coefficient of determination $R^2$: $$(R)^2 = \text{cor}^2(\hat {\mathbf y}, \mathbf y) = \frac{\|\hat{\mathbf y}\|^2}{\|\mathbf y\|^2} = R^2,$$ see e.g. this thread for an explanation: Geometric interpretation of multiple correlation coefficient $R$ and coefficient of determination $R^2$. Penalizing the intercept would lead to all of that not being true anymore.
Reason for not shrinking the bias (intercept) term in regression
The Elements of Statistical Learning by Hastie et al. define ridge regression as follows (Section 3.4.1, equation 3.41): $$\hat \beta{}^\mathrm{ridge} = \underset{\beta}{\mathrm{argmin}}\left\{\sum_{i
Reason for not shrinking the bias (intercept) term in regression The Elements of Statistical Learning by Hastie et al. define ridge regression as follows (Section 3.4.1, equation 3.41): $$\hat \beta{}^\mathrm{ridge} = \underset{\beta}{\mathrm{argmin}}\left\{\sum_{i=1}^N(y_i - \beta_0 - \sum_{j=1}^p x_{ij}\beta_j)^2 + \lambda \sum_{j=1}^p \beta_j^2\right\},$$ i.e. explicitly exclude the intercept term $\beta_0$ from the ridge penalty. Then they write: [...] notice that the intercept $\beta_0$ has been left out of the penalty term. Penalization of the intercept would make the procedure depend on the origin chosen for $Y$; that is, adding a constant $c$ to each of the targets $y_i$ would not simply result in a shift of the predictions by the same amount $c$. Indeed, in the presence of the intercept term, adding $c$ to all $y_i$ will simply lead to $\beta_0$ increasing by $c$ as well and correspondingly all predicted values $\hat y_i$ will also increase by $c$. This is not true if the intercept is penalized: $\beta_0$ will have to increase by less than $c$. In fact, there are several nice and convenient properties of linear regression that depend on there being a proper (unpenalized) intercept term. E.g. the average value of $y_i$ and the average value of $\hat y_i$ are equal, and (consequently) the squared multiple correlation coefficient $R$ is equal to the coefficient of determination $R^2$: $$(R)^2 = \text{cor}^2(\hat {\mathbf y}, \mathbf y) = \frac{\|\hat{\mathbf y}\|^2}{\|\mathbf y\|^2} = R^2,$$ see e.g. this thread for an explanation: Geometric interpretation of multiple correlation coefficient $R$ and coefficient of determination $R^2$. Penalizing the intercept would lead to all of that not being true anymore.
Reason for not shrinking the bias (intercept) term in regression The Elements of Statistical Learning by Hastie et al. define ridge regression as follows (Section 3.4.1, equation 3.41): $$\hat \beta{}^\mathrm{ridge} = \underset{\beta}{\mathrm{argmin}}\left\{\sum_{i
11,008
Reason for not shrinking the bias (intercept) term in regression
Recall the purpose of shrinkage or regularization. It is to prevent the learning algorithm to overfit the training data or equivalently - prevent from picking arbitrarily large parameter values. This is more likely for datasets with more than few training examples in the presence of noise (very interesting discussion about presence of noise and its impact is discussed in "Learning from Data" by Yaser Abu-Mustafa). A model learned on noisy data with no regularization will likely perform poorly on some unseen data points. With this in mind, imagine you have 2D data points which you want to classify in two classes. Having all but the bias parameters fixed, varying the bias term will just move the boundary up or down. You can generalize this to a higher dimensional space. The learning algorithm cannot put arbitrarily large values for the bias term since this will result in possibly gross loss value (the model will not fit the training data). In other words, given some training set, you (or a learning algorithm) cannot move the plane arbitrarily far away from the true one. So, there is no reason to shrink the bias term, the learning algorithm will find the good one without a risk of overfitting. A final note: I saw in some paper that when working in high-dimensional spaces for classification, there is no strict need to model the bias term. This might work for linearly separable data since with more dimensions added, there are more possibilities to separate the two classes.
Reason for not shrinking the bias (intercept) term in regression
Recall the purpose of shrinkage or regularization. It is to prevent the learning algorithm to overfit the training data or equivalently - prevent from picking arbitrarily large parameter values. This
Reason for not shrinking the bias (intercept) term in regression Recall the purpose of shrinkage or regularization. It is to prevent the learning algorithm to overfit the training data or equivalently - prevent from picking arbitrarily large parameter values. This is more likely for datasets with more than few training examples in the presence of noise (very interesting discussion about presence of noise and its impact is discussed in "Learning from Data" by Yaser Abu-Mustafa). A model learned on noisy data with no regularization will likely perform poorly on some unseen data points. With this in mind, imagine you have 2D data points which you want to classify in two classes. Having all but the bias parameters fixed, varying the bias term will just move the boundary up or down. You can generalize this to a higher dimensional space. The learning algorithm cannot put arbitrarily large values for the bias term since this will result in possibly gross loss value (the model will not fit the training data). In other words, given some training set, you (or a learning algorithm) cannot move the plane arbitrarily far away from the true one. So, there is no reason to shrink the bias term, the learning algorithm will find the good one without a risk of overfitting. A final note: I saw in some paper that when working in high-dimensional spaces for classification, there is no strict need to model the bias term. This might work for linearly separable data since with more dimensions added, there are more possibilities to separate the two classes.
Reason for not shrinking the bias (intercept) term in regression Recall the purpose of shrinkage or regularization. It is to prevent the learning algorithm to overfit the training data or equivalently - prevent from picking arbitrarily large parameter values. This
11,009
Reason for not shrinking the bias (intercept) term in regression
The intercept term is absolutely not immune to shrinkage. The general "shrinkage" (i.e. regularization) formulation puts the regularization term in the loss function, e.g.: $RSS(\beta) = \|y_i - X_i \beta \|^2$ $RegularizedLoss(\beta) = RSS(\beta) - \lambda f(\beta)$ Where $f(\beta)$ is usually related to a lebesgue norm, and $\lambda$ is a scalar that controls how much weight we put on the shrinkage term. By putting the shrinkage term in the loss function like this, it has an effect on all the coefficients in the model. I suspect that your question arises from a confusion about notation in which the $\beta$ (in $P(\beta)$) is a vector of all the coefficients, inclusive of $\beta_0$. Your linear model would probably be better written as $y = X \beta + \epsilon$ where $X$ is the "design matrix," by which I mean it is your data with a column of $1's$ appended to the left hand side (to take the intercept). Now, I can't speak to regularization for neural networks. It's possible that for neural networks you want to avoid shrinkage of the bias term or otherwise design the regularized loss function differently from the formulation I described above. I just don't know. But I strongly suspect that the weights and bias terms are regularized together.
Reason for not shrinking the bias (intercept) term in regression
The intercept term is absolutely not immune to shrinkage. The general "shrinkage" (i.e. regularization) formulation puts the regularization term in the loss function, e.g.: $RSS(\beta) = \|y_i - X_i \
Reason for not shrinking the bias (intercept) term in regression The intercept term is absolutely not immune to shrinkage. The general "shrinkage" (i.e. regularization) formulation puts the regularization term in the loss function, e.g.: $RSS(\beta) = \|y_i - X_i \beta \|^2$ $RegularizedLoss(\beta) = RSS(\beta) - \lambda f(\beta)$ Where $f(\beta)$ is usually related to a lebesgue norm, and $\lambda$ is a scalar that controls how much weight we put on the shrinkage term. By putting the shrinkage term in the loss function like this, it has an effect on all the coefficients in the model. I suspect that your question arises from a confusion about notation in which the $\beta$ (in $P(\beta)$) is a vector of all the coefficients, inclusive of $\beta_0$. Your linear model would probably be better written as $y = X \beta + \epsilon$ where $X$ is the "design matrix," by which I mean it is your data with a column of $1's$ appended to the left hand side (to take the intercept). Now, I can't speak to regularization for neural networks. It's possible that for neural networks you want to avoid shrinkage of the bias term or otherwise design the regularized loss function differently from the formulation I described above. I just don't know. But I strongly suspect that the weights and bias terms are regularized together.
Reason for not shrinking the bias (intercept) term in regression The intercept term is absolutely not immune to shrinkage. The general "shrinkage" (i.e. regularization) formulation puts the regularization term in the loss function, e.g.: $RSS(\beta) = \|y_i - X_i \
11,010
Reason for not shrinking the bias (intercept) term in regression
I'm not sure the above answer by David Marx is quite right; according to Andrew Ng, by convention the bias/intercept coefficient is typically not regularized in a linear regression, and in any case whether it is regularized or not does not make a significant difference.
Reason for not shrinking the bias (intercept) term in regression
I'm not sure the above answer by David Marx is quite right; according to Andrew Ng, by convention the bias/intercept coefficient is typically not regularized in a linear regression, and in any case wh
Reason for not shrinking the bias (intercept) term in regression I'm not sure the above answer by David Marx is quite right; according to Andrew Ng, by convention the bias/intercept coefficient is typically not regularized in a linear regression, and in any case whether it is regularized or not does not make a significant difference.
Reason for not shrinking the bias (intercept) term in regression I'm not sure the above answer by David Marx is quite right; according to Andrew Ng, by convention the bias/intercept coefficient is typically not regularized in a linear regression, and in any case wh
11,011
Reason for not shrinking the bias (intercept) term in regression
I'll give the simplest explanation, then expand. Suppose you shrink to zero, then your model effectively becomes: $$y_t=\varepsilon_t$$ Just one problem with this model: $E[\varepsilon_t]=E[y_t]\ne 0$, which violates exogeneity assumption of the linear regression. Hence, the estimated coefficients will not have nice properties, such as unbiasedness. This demonstrates the main purpose of the intercept: to capture the mean. I think that a lot of people do not realize the importance of the intercept in the linear regression. It's often looked down as a less sexy little brother of the "real" $\beta$ of the predictor. However, as you may know from "regression through the origin" dropping the intercept from the model often leads to undesirable consequences. Now, for the completeness if you shrink all bona fide coefficients $\beta$ and keep the intercept $\beta_0$ out, you get this: $$y_t=\beta_0+\varepsilon_t$$ $$E[y_t]=\beta_0+E[\varepsilon_t]$$ Here, we still have $E[\varepsilon_t]=0$ because the intercept will capture the mean of the data $\beta_0=\mu=E[y_t]$. This model is not as sexy as the original model, it's rather silly, in fact. However, it is a legit model. You could run ANOVA on it, for example. Concluding, you need to keep the intercept out of shrinkage so that it does what it is intended for: capture the mean of the series $\beta_0=E[y_t]$
Reason for not shrinking the bias (intercept) term in regression
I'll give the simplest explanation, then expand. Suppose you shrink to zero, then your model effectively becomes: $$y_t=\varepsilon_t$$ Just one problem with this model: $E[\varepsilon_t]=E[y_t]\ne 0$
Reason for not shrinking the bias (intercept) term in regression I'll give the simplest explanation, then expand. Suppose you shrink to zero, then your model effectively becomes: $$y_t=\varepsilon_t$$ Just one problem with this model: $E[\varepsilon_t]=E[y_t]\ne 0$, which violates exogeneity assumption of the linear regression. Hence, the estimated coefficients will not have nice properties, such as unbiasedness. This demonstrates the main purpose of the intercept: to capture the mean. I think that a lot of people do not realize the importance of the intercept in the linear regression. It's often looked down as a less sexy little brother of the "real" $\beta$ of the predictor. However, as you may know from "regression through the origin" dropping the intercept from the model often leads to undesirable consequences. Now, for the completeness if you shrink all bona fide coefficients $\beta$ and keep the intercept $\beta_0$ out, you get this: $$y_t=\beta_0+\varepsilon_t$$ $$E[y_t]=\beta_0+E[\varepsilon_t]$$ Here, we still have $E[\varepsilon_t]=0$ because the intercept will capture the mean of the data $\beta_0=\mu=E[y_t]$. This model is not as sexy as the original model, it's rather silly, in fact. However, it is a legit model. You could run ANOVA on it, for example. Concluding, you need to keep the intercept out of shrinkage so that it does what it is intended for: capture the mean of the series $\beta_0=E[y_t]$
Reason for not shrinking the bias (intercept) term in regression I'll give the simplest explanation, then expand. Suppose you shrink to zero, then your model effectively becomes: $$y_t=\varepsilon_t$$ Just one problem with this model: $E[\varepsilon_t]=E[y_t]\ne 0$
11,012
Reason for not shrinking the bias (intercept) term in regression
Suppose one of the predictors $x_i$ happens to have the same nonzero value across all training examples. We would like its coefficient $\beta_i$ to be estimated as zero. To see why, suppose $\beta_i$ is not zero, and $x_i$ takes a different value in some test example. Our prediction will change by some arbitrary amount that has no justification in the training data. By not shrinking the intercept $\beta_0$ in ridge regression, we ensure that $\beta_i$ will be zero. If we did shrink the intercept, then $\beta_i$ will not be zero, since $x_i$ plays the role of a second intercept and will split up $\beta_0$. You might argue that we should normalize $x_i$ by subtracting its mean and making it zero across all training examples. However, that act of normalization implicitly assumes the intercept is excluded from the ridge penalty.
Reason for not shrinking the bias (intercept) term in regression
Suppose one of the predictors $x_i$ happens to have the same nonzero value across all training examples. We would like its coefficient $\beta_i$ to be estimated as zero. To see why, suppose $\beta_i
Reason for not shrinking the bias (intercept) term in regression Suppose one of the predictors $x_i$ happens to have the same nonzero value across all training examples. We would like its coefficient $\beta_i$ to be estimated as zero. To see why, suppose $\beta_i$ is not zero, and $x_i$ takes a different value in some test example. Our prediction will change by some arbitrary amount that has no justification in the training data. By not shrinking the intercept $\beta_0$ in ridge regression, we ensure that $\beta_i$ will be zero. If we did shrink the intercept, then $\beta_i$ will not be zero, since $x_i$ plays the role of a second intercept and will split up $\beta_0$. You might argue that we should normalize $x_i$ by subtracting its mean and making it zero across all training examples. However, that act of normalization implicitly assumes the intercept is excluded from the ridge penalty.
Reason for not shrinking the bias (intercept) term in regression Suppose one of the predictors $x_i$ happens to have the same nonzero value across all training examples. We would like its coefficient $\beta_i$ to be estimated as zero. To see why, suppose $\beta_i
11,013
Can someone help to explain the difference between independent and random?
I'll try to explain it in non-technical terms: A random variable describes an outcome of an experiment; you can not know in advance what the exact outcome will be but you have some information: you know which outcomes are possible and you know, for each outcome, its probability. For example, if you toss a fair coin then you do not know in advance whether you will get head or tail, but you know that these are the possible outcomes and you know that each has 50% chance of occurrence. To explain independence you have to toss two fair coins. After tossing the first coin you know that for the second toss the probabilities of head is still 50% and for tail also. If the first toss has no influence on the probabilities of the second one then both tosses are independent. If the first toss has an influence on the probabilities of the second toss then they are dependent. An example of dependent tosses is when you glue the two coins together.
Can someone help to explain the difference between independent and random?
I'll try to explain it in non-technical terms: A random variable describes an outcome of an experiment; you can not know in advance what the exact outcome will be but you have some information: you kn
Can someone help to explain the difference between independent and random? I'll try to explain it in non-technical terms: A random variable describes an outcome of an experiment; you can not know in advance what the exact outcome will be but you have some information: you know which outcomes are possible and you know, for each outcome, its probability. For example, if you toss a fair coin then you do not know in advance whether you will get head or tail, but you know that these are the possible outcomes and you know that each has 50% chance of occurrence. To explain independence you have to toss two fair coins. After tossing the first coin you know that for the second toss the probabilities of head is still 50% and for tail also. If the first toss has no influence on the probabilities of the second one then both tosses are independent. If the first toss has an influence on the probabilities of the second toss then they are dependent. An example of dependent tosses is when you glue the two coins together.
Can someone help to explain the difference between independent and random? I'll try to explain it in non-technical terms: A random variable describes an outcome of an experiment; you can not know in advance what the exact outcome will be but you have some information: you kn
11,014
Can someone help to explain the difference between independent and random?
Random relates to random variable, and independent relates to probabilistic independence. By independence we mean that observing one variable does not tell us anything about the another, or in more formal terms, if $X$ and $Y$ are two random variables, then we say that they are independent if $$ p_{X,Y}(x, y) = p_X(x)\,p_Y(y) $$ moreover $$ E(XY) = E(X)E(Y) $$ and their covariance is zero. Random variable $Y$ is dependent on $X$ if it can be written as a function of $X$ $$ Y = f(X) $$ So in this case $Y$ is random and dependent on $X$. Calling process "non-independent" is pretty misleading - independent of what? I guess you meant that there are some $X_1,\dots,X_k$ independent and identically distributed random variables (check here, or here) that come from some process. By independent we would mean in here that they are independent of each other. There are processes producing dependent random variables, e.g. $$ X_i = X_{i-1} + \varepsilon $$ where $\varepsilon$ is some random noise. Obviously in such case $X_i$ is dependent on $X_{i-1}$, but it is also random.
Can someone help to explain the difference between independent and random?
Random relates to random variable, and independent relates to probabilistic independence. By independence we mean that observing one variable does not tell us anything about the another, or in more fo
Can someone help to explain the difference between independent and random? Random relates to random variable, and independent relates to probabilistic independence. By independence we mean that observing one variable does not tell us anything about the another, or in more formal terms, if $X$ and $Y$ are two random variables, then we say that they are independent if $$ p_{X,Y}(x, y) = p_X(x)\,p_Y(y) $$ moreover $$ E(XY) = E(X)E(Y) $$ and their covariance is zero. Random variable $Y$ is dependent on $X$ if it can be written as a function of $X$ $$ Y = f(X) $$ So in this case $Y$ is random and dependent on $X$. Calling process "non-independent" is pretty misleading - independent of what? I guess you meant that there are some $X_1,\dots,X_k$ independent and identically distributed random variables (check here, or here) that come from some process. By independent we would mean in here that they are independent of each other. There are processes producing dependent random variables, e.g. $$ X_i = X_{i-1} + \varepsilon $$ where $\varepsilon$ is some random noise. Obviously in such case $X_i$ is dependent on $X_{i-1}$, but it is also random.
Can someone help to explain the difference between independent and random? Random relates to random variable, and independent relates to probabilistic independence. By independence we mean that observing one variable does not tell us anything about the another, or in more fo
11,015
Can someone help to explain the difference between independent and random?
The notion of independence is relative, while you can be random by yourself. In your example, you have "two independent random variables", and do not need to talk about several "random sampling". Suppose you cast a perfect die several times. The outcome $6,5,3,5, 4\ldots$ is a priori random. Knowing the past, you cannot predict the number following 4. Suppose I generate a sequence from the other side of the die: $6\to1$, $3\to4$. I get $1,2,4,2, 3\ldots$. It is as random as the first one. You cannot guess what comes after $3$. But the two sequences are completely dependent. If one casts two dice in parallel (without interactions between they), their respective sequences will be random and independent.
Can someone help to explain the difference between independent and random?
The notion of independence is relative, while you can be random by yourself. In your example, you have "two independent random variables", and do not need to talk about several "random sampling". Sup
Can someone help to explain the difference between independent and random? The notion of independence is relative, while you can be random by yourself. In your example, you have "two independent random variables", and do not need to talk about several "random sampling". Suppose you cast a perfect die several times. The outcome $6,5,3,5, 4\ldots$ is a priori random. Knowing the past, you cannot predict the number following 4. Suppose I generate a sequence from the other side of the die: $6\to1$, $3\to4$. I get $1,2,4,2, 3\ldots$. It is as random as the first one. You cannot guess what comes after $3$. But the two sequences are completely dependent. If one casts two dice in parallel (without interactions between they), their respective sequences will be random and independent.
Can someone help to explain the difference between independent and random? The notion of independence is relative, while you can be random by yourself. In your example, you have "two independent random variables", and do not need to talk about several "random sampling". Sup
11,016
Can someone help to explain the difference between independent and random?
Variables are used in all fields of mathematics. The definitions for independence and randomness of a variable are applied unilaterally to all forms of mathematics, not just to statistics. For example, the X and Y axes in 2-dimensional Euclidean geometry represent independent variables, however, their values are not (usually) assigned at random. Two given variables can be random, or independent (of one another), or both, or neither. Statistics tends to focus on the randomness (more correctly, on probability), and whether or not two variables are independent can have many implications for the probabilities of given outcomes being observed. You tend to see these two properties (independence and randomness) described together when studying statistics, because both are important to know, and can influence the answer to the question at hand. However, these properties are not synonymous, and in other fields of mathematics they do not necessarily occur together.
Can someone help to explain the difference between independent and random?
Variables are used in all fields of mathematics. The definitions for independence and randomness of a variable are applied unilaterally to all forms of mathematics, not just to statistics. For exampl
Can someone help to explain the difference between independent and random? Variables are used in all fields of mathematics. The definitions for independence and randomness of a variable are applied unilaterally to all forms of mathematics, not just to statistics. For example, the X and Y axes in 2-dimensional Euclidean geometry represent independent variables, however, their values are not (usually) assigned at random. Two given variables can be random, or independent (of one another), or both, or neither. Statistics tends to focus on the randomness (more correctly, on probability), and whether or not two variables are independent can have many implications for the probabilities of given outcomes being observed. You tend to see these two properties (independence and randomness) described together when studying statistics, because both are important to know, and can influence the answer to the question at hand. However, these properties are not synonymous, and in other fields of mathematics they do not necessarily occur together.
Can someone help to explain the difference between independent and random? Variables are used in all fields of mathematics. The definitions for independence and randomness of a variable are applied unilaterally to all forms of mathematics, not just to statistics. For exampl
11,017
Can someone help to explain the difference between independent and random?
When you have a pair of values when the first is randomly generated and the second has any dependence on the first one. e.g. height and weight of a man. There is correlation between them. But they are both random.
Can someone help to explain the difference between independent and random?
When you have a pair of values when the first is randomly generated and the second has any dependence on the first one. e.g. height and weight of a man. There is correlation between them. But they are
Can someone help to explain the difference between independent and random? When you have a pair of values when the first is randomly generated and the second has any dependence on the first one. e.g. height and weight of a man. There is correlation between them. But they are both random.
Can someone help to explain the difference between independent and random? When you have a pair of values when the first is randomly generated and the second has any dependence on the first one. e.g. height and weight of a man. There is correlation between them. But they are
11,018
Can someone help to explain the difference between independent and random?
The coin example is a great illustration of a random and independent variable, a good good way to think of a random but dependent variable would be the next card drawn from a seven deck shoe of playing cards, the -likelihood- of any specific numerical outcome changes depending on the cards previously dealt, but until only one value of card remains in the shoe, the value of the card to come next will remain random.
Can someone help to explain the difference between independent and random?
The coin example is a great illustration of a random and independent variable, a good good way to think of a random but dependent variable would be the next card drawn from a seven deck shoe of playin
Can someone help to explain the difference between independent and random? The coin example is a great illustration of a random and independent variable, a good good way to think of a random but dependent variable would be the next card drawn from a seven deck shoe of playing cards, the -likelihood- of any specific numerical outcome changes depending on the cards previously dealt, but until only one value of card remains in the shoe, the value of the card to come next will remain random.
Can someone help to explain the difference between independent and random? The coin example is a great illustration of a random and independent variable, a good good way to think of a random but dependent variable would be the next card drawn from a seven deck shoe of playin
11,019
Can someone help to explain the difference between independent and random?
David Bohm in his work Causality and Chance in Modern Physics (London: Routledge, 1957/1984) describes causality, chance, randomness, and independence: "In nature nothing remains constant. Everything is in a perpetual state of transformation, motion, and change. However, we discover that nothing simply surges up out of nothing without having antecedents that existed before. Likewise, nothing ever disappears without a trace, in the sense that it gives rise to absolutley nothing existing at later times. .... everything comes from other things and gives rise to other things. This principle is not yet a statement of the existence of causality in nature. To come to causality, the next step is then to note that as we study processes taking place under a wide range of conditions, we discover that inside all of the complexity of change and transformation there are relationships that remain effectively constant. .... At this point, however, we meet a new problem. For the necessity of a causal law is never absolute. Thus, we see that one must conceive of the law of nature as necessary only if one abstracts from contingencies, representing essentially independent factors which may exist outside the scope of things that can be treated by the laws under consideration, and which do not follow necessarily from anything that may be specified under the context of these laws. Such contingencies lead to chance." (pp.1-2) "The tendency for contingencies lying outside a given context to fluctuate independently of happenings inside that context has demonstrated itself to be so widespread that one may enunciate it as a principle; namely, the principle of randomness. By randomness we mean just that this independence leads to fluctuation of these contingencies in a very complicated way over a wide range of possibliities, but in such a manner that statistical averages have a regular and approximately predictable behaviour." (p.22)
Can someone help to explain the difference between independent and random?
David Bohm in his work Causality and Chance in Modern Physics (London: Routledge, 1957/1984) describes causality, chance, randomness, and independence: "In nature nothing remains constant. Everything
Can someone help to explain the difference between independent and random? David Bohm in his work Causality and Chance in Modern Physics (London: Routledge, 1957/1984) describes causality, chance, randomness, and independence: "In nature nothing remains constant. Everything is in a perpetual state of transformation, motion, and change. However, we discover that nothing simply surges up out of nothing without having antecedents that existed before. Likewise, nothing ever disappears without a trace, in the sense that it gives rise to absolutley nothing existing at later times. .... everything comes from other things and gives rise to other things. This principle is not yet a statement of the existence of causality in nature. To come to causality, the next step is then to note that as we study processes taking place under a wide range of conditions, we discover that inside all of the complexity of change and transformation there are relationships that remain effectively constant. .... At this point, however, we meet a new problem. For the necessity of a causal law is never absolute. Thus, we see that one must conceive of the law of nature as necessary only if one abstracts from contingencies, representing essentially independent factors which may exist outside the scope of things that can be treated by the laws under consideration, and which do not follow necessarily from anything that may be specified under the context of these laws. Such contingencies lead to chance." (pp.1-2) "The tendency for contingencies lying outside a given context to fluctuate independently of happenings inside that context has demonstrated itself to be so widespread that one may enunciate it as a principle; namely, the principle of randomness. By randomness we mean just that this independence leads to fluctuation of these contingencies in a very complicated way over a wide range of possibliities, but in such a manner that statistical averages have a regular and approximately predictable behaviour." (p.22)
Can someone help to explain the difference between independent and random? David Bohm in his work Causality and Chance in Modern Physics (London: Routledge, 1957/1984) describes causality, chance, randomness, and independence: "In nature nothing remains constant. Everything
11,020
Hat matrix and leverages in classical multiple regression
The hat matrix, $\bf H$, is the projection matrix that expresses the values of the observations in the independent variable, $\bf y$, in terms of the linear combinations of the column vectors of the model matrix, $\bf X$, which contains the observations for each of the multiple variables you are regressing on. Naturally, $\bf y$ will typically not lie in the column space of $\bf X$ and there will be a difference between this projection, $\bf \hat Y$, and the actual values of $\bf Y$. This difference is the residual or $\bf \varepsilon=Y-X\beta$: The estimated coefficients, $\bf \hat\beta_i$ are geometrically understood as the linear combination of the column vectors (observations on variables $\bf x_i$) necessary to produce the projected vector $\bf \hat Y$. We have that $\bf H\,Y = \hat Y$; hence the mnemonic, "the H puts the hat on the y." The hat matrix is calculated as: $\bf H = X (X^TX)^{-1}X^T$. And the estimated $\bf \hat\beta_i$ coefficients will naturally be calculated as $\bf (X^TX)^{-1}X^T Y$. Each point of the data set tries to pull the ordinary least squares (OLS) line towards itself. However, the points farther away at the extreme of the regressor values will have more leverage. Here is an example of an extremely asymptotic point (in red) really pulling the regression line away from what would be a more logical fit: So, where is the connection between these two concepts: The leverage score of a particular row or observation in the dataset will be found in the corresponding entry in the diagonal of the hat matrix. So for observation $i$ the leverage score will be found in $\bf H_{ii}$. This entry in the hat matrix will have a direct influence on the way entry $y_i$ will result in $\hat y_i$ ( high-leverage of the $i\text{-th}$ observation $y_i$ in determining its own prediction value $\hat y_i$): Since the hat matrix is a projection matrix, its eigenvalues are $0$ and $1$. It follows then that the trace (sum of diagonal elements - in this case sum of $1$'s) will be the rank of the column space, while there'll be as many zeros as the dimension of the null space. Hence, the values in the diagonal of the hat matrix will be less than one (trace = sum eigenvalues), and an entry will be considered to have high leverage if $>2\sum_{i=1}^{n}h_{ii}/n$ with $n$ being the number of rows. The leverage of an outlier data point in the model matrix can also be manually calculated as one minus the ratio of the residual for the outlier when the actual outlier is included in the OLS model over the residual for the same point when the fitted curve is calculated without including the row corresponding to the outlier: $$Leverage = 1-\frac{\text{residual OLS with outlier}}{\text{residual OLS without outlier}}$$ In R the function hatvalues() returns this values for every point. Using the first data point in the dataset {mtcars} in R: fit = lm(mpg ~ wt, mtcars) # OLS including all points X = model.matrix(fit) # X model matrix hat_matrix = X%*%(solve(t(X)%*%X)%*%t(X)) # Hat matrix diag(hat_matrix)[1] # First diagonal point in Hat matrix fitwithout1 = lm(mpg ~ wt, mtcars[-1,]) # OLS excluding first data point. new = data.frame(wt=mtcars[1,'wt']) # Predicting y hat in this OLS w/o first point. y_hat_without = predict(fitwithout1, newdata=new) # ... here it is. residuals(fit)[1] # The residual when OLS includes data point. lev = 1 - (residuals(fit)[1]/(mtcars[1,'mpg'] - y_hat_without)) # Leverage all.equal(diag(hat_matrix)[1],lev) #TRUE
Hat matrix and leverages in classical multiple regression
The hat matrix, $\bf H$, is the projection matrix that expresses the values of the observations in the independent variable, $\bf y$, in terms of the linear combinations of the column vectors of the m
Hat matrix and leverages in classical multiple regression The hat matrix, $\bf H$, is the projection matrix that expresses the values of the observations in the independent variable, $\bf y$, in terms of the linear combinations of the column vectors of the model matrix, $\bf X$, which contains the observations for each of the multiple variables you are regressing on. Naturally, $\bf y$ will typically not lie in the column space of $\bf X$ and there will be a difference between this projection, $\bf \hat Y$, and the actual values of $\bf Y$. This difference is the residual or $\bf \varepsilon=Y-X\beta$: The estimated coefficients, $\bf \hat\beta_i$ are geometrically understood as the linear combination of the column vectors (observations on variables $\bf x_i$) necessary to produce the projected vector $\bf \hat Y$. We have that $\bf H\,Y = \hat Y$; hence the mnemonic, "the H puts the hat on the y." The hat matrix is calculated as: $\bf H = X (X^TX)^{-1}X^T$. And the estimated $\bf \hat\beta_i$ coefficients will naturally be calculated as $\bf (X^TX)^{-1}X^T Y$. Each point of the data set tries to pull the ordinary least squares (OLS) line towards itself. However, the points farther away at the extreme of the regressor values will have more leverage. Here is an example of an extremely asymptotic point (in red) really pulling the regression line away from what would be a more logical fit: So, where is the connection between these two concepts: The leverage score of a particular row or observation in the dataset will be found in the corresponding entry in the diagonal of the hat matrix. So for observation $i$ the leverage score will be found in $\bf H_{ii}$. This entry in the hat matrix will have a direct influence on the way entry $y_i$ will result in $\hat y_i$ ( high-leverage of the $i\text{-th}$ observation $y_i$ in determining its own prediction value $\hat y_i$): Since the hat matrix is a projection matrix, its eigenvalues are $0$ and $1$. It follows then that the trace (sum of diagonal elements - in this case sum of $1$'s) will be the rank of the column space, while there'll be as many zeros as the dimension of the null space. Hence, the values in the diagonal of the hat matrix will be less than one (trace = sum eigenvalues), and an entry will be considered to have high leverage if $>2\sum_{i=1}^{n}h_{ii}/n$ with $n$ being the number of rows. The leverage of an outlier data point in the model matrix can also be manually calculated as one minus the ratio of the residual for the outlier when the actual outlier is included in the OLS model over the residual for the same point when the fitted curve is calculated without including the row corresponding to the outlier: $$Leverage = 1-\frac{\text{residual OLS with outlier}}{\text{residual OLS without outlier}}$$ In R the function hatvalues() returns this values for every point. Using the first data point in the dataset {mtcars} in R: fit = lm(mpg ~ wt, mtcars) # OLS including all points X = model.matrix(fit) # X model matrix hat_matrix = X%*%(solve(t(X)%*%X)%*%t(X)) # Hat matrix diag(hat_matrix)[1] # First diagonal point in Hat matrix fitwithout1 = lm(mpg ~ wt, mtcars[-1,]) # OLS excluding first data point. new = data.frame(wt=mtcars[1,'wt']) # Predicting y hat in this OLS w/o first point. y_hat_without = predict(fitwithout1, newdata=new) # ... here it is. residuals(fit)[1] # The residual when OLS includes data point. lev = 1 - (residuals(fit)[1]/(mtcars[1,'mpg'] - y_hat_without)) # Leverage all.equal(diag(hat_matrix)[1],lev) #TRUE
Hat matrix and leverages in classical multiple regression The hat matrix, $\bf H$, is the projection matrix that expresses the values of the observations in the independent variable, $\bf y$, in terms of the linear combinations of the column vectors of the m
11,021
How to specify a lognormal distribution in the glm family argument in R?
The gamlss package allows you to fit generalized additive models with both lognormal and exponential distributions, and a bunch of others, with some variety in link functions and using, if you wish, semi- or non-parametric models based on penalized splines. It's got some papers published on the algorithms used and documentation and examples linked to the site I've linked to.
How to specify a lognormal distribution in the glm family argument in R?
The gamlss package allows you to fit generalized additive models with both lognormal and exponential distributions, and a bunch of others, with some variety in link functions and using, if you wish, s
How to specify a lognormal distribution in the glm family argument in R? The gamlss package allows you to fit generalized additive models with both lognormal and exponential distributions, and a bunch of others, with some variety in link functions and using, if you wish, semi- or non-parametric models based on penalized splines. It's got some papers published on the algorithms used and documentation and examples linked to the site I've linked to.
How to specify a lognormal distribution in the glm family argument in R? The gamlss package allows you to fit generalized additive models with both lognormal and exponential distributions, and a bunch of others, with some variety in link functions and using, if you wish, s
11,022
How to specify a lognormal distribution in the glm family argument in R?
Fitting a log-normal GLM has nothing to do with the distribution nor the link option of the glm() function. The term "log-normal" is quite confusing in this sense, but means that the response variable is normally distributed (family=gaussian), and a transformation is applied to this variable the following way: log.glm <- glm(log(y)~x, family=gaussian, data=my.dat) However, when comparing this log-normal glm with other glms using different distribution (e.g., gamma), the AIC() function should be corrected. Would anyone know an alternative to these erroneous AIC(), in this case?
How to specify a lognormal distribution in the glm family argument in R?
Fitting a log-normal GLM has nothing to do with the distribution nor the link option of the glm() function. The term "log-normal" is quite confusing in this sense, but means that the response variable
How to specify a lognormal distribution in the glm family argument in R? Fitting a log-normal GLM has nothing to do with the distribution nor the link option of the glm() function. The term "log-normal" is quite confusing in this sense, but means that the response variable is normally distributed (family=gaussian), and a transformation is applied to this variable the following way: log.glm <- glm(log(y)~x, family=gaussian, data=my.dat) However, when comparing this log-normal glm with other glms using different distribution (e.g., gamma), the AIC() function should be corrected. Would anyone know an alternative to these erroneous AIC(), in this case?
How to specify a lognormal distribution in the glm family argument in R? Fitting a log-normal GLM has nothing to do with the distribution nor the link option of the glm() function. The term "log-normal" is quite confusing in this sense, but means that the response variable
11,023
How to specify a lognormal distribution in the glm family argument in R?
Lognormal is not an option because the log-normal distribution is not in the exponential family of distributions. Generalized linear models can only fit distributions from the exponential family. I'm less clear why exponential is not an option, as the exponential distribution is in the exponential family (as you might hope). Other statistical software with which I am familiar allows fitting the exponential distribution as a GLM by treating it as a special case of the Gamma distribution with shape (aka scale or dispersion) parameter fixed at 1 rather than estimated. I can't see a way of fixing this parameter using R's glm() function, however. One alternative would be to use the survreg() function from the survival package with dist="exponential". If you have response data $y$ that you believe follows a lognormal distribution, the usual way of fitting a regression model to it would be to log-transform it, as $\log(y)$ will have a normal distribution. The simplest case is then to fit an ordinary (i.e. not generalized) linear model. The resulting model is not quite the same model you would get if you could fit a GLM with a log link, however, as $\operatorname{E}(\log(Y)) \ne \log(\operatorname{E}(Y)).$
How to specify a lognormal distribution in the glm family argument in R?
Lognormal is not an option because the log-normal distribution is not in the exponential family of distributions. Generalized linear models can only fit distributions from the exponential family. I'm
How to specify a lognormal distribution in the glm family argument in R? Lognormal is not an option because the log-normal distribution is not in the exponential family of distributions. Generalized linear models can only fit distributions from the exponential family. I'm less clear why exponential is not an option, as the exponential distribution is in the exponential family (as you might hope). Other statistical software with which I am familiar allows fitting the exponential distribution as a GLM by treating it as a special case of the Gamma distribution with shape (aka scale or dispersion) parameter fixed at 1 rather than estimated. I can't see a way of fixing this parameter using R's glm() function, however. One alternative would be to use the survreg() function from the survival package with dist="exponential". If you have response data $y$ that you believe follows a lognormal distribution, the usual way of fitting a regression model to it would be to log-transform it, as $\log(y)$ will have a normal distribution. The simplest case is then to fit an ordinary (i.e. not generalized) linear model. The resulting model is not quite the same model you would get if you could fit a GLM with a log link, however, as $\operatorname{E}(\log(Y)) \ne \log(\operatorname{E}(Y)).$
How to specify a lognormal distribution in the glm family argument in R? Lognormal is not an option because the log-normal distribution is not in the exponential family of distributions. Generalized linear models can only fit distributions from the exponential family. I'm
11,024
How to specify a lognormal distribution in the glm family argument in R?
Regarding fitting the exponential model with glm: When using the glm function with family=Gamma one needs to also use the supporting facilities of summary.glm in order to fix the dispersion parameter to 1: ?summary.glm fit <- glm(formula =..., family = Gamma) summary(fit,dispersion=1) And as I was going to point out but jbowman beat me to it, the "gamlss" package(s) provides for log-normal fitting: help(dLOGNO, package=gamlss.dist)
How to specify a lognormal distribution in the glm family argument in R?
Regarding fitting the exponential model with glm: When using the glm function with family=Gamma one needs to also use the supporting facilities of summary.glm in order to fix the dispersion parameter
How to specify a lognormal distribution in the glm family argument in R? Regarding fitting the exponential model with glm: When using the glm function with family=Gamma one needs to also use the supporting facilities of summary.glm in order to fix the dispersion parameter to 1: ?summary.glm fit <- glm(formula =..., family = Gamma) summary(fit,dispersion=1) And as I was going to point out but jbowman beat me to it, the "gamlss" package(s) provides for log-normal fitting: help(dLOGNO, package=gamlss.dist)
How to specify a lognormal distribution in the glm family argument in R? Regarding fitting the exponential model with glm: When using the glm function with family=Gamma one needs to also use the supporting facilities of summary.glm in order to fix the dispersion parameter
11,025
How to specify a lognormal distribution in the glm family argument in R?
Try using the following command: log.glm = glm(y ~ x, family=gaussian(link="log"), data=my.dat) It works here and the AIC seems to be correct.
How to specify a lognormal distribution in the glm family argument in R?
Try using the following command: log.glm = glm(y ~ x, family=gaussian(link="log"), data=my.dat) It works here and the AIC seems to be correct.
How to specify a lognormal distribution in the glm family argument in R? Try using the following command: log.glm = glm(y ~ x, family=gaussian(link="log"), data=my.dat) It works here and the AIC seems to be correct.
How to specify a lognormal distribution in the glm family argument in R? Try using the following command: log.glm = glm(y ~ x, family=gaussian(link="log"), data=my.dat) It works here and the AIC seems to be correct.
11,026
Can mean plus one standard deviation exceed maximum value?
Certainly the mean plus one sd can exceed the largest observation. Consider the sample 1, 5, 5, 5 - it has mean 4 and standard deviation 2, so the mean + sd is 6, one more than the sample maximum. Here's the calculation in R: > x=c(1,5,5,5) > mean(x)+sd(x) [1] 6 It's a common occurrence. It tends to happen when there's a bunch of high values and a tail off to the left (i.e. when there's strong left skewness and a peak near the maximum). -- The same possibility applies to probability distributions, not just samples - the population mean plus the population sd can easily exceed the maximum possible value. Here's an example of a $\text{beta}(10,\frac{1}{2})$ density, which has a maximum possible value of 1: In this case, we can look at the Wikipedia page for the beta distribution, which states that the mean is: $\operatorname{E}[X] = \frac{\alpha}{\alpha+\beta}\!$ and the variance is: $\operatorname{var}[X] = \frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)}\!$ (Though we needn't rely on Wikipedia, since they're pretty easy to derive.) So for $\alpha=10$ and $\beta=\frac{1}{2}$ we have mean$\approx 0.9523$ and sd$\approx 0.0628$, so mean+sd$\approx 1.0152$, more than the possible maximum of 1. That is, it's easily possible to have a value of mean+sd large enough that it cannot be observed as a data value. -- For any situation where the mode was at the maximum, the Pearson mode skewness need only be $<\,-1$ for mean+sd to exceed the maximum, an easily satisfied condition. -- A closely related issue is often seen with confidence intervals for a binomial proportion, where a commonly used interval, the normal approximation interval can produce limits outside $[0,1]$. For example, consider a 95.4% normal approximation interval for the population proportion of successes in Bernoulli trials (outcomes are 1 or 0 representing success and failure events respectively), where 3 of 4 observations are "$1$" and one observation is "$0$". Then the upper limit for the interval is $\hat p + 2 \times \sqrt{\frac{1}{4}\hat p \left(1 - \hat p \right)} = \hat p + \sqrt{\hat p (1 - \hat p )} = 0.75 + 0.433=1.183$ This is just the sample mean + the usual estimate of the sd for the binomial ... and produces an impossible value. The usual sample sd for 0,1,1,1 is 0.5 rather than 0.433 (they differ because the binomial ML estimate of the standard deviation $\hat p(1-\hat p)$ corresponds to dividing the variance by $n$ rather than $n-1$). But it makes no difference - in either case, mean + sd exceeds the largest possible proportion. This fact - that a normal approximation interval for the binomial can produce "impossible values" is often noted in books and papers. However, you're not dealing with binomial data. Nevertheless the problem - that mean + some number of standard deviations is not a possible value - is analogous. -- In your case, the unusual "0" value in your sample is making the sd large more than it pulls the mean down, which is why the mean+sd is high. -- (The question would instead be - by what reasoning would it be impossible? -- because without knowing why anyone would think there's a problem at all, what do we address?) Logically of course, one demonstrates it's possible by giving an example where it happens. You've done that already. In the absence of a stated reason why it should be otherwise, what are you to do? If an example isn't sufficient, what proof would be acceptable? There's really no point simply pointing to a statement in a book, since any book may make a statement in error - I see them all the time. One must rely on direct demonstration that it's possible, either a proof in algebra (one could be constructed from the beta example above for example*) or by numerical example (which you have already given), which anyone can examine the truth of for themselves. * whuber gives the precise conditions for the beta case in comments.
Can mean plus one standard deviation exceed maximum value?
Certainly the mean plus one sd can exceed the largest observation. Consider the sample 1, 5, 5, 5 - it has mean 4 and standard deviation 2, so the mean + sd is 6, one more than the sample maximum. He
Can mean plus one standard deviation exceed maximum value? Certainly the mean plus one sd can exceed the largest observation. Consider the sample 1, 5, 5, 5 - it has mean 4 and standard deviation 2, so the mean + sd is 6, one more than the sample maximum. Here's the calculation in R: > x=c(1,5,5,5) > mean(x)+sd(x) [1] 6 It's a common occurrence. It tends to happen when there's a bunch of high values and a tail off to the left (i.e. when there's strong left skewness and a peak near the maximum). -- The same possibility applies to probability distributions, not just samples - the population mean plus the population sd can easily exceed the maximum possible value. Here's an example of a $\text{beta}(10,\frac{1}{2})$ density, which has a maximum possible value of 1: In this case, we can look at the Wikipedia page for the beta distribution, which states that the mean is: $\operatorname{E}[X] = \frac{\alpha}{\alpha+\beta}\!$ and the variance is: $\operatorname{var}[X] = \frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)}\!$ (Though we needn't rely on Wikipedia, since they're pretty easy to derive.) So for $\alpha=10$ and $\beta=\frac{1}{2}$ we have mean$\approx 0.9523$ and sd$\approx 0.0628$, so mean+sd$\approx 1.0152$, more than the possible maximum of 1. That is, it's easily possible to have a value of mean+sd large enough that it cannot be observed as a data value. -- For any situation where the mode was at the maximum, the Pearson mode skewness need only be $<\,-1$ for mean+sd to exceed the maximum, an easily satisfied condition. -- A closely related issue is often seen with confidence intervals for a binomial proportion, where a commonly used interval, the normal approximation interval can produce limits outside $[0,1]$. For example, consider a 95.4% normal approximation interval for the population proportion of successes in Bernoulli trials (outcomes are 1 or 0 representing success and failure events respectively), where 3 of 4 observations are "$1$" and one observation is "$0$". Then the upper limit for the interval is $\hat p + 2 \times \sqrt{\frac{1}{4}\hat p \left(1 - \hat p \right)} = \hat p + \sqrt{\hat p (1 - \hat p )} = 0.75 + 0.433=1.183$ This is just the sample mean + the usual estimate of the sd for the binomial ... and produces an impossible value. The usual sample sd for 0,1,1,1 is 0.5 rather than 0.433 (they differ because the binomial ML estimate of the standard deviation $\hat p(1-\hat p)$ corresponds to dividing the variance by $n$ rather than $n-1$). But it makes no difference - in either case, mean + sd exceeds the largest possible proportion. This fact - that a normal approximation interval for the binomial can produce "impossible values" is often noted in books and papers. However, you're not dealing with binomial data. Nevertheless the problem - that mean + some number of standard deviations is not a possible value - is analogous. -- In your case, the unusual "0" value in your sample is making the sd large more than it pulls the mean down, which is why the mean+sd is high. -- (The question would instead be - by what reasoning would it be impossible? -- because without knowing why anyone would think there's a problem at all, what do we address?) Logically of course, one demonstrates it's possible by giving an example where it happens. You've done that already. In the absence of a stated reason why it should be otherwise, what are you to do? If an example isn't sufficient, what proof would be acceptable? There's really no point simply pointing to a statement in a book, since any book may make a statement in error - I see them all the time. One must rely on direct demonstration that it's possible, either a proof in algebra (one could be constructed from the beta example above for example*) or by numerical example (which you have already given), which anyone can examine the truth of for themselves. * whuber gives the precise conditions for the beta case in comments.
Can mean plus one standard deviation exceed maximum value? Certainly the mean plus one sd can exceed the largest observation. Consider the sample 1, 5, 5, 5 - it has mean 4 and standard deviation 2, so the mean + sd is 6, one more than the sample maximum. He
11,027
Can mean plus one standard deviation exceed maximum value?
Per Chebyshev's inequality, less than k -2 points can be more than k standard deviations away. So, for k=1 that means less than 100% of your samples can be more than one standard deviation away. It's more interesting to look at the low bound. Your professor should be more surprised there are points which are about 2.5 standard deviations below mean. But we now know that only about 1/6th of your samples can be 0.
Can mean plus one standard deviation exceed maximum value?
Per Chebyshev's inequality, less than k -2 points can be more than k standard deviations away. So, for k=1 that means less than 100% of your samples can be more than one standard deviation away. It's
Can mean plus one standard deviation exceed maximum value? Per Chebyshev's inequality, less than k -2 points can be more than k standard deviations away. So, for k=1 that means less than 100% of your samples can be more than one standard deviation away. It's more interesting to look at the low bound. Your professor should be more surprised there are points which are about 2.5 standard deviations below mean. But we now know that only about 1/6th of your samples can be 0.
Can mean plus one standard deviation exceed maximum value? Per Chebyshev's inequality, less than k -2 points can be more than k standard deviations away. So, for k=1 that means less than 100% of your samples can be more than one standard deviation away. It's
11,028
Can mean plus one standard deviation exceed maximum value?
In general for the Bernoulli random variable $X$, that takes the value $1$ with probability $0<p<1$ and the value $0$ with probability $1-p$, we have $$E(X) = p,\;\; SE(X) = \sqrt {p(1-p)}$$ And we want $$E(X)+ SE(X) > 1 \Rightarrow p +\sqrt {p(1-p)} >1$$ $$\Rightarrow \sqrt {p(1-p)} > (1-p)$$ Square both sides to obtain $$p(1-p) > (1-p)^2 \Rightarrow p > 1-p \Rightarrow p > \frac 12$$ In words, for any Bernoulli random variable with $p>1/2$ the theoretical expression $E(X)+ SE(X) > \max X$ holds. So for example, for any i.i.d. sample drawn from a Bernoulli with, say, $p=0.7$, in most cases the sample mean plus the sample standard deviation will exceed the value $1$, which will be the maximum value observed (bar the case of an all-zeros sample!). For other distributions we always have the opposite direction in the inequality, e.g. for a Uniform $U(a,b)$, it is always the case that $E(U)+ SE(U) < \max U=b$. Therefore, no general rule exists.
Can mean plus one standard deviation exceed maximum value?
In general for the Bernoulli random variable $X$, that takes the value $1$ with probability $0<p<1$ and the value $0$ with probability $1-p$, we have $$E(X) = p,\;\; SE(X) = \sqrt {p(1-p)}$$ And we wa
Can mean plus one standard deviation exceed maximum value? In general for the Bernoulli random variable $X$, that takes the value $1$ with probability $0<p<1$ and the value $0$ with probability $1-p$, we have $$E(X) = p,\;\; SE(X) = \sqrt {p(1-p)}$$ And we want $$E(X)+ SE(X) > 1 \Rightarrow p +\sqrt {p(1-p)} >1$$ $$\Rightarrow \sqrt {p(1-p)} > (1-p)$$ Square both sides to obtain $$p(1-p) > (1-p)^2 \Rightarrow p > 1-p \Rightarrow p > \frac 12$$ In words, for any Bernoulli random variable with $p>1/2$ the theoretical expression $E(X)+ SE(X) > \max X$ holds. So for example, for any i.i.d. sample drawn from a Bernoulli with, say, $p=0.7$, in most cases the sample mean plus the sample standard deviation will exceed the value $1$, which will be the maximum value observed (bar the case of an all-zeros sample!). For other distributions we always have the opposite direction in the inequality, e.g. for a Uniform $U(a,b)$, it is always the case that $E(U)+ SE(U) < \max U=b$. Therefore, no general rule exists.
Can mean plus one standard deviation exceed maximum value? In general for the Bernoulli random variable $X$, that takes the value $1$ with probability $0<p<1$ and the value $0$ with probability $1-p$, we have $$E(X) = p,\;\; SE(X) = \sqrt {p(1-p)}$$ And we wa
11,029
Can mean plus one standard deviation exceed maximum value?
The essence of the problem may be that your distribution is not a normal distribution which a standard deviation assumes. Your distribution is likely left skewed, so you need to transform your set into a normal distribution first by picking a suitable transform function, this process is called transformation to normality. One such function candidate in your case might be a mirrored log transform. Once your set satisfies a normality test you may then take the standard deviation. Then to use your 1$\sigma$ or 2$\sigma$ values you must transform them back into your original data space using the inverse of your transform function. I'm thinking this is what your professor was hinting at.
Can mean plus one standard deviation exceed maximum value?
The essence of the problem may be that your distribution is not a normal distribution which a standard deviation assumes. Your distribution is likely left skewed, so you need to transform your set in
Can mean plus one standard deviation exceed maximum value? The essence of the problem may be that your distribution is not a normal distribution which a standard deviation assumes. Your distribution is likely left skewed, so you need to transform your set into a normal distribution first by picking a suitable transform function, this process is called transformation to normality. One such function candidate in your case might be a mirrored log transform. Once your set satisfies a normality test you may then take the standard deviation. Then to use your 1$\sigma$ or 2$\sigma$ values you must transform them back into your original data space using the inverse of your transform function. I'm thinking this is what your professor was hinting at.
Can mean plus one standard deviation exceed maximum value? The essence of the problem may be that your distribution is not a normal distribution which a standard deviation assumes. Your distribution is likely left skewed, so you need to transform your set in
11,030
Can mean plus one standard deviation exceed maximum value?
It is quite common that people (including your professor) make this mistake. People often do calculations assuming that one has a large sample of an ideal normal distribution. At a certain moment they start thinking that alle and everything in life shows a normal distribution. That is not true! Especially when a distribution is not symmetric one then gets unexpected results. People also tend to forget that in small populations (/small colletions of numbers) never have a normal distribution. It only starts to come close to a normal distribution if both the number of samples is high, and if indeed the underlaying phenomena cause the distribution to be pure and normal.
Can mean plus one standard deviation exceed maximum value?
It is quite common that people (including your professor) make this mistake. People often do calculations assuming that one has a large sample of an ideal normal distribution. At a certain moment they
Can mean plus one standard deviation exceed maximum value? It is quite common that people (including your professor) make this mistake. People often do calculations assuming that one has a large sample of an ideal normal distribution. At a certain moment they start thinking that alle and everything in life shows a normal distribution. That is not true! Especially when a distribution is not symmetric one then gets unexpected results. People also tend to forget that in small populations (/small colletions of numbers) never have a normal distribution. It only starts to come close to a normal distribution if both the number of samples is high, and if indeed the underlaying phenomena cause the distribution to be pure and normal.
Can mean plus one standard deviation exceed maximum value? It is quite common that people (including your professor) make this mistake. People often do calculations assuming that one has a large sample of an ideal normal distribution. At a certain moment they
11,031
Can mean plus one standard deviation exceed maximum value?
I would like to emphasise with this answer why I think people think of the normal distribution when the subject of standard deviation comes up, like other people have already mentioned in other answers for this question. For a lot of people, indeed the first thing that comes to mind when they think of standard deviation is the figure below (or one variant of it): The two sections in dark below are, as you can see in the x-axis legend, one standard deviation to the right or to the left of the mean, which is zero here. When someone else mentions that one standard deviation from the mean can be outside the range of of values of this distribution mean(X)+sd(X) > max(X) (in R code), naturally they freeze. How come!? Maybe your professor went to R and did something like: set.seed(2021) N <- 10000 X <- rnorm(n=N, mean=74.10, sd=33.44) mean(X)+sd(X) > max(X) This returns false, but if you check, the max/min values do not match yours. What I did was to generate a normal distribution, as one can see in the plot below. library(ggplot2) ggplot() + aes(X) + geom_histogram(binwidth=1) Many people are introduced to the concepts of normal distributions, or standard deviations, with a figure like the first one. You can easily generate some distributions that will have the mean+sd outside the range of values in a distribution, as many other colleagues have answered in this post, to at least prove it is possible. As you've probably already heard, looking at a scatter plot or histogram of your data usually helps a lot. If your professor had had a look at the histogram of your data, I think s/he would be at least a bit more inclined to accept the idea :-)
Can mean plus one standard deviation exceed maximum value?
I would like to emphasise with this answer why I think people think of the normal distribution when the subject of standard deviation comes up, like other people have already mentioned in other answer
Can mean plus one standard deviation exceed maximum value? I would like to emphasise with this answer why I think people think of the normal distribution when the subject of standard deviation comes up, like other people have already mentioned in other answers for this question. For a lot of people, indeed the first thing that comes to mind when they think of standard deviation is the figure below (or one variant of it): The two sections in dark below are, as you can see in the x-axis legend, one standard deviation to the right or to the left of the mean, which is zero here. When someone else mentions that one standard deviation from the mean can be outside the range of of values of this distribution mean(X)+sd(X) > max(X) (in R code), naturally they freeze. How come!? Maybe your professor went to R and did something like: set.seed(2021) N <- 10000 X <- rnorm(n=N, mean=74.10, sd=33.44) mean(X)+sd(X) > max(X) This returns false, but if you check, the max/min values do not match yours. What I did was to generate a normal distribution, as one can see in the plot below. library(ggplot2) ggplot() + aes(X) + geom_histogram(binwidth=1) Many people are introduced to the concepts of normal distributions, or standard deviations, with a figure like the first one. You can easily generate some distributions that will have the mean+sd outside the range of values in a distribution, as many other colleagues have answered in this post, to at least prove it is possible. As you've probably already heard, looking at a scatter plot or histogram of your data usually helps a lot. If your professor had had a look at the histogram of your data, I think s/he would be at least a bit more inclined to accept the idea :-)
Can mean plus one standard deviation exceed maximum value? I would like to emphasise with this answer why I think people think of the normal distribution when the subject of standard deviation comes up, like other people have already mentioned in other answer
11,032
Benefits of using QQ-plots over histograms
The canonical paper here was: Wilk, M.B. and R. Gnanadesikan. 1968. Probability plotting methods for the analysis of data. Biometrika 55: 1-17 and it still repays close and repeated reading. A lucid treatment with many good examples was given by: Cleveland, W.S. 1993. Visualizing Data. Summit, NJ: Hobart Press. and it is worth mentioning the more introductory: Cleveland, W.S. 1994. The Elements of Graphing Data. Summit, NJ: Hobart Press. Other texts containing reasonable exposure to this approach include: Davison, A.C. 2003. Statistical Models. Cambridge: Cambridge University Press. Rice, J.A. 2007. Mathematical Statistics and Data Analysis. Belmont, CA: Duxbury. That aside, I don't know of anything that is quite what you ask. Once you have seen the point of quantile-quantile plots, showing in detail that histograms are a second-rate alternative seems neither interesting nor useful, too much like shooting fish in a barrel. But I would summarize like this: Binning suppresses details, and the details are often important. This can apply not only to exactly what is going on in the tails but also to what is going on in the middle. For example, granularity or multimodality may be important as well as skewness or tail weight. Binning requires decisions about bin origin and bin width, which can affect the appearance of histograms mightily, so it is hard to see what is real and what is a side-effect of choices. If your software makes these decisions for you, the problems remain. (For example, default bin choices are often designed so that you do not use "too many bins", i.e. with the motive of smoothing a little.) The graphical and psychological problem of comparing two histograms is trickier than that of judging the fit of a set of points to a straight line. [Added 27 Sept 2017] 4. Quantile plots can be varied very easily when considering one or more transformed scales. By transformation here I mean a nonlinear transformation, not e.g. scaling by a maximum or standardisation by (value $-$ mean) / SD. If the quantiles are just the order statistics, then all you need to do is to apply the transformation, as e.g. the logarithm of the maximum is identically the maximum of the logarithms, and so forth. (Trivially, reciprocation reverses order.) Even if you plot selected quantiles that are based on two order statistics, usually they are just interpolated between two original data values and the effect of the interpolation is usually minor. In contrast, histograms on log or other transformed scales require a fresh decision on bin origin and width that isn't especially difficult, but it can be awkward. Much the same can be said of density estimation as a way to summarize the distribution. Naturally, whatever transformation you apply must make sense for the data, so that logarithms can only usefully be applied for a positive variable.
Benefits of using QQ-plots over histograms
The canonical paper here was: Wilk, M.B. and R. Gnanadesikan. 1968. Probability plotting methods for the analysis of data. Biometrika 55: 1-17 and it still repays close and repeated reading. A lucid
Benefits of using QQ-plots over histograms The canonical paper here was: Wilk, M.B. and R. Gnanadesikan. 1968. Probability plotting methods for the analysis of data. Biometrika 55: 1-17 and it still repays close and repeated reading. A lucid treatment with many good examples was given by: Cleveland, W.S. 1993. Visualizing Data. Summit, NJ: Hobart Press. and it is worth mentioning the more introductory: Cleveland, W.S. 1994. The Elements of Graphing Data. Summit, NJ: Hobart Press. Other texts containing reasonable exposure to this approach include: Davison, A.C. 2003. Statistical Models. Cambridge: Cambridge University Press. Rice, J.A. 2007. Mathematical Statistics and Data Analysis. Belmont, CA: Duxbury. That aside, I don't know of anything that is quite what you ask. Once you have seen the point of quantile-quantile plots, showing in detail that histograms are a second-rate alternative seems neither interesting nor useful, too much like shooting fish in a barrel. But I would summarize like this: Binning suppresses details, and the details are often important. This can apply not only to exactly what is going on in the tails but also to what is going on in the middle. For example, granularity or multimodality may be important as well as skewness or tail weight. Binning requires decisions about bin origin and bin width, which can affect the appearance of histograms mightily, so it is hard to see what is real and what is a side-effect of choices. If your software makes these decisions for you, the problems remain. (For example, default bin choices are often designed so that you do not use "too many bins", i.e. with the motive of smoothing a little.) The graphical and psychological problem of comparing two histograms is trickier than that of judging the fit of a set of points to a straight line. [Added 27 Sept 2017] 4. Quantile plots can be varied very easily when considering one or more transformed scales. By transformation here I mean a nonlinear transformation, not e.g. scaling by a maximum or standardisation by (value $-$ mean) / SD. If the quantiles are just the order statistics, then all you need to do is to apply the transformation, as e.g. the logarithm of the maximum is identically the maximum of the logarithms, and so forth. (Trivially, reciprocation reverses order.) Even if you plot selected quantiles that are based on two order statistics, usually they are just interpolated between two original data values and the effect of the interpolation is usually minor. In contrast, histograms on log or other transformed scales require a fresh decision on bin origin and width that isn't especially difficult, but it can be awkward. Much the same can be said of density estimation as a way to summarize the distribution. Naturally, whatever transformation you apply must make sense for the data, so that logarithms can only usefully be applied for a positive variable.
Benefits of using QQ-plots over histograms The canonical paper here was: Wilk, M.B. and R. Gnanadesikan. 1968. Probability plotting methods for the analysis of data. Biometrika 55: 1-17 and it still repays close and repeated reading. A lucid
11,033
Benefits of using QQ-plots over histograms
See the work of William S. Cleveland. Visualizing data is probably the best single source, but also see his web page, especially the bibliography and the page for Visualizing Data (including S+ code that is adaptable for use in R). Cleveland has a lot of reasons why QQ plots are good and why histograms are not so good.
Benefits of using QQ-plots over histograms
See the work of William S. Cleveland. Visualizing data is probably the best single source, but also see his web page, especially the bibliography and the page for Visualizing Data (including S+ code
Benefits of using QQ-plots over histograms See the work of William S. Cleveland. Visualizing data is probably the best single source, but also see his web page, especially the bibliography and the page for Visualizing Data (including S+ code that is adaptable for use in R). Cleveland has a lot of reasons why QQ plots are good and why histograms are not so good.
Benefits of using QQ-plots over histograms See the work of William S. Cleveland. Visualizing data is probably the best single source, but also see his web page, especially the bibliography and the page for Visualizing Data (including S+ code
11,034
Benefits of using QQ-plots over histograms
Once you learn how to use them, Q-Q plots allow you to identify skewness, heavytailedness, general shape, peaks and so on, the same kinds of features people tend to use histograms to try to assess. Kernel density estimates or log-spline density estimates can avoid some of the issues with histograms that Gala pointed to in comments. Consider this example from that link: However, unless you're very lucky, unsuspected discreteness can sometimes be missed with a histogram, and even with the smooth density estimates (because they smooth, naturally), but will often be obvious on Q-Q plots. Smooth density estimates - unless treated specially - can also have trouble with bounded variables. Histograms and smooth density estimates both rely on an approximation to the data -- which can be useful -- but may also introduce artifacts or somewhat misrepresent things.
Benefits of using QQ-plots over histograms
Once you learn how to use them, Q-Q plots allow you to identify skewness, heavytailedness, general shape, peaks and so on, the same kinds of features people tend to use histograms to try to assess. Ke
Benefits of using QQ-plots over histograms Once you learn how to use them, Q-Q plots allow you to identify skewness, heavytailedness, general shape, peaks and so on, the same kinds of features people tend to use histograms to try to assess. Kernel density estimates or log-spline density estimates can avoid some of the issues with histograms that Gala pointed to in comments. Consider this example from that link: However, unless you're very lucky, unsuspected discreteness can sometimes be missed with a histogram, and even with the smooth density estimates (because they smooth, naturally), but will often be obvious on Q-Q plots. Smooth density estimates - unless treated specially - can also have trouble with bounded variables. Histograms and smooth density estimates both rely on an approximation to the data -- which can be useful -- but may also introduce artifacts or somewhat misrepresent things.
Benefits of using QQ-plots over histograms Once you learn how to use them, Q-Q plots allow you to identify skewness, heavytailedness, general shape, peaks and so on, the same kinds of features people tend to use histograms to try to assess. Ke
11,035
Benefits of using QQ-plots over histograms
Since this question has returned to the top... I see many arguments against histograms in favour of qqplots but I'm not entirely convinced. Consider this example: x <- c(rnorm(10000, mean= 0), rnorm(10000, mean= 3)) par(mfrow= c(1, 2)) hist(x, breaks= 30) qqnorm(x) It's obvious from the histogram that there are two peaks and the data could be a mixture of two normal distributions with means around 0 and 3. Personally, I would find it very hard to understand the same from the qqplot. Maybe it's just a matter of habit though... Still it would be difficult to explain the qqplot to a non-expert. On the other hand, in this example the qqplot highlights deviations from normality that are difficult to spot in the histogram: set.seed(1234) x <- c(rnorm(10000, mean= 0), rnorm(10, mean= 5), rnorm(10, mean= -5)) par(mfrow= c(1, 2)) hist(x, breaks= 30) qqnorm(x)
Benefits of using QQ-plots over histograms
Since this question has returned to the top... I see many arguments against histograms in favour of qqplots but I'm not entirely convinced. Consider this example: x <- c(rnorm(10000, mean= 0), rnorm(1
Benefits of using QQ-plots over histograms Since this question has returned to the top... I see many arguments against histograms in favour of qqplots but I'm not entirely convinced. Consider this example: x <- c(rnorm(10000, mean= 0), rnorm(10000, mean= 3)) par(mfrow= c(1, 2)) hist(x, breaks= 30) qqnorm(x) It's obvious from the histogram that there are two peaks and the data could be a mixture of two normal distributions with means around 0 and 3. Personally, I would find it very hard to understand the same from the qqplot. Maybe it's just a matter of habit though... Still it would be difficult to explain the qqplot to a non-expert. On the other hand, in this example the qqplot highlights deviations from normality that are difficult to spot in the histogram: set.seed(1234) x <- c(rnorm(10000, mean= 0), rnorm(10, mean= 5), rnorm(10, mean= -5)) par(mfrow= c(1, 2)) hist(x, breaks= 30) qqnorm(x)
Benefits of using QQ-plots over histograms Since this question has returned to the top... I see many arguments against histograms in favour of qqplots but I'm not entirely convinced. Consider this example: x <- c(rnorm(10000, mean= 0), rnorm(1
11,036
Maximum likelihood function for mixed type distribution
I admit to puzzling over this question for quite some time earlier in my career. One way I convinced myself of the answer was to take an extremely practical, applied view of the situation, a view that recognizes no measurement is perfect. Let's see where that might lead. The point of this exercise is to expose the assumptions that might be needed to justify the somewhat glib mixing of densities and probabilities in expressions for likelihoods. I will therefore highlight such assumptions wherever they are introduced. It turns out quite a few are needed, but they're pretty mild and cover every application I have encountered (which obviously will be limited, but still includes quite a few). The problem concerns a mixed distribution $F,$ one that is neither absolutely continuous nor singular. Lebesgue's Decomposition Theorem permits us to view such a distribution as a mixture of an absolutely continuous one (which by definition has a density function $f_a$) and a singular ("discrete") one, which has a probability mass function $f_d.$ (I'm going to ignore the possibility that a third, continuous but not absolutely continuous component, may be present. Those who use such models tend to know what they're doing and usually have all the technical skills to justify them.) When $F = F_\theta$ is a member of a parametric family of distributions, we may write $$F_\theta(x) = F_{a\theta}(x) + F_{d\theta}(x) = \int_{\infty}^x f_a(t;\theta)\mathrm{d}t + \sum_{t \le x} f_d(t;\theta).$$ (The sum is at most countable, of course.) Here, $f_a(\,;\theta)$ is a probability density function multiplied by some mixture coefficient $\lambda(\theta)$ and $f_d(\,;\theta)$ is a probability mass function multiplied by $1-\lambda(\theta).$ Let's interpret any observation $x_i$ in an iid dataset $X=(x_1,x_2,\ldots, x_n)$ as "really" meaning we have certain knowledge that a hypothetical true underlying value $y_i$ lies in an interval $(x_i-\delta_i, x_i+\epsilon_i]$ surrounding $x_i,$ but otherwise have no information about $y_i.$ Assuming we know all the deltas and epsilons, this no longer presents any problems for constructing a likelihood because everything can be expressed in terms of probabilities: $$\mathcal{L}(X;\theta) = \prod_i \left(F_\theta(x_i + \epsilon_i) - F_\theta(x_i - \delta_i)\right).$$ If the support of $F_{d\theta}$ has no condensation points at any $x_i,$ its contribution to the probability will reduce to at most a single term provided the epsilons and deltas are made sufficiently small: there will be no contribution when $x_i$ is not in its support. If we assume $f_a(\,;\theta)$ is Lipschitz continuous at all the data values, then uniformly in the sizes of the epsilons and deltas we may approximate the absolutely continuous part of $F_\theta(x_i)$ as $$F_{a\theta}(x_i + \epsilon_i) - F_{a\theta}(x_i - \delta_i) = f_a(x_i;\theta)(\epsilon_i + \delta_i) + o(|\epsilon_i + \delta_i|).$$ The uniformity of this approximation means that as we take all the epsilons and deltas to grow small, all the $o()$ terms also grow small. Consequently there is a vanishingly small value $\epsilon(\theta)\gt 0,$ governed by the contributions of all these error terms, for which $$\eqalign{ \mathcal{L}(X;\theta) &= \prod_i \left(f_a(x_i;\theta)(\epsilon_i + \delta_i) + o(|\epsilon_i + \delta_i|) + f_d(x_i;\theta)\right)\\ &= \prod_i \left(f_a(x_i;\theta)(\epsilon_i + \delta_i) + f_d(x_i;\theta)\right)\ + \ o(\epsilon(\theta)). }$$ This is still a little messy, but it shows where we're going. In the case of censored data, usually just one part of each term in the product will be nonzero, because these models typically assume that the support of the singular part of the distribution is disjoint from the upport of the continuous part, no matter what the parameter $\theta$ might be. (Specifically: $f_d(x) \ne 0$ implies $F_a(x+\epsilon)-F_a(x-\epsilon) = o(\epsilon).$) That permits us to break the product into two parts and we can factor the contributions from all the intervals out of the continuous part: $$\mathcal{L}(X;\theta) = \left(\prod_{i=1}^k (\epsilon_i + \delta_i) \right)\prod_{i=1}^k f_a(x_i;\theta) \ \prod_{i=k+1}^n f_d(x_i;\theta).$$ (Without any loss of generality I have indexed the data so that $x_i, i=1, 2, \ldots, k$ contribute to the continuous part and otherwise $x_i, i=k+1, k+2, \ldots, n$ contribute to the singular part of the likelihood.) This expression now makes it plain that Since the interval widths $\epsilon_i+\delta_i$ are fixed, they do not contribute to the likelihood (which is defined only up to some positive constant multiple). Accordingly, we may work with the expression $$\mathcal{L}(X;\theta) = \prod_{i=1}^k f_a(x_i;\theta) \ \prod_{i=k+1}^n f_d(x_i;\theta)$$ when constructing likelihood ratios or maximizing the likelihood. The beauty of this result is that we never need to know the sizes of the finite intervals that are used in this derivation: the epsilons and deltas drop right out. We only need to know that we can make them small enough for the likelihood expression we actually work with to be an adequate approximation to the likelihood expression we would use if we did know the interval sizes.
Maximum likelihood function for mixed type distribution
I admit to puzzling over this question for quite some time earlier in my career. One way I convinced myself of the answer was to take an extremely practical, applied view of the situation, a view tha
Maximum likelihood function for mixed type distribution I admit to puzzling over this question for quite some time earlier in my career. One way I convinced myself of the answer was to take an extremely practical, applied view of the situation, a view that recognizes no measurement is perfect. Let's see where that might lead. The point of this exercise is to expose the assumptions that might be needed to justify the somewhat glib mixing of densities and probabilities in expressions for likelihoods. I will therefore highlight such assumptions wherever they are introduced. It turns out quite a few are needed, but they're pretty mild and cover every application I have encountered (which obviously will be limited, but still includes quite a few). The problem concerns a mixed distribution $F,$ one that is neither absolutely continuous nor singular. Lebesgue's Decomposition Theorem permits us to view such a distribution as a mixture of an absolutely continuous one (which by definition has a density function $f_a$) and a singular ("discrete") one, which has a probability mass function $f_d.$ (I'm going to ignore the possibility that a third, continuous but not absolutely continuous component, may be present. Those who use such models tend to know what they're doing and usually have all the technical skills to justify them.) When $F = F_\theta$ is a member of a parametric family of distributions, we may write $$F_\theta(x) = F_{a\theta}(x) + F_{d\theta}(x) = \int_{\infty}^x f_a(t;\theta)\mathrm{d}t + \sum_{t \le x} f_d(t;\theta).$$ (The sum is at most countable, of course.) Here, $f_a(\,;\theta)$ is a probability density function multiplied by some mixture coefficient $\lambda(\theta)$ and $f_d(\,;\theta)$ is a probability mass function multiplied by $1-\lambda(\theta).$ Let's interpret any observation $x_i$ in an iid dataset $X=(x_1,x_2,\ldots, x_n)$ as "really" meaning we have certain knowledge that a hypothetical true underlying value $y_i$ lies in an interval $(x_i-\delta_i, x_i+\epsilon_i]$ surrounding $x_i,$ but otherwise have no information about $y_i.$ Assuming we know all the deltas and epsilons, this no longer presents any problems for constructing a likelihood because everything can be expressed in terms of probabilities: $$\mathcal{L}(X;\theta) = \prod_i \left(F_\theta(x_i + \epsilon_i) - F_\theta(x_i - \delta_i)\right).$$ If the support of $F_{d\theta}$ has no condensation points at any $x_i,$ its contribution to the probability will reduce to at most a single term provided the epsilons and deltas are made sufficiently small: there will be no contribution when $x_i$ is not in its support. If we assume $f_a(\,;\theta)$ is Lipschitz continuous at all the data values, then uniformly in the sizes of the epsilons and deltas we may approximate the absolutely continuous part of $F_\theta(x_i)$ as $$F_{a\theta}(x_i + \epsilon_i) - F_{a\theta}(x_i - \delta_i) = f_a(x_i;\theta)(\epsilon_i + \delta_i) + o(|\epsilon_i + \delta_i|).$$ The uniformity of this approximation means that as we take all the epsilons and deltas to grow small, all the $o()$ terms also grow small. Consequently there is a vanishingly small value $\epsilon(\theta)\gt 0,$ governed by the contributions of all these error terms, for which $$\eqalign{ \mathcal{L}(X;\theta) &= \prod_i \left(f_a(x_i;\theta)(\epsilon_i + \delta_i) + o(|\epsilon_i + \delta_i|) + f_d(x_i;\theta)\right)\\ &= \prod_i \left(f_a(x_i;\theta)(\epsilon_i + \delta_i) + f_d(x_i;\theta)\right)\ + \ o(\epsilon(\theta)). }$$ This is still a little messy, but it shows where we're going. In the case of censored data, usually just one part of each term in the product will be nonzero, because these models typically assume that the support of the singular part of the distribution is disjoint from the upport of the continuous part, no matter what the parameter $\theta$ might be. (Specifically: $f_d(x) \ne 0$ implies $F_a(x+\epsilon)-F_a(x-\epsilon) = o(\epsilon).$) That permits us to break the product into two parts and we can factor the contributions from all the intervals out of the continuous part: $$\mathcal{L}(X;\theta) = \left(\prod_{i=1}^k (\epsilon_i + \delta_i) \right)\prod_{i=1}^k f_a(x_i;\theta) \ \prod_{i=k+1}^n f_d(x_i;\theta).$$ (Without any loss of generality I have indexed the data so that $x_i, i=1, 2, \ldots, k$ contribute to the continuous part and otherwise $x_i, i=k+1, k+2, \ldots, n$ contribute to the singular part of the likelihood.) This expression now makes it plain that Since the interval widths $\epsilon_i+\delta_i$ are fixed, they do not contribute to the likelihood (which is defined only up to some positive constant multiple). Accordingly, we may work with the expression $$\mathcal{L}(X;\theta) = \prod_{i=1}^k f_a(x_i;\theta) \ \prod_{i=k+1}^n f_d(x_i;\theta)$$ when constructing likelihood ratios or maximizing the likelihood. The beauty of this result is that we never need to know the sizes of the finite intervals that are used in this derivation: the epsilons and deltas drop right out. We only need to know that we can make them small enough for the likelihood expression we actually work with to be an adequate approximation to the likelihood expression we would use if we did know the interval sizes.
Maximum likelihood function for mixed type distribution I admit to puzzling over this question for quite some time earlier in my career. One way I convinced myself of the answer was to take an extremely practical, applied view of the situation, a view tha
11,037
Maximum likelihood function for mixed type distribution
This question is an extremely important foundational problem in likelihood analysis, and also a very subtle and difficult one, so I'm quite surprised at some of the superficial answers it is receiving in the comments. In any case, in this answer I am just going to add one small point to whuber's excellent answer (which I think is the correct approach to this problem). That point is that likelihood functions in this context come from density functions over a mixed dominating measure, and this leads to the interesting property that we can scale the relative sizes of the likelihood function arbitrarily over the continuous and discrete parts and we still have a valid likelihood function. This gives rise to an obvious question of how we can implement likelihood techniques when there is no unique likelihood function. Illustrating this point requires some preliminary presentation on the sampling density as a Radon-Nikodym derivative of the probability measure, so please bear with me. I will first show how to obtain a density function for a mixed dominating measure and then I will show why this leads to the ability to scale the continuous and discrete parts of the likelihood at will. Finally, I will discuss the implications of this issue for likelihood-based analysis and give my opinion on its resolution. I think this is essentially resolved by the method whuber presents in his answer, but it would need to be extended in the direction I have discussed in the comments to that answer, so as to ensure that each point in the support of the discrete part ignores the continuous part at that point. Expressing the density using a dominating measure: The standard approach to dealing with mixed densities for real random variables is to use Lebesgue measure $\lambda_\text{LEB}$ as the dominating measure for the continuous part and counting measure $\lambda_\text{COUNT}$ (over some specified countable set $\mathcal{D} \subset \mathbb{R}$) as the dominating measure for the discrete part. This leads to the Radon-Nikodym derivative defined by: $$\mathbb{P}(X \in \mathcal{A} | \theta) = \int \limits_\mathcal{A} f(x | \theta) \ d \lambda_\text{LEB}(x) + \int \limits_\mathcal{A} p(x | \theta) \ d\lambda_\text{COUNT}(x).$$ (Note that the latter integral degenerates down to a sum over the elements $x \in \mathcal{A} \cap \mathcal{D}$. We write it here as an integral to make the similarity between the two terms clearer.) One can use a single density by taking the measure $\lambda_* \equiv \lambda_\text{LEB} + \lambda_\text{COUNT}$ and setting: $$f_*(x | \theta) \equiv \mathbb{I}(x \notin \mathcal{D}) \cdot f(x | \theta) + \mathbb{I}(x \in \mathcal{D}) \cdot p(x | \theta).$$ Using $\lambda_*$ as the dominating measure, we then have the following expression for the probability of interest: $$\mathbb{P}(X \in \mathcal{A} | \theta) = \int \limits_\mathcal{A} f_*(x | \theta) \ d \lambda_*(x).$$ This shows that the function $f_*$ is a valid Radon-Nikodym derivative of the probability measure on $X$, so it is a valid density for this random variable. Since it depends on $x$ and $\theta$ we can then define a valid likelihood function $L_x^*(\theta) \propto f_*(x | \theta)$ by holding $x$ fixed and treating this as a function of $\theta$. Effect of scaling the dominating measures: Now that we understand the extraction of a density from a dominating measure, this leads to a strange property where we can scale the relative sizes of the likelihood over the continuous and discrete parts and we still have a valid likelihood function. If we now use the dominating measure $\lambda_{**} \equiv \alpha \cdot \lambda_\text{LEB} + \beta \cdot \lambda_\text{COUNT}$ for some positive constants $\alpha > 0$ and $\beta > 0$ then we now get the corresponding Radon-Nikodym density: $$f_{**}(x | \theta) \equiv \frac{\mathbb{I}(x \notin \mathcal{D})}{\alpha} \cdot f(x | \theta) + \frac{\mathbb{I}(x \in \mathcal{D})}{\beta} \cdot p(x | \theta).$$ Using $\lambda_{**}$ as the dominating measure, we then have the following expression for the probability of interest: $$\mathbb{P}(X \in \mathcal{A} | \theta) = \int \limits_\mathcal{A} f_{**}(x | \theta) \ d \lambda_{**}(x).$$ As in the above case, we can define a valid likelihood function $L_x^{**}(\theta) \propto f_{**}(x | \theta)$ by holding $x$ fixed and treating this as a function of $\theta$. You can see that the freedom to vary $\alpha$ and $\beta$ now gives us freedom to scale the relative sizes of the continuous and discrete parts in the likelihood function as much as we want, and still have a valid likelihood function (albeit with respect to a different dominating measure, with corresponding scaling of parts). This particular result is just part of the more general result that every likelihood function is defined with respect to some (implicit) underlying dominating measure, and there is no unique likelihood function that can be defined irrespective of this underlying measure.$^\dagger$ Nevertheless, in this particular case we see that it is still based on a dominating measure that is a combination of Lebesgue measure and counting measure, so we have not really monkeyed with the measure very much. Since there is no objective justification for forming the dominating measure from equal weightings of Lebesgue measure and counting measure, the implication of this is that there is no objective justification for the relative scaling for the continuous and discrete parts of the likelihood function. Implications for likelihood analysis: This might seem to put us in a bit of a quandary. We can arbitrarily scale the discrete and continuous parts of the likelihood function up or down in relative size and still have just as reasonable a claim to this being a valid likelihood function. Fortunately, this problem can be solved by recognising that the scaling constants will come out of the likelihood function in the same way as illustrated in whuber's answer. That is, if we have $x_1,...,x_k \notin \mathcal{D}$ and $x_{k+1},...,x_n \in \mathcal{D}$ we will get: $$\begin{equation} \begin{aligned} L_\mathbb{x}^{**}(\theta) = \prod_{i=1}^n L_{x_i}^{**}(\theta) &= \prod_{i=1}^n f_{**}(x_i | \theta) \\[12pt] &= \Bigg( \prod_{i=1}^k \frac{1}{\alpha} \cdot f(x_i | \theta) \Bigg) \Bigg( \prod_{i=k+1}^n \frac{1}{\beta} \cdot p(x_i | \theta) \Bigg) \\[12pt] &= \frac{1}{\alpha^k \beta^{n-k}} \Bigg( \prod_{i=1}^k f(x_i | \theta) \Bigg) \Bigg( \prod_{i=k+1}^n p(x_i | \theta) \Bigg) \\[12pt] &= \frac{1}{\alpha^k \beta^{n-k}} \prod_{i=1}^n f_{*}(x_i | \theta) \\[12pt] &\propto \prod_{i=1}^n f_{*}(x_i | \theta) \\[12pt] &= \prod_{i=1}^n L_{x_i}^{*}(\theta) \\[12pt] &= L_\mathbb{x}^{*}(\theta). \\[12pt] \end{aligned} \end{equation}$$ This shows that the scaling properties of the dominating measure only affect the likelihood function through a scaling constant that can be ignored in standard MLE problems. Note that in my treatment of this problem, this useful property has occurred as a direct result of the fact that the sampling density is defined in a way that ignores the continuous density when we are in the support of the discrete part. (This differs from whuber's answer, where he allows for a combination of these parts. I think this might actually lead to some difficult problems; see my comments to that answer.) $^\dagger$ This result is not confined to mixed cases. Even in simple cases with continuous or discrete random variables, if you vary the underlying dominating measure it will give a corresponding variation in the Radon-Nikodym derivative, which then leads to a different likelihood function.
Maximum likelihood function for mixed type distribution
This question is an extremely important foundational problem in likelihood analysis, and also a very subtle and difficult one, so I'm quite surprised at some of the superficial answers it is receiving
Maximum likelihood function for mixed type distribution This question is an extremely important foundational problem in likelihood analysis, and also a very subtle and difficult one, so I'm quite surprised at some of the superficial answers it is receiving in the comments. In any case, in this answer I am just going to add one small point to whuber's excellent answer (which I think is the correct approach to this problem). That point is that likelihood functions in this context come from density functions over a mixed dominating measure, and this leads to the interesting property that we can scale the relative sizes of the likelihood function arbitrarily over the continuous and discrete parts and we still have a valid likelihood function. This gives rise to an obvious question of how we can implement likelihood techniques when there is no unique likelihood function. Illustrating this point requires some preliminary presentation on the sampling density as a Radon-Nikodym derivative of the probability measure, so please bear with me. I will first show how to obtain a density function for a mixed dominating measure and then I will show why this leads to the ability to scale the continuous and discrete parts of the likelihood at will. Finally, I will discuss the implications of this issue for likelihood-based analysis and give my opinion on its resolution. I think this is essentially resolved by the method whuber presents in his answer, but it would need to be extended in the direction I have discussed in the comments to that answer, so as to ensure that each point in the support of the discrete part ignores the continuous part at that point. Expressing the density using a dominating measure: The standard approach to dealing with mixed densities for real random variables is to use Lebesgue measure $\lambda_\text{LEB}$ as the dominating measure for the continuous part and counting measure $\lambda_\text{COUNT}$ (over some specified countable set $\mathcal{D} \subset \mathbb{R}$) as the dominating measure for the discrete part. This leads to the Radon-Nikodym derivative defined by: $$\mathbb{P}(X \in \mathcal{A} | \theta) = \int \limits_\mathcal{A} f(x | \theta) \ d \lambda_\text{LEB}(x) + \int \limits_\mathcal{A} p(x | \theta) \ d\lambda_\text{COUNT}(x).$$ (Note that the latter integral degenerates down to a sum over the elements $x \in \mathcal{A} \cap \mathcal{D}$. We write it here as an integral to make the similarity between the two terms clearer.) One can use a single density by taking the measure $\lambda_* \equiv \lambda_\text{LEB} + \lambda_\text{COUNT}$ and setting: $$f_*(x | \theta) \equiv \mathbb{I}(x \notin \mathcal{D}) \cdot f(x | \theta) + \mathbb{I}(x \in \mathcal{D}) \cdot p(x | \theta).$$ Using $\lambda_*$ as the dominating measure, we then have the following expression for the probability of interest: $$\mathbb{P}(X \in \mathcal{A} | \theta) = \int \limits_\mathcal{A} f_*(x | \theta) \ d \lambda_*(x).$$ This shows that the function $f_*$ is a valid Radon-Nikodym derivative of the probability measure on $X$, so it is a valid density for this random variable. Since it depends on $x$ and $\theta$ we can then define a valid likelihood function $L_x^*(\theta) \propto f_*(x | \theta)$ by holding $x$ fixed and treating this as a function of $\theta$. Effect of scaling the dominating measures: Now that we understand the extraction of a density from a dominating measure, this leads to a strange property where we can scale the relative sizes of the likelihood over the continuous and discrete parts and we still have a valid likelihood function. If we now use the dominating measure $\lambda_{**} \equiv \alpha \cdot \lambda_\text{LEB} + \beta \cdot \lambda_\text{COUNT}$ for some positive constants $\alpha > 0$ and $\beta > 0$ then we now get the corresponding Radon-Nikodym density: $$f_{**}(x | \theta) \equiv \frac{\mathbb{I}(x \notin \mathcal{D})}{\alpha} \cdot f(x | \theta) + \frac{\mathbb{I}(x \in \mathcal{D})}{\beta} \cdot p(x | \theta).$$ Using $\lambda_{**}$ as the dominating measure, we then have the following expression for the probability of interest: $$\mathbb{P}(X \in \mathcal{A} | \theta) = \int \limits_\mathcal{A} f_{**}(x | \theta) \ d \lambda_{**}(x).$$ As in the above case, we can define a valid likelihood function $L_x^{**}(\theta) \propto f_{**}(x | \theta)$ by holding $x$ fixed and treating this as a function of $\theta$. You can see that the freedom to vary $\alpha$ and $\beta$ now gives us freedom to scale the relative sizes of the continuous and discrete parts in the likelihood function as much as we want, and still have a valid likelihood function (albeit with respect to a different dominating measure, with corresponding scaling of parts). This particular result is just part of the more general result that every likelihood function is defined with respect to some (implicit) underlying dominating measure, and there is no unique likelihood function that can be defined irrespective of this underlying measure.$^\dagger$ Nevertheless, in this particular case we see that it is still based on a dominating measure that is a combination of Lebesgue measure and counting measure, so we have not really monkeyed with the measure very much. Since there is no objective justification for forming the dominating measure from equal weightings of Lebesgue measure and counting measure, the implication of this is that there is no objective justification for the relative scaling for the continuous and discrete parts of the likelihood function. Implications for likelihood analysis: This might seem to put us in a bit of a quandary. We can arbitrarily scale the discrete and continuous parts of the likelihood function up or down in relative size and still have just as reasonable a claim to this being a valid likelihood function. Fortunately, this problem can be solved by recognising that the scaling constants will come out of the likelihood function in the same way as illustrated in whuber's answer. That is, if we have $x_1,...,x_k \notin \mathcal{D}$ and $x_{k+1},...,x_n \in \mathcal{D}$ we will get: $$\begin{equation} \begin{aligned} L_\mathbb{x}^{**}(\theta) = \prod_{i=1}^n L_{x_i}^{**}(\theta) &= \prod_{i=1}^n f_{**}(x_i | \theta) \\[12pt] &= \Bigg( \prod_{i=1}^k \frac{1}{\alpha} \cdot f(x_i | \theta) \Bigg) \Bigg( \prod_{i=k+1}^n \frac{1}{\beta} \cdot p(x_i | \theta) \Bigg) \\[12pt] &= \frac{1}{\alpha^k \beta^{n-k}} \Bigg( \prod_{i=1}^k f(x_i | \theta) \Bigg) \Bigg( \prod_{i=k+1}^n p(x_i | \theta) \Bigg) \\[12pt] &= \frac{1}{\alpha^k \beta^{n-k}} \prod_{i=1}^n f_{*}(x_i | \theta) \\[12pt] &\propto \prod_{i=1}^n f_{*}(x_i | \theta) \\[12pt] &= \prod_{i=1}^n L_{x_i}^{*}(\theta) \\[12pt] &= L_\mathbb{x}^{*}(\theta). \\[12pt] \end{aligned} \end{equation}$$ This shows that the scaling properties of the dominating measure only affect the likelihood function through a scaling constant that can be ignored in standard MLE problems. Note that in my treatment of this problem, this useful property has occurred as a direct result of the fact that the sampling density is defined in a way that ignores the continuous density when we are in the support of the discrete part. (This differs from whuber's answer, where he allows for a combination of these parts. I think this might actually lead to some difficult problems; see my comments to that answer.) $^\dagger$ This result is not confined to mixed cases. Even in simple cases with continuous or discrete random variables, if you vary the underlying dominating measure it will give a corresponding variation in the Radon-Nikodym derivative, which then leads to a different likelihood function.
Maximum likelihood function for mixed type distribution This question is an extremely important foundational problem in likelihood analysis, and also a very subtle and difficult one, so I'm quite surprised at some of the superficial answers it is receiving
11,038
Maximum likelihood function for mixed type distribution
The likelihood function $\ell(\theta|\mathbf{x})$ is the density of the data at the observed value $\mathbf{x}$ expressed as a function of $\theta$ $$\ell(\theta|\mathbf{x})=f(\mathbf{x}|\theta)$$ This density is defined for every (acceptable) value of $\theta$ almost everywhere over the support of $\mathbf{x}$, $\mathfrak{X}$, against a particular measure over $\mathfrak{X}$ that does not depend on $\theta$. For any parametric family, there should exist such a dominating measure across all $\theta$'s, hence a density, hence a likelihood. Here is a relevant excerpt from the Wikipedia entry on likelihood functions (stress is mine): In measure-theoretic probability theory, the density function is defined as the Radon-Nikodym derivative of the probability distribution relative to a dominating measure. This provides a likelihood function for any probability model with all distributions, whether discrete, absolutely continuous, a mixture or something else. (Likelihoods will be comparable, e.g., for parameter estimation, only if they are Radon–Nikodym derivatives with respect to the same dominating measure.)
Maximum likelihood function for mixed type distribution
The likelihood function $\ell(\theta|\mathbf{x})$ is the density of the data at the observed value $\mathbf{x}$ expressed as a function of $\theta$ $$\ell(\theta|\mathbf{x})=f(\mathbf{x}|\theta)$$ Thi
Maximum likelihood function for mixed type distribution The likelihood function $\ell(\theta|\mathbf{x})$ is the density of the data at the observed value $\mathbf{x}$ expressed as a function of $\theta$ $$\ell(\theta|\mathbf{x})=f(\mathbf{x}|\theta)$$ This density is defined for every (acceptable) value of $\theta$ almost everywhere over the support of $\mathbf{x}$, $\mathfrak{X}$, against a particular measure over $\mathfrak{X}$ that does not depend on $\theta$. For any parametric family, there should exist such a dominating measure across all $\theta$'s, hence a density, hence a likelihood. Here is a relevant excerpt from the Wikipedia entry on likelihood functions (stress is mine): In measure-theoretic probability theory, the density function is defined as the Radon-Nikodym derivative of the probability distribution relative to a dominating measure. This provides a likelihood function for any probability model with all distributions, whether discrete, absolutely continuous, a mixture or something else. (Likelihoods will be comparable, e.g., for parameter estimation, only if they are Radon–Nikodym derivatives with respect to the same dominating measure.)
Maximum likelihood function for mixed type distribution The likelihood function $\ell(\theta|\mathbf{x})$ is the density of the data at the observed value $\mathbf{x}$ expressed as a function of $\theta$ $$\ell(\theta|\mathbf{x})=f(\mathbf{x}|\theta)$$ Thi
11,039
Maximum likelihood function for mixed type distribution
One example where this occurs, that is, likelihood given by a probability model of mixed continuous/discrete type, is with censored data. For an example see Weighted normal errors regression with censoring . In general this can be formulated using measure theory. Then assume a statistical model with a model function $f(x;\theta)$ which is a Radon-Nikodym derivative with respect to a common measure $\lambda$ (which should not depend on the parameter $\theta$). Then the likelihood function based on an independent sample $x_1, x_2, \dotsc, x_n$ is $\prod_i f(x_i;\theta)$. This is really the same in continuous, discrete and mixed cases. One simple example could be modeling of daily rainfall. That could be zero, with positive probability, or positive. So for the dominating measure $\lambda$ we could use the sum of Lebesgue measure on $(0,\infty)$ and an atom at zero.
Maximum likelihood function for mixed type distribution
One example where this occurs, that is, likelihood given by a probability model of mixed continuous/discrete type, is with censored data. For an example see Weighted normal errors regression with cen
Maximum likelihood function for mixed type distribution One example where this occurs, that is, likelihood given by a probability model of mixed continuous/discrete type, is with censored data. For an example see Weighted normal errors regression with censoring . In general this can be formulated using measure theory. Then assume a statistical model with a model function $f(x;\theta)$ which is a Radon-Nikodym derivative with respect to a common measure $\lambda$ (which should not depend on the parameter $\theta$). Then the likelihood function based on an independent sample $x_1, x_2, \dotsc, x_n$ is $\prod_i f(x_i;\theta)$. This is really the same in continuous, discrete and mixed cases. One simple example could be modeling of daily rainfall. That could be zero, with positive probability, or positive. So for the dominating measure $\lambda$ we could use the sum of Lebesgue measure on $(0,\infty)$ and an atom at zero.
Maximum likelihood function for mixed type distribution One example where this occurs, that is, likelihood given by a probability model of mixed continuous/discrete type, is with censored data. For an example see Weighted normal errors regression with cen
11,040
Which optimization algorithm is used in glm function in R?
You will be interested to know that the documentation for glm, accessed via ?glm provides many useful insights: under method we find that iteratively reweighted least squares is the default method for glm.fit, which is the workhorse function for glm. Additionally, the documentation mentions that user-defined functions may be provided here, instead of the default.
Which optimization algorithm is used in glm function in R?
You will be interested to know that the documentation for glm, accessed via ?glm provides many useful insights: under method we find that iteratively reweighted least squares is the default method for
Which optimization algorithm is used in glm function in R? You will be interested to know that the documentation for glm, accessed via ?glm provides many useful insights: under method we find that iteratively reweighted least squares is the default method for glm.fit, which is the workhorse function for glm. Additionally, the documentation mentions that user-defined functions may be provided here, instead of the default.
Which optimization algorithm is used in glm function in R? You will be interested to know that the documentation for glm, accessed via ?glm provides many useful insights: under method we find that iteratively reweighted least squares is the default method for
11,041
Which optimization algorithm is used in glm function in R?
The method used is mentioned in the output itself: it is Fisher Scoring. This is equivalent to Newton-Raphson in most cases. The exception being situations where you are using non-natural parameterizations. Relative risk regression is an example of such a scenario. There, the expected and observed information are different. In general, Newton Raphson and Fisher Scoring give nearly identical results. Another formulation of Fisher Scoring is that of Iteratively Reweighted Least Squares. To give some intuition, non-uniform error models have the inverse variance weighted least squares model as an "optimal" model according to the Gauss Markov theorem. With GLMs, there is a known mean-variance relationship. An example is logistic regression where the mean is $p$ and the variance is $p(1-p)$. So an algorithm is constructed by estimating the mean in a naive model, creating weights from the predicted mean, then re-estimating the mean using finer precision until there is convergence. This, it turns out, is Fisher Scoring. Additionally, it gives some nice intuition to the EM algorithm which is a more general framework for estimating complicated likelihoods. The default general optimizer in R uses numerical methods to estimate a second moment, basically based on a linearization (be wary of curse of dimensionality). So if you were interested in comparing the efficiency and bias, you could implement a naive logistic maximum likelihood routine with something like set.seed(1234) x <- rnorm(1000) y <- rbinom(1000, 1, exp(-2.3 + 0.1*x)/(1+exp(-2.3 + 0.1*x))) f <- function(b) { p <- exp(b[1] + b[2]*x)/(1+exp(b[1] + b[2]*x)) -sum(dbinom(y, 1, p, log=TRUE)) } ans <- nlm(f, p=0:1, hessian=TRUE) gives me > ans$estimate [1] -2.2261225 0.1651472 > coef(glm(y~x, family=binomial)) (Intercept) x -2.2261215 0.1651474
Which optimization algorithm is used in glm function in R?
The method used is mentioned in the output itself: it is Fisher Scoring. This is equivalent to Newton-Raphson in most cases. The exception being situations where you are using non-natural parameteriza
Which optimization algorithm is used in glm function in R? The method used is mentioned in the output itself: it is Fisher Scoring. This is equivalent to Newton-Raphson in most cases. The exception being situations where you are using non-natural parameterizations. Relative risk regression is an example of such a scenario. There, the expected and observed information are different. In general, Newton Raphson and Fisher Scoring give nearly identical results. Another formulation of Fisher Scoring is that of Iteratively Reweighted Least Squares. To give some intuition, non-uniform error models have the inverse variance weighted least squares model as an "optimal" model according to the Gauss Markov theorem. With GLMs, there is a known mean-variance relationship. An example is logistic regression where the mean is $p$ and the variance is $p(1-p)$. So an algorithm is constructed by estimating the mean in a naive model, creating weights from the predicted mean, then re-estimating the mean using finer precision until there is convergence. This, it turns out, is Fisher Scoring. Additionally, it gives some nice intuition to the EM algorithm which is a more general framework for estimating complicated likelihoods. The default general optimizer in R uses numerical methods to estimate a second moment, basically based on a linearization (be wary of curse of dimensionality). So if you were interested in comparing the efficiency and bias, you could implement a naive logistic maximum likelihood routine with something like set.seed(1234) x <- rnorm(1000) y <- rbinom(1000, 1, exp(-2.3 + 0.1*x)/(1+exp(-2.3 + 0.1*x))) f <- function(b) { p <- exp(b[1] + b[2]*x)/(1+exp(b[1] + b[2]*x)) -sum(dbinom(y, 1, p, log=TRUE)) } ans <- nlm(f, p=0:1, hessian=TRUE) gives me > ans$estimate [1] -2.2261225 0.1651472 > coef(glm(y~x, family=binomial)) (Intercept) x -2.2261215 0.1651474
Which optimization algorithm is used in glm function in R? The method used is mentioned in the output itself: it is Fisher Scoring. This is equivalent to Newton-Raphson in most cases. The exception being situations where you are using non-natural parameteriza
11,042
Which optimization algorithm is used in glm function in R?
For the record, a simple pure R implementation of R's glm algorithm, based on Fisher scoring (iteratively reweighted least squares), as explained in the other answer is given by: glm_irls = function(X, y, weights=rep(1,nrow(X)), family=poisson(log), maxit=25, tol=1e-16) { if (!is(family, "family")) family = family() variance = family$variance linkinv = family$linkinv mu.eta = family$mu.eta etastart = NULL nobs = nrow(X) # needed by the initialize expression below nvars = ncol(X) # needed by the initialize expression below eval(family$initialize) # initializes n and fitted values mustart eta = family$linkfun(mustart) # we then initialize eta with this dev.resids = family$dev.resids dev = sum(dev.resids(y, linkinv(eta), weights)) devold = 0 beta_old = rep(1, nvars) for(j in 1:maxit) { mu = linkinv(eta) varg = variance(mu) gprime = mu.eta(eta) z = eta + (y - mu) / gprime # potentially -offset if you would have an offset argument as well W = weights * as.vector(gprime^2 / varg) beta = solve(crossprod(X,W*X), crossprod(X,W*z), tol=2*.Machine$double.eps) eta = X %*% beta # potentially +offset if you would have an offset argument as well dev = sum(dev.resids(y, mu, weights)) if (abs(dev - devold) / (0.1 + abs(dev)) < tol) break devold = dev beta_old = beta } list(coefficients=t(beta), iterations=j) } Example: ## Dobson (1990) Page 93: Randomized Controlled Trial : y <- counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) X <- model.matrix(counts ~ outcome + treatment) coef(glm.fit(x=X, y=y, family = poisson(log))) (Intercept) outcome2 outcome3 treatment2 treatment3 3.044522e+00 -4.542553e-01 -2.929871e-01 -7.635479e-16 -9.532452e-16 coef(glm_irls(X=X, y=y, family=poisson(log))) (Intercept) outcome2 outcome3 treatment2 treatment3 [1,] 3.044522 -0.4542553 -0.2929871 -3.151689e-16 -8.24099e-16 A good discussion of GLM fitting algorithms, including a comparison with Newton-Raphson (which uses the observed Hessian as opposed to the expected Hessian in the IRLS algorithm) and hybrid algorithms (which start with IRLS, as these are easier to initialize, but then finish with further optimization using Newton-Raphson) can be found in the book "Generalized Linear Models and Extensions" by James W. Hardin & Joseph M. Hilbe.
Which optimization algorithm is used in glm function in R?
For the record, a simple pure R implementation of R's glm algorithm, based on Fisher scoring (iteratively reweighted least squares), as explained in the other answer is given by: glm_irls = function(X
Which optimization algorithm is used in glm function in R? For the record, a simple pure R implementation of R's glm algorithm, based on Fisher scoring (iteratively reweighted least squares), as explained in the other answer is given by: glm_irls = function(X, y, weights=rep(1,nrow(X)), family=poisson(log), maxit=25, tol=1e-16) { if (!is(family, "family")) family = family() variance = family$variance linkinv = family$linkinv mu.eta = family$mu.eta etastart = NULL nobs = nrow(X) # needed by the initialize expression below nvars = ncol(X) # needed by the initialize expression below eval(family$initialize) # initializes n and fitted values mustart eta = family$linkfun(mustart) # we then initialize eta with this dev.resids = family$dev.resids dev = sum(dev.resids(y, linkinv(eta), weights)) devold = 0 beta_old = rep(1, nvars) for(j in 1:maxit) { mu = linkinv(eta) varg = variance(mu) gprime = mu.eta(eta) z = eta + (y - mu) / gprime # potentially -offset if you would have an offset argument as well W = weights * as.vector(gprime^2 / varg) beta = solve(crossprod(X,W*X), crossprod(X,W*z), tol=2*.Machine$double.eps) eta = X %*% beta # potentially +offset if you would have an offset argument as well dev = sum(dev.resids(y, mu, weights)) if (abs(dev - devold) / (0.1 + abs(dev)) < tol) break devold = dev beta_old = beta } list(coefficients=t(beta), iterations=j) } Example: ## Dobson (1990) Page 93: Randomized Controlled Trial : y <- counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) X <- model.matrix(counts ~ outcome + treatment) coef(glm.fit(x=X, y=y, family = poisson(log))) (Intercept) outcome2 outcome3 treatment2 treatment3 3.044522e+00 -4.542553e-01 -2.929871e-01 -7.635479e-16 -9.532452e-16 coef(glm_irls(X=X, y=y, family=poisson(log))) (Intercept) outcome2 outcome3 treatment2 treatment3 [1,] 3.044522 -0.4542553 -0.2929871 -3.151689e-16 -8.24099e-16 A good discussion of GLM fitting algorithms, including a comparison with Newton-Raphson (which uses the observed Hessian as opposed to the expected Hessian in the IRLS algorithm) and hybrid algorithms (which start with IRLS, as these are easier to initialize, but then finish with further optimization using Newton-Raphson) can be found in the book "Generalized Linear Models and Extensions" by James W. Hardin & Joseph M. Hilbe.
Which optimization algorithm is used in glm function in R? For the record, a simple pure R implementation of R's glm algorithm, based on Fisher scoring (iteratively reweighted least squares), as explained in the other answer is given by: glm_irls = function(X
11,043
Dealing with 0,1 values in a beta regression
According to Smithson & Verkuilen (2006)$^1$, an appropriate transformation is $$ x' = \frac{x(N-1) + s}{N} $$ "where N is the sample size and s is a constant between 0 and 1. From a Bayesian standpoint, s acts as if we are taking a prior into account. A reasonable choice for s would be .5." This will squeeze data that lies in $[0,1]$ to be in $(0,1)$. The above quote, and a mathematical reason of the transformation is available in the [paper's supplementary notes]. Reference: Smithson, M. & Verkuilen, J. A better lemon squeezer? Maximum-likelihood regression with beta-distributed dependent variables. Psychol. Methods 11, 54–71 (2006). DOI: 10.1037/1082-989X.11.1.54
Dealing with 0,1 values in a beta regression
According to Smithson & Verkuilen (2006)$^1$, an appropriate transformation is $$ x' = \frac{x(N-1) + s}{N} $$ "where N is the sample size and s is a constant between 0 and 1. From a Bayesian standpo
Dealing with 0,1 values in a beta regression According to Smithson & Verkuilen (2006)$^1$, an appropriate transformation is $$ x' = \frac{x(N-1) + s}{N} $$ "where N is the sample size and s is a constant between 0 and 1. From a Bayesian standpoint, s acts as if we are taking a prior into account. A reasonable choice for s would be .5." This will squeeze data that lies in $[0,1]$ to be in $(0,1)$. The above quote, and a mathematical reason of the transformation is available in the [paper's supplementary notes]. Reference: Smithson, M. & Verkuilen, J. A better lemon squeezer? Maximum-likelihood regression with beta-distributed dependent variables. Psychol. Methods 11, 54–71 (2006). DOI: 10.1037/1082-989X.11.1.54
Dealing with 0,1 values in a beta regression According to Smithson & Verkuilen (2006)$^1$, an appropriate transformation is $$ x' = \frac{x(N-1) + s}{N} $$ "where N is the sample size and s is a constant between 0 and 1. From a Bayesian standpo
11,044
Dealing with 0,1 values in a beta regression
I think the actual "correct" answer to this question is zero-one inflated beta regression. This is designed to handle data that vary continuously on the interval [0,1], and allows many real 0's and 1's to be in the data. This approach fits three separate models in a bayesian context, similar to what @B_Miner proposed. Model 1: Is a value a discrete 0/1, or is the value in (0,1)? Fit with a bernoulli distribution. Model 2: Fit discrete subset with a bernoulli distribution. Model 3: Fit (0,1) subset with beta regression. For prediction, the first model results can be used to weight the predictions of models 2 and 3. This can be implemented within the zoib R package, or home-brewed in BUGS/JAGS/STAN/etc.
Dealing with 0,1 values in a beta regression
I think the actual "correct" answer to this question is zero-one inflated beta regression. This is designed to handle data that vary continuously on the interval [0,1], and allows many real 0's and 1'
Dealing with 0,1 values in a beta regression I think the actual "correct" answer to this question is zero-one inflated beta regression. This is designed to handle data that vary continuously on the interval [0,1], and allows many real 0's and 1's to be in the data. This approach fits three separate models in a bayesian context, similar to what @B_Miner proposed. Model 1: Is a value a discrete 0/1, or is the value in (0,1)? Fit with a bernoulli distribution. Model 2: Fit discrete subset with a bernoulli distribution. Model 3: Fit (0,1) subset with beta regression. For prediction, the first model results can be used to weight the predictions of models 2 and 3. This can be implemented within the zoib R package, or home-brewed in BUGS/JAGS/STAN/etc.
Dealing with 0,1 values in a beta regression I think the actual "correct" answer to this question is zero-one inflated beta regression. This is designed to handle data that vary continuously on the interval [0,1], and allows many real 0's and 1'
11,045
Dealing with 0,1 values in a beta regression
Dave, A common approach to this problem is to fit 2 logistic regression models to predict whether a case is 0 or 1. Then, a beta regression is used for those in the range (0,1).
Dealing with 0,1 values in a beta regression
Dave, A common approach to this problem is to fit 2 logistic regression models to predict whether a case is 0 or 1. Then, a beta regression is used for those in the range (0,1).
Dealing with 0,1 values in a beta regression Dave, A common approach to this problem is to fit 2 logistic regression models to predict whether a case is 0 or 1. Then, a beta regression is used for those in the range (0,1).
Dealing with 0,1 values in a beta regression Dave, A common approach to this problem is to fit 2 logistic regression models to predict whether a case is 0 or 1. Then, a beta regression is used for those in the range (0,1).
11,046
Dealing with 0,1 values in a beta regression
The beta distribution follows from the sufficient statistics $(\log(x), \log(1-x))$. Do those statistics make sense for your data? If you have so many zeros and ones, then it seems doubtful that they do, and you might consider not using a beta distribution at all. If you were to choose the sufficient statistic $x$ instead (over your bounded support), then I believe you end up with a truncated exponential distribution, and with $(x,x^2)$ a truncated normal distribution. I believe that both are easily estimated in a Bayesian way as they are both exponential families. This is a modification of the model as you were hoping.
Dealing with 0,1 values in a beta regression
The beta distribution follows from the sufficient statistics $(\log(x), \log(1-x))$. Do those statistics make sense for your data? If you have so many zeros and ones, then it seems doubtful that the
Dealing with 0,1 values in a beta regression The beta distribution follows from the sufficient statistics $(\log(x), \log(1-x))$. Do those statistics make sense for your data? If you have so many zeros and ones, then it seems doubtful that they do, and you might consider not using a beta distribution at all. If you were to choose the sufficient statistic $x$ instead (over your bounded support), then I believe you end up with a truncated exponential distribution, and with $(x,x^2)$ a truncated normal distribution. I believe that both are easily estimated in a Bayesian way as they are both exponential families. This is a modification of the model as you were hoping.
Dealing with 0,1 values in a beta regression The beta distribution follows from the sufficient statistics $(\log(x), \log(1-x))$. Do those statistics make sense for your data? If you have so many zeros and ones, then it seems doubtful that the
11,047
Dealing with 0,1 values in a beta regression
My experience with regression modeling, in general, involves also the exercise of judgment and in that regard, it is something of an art, especially when it comes to constructing good forecasting models. My observation is that actually parsimonious models appear to be superior, overfitting a model is not the apparent optimal best approach. My experience includes time series modeling and reading of the works of Box-Jenkins both of which expound judgment based parsimonious modeling. If one reads the original work on beta regression, “BETA REGRESSION FOR MODELLING RATES AND PROPORTIONS”, the authors suggest several link functions or the use of no link function. The idea that the odds ratio link function is the most appropriate, or the only choice, given its singularity at O and 1, with many such (or near such) points in the data, is just bad judgment in my view. I just noticed comments by Neil, "Do those statistics make sense for your data? If you have so many zeros and ones, then it seems doubtful that they do.." which appears to echo my point.
Dealing with 0,1 values in a beta regression
My experience with regression modeling, in general, involves also the exercise of judgment and in that regard, it is something of an art, especially when it comes to constructing good forecasting mode
Dealing with 0,1 values in a beta regression My experience with regression modeling, in general, involves also the exercise of judgment and in that regard, it is something of an art, especially when it comes to constructing good forecasting models. My observation is that actually parsimonious models appear to be superior, overfitting a model is not the apparent optimal best approach. My experience includes time series modeling and reading of the works of Box-Jenkins both of which expound judgment based parsimonious modeling. If one reads the original work on beta regression, “BETA REGRESSION FOR MODELLING RATES AND PROPORTIONS”, the authors suggest several link functions or the use of no link function. The idea that the odds ratio link function is the most appropriate, or the only choice, given its singularity at O and 1, with many such (or near such) points in the data, is just bad judgment in my view. I just noticed comments by Neil, "Do those statistics make sense for your data? If you have so many zeros and ones, then it seems doubtful that they do.." which appears to echo my point.
Dealing with 0,1 values in a beta regression My experience with regression modeling, in general, involves also the exercise of judgment and in that regard, it is something of an art, especially when it comes to constructing good forecasting mode
11,048
Addressing model uncertainty
There are two cases which arise in dealing with model-selection: When the true model belongs in the model space. This is very simple to deal with using BIC. There are results which show that BIC will select the true model with high probability. However, in practice it is very rare that we know the true model. I must remark BIC tends to be misused because of this (probable reason is its similar looks as AIC). These issues have been addressed on this forum before in various forms. A good discussion is here. When the true model is not in the model space. This is an active area of research in the Bayesian community. However, it is confirmed that people know that using BIC as a model selection criteria in this case is dangerous. Recent literature in high dimension data analysis shows this. One such example is this. Bayes factor definitely performs surprisingly well in high dimensions. Several modifications of BIC have been proposed, such as mBIC, but there is no consensus. Green's RJMCMC is another popular way of doing Bayesian model selection, but it has its own short-comings. You can follow-up more on this. There is another camp in Bayesian world which recommends model averaging. Notable being, Dr. Raftery. Bayesian model averaging. This website of Chris Volinksy is a comprehensive source of Bayesian model averging. Some other works are here. Again, Bayesian model-selection is still an active area of research and you may get very different answers depending on who you ask.
Addressing model uncertainty
There are two cases which arise in dealing with model-selection: When the true model belongs in the model space. This is very simple to deal with using BIC. There are results which show that BIC will
Addressing model uncertainty There are two cases which arise in dealing with model-selection: When the true model belongs in the model space. This is very simple to deal with using BIC. There are results which show that BIC will select the true model with high probability. However, in practice it is very rare that we know the true model. I must remark BIC tends to be misused because of this (probable reason is its similar looks as AIC). These issues have been addressed on this forum before in various forms. A good discussion is here. When the true model is not in the model space. This is an active area of research in the Bayesian community. However, it is confirmed that people know that using BIC as a model selection criteria in this case is dangerous. Recent literature in high dimension data analysis shows this. One such example is this. Bayes factor definitely performs surprisingly well in high dimensions. Several modifications of BIC have been proposed, such as mBIC, but there is no consensus. Green's RJMCMC is another popular way of doing Bayesian model selection, but it has its own short-comings. You can follow-up more on this. There is another camp in Bayesian world which recommends model averaging. Notable being, Dr. Raftery. Bayesian model averaging. This website of Chris Volinksy is a comprehensive source of Bayesian model averging. Some other works are here. Again, Bayesian model-selection is still an active area of research and you may get very different answers depending on who you ask.
Addressing model uncertainty There are two cases which arise in dealing with model-selection: When the true model belongs in the model space. This is very simple to deal with using BIC. There are results which show that BIC will
11,049
Addressing model uncertainty
A "true" Bayesian would deal with model uncertainty by marginalising (integrating) over all plausble models. So for example in a linear ridge regression problem you would marginalise over the regression parameters (which would have a Gaussian posterior, so it could be done analytically), but then marginalise over the hyper-paremeters (noise level and regularisation parameter) via e.g. MCMC methods. A "lesser" Bayesian solution would be to marginalise over the model parameters, but to optimise the hyper-parameters by maximising the marginal likelihood (also known as the "Bayesian evidence") for the model. However, this can lead to more over-fitting than might be expected (see e.g. Cawley and Talbot). See the work of David MacKay for information on evidence maximisation in machine learning. For comparison, see the work of Radford Neal on the "integrate everything out" approach to similar problems. Note that the evidence framework is very handy for situations where integrating out is too computationally expensive, so there is scope for both approaches. Effectively Bayesians integrate rather than optimise. Ideally, we would state our prior belief regarding the characteristics of the solution (e.g. smoothness) and make predictions notoionally without actually making a model. The Gaussian process "models" used in machine learning are an example of this idea, where the covariance function encodes our prior belief regarding the solution. See the excellent book by Rasmussen and Williams. For practical Bayesians, there is always cross-validation, it is hard to beat for most things!
Addressing model uncertainty
A "true" Bayesian would deal with model uncertainty by marginalising (integrating) over all plausble models. So for example in a linear ridge regression problem you would marginalise over the regress
Addressing model uncertainty A "true" Bayesian would deal with model uncertainty by marginalising (integrating) over all plausble models. So for example in a linear ridge regression problem you would marginalise over the regression parameters (which would have a Gaussian posterior, so it could be done analytically), but then marginalise over the hyper-paremeters (noise level and regularisation parameter) via e.g. MCMC methods. A "lesser" Bayesian solution would be to marginalise over the model parameters, but to optimise the hyper-parameters by maximising the marginal likelihood (also known as the "Bayesian evidence") for the model. However, this can lead to more over-fitting than might be expected (see e.g. Cawley and Talbot). See the work of David MacKay for information on evidence maximisation in machine learning. For comparison, see the work of Radford Neal on the "integrate everything out" approach to similar problems. Note that the evidence framework is very handy for situations where integrating out is too computationally expensive, so there is scope for both approaches. Effectively Bayesians integrate rather than optimise. Ideally, we would state our prior belief regarding the characteristics of the solution (e.g. smoothness) and make predictions notoionally without actually making a model. The Gaussian process "models" used in machine learning are an example of this idea, where the covariance function encodes our prior belief regarding the solution. See the excellent book by Rasmussen and Williams. For practical Bayesians, there is always cross-validation, it is hard to beat for most things!
Addressing model uncertainty A "true" Bayesian would deal with model uncertainty by marginalising (integrating) over all plausble models. So for example in a linear ridge regression problem you would marginalise over the regress
11,050
Addressing model uncertainty
One of the interesting things I find in the "Model Uncertainty" world is this notion of a "true model". This implicitly means that our "model propositions" are of the form: $$M_i^{(1)}:\text{The ith model is the true model}$$ From which we calculate the posterior probabilities $P(M_i^{(1)}|DI)$. This procedure seems highly dubious at a conceptual level to me. It is a big call (or an impossible calculation) to suppose that the $M_i^{(1)}$ propositions are exhaustive. For any set of models you can produce, there is sure to be an alternative model you haven't thought of yet. And so goes the infinite regress... Exhaustiveness is crucial here, because this ensures the probabilities add to 1, which means we can marginalise out the model. But this is all at the conceptual level - model averaging has good performance. So this means there must be a better concept. Personally, I view models as tools, like a hammer or a drill. Models are mental constructs used for making predictions about or describing things we can observe. It sounds very odd to speak of a "true hammer", and equally bizzare to speak of a "true mental construct". Based on this, the notion of a "true model" seems weird to me. It seems much more natural to think of "good" models and "bad" models, rather than "right" models and "wrong" models. Taking this viewpoint, we could equally well be uncertain as to the "best" model to use, from a selection of models. So suppose we instead reason about the propostion: $$M_i^{(2)}:\text{Out of all the models that have been specified,}$$ $$\text{the ith model is best model to use}$$ Now this is a much better way to think about "model uncertainty" I think. We are uncertain about which model to use, rather than which model is "right". This also makes the model averaging seem like a better thing to do (to me anyways). And as far as I can tell, the posterior for $M_{i}^{(2)}$ using BIC is perfectly fine as a rough, easy approximation. And further, the propositions $M_{i}^{(2)}$ are exhaustive in addition to being exclusive. In this approach however, you do need some sort of goodness of fit measure, in order to gauge how good your "best" model is. This can be done in two ways, by testing against "sure thing" models, which amounts to the usual GoF statistics (KL divergence, Chi-square, etc.). Another way to gauge this is to include an extremely flexible model in your class of models - perhaps a normal mixture model with hundreds of components, or a Dirichlet process mixture. If this model comes out as the best, then it is likely that your other models are inadequate. This paper has a good theoretical discussion, and goes through, step by step, an example of how you actually do model selection.
Addressing model uncertainty
One of the interesting things I find in the "Model Uncertainty" world is this notion of a "true model". This implicitly means that our "model propositions" are of the form: $$M_i^{(1)}:\text{The ith
Addressing model uncertainty One of the interesting things I find in the "Model Uncertainty" world is this notion of a "true model". This implicitly means that our "model propositions" are of the form: $$M_i^{(1)}:\text{The ith model is the true model}$$ From which we calculate the posterior probabilities $P(M_i^{(1)}|DI)$. This procedure seems highly dubious at a conceptual level to me. It is a big call (or an impossible calculation) to suppose that the $M_i^{(1)}$ propositions are exhaustive. For any set of models you can produce, there is sure to be an alternative model you haven't thought of yet. And so goes the infinite regress... Exhaustiveness is crucial here, because this ensures the probabilities add to 1, which means we can marginalise out the model. But this is all at the conceptual level - model averaging has good performance. So this means there must be a better concept. Personally, I view models as tools, like a hammer or a drill. Models are mental constructs used for making predictions about or describing things we can observe. It sounds very odd to speak of a "true hammer", and equally bizzare to speak of a "true mental construct". Based on this, the notion of a "true model" seems weird to me. It seems much more natural to think of "good" models and "bad" models, rather than "right" models and "wrong" models. Taking this viewpoint, we could equally well be uncertain as to the "best" model to use, from a selection of models. So suppose we instead reason about the propostion: $$M_i^{(2)}:\text{Out of all the models that have been specified,}$$ $$\text{the ith model is best model to use}$$ Now this is a much better way to think about "model uncertainty" I think. We are uncertain about which model to use, rather than which model is "right". This also makes the model averaging seem like a better thing to do (to me anyways). And as far as I can tell, the posterior for $M_{i}^{(2)}$ using BIC is perfectly fine as a rough, easy approximation. And further, the propositions $M_{i}^{(2)}$ are exhaustive in addition to being exclusive. In this approach however, you do need some sort of goodness of fit measure, in order to gauge how good your "best" model is. This can be done in two ways, by testing against "sure thing" models, which amounts to the usual GoF statistics (KL divergence, Chi-square, etc.). Another way to gauge this is to include an extremely flexible model in your class of models - perhaps a normal mixture model with hundreds of components, or a Dirichlet process mixture. If this model comes out as the best, then it is likely that your other models are inadequate. This paper has a good theoretical discussion, and goes through, step by step, an example of how you actually do model selection.
Addressing model uncertainty One of the interesting things I find in the "Model Uncertainty" world is this notion of a "true model". This implicitly means that our "model propositions" are of the form: $$M_i^{(1)}:\text{The ith
11,051
Addressing model uncertainty
I know people use DIC and Bayes factor, as suncoolsu said. And I was interested when he said "There are results which show that BIC will select the true model with high probability" (references?). But I use the only thing I know, which is posterior predictive check, championed by Andrew Gelman. If you google Andrew Gelman and posterior predictive checks you will find a lot of things. And I'd take a look at what Christian Robert is writting on ABC about model choice. In any case, here are some references I like, and some recent posts in Gelman's blog: Blog DIC and AIC; More on DIC. Model checking and external validation Papers on posterior predictive checks: GELMAN, Andrew. (2003a). “A Bayesian Formulation of Exploratory Data Analysis and Goodness-of-fit Testing”. International Statistical Review, vol. 71, n.2, pp. 389-382. GELMAN, Andrew. (2003b). “Exploratory Data Analysis for Complex Models”. Journal of Computational and Graphic Statistics, vol. 13, n. 4, pp. 755/779. GELMAN, Andrew; MECHELEN, Iven Van; VERBEKE, Geert; HEITJAN, Daniel F.; MEULDERS, Michel. (2005). “Multiple Imputation for Model Checking: Completed-Data Plots with Missing and Latent Data.” Biometrics 61, 74–85, March GELMAN, Andrew; MENG, Xiao-Li; STERN, Hal. (1996). “Posterior Predictive Assessment of Model Fitness via Realized Discrepancies”. Statistica Sinica, 6, pp. 733-807.
Addressing model uncertainty
I know people use DIC and Bayes factor, as suncoolsu said. And I was interested when he said "There are results which show that BIC will select the true model with high probability" (references?). But
Addressing model uncertainty I know people use DIC and Bayes factor, as suncoolsu said. And I was interested when he said "There are results which show that BIC will select the true model with high probability" (references?). But I use the only thing I know, which is posterior predictive check, championed by Andrew Gelman. If you google Andrew Gelman and posterior predictive checks you will find a lot of things. And I'd take a look at what Christian Robert is writting on ABC about model choice. In any case, here are some references I like, and some recent posts in Gelman's blog: Blog DIC and AIC; More on DIC. Model checking and external validation Papers on posterior predictive checks: GELMAN, Andrew. (2003a). “A Bayesian Formulation of Exploratory Data Analysis and Goodness-of-fit Testing”. International Statistical Review, vol. 71, n.2, pp. 389-382. GELMAN, Andrew. (2003b). “Exploratory Data Analysis for Complex Models”. Journal of Computational and Graphic Statistics, vol. 13, n. 4, pp. 755/779. GELMAN, Andrew; MECHELEN, Iven Van; VERBEKE, Geert; HEITJAN, Daniel F.; MEULDERS, Michel. (2005). “Multiple Imputation for Model Checking: Completed-Data Plots with Missing and Latent Data.” Biometrics 61, 74–85, March GELMAN, Andrew; MENG, Xiao-Li; STERN, Hal. (1996). “Posterior Predictive Assessment of Model Fitness via Realized Discrepancies”. Statistica Sinica, 6, pp. 733-807.
Addressing model uncertainty I know people use DIC and Bayes factor, as suncoolsu said. And I was interested when he said "There are results which show that BIC will select the true model with high probability" (references?). But
11,052
What could cause big differences in correlation coefficient between Pearson's and Spearman's correlation for a given dataset?
Why the big difference If your data is normally distributed or uniformly distributed, I would think that Spearman's and Pearson's correlation should be fairly similar. If they are giving very different results as in your case (.65 versus .30), my guess is that you have skewed data or outliers, and that outliers are leading Pearson's correlation to be larger than Spearman's correlation. I.e., very high values on X might co-occur with very high values on Y. @chl is spot on. Your first step should be to look at the scatter plot. In general, such a big difference between Pearson and Spearman is a red flag suggesting that the Pearson correlation may not be a useful summary of the association between your two variables, or you should transform one or both variables before using Pearson's correlation, or you should remove or adjust outliers before using Pearson's correlation. Related Questions Also see these previous questions on differences between Spearman and Pearson's correlation: How to choose between Pearson and Spearman correlation? Pearson's or Spearman's correlation with non-normal data Simple R Example The following is a simple simulation of how this might occur. Note that the case below involves a single outlier, but that you could produce similar effects with multiple outliers or skewed data. # Set Seed of random number generator set.seed(4444) # Generate random data # First, create some normally distributed correlated data x1 <- rnorm(200) y1 <- rnorm(200) + .6 * x1 # Second, add a major outlier x2 <- c(x1, 14) y2 <- c(y1, 14) # Plot both data sets par(mfrow=c(2,2)) plot(x1, y1, main="Raw no outlier") plot(x2, y2, main="Raw with outlier") plot(rank(x1), rank(y1), main="Rank no outlier") plot(rank(x2), rank(y2), main="Rank with outlier") # Calculate correlations on both datasets round(cor(x1, y1, method="pearson"), 2) round(cor(x1, y1, method="spearman"), 2) round(cor(x2, y2, method="pearson"), 2) round(cor(x2, y2, method="spearman"), 2) Which gives this output [1] 0.44 [1] 0.44 [1] 0.7 [1] 0.44 The correlation analysis shows that without the outlier Spearman and Pearson are quite similar, and with the rather extreme outlier, the correlation is quite different. The plot below shows how treating the data as ranks removes the extreme influence of the outlier, thus leading Spearman to be similar both with and without the outlier whereas Pearson is quite different when the outlier is added. This highlights why Spearman is often called robust.
What could cause big differences in correlation coefficient between Pearson's and Spearman's correla
Why the big difference If your data is normally distributed or uniformly distributed, I would think that Spearman's and Pearson's correlation should be fairly similar. If they are giving very differe
What could cause big differences in correlation coefficient between Pearson's and Spearman's correlation for a given dataset? Why the big difference If your data is normally distributed or uniformly distributed, I would think that Spearman's and Pearson's correlation should be fairly similar. If they are giving very different results as in your case (.65 versus .30), my guess is that you have skewed data or outliers, and that outliers are leading Pearson's correlation to be larger than Spearman's correlation. I.e., very high values on X might co-occur with very high values on Y. @chl is spot on. Your first step should be to look at the scatter plot. In general, such a big difference between Pearson and Spearman is a red flag suggesting that the Pearson correlation may not be a useful summary of the association between your two variables, or you should transform one or both variables before using Pearson's correlation, or you should remove or adjust outliers before using Pearson's correlation. Related Questions Also see these previous questions on differences between Spearman and Pearson's correlation: How to choose between Pearson and Spearman correlation? Pearson's or Spearman's correlation with non-normal data Simple R Example The following is a simple simulation of how this might occur. Note that the case below involves a single outlier, but that you could produce similar effects with multiple outliers or skewed data. # Set Seed of random number generator set.seed(4444) # Generate random data # First, create some normally distributed correlated data x1 <- rnorm(200) y1 <- rnorm(200) + .6 * x1 # Second, add a major outlier x2 <- c(x1, 14) y2 <- c(y1, 14) # Plot both data sets par(mfrow=c(2,2)) plot(x1, y1, main="Raw no outlier") plot(x2, y2, main="Raw with outlier") plot(rank(x1), rank(y1), main="Rank no outlier") plot(rank(x2), rank(y2), main="Rank with outlier") # Calculate correlations on both datasets round(cor(x1, y1, method="pearson"), 2) round(cor(x1, y1, method="spearman"), 2) round(cor(x2, y2, method="pearson"), 2) round(cor(x2, y2, method="spearman"), 2) Which gives this output [1] 0.44 [1] 0.44 [1] 0.7 [1] 0.44 The correlation analysis shows that without the outlier Spearman and Pearson are quite similar, and with the rather extreme outlier, the correlation is quite different. The plot below shows how treating the data as ranks removes the extreme influence of the outlier, thus leading Spearman to be similar both with and without the outlier whereas Pearson is quite different when the outlier is added. This highlights why Spearman is often called robust.
What could cause big differences in correlation coefficient between Pearson's and Spearman's correla Why the big difference If your data is normally distributed or uniformly distributed, I would think that Spearman's and Pearson's correlation should be fairly similar. If they are giving very differe
11,053
Why is skip-gram better for infrequent words than CBOW?
Here is my oversimplified and rather naive understanding of the difference: As we know, CBOW is learning to predict the word by the context. Or maximize the probability of the target word by looking at the context. And this happens to be a problem for rare words. For example, given the context yesterday was really [...] day CBOW model will tell you that most probably the word is beautiful or nice. Words like delightful will get much less attention of the model, because it is designed to predict the most probable word. Rare words will be smoothed over a lot of examples with more frequent words. On the other hand, the skip-gram is designed to predict the context. Given the word delightful it must understand it and tell us, that there is huge probability, the context is yesterday was really [...] day, or some other relevant context. With skip-gram the word delightful will not try to compete with word beautiful but instead, delightful+context pairs will be treated as new observations. Because of this, skip-gram will need more data so it will learn to understand even rare words.
Why is skip-gram better for infrequent words than CBOW?
Here is my oversimplified and rather naive understanding of the difference: As we know, CBOW is learning to predict the word by the context. Or maximize the probability of the target word by looking a
Why is skip-gram better for infrequent words than CBOW? Here is my oversimplified and rather naive understanding of the difference: As we know, CBOW is learning to predict the word by the context. Or maximize the probability of the target word by looking at the context. And this happens to be a problem for rare words. For example, given the context yesterday was really [...] day CBOW model will tell you that most probably the word is beautiful or nice. Words like delightful will get much less attention of the model, because it is designed to predict the most probable word. Rare words will be smoothed over a lot of examples with more frequent words. On the other hand, the skip-gram is designed to predict the context. Given the word delightful it must understand it and tell us, that there is huge probability, the context is yesterday was really [...] day, or some other relevant context. With skip-gram the word delightful will not try to compete with word beautiful but instead, delightful+context pairs will be treated as new observations. Because of this, skip-gram will need more data so it will learn to understand even rare words.
Why is skip-gram better for infrequent words than CBOW? Here is my oversimplified and rather naive understanding of the difference: As we know, CBOW is learning to predict the word by the context. Or maximize the probability of the target word by looking a
11,054
Why is skip-gram better for infrequent words than CBOW?
In CBOW the vectors from the context words are averaged before predicting the center word. In skip-gram there is no averaging of embedding vectors. It seems like the model can learn better representations for the rare words when their vectors are not averaged with the other context words in the process of making the predictions.
Why is skip-gram better for infrequent words than CBOW?
In CBOW the vectors from the context words are averaged before predicting the center word. In skip-gram there is no averaging of embedding vectors. It seems like the model can learn better representat
Why is skip-gram better for infrequent words than CBOW? In CBOW the vectors from the context words are averaged before predicting the center word. In skip-gram there is no averaging of embedding vectors. It seems like the model can learn better representations for the rare words when their vectors are not averaged with the other context words in the process of making the predictions.
Why is skip-gram better for infrequent words than CBOW? In CBOW the vectors from the context words are averaged before predicting the center word. In skip-gram there is no averaging of embedding vectors. It seems like the model can learn better representat
11,055
Why is skip-gram better for infrequent words than CBOW?
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. I have just come across a paper that shows the opposite: that CBOW is better for infrequent words than skip-gram https://arxiv.org/abs/1609.08293. I wonder what are the sources of the stated claim on https://code.google.com/p/word2vec/.
Why is skip-gram better for infrequent words than CBOW?
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.
Why is skip-gram better for infrequent words than CBOW? 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. I have just come across a paper that shows the opposite: that CBOW is better for infrequent words than skip-gram https://arxiv.org/abs/1609.08293. I wonder what are the sources of the stated claim on https://code.google.com/p/word2vec/.
Why is skip-gram better for infrequent words than CBOW? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
11,056
Goodness of fit and which model to choose linear regression or Poisson
Most important is the logic behind the model. Your variable "number of patents per year" is a count variable, so Poisson regression is indicated. That is a GLM (generalized linear model) with (usually) log link function, while the usual linear regression is a Gaussian GLM with identity link. Here, it is truly the log link function which is most important, more important than the error distribution (Poisson or Gaussian). The variable "Patents" is an extensive variable: see intensive and extensive properties. For intensive variables, such as temperature, linear models (with identity link) are often appropriate. But with an extensive variable it is different. Think that one of your pharmaceutical companies split into two different companies. Then the patents had to be split among the two new companies. What happens with the covariables, the $x$'s in your regression? Variables like number of employees and RD budget would have to be split too. Broadly, in this context, an intensive variable is a variable which is independent of company size, while an extensive variable depends (typically, linearly) on company size. So, in a sense, if we have many different extensive variables in the regression equation, we are measuring size effects repeatedly. That seems redundant, so we should try to, when possible, express variables in intensive form, like RD budget per employee (or as percent of total budget), likewise revenue, etc. A variable like number of employees will have to be left as extensive. See @onestop's answer to Dealing with correlated regressors for another discussion of this extensive/intensive variable issue. Let's look at this algebraically: $P, B, E$ are Patents, Budget (per employee), Employees in the original company, while $P_1, B_1, E_1$ and $P_2, B_2, E_2$ are the corresponding variables after a split. Assume, as above, that $E$ is the only extensive covariable (with $P$, of course, also extensive). Then, before the split, we have the model, identity link, with random part left out: $$ P= \mu+\beta_1 E + \beta_2 B $$ Let the split fractions be $\alpha, 1-\alpha$ so for company 1 after the split we get \begin{align} \alpha P &= \alpha \mu +\alpha\beta_1 E +\alpha\beta_2 B \\[5pt] P_1 &= \alpha\mu + \beta_1 E_1 + \alpha\beta_2 B_1 \end{align} since $P_1=\alpha P, E_1=\alpha E$ but $B_1=B$. Likewise for company two. So the model depends in a quite complicated way on company size, only the regression coefficient on $E$ being independent of company size, size influencing all other parameters. That makes interpretation of results difficult, especially so, if in your data you have companies of varying size, then how are you going to interpret those coefficients? Comparison with other studies based on other data, etc., gets wildly complicated. Now, let us see if using a log link function can help. Again, we write idealized models without disturbance terms. The variables are as above. First, the model before the split: $$ P = \exp\left(\mu+\beta_1 E + \beta_2 B\right) $$ After the split, for company one, we get: \begin{align} P_1 &= \exp(\log\alpha) \exp\left(\mu+\beta_1 E + \beta_2 B\right) \\[5pt] P_1 &= \exp\left(\log\alpha+\mu+\beta_1 E +\beta_2 B_1 \right) \end{align} This looks almost right, except for one problem, the part of dependency on $E$ doesn't quite work out. So we see that number of employees, the one covariable in extensive form, must be used on a log scale. Then, trying again, we get: Model before the split: $$ P = \exp\left(\mu+\beta_1 \log E + \beta_2 B\right) $$ After the split: \begin{align} P_1 &= \exp(\log\alpha) \exp\left(\hspace{9.5mm}\mu+\beta_1 \log E + \beta_2 B\right) \\[5pt] P_1 &= \exp\left(\log\alpha+\hspace{6mm}\hspace{9.5mm}\mu+\beta_1 \log E +\beta_2 B_1 \right) \\[5pt] P_1 &= \exp\left((1-\beta)\log\alpha+\mu+\beta_1 \log E_1 +\beta_2 B_1\right) \\[5pt] P_1 &= \exp\left(\hspace{31mm}\mu'+\beta_1 \log E_1 +\beta_2 B_1\right) \end{align} where $\mu'$ is a new intercept. Now, we have put the model in a form where all parameters (except the intercept) have an interpretation independent of company size. That makes interpretations of results much easier, and also comparisons with studies using other data, trends with time, and so on. You cannot achieve this form with parameters with size-independent interpretations with an identity link. Conclusion: Use a GLM with log link function, maybe a Poisson regression, or negative-binomial, or ... The link function is orders of magnitude more important! To sum up, when constructing a regression model for a response variable which is extensive, like a count variable. Try to express covariables in intensive form. Covariables which must be left as extensive: log them (the algebra above depends on there being at most one extensive covariable). Use a log link function. Then, other criteria, such as those based on fit, can be used for secondary decisions, such as the distribution of the disturbance term.
Goodness of fit and which model to choose linear regression or Poisson
Most important is the logic behind the model. Your variable "number of patents per year" is a count variable, so Poisson regression is indicated. That is a GLM (generalized linear model) with (usually
Goodness of fit and which model to choose linear regression or Poisson Most important is the logic behind the model. Your variable "number of patents per year" is a count variable, so Poisson regression is indicated. That is a GLM (generalized linear model) with (usually) log link function, while the usual linear regression is a Gaussian GLM with identity link. Here, it is truly the log link function which is most important, more important than the error distribution (Poisson or Gaussian). The variable "Patents" is an extensive variable: see intensive and extensive properties. For intensive variables, such as temperature, linear models (with identity link) are often appropriate. But with an extensive variable it is different. Think that one of your pharmaceutical companies split into two different companies. Then the patents had to be split among the two new companies. What happens with the covariables, the $x$'s in your regression? Variables like number of employees and RD budget would have to be split too. Broadly, in this context, an intensive variable is a variable which is independent of company size, while an extensive variable depends (typically, linearly) on company size. So, in a sense, if we have many different extensive variables in the regression equation, we are measuring size effects repeatedly. That seems redundant, so we should try to, when possible, express variables in intensive form, like RD budget per employee (or as percent of total budget), likewise revenue, etc. A variable like number of employees will have to be left as extensive. See @onestop's answer to Dealing with correlated regressors for another discussion of this extensive/intensive variable issue. Let's look at this algebraically: $P, B, E$ are Patents, Budget (per employee), Employees in the original company, while $P_1, B_1, E_1$ and $P_2, B_2, E_2$ are the corresponding variables after a split. Assume, as above, that $E$ is the only extensive covariable (with $P$, of course, also extensive). Then, before the split, we have the model, identity link, with random part left out: $$ P= \mu+\beta_1 E + \beta_2 B $$ Let the split fractions be $\alpha, 1-\alpha$ so for company 1 after the split we get \begin{align} \alpha P &= \alpha \mu +\alpha\beta_1 E +\alpha\beta_2 B \\[5pt] P_1 &= \alpha\mu + \beta_1 E_1 + \alpha\beta_2 B_1 \end{align} since $P_1=\alpha P, E_1=\alpha E$ but $B_1=B$. Likewise for company two. So the model depends in a quite complicated way on company size, only the regression coefficient on $E$ being independent of company size, size influencing all other parameters. That makes interpretation of results difficult, especially so, if in your data you have companies of varying size, then how are you going to interpret those coefficients? Comparison with other studies based on other data, etc., gets wildly complicated. Now, let us see if using a log link function can help. Again, we write idealized models without disturbance terms. The variables are as above. First, the model before the split: $$ P = \exp\left(\mu+\beta_1 E + \beta_2 B\right) $$ After the split, for company one, we get: \begin{align} P_1 &= \exp(\log\alpha) \exp\left(\mu+\beta_1 E + \beta_2 B\right) \\[5pt] P_1 &= \exp\left(\log\alpha+\mu+\beta_1 E +\beta_2 B_1 \right) \end{align} This looks almost right, except for one problem, the part of dependency on $E$ doesn't quite work out. So we see that number of employees, the one covariable in extensive form, must be used on a log scale. Then, trying again, we get: Model before the split: $$ P = \exp\left(\mu+\beta_1 \log E + \beta_2 B\right) $$ After the split: \begin{align} P_1 &= \exp(\log\alpha) \exp\left(\hspace{9.5mm}\mu+\beta_1 \log E + \beta_2 B\right) \\[5pt] P_1 &= \exp\left(\log\alpha+\hspace{6mm}\hspace{9.5mm}\mu+\beta_1 \log E +\beta_2 B_1 \right) \\[5pt] P_1 &= \exp\left((1-\beta)\log\alpha+\mu+\beta_1 \log E_1 +\beta_2 B_1\right) \\[5pt] P_1 &= \exp\left(\hspace{31mm}\mu'+\beta_1 \log E_1 +\beta_2 B_1\right) \end{align} where $\mu'$ is a new intercept. Now, we have put the model in a form where all parameters (except the intercept) have an interpretation independent of company size. That makes interpretations of results much easier, and also comparisons with studies using other data, trends with time, and so on. You cannot achieve this form with parameters with size-independent interpretations with an identity link. Conclusion: Use a GLM with log link function, maybe a Poisson regression, or negative-binomial, or ... The link function is orders of magnitude more important! To sum up, when constructing a regression model for a response variable which is extensive, like a count variable. Try to express covariables in intensive form. Covariables which must be left as extensive: log them (the algebra above depends on there being at most one extensive covariable). Use a log link function. Then, other criteria, such as those based on fit, can be used for secondary decisions, such as the distribution of the disturbance term.
Goodness of fit and which model to choose linear regression or Poisson Most important is the logic behind the model. Your variable "number of patents per year" is a count variable, so Poisson regression is indicated. That is a GLM (generalized linear model) with (usually
11,057
Always Report Robust (White) Standard Errors?
Using robust standard errors has become common practice in economics. Robust standard errors are typically larger than non-robust (standard?) standard errors, so the practice can be viewed as an effort to be conservative. In large samples (e.g., if you are working with Census data with millions of observations or data sets with "just" thousands of observations), heteroskedasticity tests will almost surely turn up positive, so this approach is appropriate. Another means for combating heteroskedasticity is weighted least squares, but this approach has become looked down upon because it changes the estimates for parameters, unlike the use of robust standard errors. If your weights are incorrect, your estimates are biased. If your weights are right, however, you get smaller ("more efficient") standard errors than OLS with robust standard errors.
Always Report Robust (White) Standard Errors?
Using robust standard errors has become common practice in economics. Robust standard errors are typically larger than non-robust (standard?) standard errors, so the practice can be viewed as an effor
Always Report Robust (White) Standard Errors? Using robust standard errors has become common practice in economics. Robust standard errors are typically larger than non-robust (standard?) standard errors, so the practice can be viewed as an effort to be conservative. In large samples (e.g., if you are working with Census data with millions of observations or data sets with "just" thousands of observations), heteroskedasticity tests will almost surely turn up positive, so this approach is appropriate. Another means for combating heteroskedasticity is weighted least squares, but this approach has become looked down upon because it changes the estimates for parameters, unlike the use of robust standard errors. If your weights are incorrect, your estimates are biased. If your weights are right, however, you get smaller ("more efficient") standard errors than OLS with robust standard errors.
Always Report Robust (White) Standard Errors? Using robust standard errors has become common practice in economics. Robust standard errors are typically larger than non-robust (standard?) standard errors, so the practice can be viewed as an effor
11,058
Always Report Robust (White) Standard Errors?
Robust standard errors provide unbiased standard errors estimates under heteroscedasticity. There exists several statistical text books that provide a large and lengthy discussion on robust standard errors. The following site provides a somewhat comprehensive summary on robust standard errors: https://economictheoryblog.com/2016/08/07/robust-standard-errors/ Coming back to your questions. Using robust standard errors is not without caveats. According to Woolridge (2009 edition, page 268) using robust standard errors, the t-statistics obtained only have distributions which are similar to the exact t-distributions if the sample size is large. If the sample size is small, the t-stats obtained using robust regression might have distributions that are not close to the t distribution. This could throw off inference. Furthermore, in case of homoscedasticity, robust standard errors are still unbiased. However, they are not efficient. That is, conventional standard errors are more precise than robust standard errors. Finally, using robust standard errors is common practice in many academic fields.
Always Report Robust (White) Standard Errors?
Robust standard errors provide unbiased standard errors estimates under heteroscedasticity. There exists several statistical text books that provide a large and lengthy discussion on robust standard e
Always Report Robust (White) Standard Errors? Robust standard errors provide unbiased standard errors estimates under heteroscedasticity. There exists several statistical text books that provide a large and lengthy discussion on robust standard errors. The following site provides a somewhat comprehensive summary on robust standard errors: https://economictheoryblog.com/2016/08/07/robust-standard-errors/ Coming back to your questions. Using robust standard errors is not without caveats. According to Woolridge (2009 edition, page 268) using robust standard errors, the t-statistics obtained only have distributions which are similar to the exact t-distributions if the sample size is large. If the sample size is small, the t-stats obtained using robust regression might have distributions that are not close to the t distribution. This could throw off inference. Furthermore, in case of homoscedasticity, robust standard errors are still unbiased. However, they are not efficient. That is, conventional standard errors are more precise than robust standard errors. Finally, using robust standard errors is common practice in many academic fields.
Always Report Robust (White) Standard Errors? Robust standard errors provide unbiased standard errors estimates under heteroscedasticity. There exists several statistical text books that provide a large and lengthy discussion on robust standard e
11,059
Always Report Robust (White) Standard Errors?
In Introductory Econometrics (Woolridge, 2009 edition page 268) this question is addressed. Woolridge says that when using robust standard errors, the t-statistics obtained only have distributions which are similar to the exact t-distributions if the sample size is large. If the sample size is small, the t-stats obtained using robust regression might have distributions that are not close to the t distribution and this could throw off inference.
Always Report Robust (White) Standard Errors?
In Introductory Econometrics (Woolridge, 2009 edition page 268) this question is addressed. Woolridge says that when using robust standard errors, the t-statistics obtained only have distributions wh
Always Report Robust (White) Standard Errors? In Introductory Econometrics (Woolridge, 2009 edition page 268) this question is addressed. Woolridge says that when using robust standard errors, the t-statistics obtained only have distributions which are similar to the exact t-distributions if the sample size is large. If the sample size is small, the t-stats obtained using robust regression might have distributions that are not close to the t distribution and this could throw off inference.
Always Report Robust (White) Standard Errors? In Introductory Econometrics (Woolridge, 2009 edition page 268) this question is addressed. Woolridge says that when using robust standard errors, the t-statistics obtained only have distributions wh
11,060
Always Report Robust (White) Standard Errors?
There are a lot of reasons to avoid using robust standard errors. Technically what happens is, that the variances get weighted by weights that you can not prove in reality. Thus robustness is just a cosmetic tool. In general you should thin about changing the model. There are a lot of implications to deal with heterogeneity in a better way than just to paint over the problem that occurs from your data. Take it as a sign to switch the model. The question is close related to the question how to deal with outliers. Some people just delete them to get better results, it's nearly the same when using robust standard errors, just in another context.
Always Report Robust (White) Standard Errors?
There are a lot of reasons to avoid using robust standard errors. Technically what happens is, that the variances get weighted by weights that you can not prove in reality. Thus robustness is just a c
Always Report Robust (White) Standard Errors? There are a lot of reasons to avoid using robust standard errors. Technically what happens is, that the variances get weighted by weights that you can not prove in reality. Thus robustness is just a cosmetic tool. In general you should thin about changing the model. There are a lot of implications to deal with heterogeneity in a better way than just to paint over the problem that occurs from your data. Take it as a sign to switch the model. The question is close related to the question how to deal with outliers. Some people just delete them to get better results, it's nearly the same when using robust standard errors, just in another context.
Always Report Robust (White) Standard Errors? There are a lot of reasons to avoid using robust standard errors. Technically what happens is, that the variances get weighted by weights that you can not prove in reality. Thus robustness is just a c
11,061
Always Report Robust (White) Standard Errors?
I thought that the White Standard Error and the Standard Error computed in the "normal" way (eg, Hessian and/or OPG in the case of maximum likelihood) were asymptotically equivalent in the case of homoskedasticity? Only if there is heteroskedasticity will the "normal" standard error be inappropriate, which means that the White Standard Error is appropriate with or without heteroskedasticity, that is, even when your model is homoskedastic. I can't really talk about 2, but I don't see the why one wouldn't want to calculate the White SE and include in the results.
Always Report Robust (White) Standard Errors?
I thought that the White Standard Error and the Standard Error computed in the "normal" way (eg, Hessian and/or OPG in the case of maximum likelihood) were asymptotically equivalent in the case of hom
Always Report Robust (White) Standard Errors? I thought that the White Standard Error and the Standard Error computed in the "normal" way (eg, Hessian and/or OPG in the case of maximum likelihood) were asymptotically equivalent in the case of homoskedasticity? Only if there is heteroskedasticity will the "normal" standard error be inappropriate, which means that the White Standard Error is appropriate with or without heteroskedasticity, that is, even when your model is homoskedastic. I can't really talk about 2, but I don't see the why one wouldn't want to calculate the White SE and include in the results.
Always Report Robust (White) Standard Errors? I thought that the White Standard Error and the Standard Error computed in the "normal" way (eg, Hessian and/or OPG in the case of maximum likelihood) were asymptotically equivalent in the case of hom
11,062
Always Report Robust (White) Standard Errors?
I have a textbook entitled Introduction to Econometrics, 3rd ed. by Stock and Watson that reads, "if the errors are heteroskedastic, then the t-statistic computed using the homoskedasticity-only standard error does not have a standard normal distribution, even in large samples." I believe you cannot do proper inference/hypothesis testing without being able to assume your t-statistic is distributed as standard normal. I have a LOT of respect for Wooldridge (in fact, my graduate-level class also used his book) so I believe what he says about the t-stats using robust SEs require large samples to be appropriate is definitely correct, but I think we often have to deal with the large-sample requirement, and we accept that. However, the fact that using non-robust SEs won't give a t-stat with the proper standard normal distribution even if you DO have a large sample creates a much bigger challenge to overcome.
Always Report Robust (White) Standard Errors?
I have a textbook entitled Introduction to Econometrics, 3rd ed. by Stock and Watson that reads, "if the errors are heteroskedastic, then the t-statistic computed using the homoskedasticity-only stand
Always Report Robust (White) Standard Errors? I have a textbook entitled Introduction to Econometrics, 3rd ed. by Stock and Watson that reads, "if the errors are heteroskedastic, then the t-statistic computed using the homoskedasticity-only standard error does not have a standard normal distribution, even in large samples." I believe you cannot do proper inference/hypothesis testing without being able to assume your t-statistic is distributed as standard normal. I have a LOT of respect for Wooldridge (in fact, my graduate-level class also used his book) so I believe what he says about the t-stats using robust SEs require large samples to be appropriate is definitely correct, but I think we often have to deal with the large-sample requirement, and we accept that. However, the fact that using non-robust SEs won't give a t-stat with the proper standard normal distribution even if you DO have a large sample creates a much bigger challenge to overcome.
Always Report Robust (White) Standard Errors? I have a textbook entitled Introduction to Econometrics, 3rd ed. by Stock and Watson that reads, "if the errors are heteroskedastic, then the t-statistic computed using the homoskedasticity-only stand
11,063
Bayesian updating with new data
The basic idea of Bayesian updating is that given some data $X$ and prior over parameter of interest $\theta$, where the relation between data and parameter is described using likelihood function, you use Bayes theorem to obtain posterior $$ p(\theta \mid X) \propto p(X \mid \theta) \, p(\theta) $$ This can be done sequentially, where after seeing first data point $x_1$ prior $\theta$ becomes updated to posterior $\theta'$, next you can take second data point $x_2$ and use posterior obtained before $\theta'$ as your prior, to update it once again etc. Let me give you an example. Imagine that you want to estimate mean $\mu$ of normal distribution and $\sigma^2$ is known to you. In such case we can use normal-normal model. We assume normal prior for $\mu$ with hyperparameters $\mu_0,\sigma_0^2:$ \begin{align} X\mid\mu &\sim \mathrm{Normal}(\mu,\ \sigma^2) \\ \mu &\sim \mathrm{Normal}(\mu_0,\ \sigma_0^2) \end{align} Since normal distribution is a conjugate prior for $\mu$ of normal distribution, we have closed-form solution to update the prior \begin{align} E(\mu' \mid x) &= \frac{\sigma^2\mu + \sigma^2_0 x}{\sigma^2 + \sigma^2_0} \\[7pt] \mathrm{Var}(\mu' \mid x) &= \frac{\sigma^2 \sigma^2_0}{\sigma^2 + \sigma^2_0} \end{align} Unfortunately, such simple closed-form solutions are not available for more sophisticated problems and you have to rely on optimization algorithms (for point estimates using maximum a posteriori approach), or MCMC simulation. Below you can see data example: n <- 1000 set.seed(123) x <- rnorm(n, 1.4, 2.7) mu <- numeric(n) sigma <- numeric(n) mu[1] <- (10000*x[i] + (2.7^2)*0)/(10000+2.7^2) sigma[1] <- (10000*2.7^2)/(10000+2.7^2) for (i in 2:n) { mu[i] <- ( sigma[i-1]*x[i] + (2.7^2)*mu[i-1] )/(sigma[i-1]+2.7^2) sigma[i] <- ( sigma[i-1]*2.7^2 )/(sigma[i-1]+2.7^2) } If you plot the results, you'll see how posterior approaches the estimated value (it's true value is marked by red line) as new data is accumulated. For learning more you can check those slides and Conjugate Bayesian analysis of the Gaussian distribution paper by Kevin P. Murphy. Check also Do Bayesian priors become irrelevant with large sample size? You can also check those notes and this blog entry for accessible step-by-step introduction to Bayesian inference.
Bayesian updating with new data
The basic idea of Bayesian updating is that given some data $X$ and prior over parameter of interest $\theta$, where the relation between data and parameter is described using likelihood function, you
Bayesian updating with new data The basic idea of Bayesian updating is that given some data $X$ and prior over parameter of interest $\theta$, where the relation between data and parameter is described using likelihood function, you use Bayes theorem to obtain posterior $$ p(\theta \mid X) \propto p(X \mid \theta) \, p(\theta) $$ This can be done sequentially, where after seeing first data point $x_1$ prior $\theta$ becomes updated to posterior $\theta'$, next you can take second data point $x_2$ and use posterior obtained before $\theta'$ as your prior, to update it once again etc. Let me give you an example. Imagine that you want to estimate mean $\mu$ of normal distribution and $\sigma^2$ is known to you. In such case we can use normal-normal model. We assume normal prior for $\mu$ with hyperparameters $\mu_0,\sigma_0^2:$ \begin{align} X\mid\mu &\sim \mathrm{Normal}(\mu,\ \sigma^2) \\ \mu &\sim \mathrm{Normal}(\mu_0,\ \sigma_0^2) \end{align} Since normal distribution is a conjugate prior for $\mu$ of normal distribution, we have closed-form solution to update the prior \begin{align} E(\mu' \mid x) &= \frac{\sigma^2\mu + \sigma^2_0 x}{\sigma^2 + \sigma^2_0} \\[7pt] \mathrm{Var}(\mu' \mid x) &= \frac{\sigma^2 \sigma^2_0}{\sigma^2 + \sigma^2_0} \end{align} Unfortunately, such simple closed-form solutions are not available for more sophisticated problems and you have to rely on optimization algorithms (for point estimates using maximum a posteriori approach), or MCMC simulation. Below you can see data example: n <- 1000 set.seed(123) x <- rnorm(n, 1.4, 2.7) mu <- numeric(n) sigma <- numeric(n) mu[1] <- (10000*x[i] + (2.7^2)*0)/(10000+2.7^2) sigma[1] <- (10000*2.7^2)/(10000+2.7^2) for (i in 2:n) { mu[i] <- ( sigma[i-1]*x[i] + (2.7^2)*mu[i-1] )/(sigma[i-1]+2.7^2) sigma[i] <- ( sigma[i-1]*2.7^2 )/(sigma[i-1]+2.7^2) } If you plot the results, you'll see how posterior approaches the estimated value (it's true value is marked by red line) as new data is accumulated. For learning more you can check those slides and Conjugate Bayesian analysis of the Gaussian distribution paper by Kevin P. Murphy. Check also Do Bayesian priors become irrelevant with large sample size? You can also check those notes and this blog entry for accessible step-by-step introduction to Bayesian inference.
Bayesian updating with new data The basic idea of Bayesian updating is that given some data $X$ and prior over parameter of interest $\theta$, where the relation between data and parameter is described using likelihood function, you
11,064
Bayesian updating with new data
If you have a prior $P(\theta)$ and a likelihood function $P(x \mid \theta)$ you can calculate the posterior with: $$ P(\theta \mid x) = \frac{\sum_\theta P(x \mid \theta) P(\theta)}{P(x)} $$ Since $P(x)$ is just a normalization constant to make probabilities sum to one, you could write: $$P(\theta \mid x) \sim \sum_\theta P(x \mid \theta)P(\theta) $$ Where $\sim$ means "is proportional to." The case of conjugate priors (where you often get nice closed form formulas) This Wikipedia article on conjugate priors may be informative. Let $\boldsymbol{\theta}$ be a vector of your parameters. Let $P(\boldsymbol{\theta})$ be a prior over your parameters. Let $P(\mathbf{x} \mid \boldsymbol{\theta})$ be the likelihood function, the probability of the data given the parameters. The prior is a conjugate prior for the likelihood function if the prior $P(\boldsymbol{\theta})$ and the posterior $P(\boldsymbol{\theta} \mid \mathbf{x})$ are in the same family (eg. both Gaussian). The table of conjugate distributions may help build some intuition (and also give some instructive examples to work through yourself).
Bayesian updating with new data
If you have a prior $P(\theta)$ and a likelihood function $P(x \mid \theta)$ you can calculate the posterior with: $$ P(\theta \mid x) = \frac{\sum_\theta P(x \mid \theta) P(\theta)}{P(x)} $$ Since $
Bayesian updating with new data If you have a prior $P(\theta)$ and a likelihood function $P(x \mid \theta)$ you can calculate the posterior with: $$ P(\theta \mid x) = \frac{\sum_\theta P(x \mid \theta) P(\theta)}{P(x)} $$ Since $P(x)$ is just a normalization constant to make probabilities sum to one, you could write: $$P(\theta \mid x) \sim \sum_\theta P(x \mid \theta)P(\theta) $$ Where $\sim$ means "is proportional to." The case of conjugate priors (where you often get nice closed form formulas) This Wikipedia article on conjugate priors may be informative. Let $\boldsymbol{\theta}$ be a vector of your parameters. Let $P(\boldsymbol{\theta})$ be a prior over your parameters. Let $P(\mathbf{x} \mid \boldsymbol{\theta})$ be the likelihood function, the probability of the data given the parameters. The prior is a conjugate prior for the likelihood function if the prior $P(\boldsymbol{\theta})$ and the posterior $P(\boldsymbol{\theta} \mid \mathbf{x})$ are in the same family (eg. both Gaussian). The table of conjugate distributions may help build some intuition (and also give some instructive examples to work through yourself).
Bayesian updating with new data If you have a prior $P(\theta)$ and a likelihood function $P(x \mid \theta)$ you can calculate the posterior with: $$ P(\theta \mid x) = \frac{\sum_\theta P(x \mid \theta) P(\theta)}{P(x)} $$ Since $
11,065
Bayesian updating with new data
This is the central computation issue for Bayesian data analysis. It really depends on the data and distributions involved. For simple cases where everything can be expressed in closed form (e.g., with conjugate priors), you can use Bayes's theorem directly. The most popular family of techniques for more complex cases is Markov chain Monte Carlo. For details, see any introductory textbook on Bayesian data analysis.
Bayesian updating with new data
This is the central computation issue for Bayesian data analysis. It really depends on the data and distributions involved. For simple cases where everything can be expressed in closed form (e.g., wit
Bayesian updating with new data This is the central computation issue for Bayesian data analysis. It really depends on the data and distributions involved. For simple cases where everything can be expressed in closed form (e.g., with conjugate priors), you can use Bayes's theorem directly. The most popular family of techniques for more complex cases is Markov chain Monte Carlo. For details, see any introductory textbook on Bayesian data analysis.
Bayesian updating with new data This is the central computation issue for Bayesian data analysis. It really depends on the data and distributions involved. For simple cases where everything can be expressed in closed form (e.g., wit
11,066
VAR forecasting methodology
I think you got it pretty right, but when building a VAR model, I usually make sure I follow these steps: 1. Select the variables This is the most important part of building your model. If you want to forecast the price of an asset, you need to include variables that are related with the mechanism of price formation. The best way to do this is through a theoretical model. Since you did not mention what is the asset and what are the other variables you included in your model I really cannot say much about this item, but you can find a summary of asset pricing models in here. 2. Check the data and make the proper adjustments Once you select the variables, you can make some adjustments to the data that will improve the estimation and interpretation of the model. It is useful to use summary statistics and see a plot of the series to detect outliers, missing data and other strange behaviors. When working with price data, people usually take natural logs, which is a variance-stabilizing transformation and also has a good interpretation (price difference in logs become continuously compound returns). I'm not sure if you have taken logs before estimating the model, but it is a good idea to do so if you are working with asset prices. 3. Check if data contains non-stationary components Now you can use unit root tests to check if your series are stationary. If you are only interested in forecasting, as noted by @JacobH, you can run VAR in levels even when your series are non-stationary, but then your standard errors cannot be trusted, meaning that you can't make inference about the value of the coefficients. You've tested stationary using the ADF test, which is very commonly used in these applications, but note that you should specify if you want to run the test with i) no constant and no trend; ii) a constant and no trend; and iii) a constant and a trend. Usually price series have stochastic trends, so a linear trend will not be accurate. In this case you may choose the specification ii. In your code you used the ndiffs function of the forecast package. I am not sure which of those three alternatives this function implements in order to calculate the number of differences (I couldn't find it in the documentation). To check your result you may want to use the ur.df function in the "urca" package: adf <- ur.df(x[, "VAR1"], type = "drift", lags = 10, selectlags = "AIC") Note that this command will run the ADF test with a constant and the lags selected by the AIC command, with maximum lag of 10. If you have problems interpreting the results just look at this question. If the series are I(1) just use the difference, which will be equal to the continuously compounded returns. If the test indicates that the series are I(2) and you are in doubt about that you can use other tests, e.g. Phillips-Perron test (PP.test function in R). If all tests confirm that your series are I(2) (remember to use the log of the series before running the tests) then take the second difference, but note that your interpretation of the results will change, since now you are working with the difference of the continuously compounded returns. Prices of assets are usually I(1) since they are close to a random walk, which is a white noise when applying the first difference. 4. Select the order of the model This can be done with commonly used criteria such as Akaike, Schwarz (BIC) and Hannan-Quinn. You've done that with the VARselect function and that is right, but remember what is the criterion that you used to make your decision. Usually different criteria indicate different orders for the VAR. 5. Check if there are cointegrating relationships If all your series are I(1) or I(2), before running a VAR model, it is usually a good idea to check if there is no cointegration relationships between the series, specially if you want to make impulse response analysis with the residuals. You can do that using the Johansenn test or the Engle-Granger (only for bivariate models). In R you can run the Johansen test with the ca.jo function of the "urca" package. Note that this test also has different specifications. For price series I usually use the following code (where p is the lag length of item 4, performed with the series in levels): jo_eigen <- ca.jo(x, type = "eigen", ecdet = "const", K = p) jo_trace <- ca.jo(x, type = "trace", ecdet = "const", K = p) 6. Estimate the model If your series are not cointegrated, you can easily estimate the model with the VAR command, as done in your code. In case the series are cointegrated you need to consider the long run relationship by estimating a Vector Error Correction model with the following code (where k is the order of cointegration): vecm <- cajorls(joeigen, r = k) 7. Run diagnostics tests To test if your model is well specified you can run a test of serial correlation on the residuals. In your code you used a Portmanteau test with the serial.test function. I've never used this function but I think it is OK. There is also a multivariate version of the Ljung-Box test implemented in the package MTS which you can run with the function mq. 8. Make predictions After you are sure your model is well specified you can use the predict function as you did in your code. You can even plot impulse response functions to check how the variables respond to a particular shock using the irf function. 9. Evaluate predictions Once you made your predictions you must evaluate them and compare against other models. Some methods to evaluate accuracy of forecasts can be found here, but to do that it is crucial that you divide your series in a training and a test set, as explained in the link.
VAR forecasting methodology
I think you got it pretty right, but when building a VAR model, I usually make sure I follow these steps: 1. Select the variables This is the most important part of building your model. If you want to
VAR forecasting methodology I think you got it pretty right, but when building a VAR model, I usually make sure I follow these steps: 1. Select the variables This is the most important part of building your model. If you want to forecast the price of an asset, you need to include variables that are related with the mechanism of price formation. The best way to do this is through a theoretical model. Since you did not mention what is the asset and what are the other variables you included in your model I really cannot say much about this item, but you can find a summary of asset pricing models in here. 2. Check the data and make the proper adjustments Once you select the variables, you can make some adjustments to the data that will improve the estimation and interpretation of the model. It is useful to use summary statistics and see a plot of the series to detect outliers, missing data and other strange behaviors. When working with price data, people usually take natural logs, which is a variance-stabilizing transformation and also has a good interpretation (price difference in logs become continuously compound returns). I'm not sure if you have taken logs before estimating the model, but it is a good idea to do so if you are working with asset prices. 3. Check if data contains non-stationary components Now you can use unit root tests to check if your series are stationary. If you are only interested in forecasting, as noted by @JacobH, you can run VAR in levels even when your series are non-stationary, but then your standard errors cannot be trusted, meaning that you can't make inference about the value of the coefficients. You've tested stationary using the ADF test, which is very commonly used in these applications, but note that you should specify if you want to run the test with i) no constant and no trend; ii) a constant and no trend; and iii) a constant and a trend. Usually price series have stochastic trends, so a linear trend will not be accurate. In this case you may choose the specification ii. In your code you used the ndiffs function of the forecast package. I am not sure which of those three alternatives this function implements in order to calculate the number of differences (I couldn't find it in the documentation). To check your result you may want to use the ur.df function in the "urca" package: adf <- ur.df(x[, "VAR1"], type = "drift", lags = 10, selectlags = "AIC") Note that this command will run the ADF test with a constant and the lags selected by the AIC command, with maximum lag of 10. If you have problems interpreting the results just look at this question. If the series are I(1) just use the difference, which will be equal to the continuously compounded returns. If the test indicates that the series are I(2) and you are in doubt about that you can use other tests, e.g. Phillips-Perron test (PP.test function in R). If all tests confirm that your series are I(2) (remember to use the log of the series before running the tests) then take the second difference, but note that your interpretation of the results will change, since now you are working with the difference of the continuously compounded returns. Prices of assets are usually I(1) since they are close to a random walk, which is a white noise when applying the first difference. 4. Select the order of the model This can be done with commonly used criteria such as Akaike, Schwarz (BIC) and Hannan-Quinn. You've done that with the VARselect function and that is right, but remember what is the criterion that you used to make your decision. Usually different criteria indicate different orders for the VAR. 5. Check if there are cointegrating relationships If all your series are I(1) or I(2), before running a VAR model, it is usually a good idea to check if there is no cointegration relationships between the series, specially if you want to make impulse response analysis with the residuals. You can do that using the Johansenn test or the Engle-Granger (only for bivariate models). In R you can run the Johansen test with the ca.jo function of the "urca" package. Note that this test also has different specifications. For price series I usually use the following code (where p is the lag length of item 4, performed with the series in levels): jo_eigen <- ca.jo(x, type = "eigen", ecdet = "const", K = p) jo_trace <- ca.jo(x, type = "trace", ecdet = "const", K = p) 6. Estimate the model If your series are not cointegrated, you can easily estimate the model with the VAR command, as done in your code. In case the series are cointegrated you need to consider the long run relationship by estimating a Vector Error Correction model with the following code (where k is the order of cointegration): vecm <- cajorls(joeigen, r = k) 7. Run diagnostics tests To test if your model is well specified you can run a test of serial correlation on the residuals. In your code you used a Portmanteau test with the serial.test function. I've never used this function but I think it is OK. There is also a multivariate version of the Ljung-Box test implemented in the package MTS which you can run with the function mq. 8. Make predictions After you are sure your model is well specified you can use the predict function as you did in your code. You can even plot impulse response functions to check how the variables respond to a particular shock using the irf function. 9. Evaluate predictions Once you made your predictions you must evaluate them and compare against other models. Some methods to evaluate accuracy of forecasts can be found here, but to do that it is crucial that you divide your series in a training and a test set, as explained in the link.
VAR forecasting methodology I think you got it pretty right, but when building a VAR model, I usually make sure I follow these steps: 1. Select the variables This is the most important part of building your model. If you want to
11,067
VAR forecasting methodology
I thought I would add to Regis A Ely very nice answer. His answer is not wrong, but using a VAR to forecast is different than using a VAR to do other VAR type things (i.e. IRF, FEVD, Historical Decomp. etc...). Consequently, some of the steps outlined by Regis A Ely will negatively effect your forecast in some cases. Disclaimer: When I refer to non-stationary data, I mean that the series contains a stochastic trend. If the data has a time/seasonal trend it must be filter appropriately. First Generally speaking, in an unrestricted VAR there is no need to worry about a spurious relationship. A spurious regression occurs when you regress a non-stationary series (Y) on another non-stationary series (X) and both series are not cointegrated. However, if you regress Y on X as well as lags of Y then the regression will not be spurious as the inclusion of the lag Y insures that the errors will be stationary. Said another way, lags of Y pick up the variation which was previous wrongly assigned to X. Since an unrestricted VAR is essentially a system of ARDL regressions where each equation contains the same number of lags and regressors, it should be clear that spurious regression are therefore not likely to be a problem. Said another way if your data is all I(1), regardless of whether of not it is co-integrated, you can run a VAR. VECM are only necessary when you want to both model and identify the short and long run/co-integration relationship between variables. The question now is, should you run the VAR in levels or in first differences. Second When forecasting, it is not necessary to first difference I(1) data. You can if you like, thought a surprisingly amount of practitioner don't. Remember when we have a non-stationary series, we can still obtain a consistent estimator. For a regression with a single lag of the dependent variable this is intuitive. If a series is following a random walk (i.e. non-stationary) we know the best estimate of where it will be next period is exactly were it was last period (i.e. beta is 1). The standard errors of estimates derived from models with non-stationary data, however, is different because strictly speaking the variance of the estimate approaches infinity as T approaches infinity. This, however, is not a problem for forecasting. Forecasting is essentially a conditional expectation and therefore only relies on the parameters estimates of your model and not standard errors. Further, prediction intervals of your forecast will either be obtained directly from your errors, by bootstrapping errors, or if you have a lot of data via empirical prediction intervals (my favorite!), all three of these approaches are unaffected by non-stationary data because again your errors will be stationary as per our spurious regression discussion above. Why do I care? The ADF test has low power, especially when the series is close to being unit root, but is not. Said another the ADF test will tend to mistakenly assert that a series is non-stationary when it in fact is not. Assume that your ADF test wrongly assures that the series is non-stationary. If you make all the necessary transformation and estimate a VECM, your forecast is going to be wrong, because your model is wrong. This is why people forecast in levels. What about Granger Causality??? You can even test GC with a VAR in levels when data is I(1). I know that sounds crazy. We know that inference is usually not possible with non-stationary data. It is however possible to test joint hypotheses, e.g. GC. This is shown in Toda and Yamamoto (1995) which draws on Sims, Stock and Watson (1990). For an application see http://davegiles.blogspot.com/2011/04/testing-for-granger-causality.html. Last thing If however, you want to use your VAR for things other than forecasting, be careful. A VAR in levels with non-stationary and co-integrated series can yield some weird results. For example, strictly speaking, the Moving Average representation of the VAR does not exist as the parameter matrix will not be invertible. Despite this fact IRF can still be obtained. Inference is also not feasible (thought joint hypotheses can be tested as discussed above). Also be worry of small samples. Everything I've discussed works well in large sample, but things can get wacky in small samples. This is especially true for GC with I(1) data.
VAR forecasting methodology
I thought I would add to Regis A Ely very nice answer. His answer is not wrong, but using a VAR to forecast is different than using a VAR to do other VAR type things (i.e. IRF, FEVD, Historical Decom
VAR forecasting methodology I thought I would add to Regis A Ely very nice answer. His answer is not wrong, but using a VAR to forecast is different than using a VAR to do other VAR type things (i.e. IRF, FEVD, Historical Decomp. etc...). Consequently, some of the steps outlined by Regis A Ely will negatively effect your forecast in some cases. Disclaimer: When I refer to non-stationary data, I mean that the series contains a stochastic trend. If the data has a time/seasonal trend it must be filter appropriately. First Generally speaking, in an unrestricted VAR there is no need to worry about a spurious relationship. A spurious regression occurs when you regress a non-stationary series (Y) on another non-stationary series (X) and both series are not cointegrated. However, if you regress Y on X as well as lags of Y then the regression will not be spurious as the inclusion of the lag Y insures that the errors will be stationary. Said another way, lags of Y pick up the variation which was previous wrongly assigned to X. Since an unrestricted VAR is essentially a system of ARDL regressions where each equation contains the same number of lags and regressors, it should be clear that spurious regression are therefore not likely to be a problem. Said another way if your data is all I(1), regardless of whether of not it is co-integrated, you can run a VAR. VECM are only necessary when you want to both model and identify the short and long run/co-integration relationship between variables. The question now is, should you run the VAR in levels or in first differences. Second When forecasting, it is not necessary to first difference I(1) data. You can if you like, thought a surprisingly amount of practitioner don't. Remember when we have a non-stationary series, we can still obtain a consistent estimator. For a regression with a single lag of the dependent variable this is intuitive. If a series is following a random walk (i.e. non-stationary) we know the best estimate of where it will be next period is exactly were it was last period (i.e. beta is 1). The standard errors of estimates derived from models with non-stationary data, however, is different because strictly speaking the variance of the estimate approaches infinity as T approaches infinity. This, however, is not a problem for forecasting. Forecasting is essentially a conditional expectation and therefore only relies on the parameters estimates of your model and not standard errors. Further, prediction intervals of your forecast will either be obtained directly from your errors, by bootstrapping errors, or if you have a lot of data via empirical prediction intervals (my favorite!), all three of these approaches are unaffected by non-stationary data because again your errors will be stationary as per our spurious regression discussion above. Why do I care? The ADF test has low power, especially when the series is close to being unit root, but is not. Said another the ADF test will tend to mistakenly assert that a series is non-stationary when it in fact is not. Assume that your ADF test wrongly assures that the series is non-stationary. If you make all the necessary transformation and estimate a VECM, your forecast is going to be wrong, because your model is wrong. This is why people forecast in levels. What about Granger Causality??? You can even test GC with a VAR in levels when data is I(1). I know that sounds crazy. We know that inference is usually not possible with non-stationary data. It is however possible to test joint hypotheses, e.g. GC. This is shown in Toda and Yamamoto (1995) which draws on Sims, Stock and Watson (1990). For an application see http://davegiles.blogspot.com/2011/04/testing-for-granger-causality.html. Last thing If however, you want to use your VAR for things other than forecasting, be careful. A VAR in levels with non-stationary and co-integrated series can yield some weird results. For example, strictly speaking, the Moving Average representation of the VAR does not exist as the parameter matrix will not be invertible. Despite this fact IRF can still be obtained. Inference is also not feasible (thought joint hypotheses can be tested as discussed above). Also be worry of small samples. Everything I've discussed works well in large sample, but things can get wacky in small samples. This is especially true for GC with I(1) data.
VAR forecasting methodology I thought I would add to Regis A Ely very nice answer. His answer is not wrong, but using a VAR to forecast is different than using a VAR to do other VAR type things (i.e. IRF, FEVD, Historical Decom
11,068
How to interpret parameters in GLM with family=Gamma
The log-linked gamma GLM specification is identical to exponential regression: $$E[y \vert x,z] = \exp \left( \alpha + \beta \cdot x +\gamma \cdot z \right)=\hat y$$ This means that $E[y \vert x=0,z=0]=\exp(\alpha)$. That's not a very meaningful value (unless you centered your variables to be be mean zero beforehand). There are at least three way to interpret your model. One is to take derivative of the expected value of $y$ given $x$ with respect to $x$: $$\frac{\partial E[y \vert x,z]}{\partial x} = \exp \left( \alpha + \beta \cdot x +\gamma \cdot z\right)\cdot \beta=\hat y \cdot \beta$$ This quantity depends on $x$ and $z$, so you can either evaluate this at the mean/median/modal or representative values of $x$ and $z$, or take the average of $\hat y \cdot \beta$ over your sample. These are both called marginal effects. These derivatives only make sense for continuous variables (like height) and tell you an additive effect of a small change in $x$ on $y$. If $x$ was binary (like sex), you might consider calculating finite differences instead: $$E[y \vert z,x=1]-E[y \vert z,x=0]=\exp \left( \alpha + \beta +\gamma \cdot z\right) - \exp \left( \alpha +\gamma \cdot z\right)= \exp \left( \alpha +\gamma \cdot z\right) \cdot\left( \exp(\beta)-1 \right)$$ This makes more sense since it's hard to imagine an infinitesimal change in sex. Of course, you can also do this with a continuous variable. These are additive effects from a one unit change in $x$, rather than a tiny one. The third method is to exponentiate the coefficients. Note that: $$ \begin{array} _E[y \vert z,x+1] &= \exp \left( \alpha + \beta \cdot (x+1) +\gamma \cdot z \right) \\ &=\exp \left( \alpha + \beta \cdot x+\beta +\gamma \cdot z \right)\\ &=\exp \left( \alpha + \beta \cdot x +\gamma \cdot z \right)\cdot \exp(\beta) \\ &= E[y \vert z,x]\cdot \exp(\beta) \end{array} $$ This means that you can interpret the exponentiated coefficients multiplicatively rather than additively. They give you the multiplier on the expected value when $x$ changes by 1.
How to interpret parameters in GLM with family=Gamma
The log-linked gamma GLM specification is identical to exponential regression: $$E[y \vert x,z] = \exp \left( \alpha + \beta \cdot x +\gamma \cdot z \right)=\hat y$$ This means that $E[y \vert x=0,z=
How to interpret parameters in GLM with family=Gamma The log-linked gamma GLM specification is identical to exponential regression: $$E[y \vert x,z] = \exp \left( \alpha + \beta \cdot x +\gamma \cdot z \right)=\hat y$$ This means that $E[y \vert x=0,z=0]=\exp(\alpha)$. That's not a very meaningful value (unless you centered your variables to be be mean zero beforehand). There are at least three way to interpret your model. One is to take derivative of the expected value of $y$ given $x$ with respect to $x$: $$\frac{\partial E[y \vert x,z]}{\partial x} = \exp \left( \alpha + \beta \cdot x +\gamma \cdot z\right)\cdot \beta=\hat y \cdot \beta$$ This quantity depends on $x$ and $z$, so you can either evaluate this at the mean/median/modal or representative values of $x$ and $z$, or take the average of $\hat y \cdot \beta$ over your sample. These are both called marginal effects. These derivatives only make sense for continuous variables (like height) and tell you an additive effect of a small change in $x$ on $y$. If $x$ was binary (like sex), you might consider calculating finite differences instead: $$E[y \vert z,x=1]-E[y \vert z,x=0]=\exp \left( \alpha + \beta +\gamma \cdot z\right) - \exp \left( \alpha +\gamma \cdot z\right)= \exp \left( \alpha +\gamma \cdot z\right) \cdot\left( \exp(\beta)-1 \right)$$ This makes more sense since it's hard to imagine an infinitesimal change in sex. Of course, you can also do this with a continuous variable. These are additive effects from a one unit change in $x$, rather than a tiny one. The third method is to exponentiate the coefficients. Note that: $$ \begin{array} _E[y \vert z,x+1] &= \exp \left( \alpha + \beta \cdot (x+1) +\gamma \cdot z \right) \\ &=\exp \left( \alpha + \beta \cdot x+\beta +\gamma \cdot z \right)\\ &=\exp \left( \alpha + \beta \cdot x +\gamma \cdot z \right)\cdot \exp(\beta) \\ &= E[y \vert z,x]\cdot \exp(\beta) \end{array} $$ This means that you can interpret the exponentiated coefficients multiplicatively rather than additively. They give you the multiplier on the expected value when $x$ changes by 1.
How to interpret parameters in GLM with family=Gamma The log-linked gamma GLM specification is identical to exponential regression: $$E[y \vert x,z] = \exp \left( \alpha + \beta \cdot x +\gamma \cdot z \right)=\hat y$$ This means that $E[y \vert x=0,z=
11,069
How to interpret parameters in GLM with family=Gamma
First I would look at the residuals to see how well the model fits. If it's OK, I would try using other link functions unless I had reason to believe it really came from a gamma distribution. If the gamma still looked convincing, I would conclude that the statistically significant terms are the intercept, height, education, sex, and high school (the ones marked with three stars). Among themselves one can't say more unless they are standardized (have the same range). Response to comment: I understand your question better now. You absolutely can do that! A unit increase in the height causes a exp(0.0082530)-1 ~= 0.0082530 (using the exp x = 1 + x approximation for small x) relative change in the income. Very easy to interpret, no?
How to interpret parameters in GLM with family=Gamma
First I would look at the residuals to see how well the model fits. If it's OK, I would try using other link functions unless I had reason to believe it really came from a gamma distribution. If the g
How to interpret parameters in GLM with family=Gamma First I would look at the residuals to see how well the model fits. If it's OK, I would try using other link functions unless I had reason to believe it really came from a gamma distribution. If the gamma still looked convincing, I would conclude that the statistically significant terms are the intercept, height, education, sex, and high school (the ones marked with three stars). Among themselves one can't say more unless they are standardized (have the same range). Response to comment: I understand your question better now. You absolutely can do that! A unit increase in the height causes a exp(0.0082530)-1 ~= 0.0082530 (using the exp x = 1 + x approximation for small x) relative change in the income. Very easy to interpret, no?
How to interpret parameters in GLM with family=Gamma First I would look at the residuals to see how well the model fits. If it's OK, I would try using other link functions unless I had reason to believe it really came from a gamma distribution. If the g
11,070
Does differential geometry have anything to do with statistics?
Two canonical books on the subject, with reviews, then two other references: Differential Geometry and Statistics, M.K. Murray, J.W. Rice Ever since the introduction by Rao in 1945 of the Fisher information metric on a family of probability distributions there has been interest among statisticians in the application of differential geometry to statistics. This interest has increased rapidly in the last couple of decades with the work of a large number of researchers. Until now an impediment to the spread of these ideas into the wider community of statisticians is the lack of a suitable text introducing the modern co-ordinate free approach to differential geometry in a manner accessible to statisticians. This book aims to fill this gap. The authors bring to the book extensive research experience in differential geometry and its application to statistics. The book commences with the study of the simplest differential manifolds - affine spaces and their relevance to exponential families and passes into the general theory, the Fisher information metric, the Amari connection and asymptotics. It culminates in the theory of the vector bundles, principle bundles and jets and their application to the theory of strings - a topic presently at the cutting edge of research in statistics and differential geometry. Methods of Information Geometry, S.-I. Amari, H. Nagaoka Information geometry provides the mathematical sciences with a new framework of analysis. It has emerged from the investigation of the natural differential geometric structure on manifolds of probability distributions, which consists of a Riemannian metric defined by the Fisher information and a one-parameter family of affine connections called the $\alpha$-connections. The duality between the $\alpha$-connection and the $(-\alpha)$-connection together with the metric play an essential role in this geometry. This kind of duality, having emerged from manifolds of probability distributions, is ubiquitous, appearing in a variety of problems which might have no explicit relation to probability theory. Through the duality, it is possible to analyze various fundamental problems in a unified perspective. The first half of this book is devoted to a comprehensive introduction to the mathematical foundation of information geometry, including preliminaries from differential geometry, the geometry of manifolds or probability distributions, and the general theory of dual affine connections. The second half of the text provides an overview of many areas of applications, such as statistics, linear systems, information theory, quantum mechanics, convex analysis, neural networks, and affine differential geometry. The book can serve as a suitable text for a topics course for advanced undergraduates and graduate students. Differential geometry in statistical inference, S.-I. Amari, O. E. Barndorff-Nielsen, R. E. Kass, S. L. Lauritzen, and C. R. Rao, IMS Lecture Notes Monogr. Ser. Volume 10, 1987, 240 pp. The Role of Differential Geometry in Statistical Theory, O. E. Barndorff-Nielsen, D. R. Cox and N. Reid, International Statistical Review / Revue Internationale de Statistique, Vol. 54, No. 1 (Apr., 1986), pp. 83-96
Does differential geometry have anything to do with statistics?
Two canonical books on the subject, with reviews, then two other references: Differential Geometry and Statistics, M.K. Murray, J.W. Rice Ever since the introduction by Rao in 1945 of the Fisher inf
Does differential geometry have anything to do with statistics? Two canonical books on the subject, with reviews, then two other references: Differential Geometry and Statistics, M.K. Murray, J.W. Rice Ever since the introduction by Rao in 1945 of the Fisher information metric on a family of probability distributions there has been interest among statisticians in the application of differential geometry to statistics. This interest has increased rapidly in the last couple of decades with the work of a large number of researchers. Until now an impediment to the spread of these ideas into the wider community of statisticians is the lack of a suitable text introducing the modern co-ordinate free approach to differential geometry in a manner accessible to statisticians. This book aims to fill this gap. The authors bring to the book extensive research experience in differential geometry and its application to statistics. The book commences with the study of the simplest differential manifolds - affine spaces and their relevance to exponential families and passes into the general theory, the Fisher information metric, the Amari connection and asymptotics. It culminates in the theory of the vector bundles, principle bundles and jets and their application to the theory of strings - a topic presently at the cutting edge of research in statistics and differential geometry. Methods of Information Geometry, S.-I. Amari, H. Nagaoka Information geometry provides the mathematical sciences with a new framework of analysis. It has emerged from the investigation of the natural differential geometric structure on manifolds of probability distributions, which consists of a Riemannian metric defined by the Fisher information and a one-parameter family of affine connections called the $\alpha$-connections. The duality between the $\alpha$-connection and the $(-\alpha)$-connection together with the metric play an essential role in this geometry. This kind of duality, having emerged from manifolds of probability distributions, is ubiquitous, appearing in a variety of problems which might have no explicit relation to probability theory. Through the duality, it is possible to analyze various fundamental problems in a unified perspective. The first half of this book is devoted to a comprehensive introduction to the mathematical foundation of information geometry, including preliminaries from differential geometry, the geometry of manifolds or probability distributions, and the general theory of dual affine connections. The second half of the text provides an overview of many areas of applications, such as statistics, linear systems, information theory, quantum mechanics, convex analysis, neural networks, and affine differential geometry. The book can serve as a suitable text for a topics course for advanced undergraduates and graduate students. Differential geometry in statistical inference, S.-I. Amari, O. E. Barndorff-Nielsen, R. E. Kass, S. L. Lauritzen, and C. R. Rao, IMS Lecture Notes Monogr. Ser. Volume 10, 1987, 240 pp. The Role of Differential Geometry in Statistical Theory, O. E. Barndorff-Nielsen, D. R. Cox and N. Reid, International Statistical Review / Revue Internationale de Statistique, Vol. 54, No. 1 (Apr., 1986), pp. 83-96
Does differential geometry have anything to do with statistics? Two canonical books on the subject, with reviews, then two other references: Differential Geometry and Statistics, M.K. Murray, J.W. Rice Ever since the introduction by Rao in 1945 of the Fisher inf
11,071
Does differential geometry have anything to do with statistics?
Riemannian geometry is used in the study of random fields (a generalization of stochastic processes), where the process doesn't have to be stationary. The reference I'm studying is given below with two reviews. There are applications in oceanography, astrophysics and brain imaging. Random Fields and Geometry, Adler, R. J., Taylor, Jonathan E. http://www.springer.com/us/book/9780387481128#otherversion=9781441923691 Reviews: "Developing good bounds for the distribution of the suprema of a Gaussian field $f$, i.e., for the quantity $\Bbb{P}\{\sup_{t\in M}f(t)\ge u\}$, has been for a long time both a difficult and an interesting subject of research. A thorough presentation of this problem is the main goal of the book under review, as is stated by the authors in its preface. The authors develop their results in the context of smooth Gaussian fields, where the parameter spaces $M$ are Riemannian stratified manifolds, and their approach is of a geometrical nature. The book is divided into three parts. Part I is devoted to the presentation of the necessary tools of Gaussian processes and fields. Part II concisely exposes the required prerequisites of integral and differential geometry. Finally, in part III, the kernel of the book, a formula for the expectation of the Euler characteristic function of an excursion set and its approximation to the distribution of the maxima of the field, is precisely established. The book is written in an informal style, which affords a very pleasant reading. Each chapter begins with a presentation of the matters to be addressed, and the footnotes, located throughout the text, serve as an indispensable complement and many times as historical references. The authors insist on the fact that this book should not only be considered as a theoretical adventure and they recommend a second volume where they develop indispensable applications which highlight all the power of their results." (José Rafael León for Mathematical Reviews) "This book presents the modern theory of excursion probabilities and the geometry of excursion sets for … random fields defined on manifolds. ... The book is understandable for students … with a good background in analysis. ... The interdisciplinary nature of this book, the beauty and depth of the presented mathematical theory make it an indispensable part of every mathematical library and a bookshelf of all probabilists interested in Gaussian processes, random fields and their statistical applications." (Ilya S. Molchanov, Zentralblatt MATH, Vol. 1149, 2008)
Does differential geometry have anything to do with statistics?
Riemannian geometry is used in the study of random fields (a generalization of stochastic processes), where the process doesn't have to be stationary. The reference I'm studying is given below with tw
Does differential geometry have anything to do with statistics? Riemannian geometry is used in the study of random fields (a generalization of stochastic processes), where the process doesn't have to be stationary. The reference I'm studying is given below with two reviews. There are applications in oceanography, astrophysics and brain imaging. Random Fields and Geometry, Adler, R. J., Taylor, Jonathan E. http://www.springer.com/us/book/9780387481128#otherversion=9781441923691 Reviews: "Developing good bounds for the distribution of the suprema of a Gaussian field $f$, i.e., for the quantity $\Bbb{P}\{\sup_{t\in M}f(t)\ge u\}$, has been for a long time both a difficult and an interesting subject of research. A thorough presentation of this problem is the main goal of the book under review, as is stated by the authors in its preface. The authors develop their results in the context of smooth Gaussian fields, where the parameter spaces $M$ are Riemannian stratified manifolds, and their approach is of a geometrical nature. The book is divided into three parts. Part I is devoted to the presentation of the necessary tools of Gaussian processes and fields. Part II concisely exposes the required prerequisites of integral and differential geometry. Finally, in part III, the kernel of the book, a formula for the expectation of the Euler characteristic function of an excursion set and its approximation to the distribution of the maxima of the field, is precisely established. The book is written in an informal style, which affords a very pleasant reading. Each chapter begins with a presentation of the matters to be addressed, and the footnotes, located throughout the text, serve as an indispensable complement and many times as historical references. The authors insist on the fact that this book should not only be considered as a theoretical adventure and they recommend a second volume where they develop indispensable applications which highlight all the power of their results." (José Rafael León for Mathematical Reviews) "This book presents the modern theory of excursion probabilities and the geometry of excursion sets for … random fields defined on manifolds. ... The book is understandable for students … with a good background in analysis. ... The interdisciplinary nature of this book, the beauty and depth of the presented mathematical theory make it an indispensable part of every mathematical library and a bookshelf of all probabilists interested in Gaussian processes, random fields and their statistical applications." (Ilya S. Molchanov, Zentralblatt MATH, Vol. 1149, 2008)
Does differential geometry have anything to do with statistics? Riemannian geometry is used in the study of random fields (a generalization of stochastic processes), where the process doesn't have to be stationary. The reference I'm studying is given below with tw
11,072
Does differential geometry have anything to do with statistics?
One area of statistics/applied mathematics where differential geometry is used in an essential way (together with a lot of other areas of mathematics!) is pattern theory. You could have a look at the book by Ulf Grenander: https://www.amazon.com/Pattern-Theory-Representation-Inference-European/dp/0199297061/ref=asap_bc?ie=UTF8 or the somewhat more accessible text by David Mumford (a fields medal winner no less): https://www.amazon.com/Pattern-Theory-Stochastic-Real-World-Mathematics/dp/1568815794/ref=pd_bxgy_14_img_2?_encoding=UTF8&pd_rd_i=1568815794&pd_rd_r=Q40ESHME10ZPC7XYVT59&pd_rd_w=fBcaR&pd_rd_wg=LIesY&psc=1&refRID=Q40ESHME10ZPC7XYVT59 From the preface of the last text: The term “pattern theory” was coined by Ulf Grenander to distinguish his approach to the analysis of patterned structures in the world from “pattern recognition.” In this book, we use it in a rather broad sense to include the statistical methods used in analyzing all “signals” generated by the world, whether they be images, sounds, written text, DNA or protein strings, spike trains in neurons, or time series of prices or weather; examples from all of these appear either inGrenander’s book Elements of Pattern Theory [94] or in the work of our colleagues, collaborators, and students on pattern theory. One example where differential geometry is used is for face models. Trying to answer the question (in comments) by @whuber, look at chapter 16 of Grenander's book, with title "computational anatomy". There manifolds is used to represent various parts of human anatomy (like the hearth), and diffeomorhisms used to represent changes of these anatomical manifolds, enabling comparison, modeling of growth, modeling of action of some sickness. This ideas can be traced back to D'Arcy Thompson's monumental treatise "on growth and form" from 1917! Grenander goes on to cite from that treatise: In a very large part of morphology, our essential task lies in the comparison of related forms rather than in the precise definition of each; and the deformation of a complicated figure may be a phenomenon easy of comprehension, though the figure itself may have to be left unanalyzed and undefined. This process of comparison, of recognizing in one form a definite permutation or deformation of another, apart altogether from a precise and adequate understanding of the original “type” or standard of comparison, lies within the immediate province of mathematics and finds its solution in the elementary use of a certain method of the mathematician. This method is the Method of Coordinates, on which is based the Theory of Transformations. The most well-known example of this ideas is when is some child has disappeared, say three years ago, and one publishes some photo of his face, transformed (usually using splines), into what he might look like today.
Does differential geometry have anything to do with statistics?
One area of statistics/applied mathematics where differential geometry is used in an essential way (together with a lot of other areas of mathematics!) is pattern theory. You could have a look at the
Does differential geometry have anything to do with statistics? One area of statistics/applied mathematics where differential geometry is used in an essential way (together with a lot of other areas of mathematics!) is pattern theory. You could have a look at the book by Ulf Grenander: https://www.amazon.com/Pattern-Theory-Representation-Inference-European/dp/0199297061/ref=asap_bc?ie=UTF8 or the somewhat more accessible text by David Mumford (a fields medal winner no less): https://www.amazon.com/Pattern-Theory-Stochastic-Real-World-Mathematics/dp/1568815794/ref=pd_bxgy_14_img_2?_encoding=UTF8&pd_rd_i=1568815794&pd_rd_r=Q40ESHME10ZPC7XYVT59&pd_rd_w=fBcaR&pd_rd_wg=LIesY&psc=1&refRID=Q40ESHME10ZPC7XYVT59 From the preface of the last text: The term “pattern theory” was coined by Ulf Grenander to distinguish his approach to the analysis of patterned structures in the world from “pattern recognition.” In this book, we use it in a rather broad sense to include the statistical methods used in analyzing all “signals” generated by the world, whether they be images, sounds, written text, DNA or protein strings, spike trains in neurons, or time series of prices or weather; examples from all of these appear either inGrenander’s book Elements of Pattern Theory [94] or in the work of our colleagues, collaborators, and students on pattern theory. One example where differential geometry is used is for face models. Trying to answer the question (in comments) by @whuber, look at chapter 16 of Grenander's book, with title "computational anatomy". There manifolds is used to represent various parts of human anatomy (like the hearth), and diffeomorhisms used to represent changes of these anatomical manifolds, enabling comparison, modeling of growth, modeling of action of some sickness. This ideas can be traced back to D'Arcy Thompson's monumental treatise "on growth and form" from 1917! Grenander goes on to cite from that treatise: In a very large part of morphology, our essential task lies in the comparison of related forms rather than in the precise definition of each; and the deformation of a complicated figure may be a phenomenon easy of comprehension, though the figure itself may have to be left unanalyzed and undefined. This process of comparison, of recognizing in one form a definite permutation or deformation of another, apart altogether from a precise and adequate understanding of the original “type” or standard of comparison, lies within the immediate province of mathematics and finds its solution in the elementary use of a certain method of the mathematician. This method is the Method of Coordinates, on which is based the Theory of Transformations. The most well-known example of this ideas is when is some child has disappeared, say three years ago, and one publishes some photo of his face, transformed (usually using splines), into what he might look like today.
Does differential geometry have anything to do with statistics? One area of statistics/applied mathematics where differential geometry is used in an essential way (together with a lot of other areas of mathematics!) is pattern theory. You could have a look at the
11,073
Choosing between $z$-test and $t$-test
@AdamO is right, you simply always use the $t$-test if you don't know the population standard deviation a-priori. You don't have to worry about when to switch to the $z$-test, because the $t$-distribution 'switches' for you. More specifically, the $t$-distribution converges to the normal, thus it is the correct distribution to use at every $N$. There is also a confusion here about the meaning of the traditional line at $N=30$. There are two kinds of convergence that people talk about: The first is that the sampling distribution of the test statistic (i.e., $t$) computed from normally distributed (within group) raw data converges to a normal distribution as $N\rightarrow\infty$ despite the fact that the SD is estimated from the data. (The $t$-distribution takes care of this for you, as noted above.) The second is that the sampling distribution of the mean of non-normally distributed (within group) raw data converges to a normal distribution (more slowly than above) as $N\rightarrow\infty$. People count on the Central Limit Theorem to take care of this for them. However, there is no guarantee that it will converge within any reasonable sample size--there is certainly no reason to believe $30$ (or $300$) is the magic number. Depending on the magnitude and nature of the non-normality, it can take very long (cf. @Macro's answer here: Regression when the OLS residuals are not normally distributed). If you believe your (within group) raw data are not very normal, it may be better to use a different type of test, such as the Mann-Whitney $U$-test. Note that with non-normal data, the Mann-Whitney $U$-test is likely to be more powerful than the $t$-test, and can be so even if the CLT has kicked in. (It is also worth pointing out that testing for normality is likely to lead you astray, see: Is normality testing 'essentially useless'?) At any rate, to answer your questions more explicitly, if you believe your (within group) raw data are not normally distributed, use the Mann-Whitney $U$-test; if you believe you data are normally distributed, but you don't know the SD a-priori, use the $t$-test; and if you believe your data are normally distributed and you know the SD a-priori, use the $z$-test. It may help you to read @GregSnow's recent answer here: Interpretation of p-value in comparing proportions between two small groups in R regarding these issues as well.
Choosing between $z$-test and $t$-test
@AdamO is right, you simply always use the $t$-test if you don't know the population standard deviation a-priori. You don't have to worry about when to switch to the $z$-test, because the $t$-distrib
Choosing between $z$-test and $t$-test @AdamO is right, you simply always use the $t$-test if you don't know the population standard deviation a-priori. You don't have to worry about when to switch to the $z$-test, because the $t$-distribution 'switches' for you. More specifically, the $t$-distribution converges to the normal, thus it is the correct distribution to use at every $N$. There is also a confusion here about the meaning of the traditional line at $N=30$. There are two kinds of convergence that people talk about: The first is that the sampling distribution of the test statistic (i.e., $t$) computed from normally distributed (within group) raw data converges to a normal distribution as $N\rightarrow\infty$ despite the fact that the SD is estimated from the data. (The $t$-distribution takes care of this for you, as noted above.) The second is that the sampling distribution of the mean of non-normally distributed (within group) raw data converges to a normal distribution (more slowly than above) as $N\rightarrow\infty$. People count on the Central Limit Theorem to take care of this for them. However, there is no guarantee that it will converge within any reasonable sample size--there is certainly no reason to believe $30$ (or $300$) is the magic number. Depending on the magnitude and nature of the non-normality, it can take very long (cf. @Macro's answer here: Regression when the OLS residuals are not normally distributed). If you believe your (within group) raw data are not very normal, it may be better to use a different type of test, such as the Mann-Whitney $U$-test. Note that with non-normal data, the Mann-Whitney $U$-test is likely to be more powerful than the $t$-test, and can be so even if the CLT has kicked in. (It is also worth pointing out that testing for normality is likely to lead you astray, see: Is normality testing 'essentially useless'?) At any rate, to answer your questions more explicitly, if you believe your (within group) raw data are not normally distributed, use the Mann-Whitney $U$-test; if you believe you data are normally distributed, but you don't know the SD a-priori, use the $t$-test; and if you believe your data are normally distributed and you know the SD a-priori, use the $z$-test. It may help you to read @GregSnow's recent answer here: Interpretation of p-value in comparing proportions between two small groups in R regarding these issues as well.
Choosing between $z$-test and $t$-test @AdamO is right, you simply always use the $t$-test if you don't know the population standard deviation a-priori. You don't have to worry about when to switch to the $z$-test, because the $t$-distrib
11,074
Choosing between $z$-test and $t$-test
There's nothing to discuss on the matter. Use a $t$-test always for a nonparametric test of differences in means, unless a more sophisticated resampling tool—e.g. permutation or bootstrap—is called for (useful in very small samples with large departures from normality). If the degrees of freedom actually matter, then the $t$-test will provide consistent estimation of critical values and standard errors for the distribution of the test statistic under the null hypothesis. Otherwise, the $t$-test is approximately the same as the $z$-test. The normal approximation to tests of parametric model parameters, like the population proportion test, is kind of defunct. When the data are small enough that there really is a distinction between critical values generated from $t$ or $z$ distributions, you really should be using an exact test of proportions based on the scaled binomial distribution of the test statistic. Resampling tests work this way as well. Making arbitrary rule-of-thumb assumptions about sample sizes and prevalence of cases/controls in estimation of Bernoulli parameters is confusing and extremely error prone. The concept of a $z$-test ("known" variance) is confusing because you never "know" variance, nor do you spend much to estimate it. When that cost matters, only the $t$-test reflects its impact upon the degrees of freedom.
Choosing between $z$-test and $t$-test
There's nothing to discuss on the matter. Use a $t$-test always for a nonparametric test of differences in means, unless a more sophisticated resampling tool—e.g. permutation or bootstrap—is called fo
Choosing between $z$-test and $t$-test There's nothing to discuss on the matter. Use a $t$-test always for a nonparametric test of differences in means, unless a more sophisticated resampling tool—e.g. permutation or bootstrap—is called for (useful in very small samples with large departures from normality). If the degrees of freedom actually matter, then the $t$-test will provide consistent estimation of critical values and standard errors for the distribution of the test statistic under the null hypothesis. Otherwise, the $t$-test is approximately the same as the $z$-test. The normal approximation to tests of parametric model parameters, like the population proportion test, is kind of defunct. When the data are small enough that there really is a distinction between critical values generated from $t$ or $z$ distributions, you really should be using an exact test of proportions based on the scaled binomial distribution of the test statistic. Resampling tests work this way as well. Making arbitrary rule-of-thumb assumptions about sample sizes and prevalence of cases/controls in estimation of Bernoulli parameters is confusing and extremely error prone. The concept of a $z$-test ("known" variance) is confusing because you never "know" variance, nor do you spend much to estimate it. When that cost matters, only the $t$-test reflects its impact upon the degrees of freedom.
Choosing between $z$-test and $t$-test There's nothing to discuss on the matter. Use a $t$-test always for a nonparametric test of differences in means, unless a more sophisticated resampling tool—e.g. permutation or bootstrap—is called fo
11,075
t-test on highly skewed data
Neither the t-test nor the permutation test have much power to identify a difference in means between two such extraordinarily skewed distributions. Thus they both give anodyne p-values indicating no significance at all. The issue is not that they seem to agree; it is that because they have a hard time detecting any difference at all, they simply cannot disagree! For some intuition, consider what would happen if a change in a single value occurred in one dataset. Suppose that the maximum of 721,700 had not occurred in the second data set, for instance. The mean would have dropped by approximately 721700/3000, which is about 240. Yet the difference in the means is only 4964-4536 = 438, not even twice as big. That suggests (although it does not prove) that any comparison of the means would not find the difference significant. We can verify, though, that the t-test is not applicable. Let's generate some datasets with the same statistical characteristics as these. To do so I have created mixtures in which $5/8$ of the data are zeros in any case. The remaining data have a lognormal distribution. The parameters of that distribution are arranged to reproduce the observed means and third quartiles. It turns out in these simulations that the maximum values are not far from the reported maxima, either. Let's replicate the first dataset 10,000 times and track its mean. (The results will be almost the same when we do this for the second dataset.) The histogram of these means estimates the sampling distribution of the mean. The t-test is valid when this distribution is approximately Normal; the extent to which it deviates from Normality indicates the extent to which the Student t distribution will err. So, for reference, I have also drawn (in red) the PDF of the Normal distribution fit to these results. We can't see much detail because there are some whopping big outliers. (That's a manifestation of this sensitivity of the means I mentioned.) There are 123 of them--1.23%--above 10,000. Let's focus on the rest so we can see the detail and because these outliers may result from the assumed lognormality of the distribution, which is not necessarily the case for the original dataset. That is still strongly skewed and deviates visibly from the Normal approximation, providing sufficient explanation for the phenomena recounted in the question. It also gives us a sense of how large a difference in means could be detected by a test: it would have to be around 3000 or more to appear significant. Conversely, the actual difference of 428 might be detected provided you had approximately $(3000/428)^2 = 50$ times as much data (in each group). Given 50 times as much data, I estimate the power to detect this difference at a significance level of 5% would be around 0.4 (which is not good, but at least you would have a chance). Here is the R code that produced these figures. # # Generate positive random values with a median of 0, given Q3, # and given mean. Make a proportion 1-e of them true zeros. # rskew <- function(n, x.mean, x.q3, e=3/8) { beta <- qnorm(1 - (1/4)/e) gamma <- 2*(log(x.q3) - log(x.mean/e)) sigma <- sqrt(beta^2 - gamma) + beta mu <- log(x.mean/e) - sigma^2/2 m <- floor(n * e) c(exp(rnorm(m, mu, sigma)), rep(0, n-m)) } # # See how closely the summary statistics are reproduced. # (The quartiles will be close; the maxima not too far off; # the means may differ a lot, though.) # set.seed(23) x <- rskew(3300, 4536, 302.6) y <- rskew(3400, 4964, 423.8) summary(x) summary(y) # # Estimate the sampling distribution of the mean. # set.seed(17) sim.x <- replicate(10^4, mean(rskew(3367, 4536, 302.6))) hist(sim.x, freq=FALSE, ylim=c(0, dnorm(0, sd=sd(sim.x)))) curve(dnorm(x, mean(sim.x), sd(sim.x)), add=TRUE, col="Red") hist(sim.x[sim.x < 10000], xlab="x", freq=FALSE) curve(dnorm(x, mean(sim.x), sd(sim.x)), add=TRUE, col="Red") # # Can a t-test detect a difference with more data? # set.seed(23) n.factor <- 50 z <- replicate(10^3, { x <- rskew(3300*n.factor, 4536, 302.6) y <- rskew(3400*n.factor, 4964, 423.8) t.test(x,y)$p.value }) hist(z) mean(z < .05) # The estimated power at a 5% significance level
t-test on highly skewed data
Neither the t-test nor the permutation test have much power to identify a difference in means between two such extraordinarily skewed distributions. Thus they both give anodyne p-values indicating no
t-test on highly skewed data Neither the t-test nor the permutation test have much power to identify a difference in means between two such extraordinarily skewed distributions. Thus they both give anodyne p-values indicating no significance at all. The issue is not that they seem to agree; it is that because they have a hard time detecting any difference at all, they simply cannot disagree! For some intuition, consider what would happen if a change in a single value occurred in one dataset. Suppose that the maximum of 721,700 had not occurred in the second data set, for instance. The mean would have dropped by approximately 721700/3000, which is about 240. Yet the difference in the means is only 4964-4536 = 438, not even twice as big. That suggests (although it does not prove) that any comparison of the means would not find the difference significant. We can verify, though, that the t-test is not applicable. Let's generate some datasets with the same statistical characteristics as these. To do so I have created mixtures in which $5/8$ of the data are zeros in any case. The remaining data have a lognormal distribution. The parameters of that distribution are arranged to reproduce the observed means and third quartiles. It turns out in these simulations that the maximum values are not far from the reported maxima, either. Let's replicate the first dataset 10,000 times and track its mean. (The results will be almost the same when we do this for the second dataset.) The histogram of these means estimates the sampling distribution of the mean. The t-test is valid when this distribution is approximately Normal; the extent to which it deviates from Normality indicates the extent to which the Student t distribution will err. So, for reference, I have also drawn (in red) the PDF of the Normal distribution fit to these results. We can't see much detail because there are some whopping big outliers. (That's a manifestation of this sensitivity of the means I mentioned.) There are 123 of them--1.23%--above 10,000. Let's focus on the rest so we can see the detail and because these outliers may result from the assumed lognormality of the distribution, which is not necessarily the case for the original dataset. That is still strongly skewed and deviates visibly from the Normal approximation, providing sufficient explanation for the phenomena recounted in the question. It also gives us a sense of how large a difference in means could be detected by a test: it would have to be around 3000 or more to appear significant. Conversely, the actual difference of 428 might be detected provided you had approximately $(3000/428)^2 = 50$ times as much data (in each group). Given 50 times as much data, I estimate the power to detect this difference at a significance level of 5% would be around 0.4 (which is not good, but at least you would have a chance). Here is the R code that produced these figures. # # Generate positive random values with a median of 0, given Q3, # and given mean. Make a proportion 1-e of them true zeros. # rskew <- function(n, x.mean, x.q3, e=3/8) { beta <- qnorm(1 - (1/4)/e) gamma <- 2*(log(x.q3) - log(x.mean/e)) sigma <- sqrt(beta^2 - gamma) + beta mu <- log(x.mean/e) - sigma^2/2 m <- floor(n * e) c(exp(rnorm(m, mu, sigma)), rep(0, n-m)) } # # See how closely the summary statistics are reproduced. # (The quartiles will be close; the maxima not too far off; # the means may differ a lot, though.) # set.seed(23) x <- rskew(3300, 4536, 302.6) y <- rskew(3400, 4964, 423.8) summary(x) summary(y) # # Estimate the sampling distribution of the mean. # set.seed(17) sim.x <- replicate(10^4, mean(rskew(3367, 4536, 302.6))) hist(sim.x, freq=FALSE, ylim=c(0, dnorm(0, sd=sd(sim.x)))) curve(dnorm(x, mean(sim.x), sd(sim.x)), add=TRUE, col="Red") hist(sim.x[sim.x < 10000], xlab="x", freq=FALSE) curve(dnorm(x, mean(sim.x), sd(sim.x)), add=TRUE, col="Red") # # Can a t-test detect a difference with more data? # set.seed(23) n.factor <- 50 z <- replicate(10^3, { x <- rskew(3300*n.factor, 4536, 302.6) y <- rskew(3400*n.factor, 4964, 423.8) t.test(x,y)$p.value }) hist(z) mean(z < .05) # The estimated power at a 5% significance level
t-test on highly skewed data Neither the t-test nor the permutation test have much power to identify a difference in means between two such extraordinarily skewed distributions. Thus they both give anodyne p-values indicating no
11,076
t-test on highly skewed data
When n is large (like 300, even far less than 3000), the t-test is essentially the same as the z-test. That is, the t-test becomes nothing more than an application of the central limit theorem, which says that the MEAN for each of your two groups is almost exactly normally distributed (even if the observations underlying the two means are very far from being normally distributed!). This is also the reason that your typical t-table does not bother to show values for n greater than 1000 (for example, this t-table). Thus, I am not surprised to see that you are getting such well-behaved results. Edit: I seem to have underestimated the extremity of the skewness and its importance. While my point above has merit in less extreme circumstances, whuber's answer to the question is much better overall.
t-test on highly skewed data
When n is large (like 300, even far less than 3000), the t-test is essentially the same as the z-test. That is, the t-test becomes nothing more than an application of the central limit theorem, which
t-test on highly skewed data When n is large (like 300, even far less than 3000), the t-test is essentially the same as the z-test. That is, the t-test becomes nothing more than an application of the central limit theorem, which says that the MEAN for each of your two groups is almost exactly normally distributed (even if the observations underlying the two means are very far from being normally distributed!). This is also the reason that your typical t-table does not bother to show values for n greater than 1000 (for example, this t-table). Thus, I am not surprised to see that you are getting such well-behaved results. Edit: I seem to have underestimated the extremity of the skewness and its importance. While my point above has merit in less extreme circumstances, whuber's answer to the question is much better overall.
t-test on highly skewed data When n is large (like 300, even far less than 3000), the t-test is essentially the same as the z-test. That is, the t-test becomes nothing more than an application of the central limit theorem, which
11,077
t-test on highly skewed data
I know this answer is way late. However, I am getting a PhD in health services research, so I work with healthcare data a lot, including cost data. I don't know what data the OP had. If it were cross-sectional data, then chances are it was justifiably IID. Independence means that each unit, so each person, is independent. That is very likely justifiable. As to identically distributed, the data can be modeled as all coming from, say, a gamma distribution in a generalized linear model with a log link. This is what people commonly do in practice. Or if you want to get fancy, there are probably hurdle models (popular in econometrics) that deal with the excess 0s. Which, by the way, are pretty common in healthcare spending. The OP is technically correct that the data aren't necessarily identically distributed, e.g. the mean and variance will shift with age, but it's a workable assumption in multiple regression models. If each person was in the dataset for more than one year, then the data wouldn't be IID. There are more complex models available for that. A relatively simple one of those would probably be generalized estimating equations, gamma distribution and log link again, assume an exchangeable working correlation. Or, if these data are from publicly available survey data, there is NOT an equal probability of being sampled - many of those surveys interview multiple people in each household, and they also stratify the population and oversample some groups (e.g. racial minorities). The user would have to correct for that. I don't use t-tests, especially not for observational data. There are too many confounders, so you would want to adjust for them in a (generalized) linear model. So, I can't comment on the questions related specifically to t-tests.
t-test on highly skewed data
I know this answer is way late. However, I am getting a PhD in health services research, so I work with healthcare data a lot, including cost data. I don't know what data the OP had. If it were cross-
t-test on highly skewed data I know this answer is way late. However, I am getting a PhD in health services research, so I work with healthcare data a lot, including cost data. I don't know what data the OP had. If it were cross-sectional data, then chances are it was justifiably IID. Independence means that each unit, so each person, is independent. That is very likely justifiable. As to identically distributed, the data can be modeled as all coming from, say, a gamma distribution in a generalized linear model with a log link. This is what people commonly do in practice. Or if you want to get fancy, there are probably hurdle models (popular in econometrics) that deal with the excess 0s. Which, by the way, are pretty common in healthcare spending. The OP is technically correct that the data aren't necessarily identically distributed, e.g. the mean and variance will shift with age, but it's a workable assumption in multiple regression models. If each person was in the dataset for more than one year, then the data wouldn't be IID. There are more complex models available for that. A relatively simple one of those would probably be generalized estimating equations, gamma distribution and log link again, assume an exchangeable working correlation. Or, if these data are from publicly available survey data, there is NOT an equal probability of being sampled - many of those surveys interview multiple people in each household, and they also stratify the population and oversample some groups (e.g. racial minorities). The user would have to correct for that. I don't use t-tests, especially not for observational data. There are too many confounders, so you would want to adjust for them in a (generalized) linear model. So, I can't comment on the questions related specifically to t-tests.
t-test on highly skewed data I know this answer is way late. However, I am getting a PhD in health services research, so I work with healthcare data a lot, including cost data. I don't know what data the OP had. If it were cross-
11,078
Does non-zero correlation imply dependence?
Yes, because $$\text{Corr}(X,Y)\ne0 \Rightarrow \text{Cov}(X,Y)\ne0$$ $$\Rightarrow E(XY) - E(X)E(Y) \ne 0 $$ $$\Rightarrow \int \int xyf_{X,Y}(x,y)dxdy -\int xf_X(x) dx\int yf_Y(y)dy \ne 0$$ $$\Rightarrow \int \int xyf_{X,Y}(x,y)dxdy -\int \int xyf_X(x) f_Y(y)dxdy \ne 0$$ $$\Rightarrow \int \int xy \big[f_{X,Y}(x,y) -f_X(x) f_Y(y)\big]dxdy \ne 0$$ which would be impossible if $f_{X,Y}(x,y) -f_X(x) f_Y(y) =0,\;\; \forall \{x,y\}$. So $$\text{Corr}(X,Y)\ne0 \Rightarrow \exists \{x,y\}:f_{X,Y}(x,y) \ne f_X(x) f_Y(y)$$ Question: what happens with random variables that have no densities?
Does non-zero correlation imply dependence?
Yes, because $$\text{Corr}(X,Y)\ne0 \Rightarrow \text{Cov}(X,Y)\ne0$$ $$\Rightarrow E(XY) - E(X)E(Y) \ne 0 $$ $$\Rightarrow \int \int xyf_{X,Y}(x,y)dxdy -\int xf_X(x) dx\int yf_Y(y)dy \ne 0$$ $$\Right
Does non-zero correlation imply dependence? Yes, because $$\text{Corr}(X,Y)\ne0 \Rightarrow \text{Cov}(X,Y)\ne0$$ $$\Rightarrow E(XY) - E(X)E(Y) \ne 0 $$ $$\Rightarrow \int \int xyf_{X,Y}(x,y)dxdy -\int xf_X(x) dx\int yf_Y(y)dy \ne 0$$ $$\Rightarrow \int \int xyf_{X,Y}(x,y)dxdy -\int \int xyf_X(x) f_Y(y)dxdy \ne 0$$ $$\Rightarrow \int \int xy \big[f_{X,Y}(x,y) -f_X(x) f_Y(y)\big]dxdy \ne 0$$ which would be impossible if $f_{X,Y}(x,y) -f_X(x) f_Y(y) =0,\;\; \forall \{x,y\}$. So $$\text{Corr}(X,Y)\ne0 \Rightarrow \exists \{x,y\}:f_{X,Y}(x,y) \ne f_X(x) f_Y(y)$$ Question: what happens with random variables that have no densities?
Does non-zero correlation imply dependence? Yes, because $$\text{Corr}(X,Y)\ne0 \Rightarrow \text{Cov}(X,Y)\ne0$$ $$\Rightarrow E(XY) - E(X)E(Y) \ne 0 $$ $$\Rightarrow \int \int xyf_{X,Y}(x,y)dxdy -\int xf_X(x) dx\int yf_Y(y)dy \ne 0$$ $$\Right
11,079
Does non-zero correlation imply dependence?
Let $X$ and $Y$ denote random variables such that $E[X^2]$ and $E[Y^2]$ are finite. Then, $E[XY]$, $E[X]$ and $E[Y]$ all are finite. Restricting our attention to such random variables, let $A$ denote the statement that $X$ and $Y$ are independent random variables and $B$ the statement that $X$ and $Y$ are uncorrelated random variables, that is, $E[XY] = E[X]E[Y]$. Then we know that $A$ implies $B$, that is, independent random variables are uncorrelated random variables. Indeed, one definition of independent random variables is that $E[g(X)h(Y)]$ equals $E[g(X)]E[h(Y)]$ for all measurable functions $g(\cdot)$ and $h(\cdot)$). This is usually expressed as $$A \implies B.$$ But $A \implies B$ is logically equivalent to $\neg B \implies \neg A$, that is, correlated random variables are dependent random variables. If $E[XY]$, $E[X]$ or $E[Y]$ are not finite or do not exist, then it is not possible to say whether $X$ and $Y$ are uncorrelated or not in the classical meaning of uncorrelated random variables being those for which $E[XY] = E[X]E[Y]$. For example, $X$ and $Y$ could be independent Cauchy random variables (for which the mean does not exist). Are they uncorrelated random variables in the classical sense?
Does non-zero correlation imply dependence?
Let $X$ and $Y$ denote random variables such that $E[X^2]$ and $E[Y^2]$ are finite. Then, $E[XY]$, $E[X]$ and $E[Y]$ all are finite. Restricting our attention to such random variables, let $A$ denot
Does non-zero correlation imply dependence? Let $X$ and $Y$ denote random variables such that $E[X^2]$ and $E[Y^2]$ are finite. Then, $E[XY]$, $E[X]$ and $E[Y]$ all are finite. Restricting our attention to such random variables, let $A$ denote the statement that $X$ and $Y$ are independent random variables and $B$ the statement that $X$ and $Y$ are uncorrelated random variables, that is, $E[XY] = E[X]E[Y]$. Then we know that $A$ implies $B$, that is, independent random variables are uncorrelated random variables. Indeed, one definition of independent random variables is that $E[g(X)h(Y)]$ equals $E[g(X)]E[h(Y)]$ for all measurable functions $g(\cdot)$ and $h(\cdot)$). This is usually expressed as $$A \implies B.$$ But $A \implies B$ is logically equivalent to $\neg B \implies \neg A$, that is, correlated random variables are dependent random variables. If $E[XY]$, $E[X]$ or $E[Y]$ are not finite or do not exist, then it is not possible to say whether $X$ and $Y$ are uncorrelated or not in the classical meaning of uncorrelated random variables being those for which $E[XY] = E[X]E[Y]$. For example, $X$ and $Y$ could be independent Cauchy random variables (for which the mean does not exist). Are they uncorrelated random variables in the classical sense?
Does non-zero correlation imply dependence? Let $X$ and $Y$ denote random variables such that $E[X^2]$ and $E[Y^2]$ are finite. Then, $E[XY]$, $E[X]$ and $E[Y]$ all are finite. Restricting our attention to such random variables, let $A$ denot
11,080
Does non-zero correlation imply dependence?
Here a purely logical proof. If $A\rightarrow B$ then necessarily $\neg B \rightarrow \neg A$, as the two are equivalent. Thus if $\neg B$ then $\neg A$. Now replace $A$ with independence and $B$ with correlation. Think about a statement "if volcano erupts there are going to be damages". Now think about a case where there are no damages. Clearly a volcano didn't erupt or we would have a condtradicition. Similarly, think about a case "If independent $X,Y$, then non-correlated $X,Y$". Now, consider the case where $X,Y$ are correlated. Clearly they can't be independent, for if they were, they would also be correlated. Thus conclude dependence.
Does non-zero correlation imply dependence?
Here a purely logical proof. If $A\rightarrow B$ then necessarily $\neg B \rightarrow \neg A$, as the two are equivalent. Thus if $\neg B$ then $\neg A$. Now replace $A$ with independence and $B$ with
Does non-zero correlation imply dependence? Here a purely logical proof. If $A\rightarrow B$ then necessarily $\neg B \rightarrow \neg A$, as the two are equivalent. Thus if $\neg B$ then $\neg A$. Now replace $A$ with independence and $B$ with correlation. Think about a statement "if volcano erupts there are going to be damages". Now think about a case where there are no damages. Clearly a volcano didn't erupt or we would have a condtradicition. Similarly, think about a case "If independent $X,Y$, then non-correlated $X,Y$". Now, consider the case where $X,Y$ are correlated. Clearly they can't be independent, for if they were, they would also be correlated. Thus conclude dependence.
Does non-zero correlation imply dependence? Here a purely logical proof. If $A\rightarrow B$ then necessarily $\neg B \rightarrow \neg A$, as the two are equivalent. Thus if $\neg B$ then $\neg A$. Now replace $A$ with independence and $B$ with
11,081
Interpreting spline results
You can reverse-engineer the spline formulae without having to go into the R code. It suffices to know that A spline is a piecewise polynomial function. Polynomials of degree $d$ are determined by their values at $d+1$ points. The coefficients of a polynomial can be obtained via linear regression. Thus, you only have to create $d+1$ points spaced between each pair of successive knots (including the implicit endpoints of the data range), predict the spline values, and regress the prediction against the powers of $x$ up to $x^d$. There will be a separate formula for each spline basis element within each such knot "bin." For instance, in the example below there are three internal knots (for four knot bins) and cubic splines ($d=3$) were used, resulting in $4\times 4=16$ cubic polynomials, each with $d+1=4$ coefficients. Because relatively high powers of $x$ are involved, it is imperative to preserve all the precision in the coefficients. As you might imagine, the full formula for any spline basis element can get pretty long! As I mentioned quite a while ago, being able to use the output of one program as the input of another (without manual intervention, which can introduce irreproducible errors) is a useful statistical communication skill. This question provides a nice example of how that principle applies: instead of copying those $64$ sixteen-digit coefficients manually, we can hack together a way to convert the splines computed by R into formulas that Excel can understand. All we need do is extract the spline coefficients from R as described above, have it reformat them into Excel-like formulas, and copy and paste those into Excel. This method will work with any statistical software, even undocumented proprietary software whose source code is unavailable. Here is an example taken from the question, but modified to have knots at three internal points ($200, 500, 800$) as well as at the endpoints $(1, 1000)$. The plots show R's version followed by Excel's rendering. Very little customization was performed in either environment (apart from specifying colors in R to match Excel's default colors approximately). (The vertical gray gridlines in the R version show where the internal knots are.) Here is the full R code. It's an unsophisticated hack, relying entirely on the paste function to accomplish the string manipulation. (A better way would be to create a formula template and fill it in using string matching and substitution commands.) # # Create and display a spline basis. # x <- 1:1000 n <- ns(x, knots=c(200, 500, 800)) colors <- c("Orange", "Gray", "tomato2", "deepskyblue3") plot(range(x), range(n), type="n", main="R Version", xlab="x", ylab="Spline value") for (k in attr(n, "knots")) abline(v=k, col="Gray", lty=2) for (j in 1:ncol(n)) { lines(x, n[,j], col=colors[j], lwd=2) } # # Export this basis in Excel-readable format. # ns.formula <- function(n, ref="A1") { ref.p <- paste("I(", ref, sep="") knots <- sort(c(attr(n, "Boundary.knots"), attr(n, "knots"))) d <- attr(n, "degree") f <- sapply(2:length(knots), function(i) { s.pre <- paste("IF(AND(", knots[i-1], "<=", ref, ", ", ref, "<", knots[i], "), ", sep="") x <- seq(knots[i-1], knots[i], length.out=d+1) y <- predict(n, x) apply(y, 2, function(z) { s.f <- paste("z ~ x+", paste("I(x", 2:d, sep="^", collapse=")+"), ")", sep="") f <- as.formula(s.f) b.hat <- coef(lm(f)) s <- paste(c(b.hat[1], sapply(1:d, function(j) paste(b.hat[j+1], "*", ref, "^", j, sep=""))), collapse=" + ") paste(s.pre, s, ", 0)", sep="") }) }) apply(f, 1, function(s) paste(s, collapse=" + ")) } ns.formula(n) # Each line of this output is one basis formula: paste into Excel The first spline output formula (out of the four produced here) is "IF(AND(1<=A1, A1<200), -1.26037447288906e-08 + 3.78112341937071e-08*A1^1 + -3.78112341940948e-08*A1^2 + 1.26037447313669e-08*A1^3, 0) + IF(AND(200<=A1, A1<500), 0.278894459758071 + -0.00418337927419299*A1^1 + 2.08792741929417e-05*A1^2 + -2.22580643138594e-08*A1^3, 0) + IF(AND(500<=A1, A1<800), -5.28222778473101 + 0.0291833541927414*A1^1 + -4.58541927409268e-05*A1^2 + 2.22309136420529e-08*A1^3, 0) + IF(AND(800<=A1, A1<1000), 12.500000000002 + -0.0375000000000067*A1^1 + 3.75000000000076e-05*A1^2 + -1.25000000000028e-08*A1^3, 0)" For this to work in Excel, all you need do is remove the surrounding quotation marks and prefix it with an "=" sign. (With a bit more effort you could have R write a file which, when imported by Excel, contains copies of these formulas in all the right places.) Paste it into a formula box and then drag that cell around until "A1" references the first $x$ value where the spline is to be computed. Copy and paste (or drag and drop) that cell to compute values for other cells. I filled cells B2:E:102 with these formulas, referencing $x$ values in cells A2:A102.
Interpreting spline results
You can reverse-engineer the spline formulae without having to go into the R code. It suffices to know that A spline is a piecewise polynomial function. Polynomials of degree $d$ are determined by t
Interpreting spline results You can reverse-engineer the spline formulae without having to go into the R code. It suffices to know that A spline is a piecewise polynomial function. Polynomials of degree $d$ are determined by their values at $d+1$ points. The coefficients of a polynomial can be obtained via linear regression. Thus, you only have to create $d+1$ points spaced between each pair of successive knots (including the implicit endpoints of the data range), predict the spline values, and regress the prediction against the powers of $x$ up to $x^d$. There will be a separate formula for each spline basis element within each such knot "bin." For instance, in the example below there are three internal knots (for four knot bins) and cubic splines ($d=3$) were used, resulting in $4\times 4=16$ cubic polynomials, each with $d+1=4$ coefficients. Because relatively high powers of $x$ are involved, it is imperative to preserve all the precision in the coefficients. As you might imagine, the full formula for any spline basis element can get pretty long! As I mentioned quite a while ago, being able to use the output of one program as the input of another (without manual intervention, which can introduce irreproducible errors) is a useful statistical communication skill. This question provides a nice example of how that principle applies: instead of copying those $64$ sixteen-digit coefficients manually, we can hack together a way to convert the splines computed by R into formulas that Excel can understand. All we need do is extract the spline coefficients from R as described above, have it reformat them into Excel-like formulas, and copy and paste those into Excel. This method will work with any statistical software, even undocumented proprietary software whose source code is unavailable. Here is an example taken from the question, but modified to have knots at three internal points ($200, 500, 800$) as well as at the endpoints $(1, 1000)$. The plots show R's version followed by Excel's rendering. Very little customization was performed in either environment (apart from specifying colors in R to match Excel's default colors approximately). (The vertical gray gridlines in the R version show where the internal knots are.) Here is the full R code. It's an unsophisticated hack, relying entirely on the paste function to accomplish the string manipulation. (A better way would be to create a formula template and fill it in using string matching and substitution commands.) # # Create and display a spline basis. # x <- 1:1000 n <- ns(x, knots=c(200, 500, 800)) colors <- c("Orange", "Gray", "tomato2", "deepskyblue3") plot(range(x), range(n), type="n", main="R Version", xlab="x", ylab="Spline value") for (k in attr(n, "knots")) abline(v=k, col="Gray", lty=2) for (j in 1:ncol(n)) { lines(x, n[,j], col=colors[j], lwd=2) } # # Export this basis in Excel-readable format. # ns.formula <- function(n, ref="A1") { ref.p <- paste("I(", ref, sep="") knots <- sort(c(attr(n, "Boundary.knots"), attr(n, "knots"))) d <- attr(n, "degree") f <- sapply(2:length(knots), function(i) { s.pre <- paste("IF(AND(", knots[i-1], "<=", ref, ", ", ref, "<", knots[i], "), ", sep="") x <- seq(knots[i-1], knots[i], length.out=d+1) y <- predict(n, x) apply(y, 2, function(z) { s.f <- paste("z ~ x+", paste("I(x", 2:d, sep="^", collapse=")+"), ")", sep="") f <- as.formula(s.f) b.hat <- coef(lm(f)) s <- paste(c(b.hat[1], sapply(1:d, function(j) paste(b.hat[j+1], "*", ref, "^", j, sep=""))), collapse=" + ") paste(s.pre, s, ", 0)", sep="") }) }) apply(f, 1, function(s) paste(s, collapse=" + ")) } ns.formula(n) # Each line of this output is one basis formula: paste into Excel The first spline output formula (out of the four produced here) is "IF(AND(1<=A1, A1<200), -1.26037447288906e-08 + 3.78112341937071e-08*A1^1 + -3.78112341940948e-08*A1^2 + 1.26037447313669e-08*A1^3, 0) + IF(AND(200<=A1, A1<500), 0.278894459758071 + -0.00418337927419299*A1^1 + 2.08792741929417e-05*A1^2 + -2.22580643138594e-08*A1^3, 0) + IF(AND(500<=A1, A1<800), -5.28222778473101 + 0.0291833541927414*A1^1 + -4.58541927409268e-05*A1^2 + 2.22309136420529e-08*A1^3, 0) + IF(AND(800<=A1, A1<1000), 12.500000000002 + -0.0375000000000067*A1^1 + 3.75000000000076e-05*A1^2 + -1.25000000000028e-08*A1^3, 0)" For this to work in Excel, all you need do is remove the surrounding quotation marks and prefix it with an "=" sign. (With a bit more effort you could have R write a file which, when imported by Excel, contains copies of these formulas in all the right places.) Paste it into a formula box and then drag that cell around until "A1" references the first $x$ value where the spline is to be computed. Copy and paste (or drag and drop) that cell to compute values for other cells. I filled cells B2:E:102 with these formulas, referencing $x$ values in cells A2:A102.
Interpreting spline results You can reverse-engineer the spline formulae without having to go into the R code. It suffices to know that A spline is a piecewise polynomial function. Polynomials of degree $d$ are determined by t
11,082
Interpreting spline results
You may find it easier to use the truncated power basis for cubic regression splines, using the R rms package. Once you fit the model you can retrieve the algebraic representation of the fitted spline function using the Function or latex functions in rms.
Interpreting spline results
You may find it easier to use the truncated power basis for cubic regression splines, using the R rms package. Once you fit the model you can retrieve the algebraic representation of the fitted splin
Interpreting spline results You may find it easier to use the truncated power basis for cubic regression splines, using the R rms package. Once you fit the model you can retrieve the algebraic representation of the fitted spline function using the Function or latex functions in rms.
Interpreting spline results You may find it easier to use the truncated power basis for cubic regression splines, using the R rms package. Once you fit the model you can retrieve the algebraic representation of the fitted splin
11,083
Interpreting spline results
You already did the following: > rm(list=ls()) > set.seed(1066) > x<- 1:1000 > y<- rep(0,1000) > y[1:500]<- pmax(x[1:500]+(runif(500)-.5)*67*500/pmax(x[1:500],100),0.01) > y[501:1000]<-500+x[501:1000]^1.05*(runif(500)-.5)/7.5 > df<-as.data.frame(cbind(x,y)) > library(splines) > spline1 <- glm(y~ns(x,knots=c(500)),data=df,family=Gamma(link="log")) > Now I will show you how to predict (the response) for x=12 in two different ways: First using the predict function (the easy way!) > new.dat=data.frame(x=12) > predict(spline1,new.dat,type="response") 1 68.78721 The 2nd way is based on the model matrix directly. Note I used exp since the link function used is log. > m=model.matrix( ~ ns(df$x,knots=c(500))) > prd=exp(coefficients(spline1) %*% t(m)) > prd[12] [1] 68.78721 Note that in above I extracted the 12th element, since that correspond to x=12. If you want to predict for an x outside the training set, then simply you can again use the predict function. Lets say we want to find the predicted response value for x=1100 then > predict(spline1, newdata=data.frame(x=1100),type="response") 1 366.3483
Interpreting spline results
You already did the following: > rm(list=ls()) > set.seed(1066) > x<- 1:1000 > y<- rep(0,1000) > y[1:500]<- pmax(x[1:500]+(runif(500)-.5)*67*500/pmax(x[1:500],100),0.01) > y[501:1000]<-500+x[501:1000
Interpreting spline results You already did the following: > rm(list=ls()) > set.seed(1066) > x<- 1:1000 > y<- rep(0,1000) > y[1:500]<- pmax(x[1:500]+(runif(500)-.5)*67*500/pmax(x[1:500],100),0.01) > y[501:1000]<-500+x[501:1000]^1.05*(runif(500)-.5)/7.5 > df<-as.data.frame(cbind(x,y)) > library(splines) > spline1 <- glm(y~ns(x,knots=c(500)),data=df,family=Gamma(link="log")) > Now I will show you how to predict (the response) for x=12 in two different ways: First using the predict function (the easy way!) > new.dat=data.frame(x=12) > predict(spline1,new.dat,type="response") 1 68.78721 The 2nd way is based on the model matrix directly. Note I used exp since the link function used is log. > m=model.matrix( ~ ns(df$x,knots=c(500))) > prd=exp(coefficients(spline1) %*% t(m)) > prd[12] [1] 68.78721 Note that in above I extracted the 12th element, since that correspond to x=12. If you want to predict for an x outside the training set, then simply you can again use the predict function. Lets say we want to find the predicted response value for x=1100 then > predict(spline1, newdata=data.frame(x=1100),type="response") 1 366.3483
Interpreting spline results You already did the following: > rm(list=ls()) > set.seed(1066) > x<- 1:1000 > y<- rep(0,1000) > y[1:500]<- pmax(x[1:500]+(runif(500)-.5)*67*500/pmax(x[1:500],100),0.01) > y[501:1000]<-500+x[501:1000
11,084
How would you explain Moment Generating Function(MGF) in layman's terms?
Let's assume that an equation-free intuition is not possible, and still insist on boiling down the math to the very essentials to get an idea of what's going on: we are trying to obtain the statistical raw moments, which, after the obligatory reference to physics, we define as the expected value of a power of a random variable. For a continuous random variable, the raw $k$-th moment is by LOTUS: \begin{align}\large \color{red}{\mathbb{E}\left[{X^k}\right]} &= \displaystyle\int_{-\infty}^{\infty}\color{blue}{X^k}\,\,\color{green}{\text{pdf}}\,\,\,dx\tag{1}\end{align} The moment generating function, $$M_X(t):=\mathbb E\big[e^{tX}\big],$$ is a way to walk around this integral (Eq.1) by, instead, carrying out: \begin{align} \large \color{blue}{\mathbb{E}\left[e^{\,tX}\right]}&=\displaystyle \int_{-\infty}^{\infty}\color{blue}{e^{tX}}\,\color{green}{\text{pdf}}\, dx\tag{2}\end{align} Why? Because it's easier and there is a fantastic property of the MGF that can be seen by expanding the Maclaurin series of $\color{blue}{e^{\,tX}}$ $$e^{tX}=1+\frac{ X }{1!}\, t +\frac{ X^{2} }{2!}t^{2} +\frac{ X^{3} }{3!} t^{3} +\cdots$$ Taking the expectation of both sides of this power series: $$\begin{align} M_X(t) &= \color{blue}{\mathbb{E}\left[e^{\,tX}\right]} \\[1.5ex] &=1 + \frac{\color{red}{\mathbb{E} \left[X\right]}}{1!} \, t \, + \frac{\color{red}{\mathbb{E} \left[X^2\right]}}{2!} \, t^2 \, + \frac{\color{red}{\mathbb{E} \left[X^3\right]}}{3!} \, t^3 \, + \cdots\tag{3} \end{align}$$ the raw moments appear "perched" on this polynomial "clothesline", ready to be culled by simply differentiating $k$ times and evaluating at zero once we go through the easier integration (in eq. (2)) just once for all moments! The fact that it is an easier integration is most apparent when the pdf is an exponential. To recover the $k$-th moment: $$M_X^{(k)}(0)=\frac{d^k}{dt^k}M_X(t)\Bigr|_{t=0}$$ The fact that eventually there is a need to differentiate makes it a not a free lunch - in the end it is a two-sided Laplace transform of the pdf with a changed sign in the exponent: $$\mathcal L \{\text{pdf}(x)\}(s) =\int_{-\infty}^{\infty}e^{-sx}\text{pdf}(x) dx$$ such that $$M_X(t)=\mathcal L\{\text{pdf}(x)\}(-s)\tag 4.$$ This, in effect, gives us a physics avenue to the intuition. The Laplace transform is acting on the $\color{green}{\text{pdf}}$ and decomposing it into moments. The similarity to a Fourier transform is inescapable: a FT maps a function to a new function on the real line, and Laplace maps a function to a new function on the complex plane. The Fourier transform expresses a function or signal as a series of frequencies, while the Laplace transform resolves a function into its moments. In fact, a different way of obtaining moments is through a Fourier transform (characteristic function). The exponential term in the Laplace transform is in general of the form $e^{-st}$ with $s=\sigma + i\,\omega$, corresponding to the real exponentials and imaginary sinusoidals, and yielding plots such as this: [From The Scientist and Engineer's Guide to Signal Processing by Steven W. Smith] Therefore the $M_X(t)$ function decomposes the $\text{pdf}$ somehow into its "constituent frequencies" when $\sigma=0.$ From eq. (4): \begin{align}\require{cancel} M_X(t)&=\mathbb E\big[e^{-sX}\big]\\[2ex] &=\displaystyle \int_{-\infty}^{\infty}{e^{-sx}}\,\text{pdf}(x)\, dx\\[2ex] &=\displaystyle \int_{-\infty}^{\infty}{e^{-(\sigma+i\omega)x}}\,\text{pdf}(x)\, dx\\[2ex] &=\displaystyle \int_{-\infty}^{\infty}\cancel{e^{-\sigma x}}\,\color{red}{e^{-i\omega x}\,\text{pdf}(x)\, dx} \end{align} which leaves us with the improper integral of the part of the expression in red, corresponding to the Fourier transform of the pdf. In general, the intuition of the Laplace transform poles of a function would be that they provide information of the exponential (decay) and frequency components of the function (in this case, the pdf). In response to the question under comments about the switching from $X^k$ to $e^{tx}$, this is a completely strategic move: one expression does not follow from the other. Here is an analogy: We have a car of our own and we are free to drive into the city every time we need to take care of some business (read, integrating Eq $(1)$ no matter how tough for every separate, single moment). Instead, we can do something completely different: we can drive to the nearest subway station (read, solve Eq $(2)$ just once), and from there use public transportation to reach every single place we need to visit (read, get any $k$ derivative of the integral in Eq $(2)$ to extract whichever $k$-th moment we need, knowing (thanks to Eq $(3)$) that all the moments are "hiding" in there and isolated by differentiating and evaluating at $0$.
How would you explain Moment Generating Function(MGF) in layman's terms?
Let's assume that an equation-free intuition is not possible, and still insist on boiling down the math to the very essentials to get an idea of what's going on: we are trying to obtain the statistica
How would you explain Moment Generating Function(MGF) in layman's terms? Let's assume that an equation-free intuition is not possible, and still insist on boiling down the math to the very essentials to get an idea of what's going on: we are trying to obtain the statistical raw moments, which, after the obligatory reference to physics, we define as the expected value of a power of a random variable. For a continuous random variable, the raw $k$-th moment is by LOTUS: \begin{align}\large \color{red}{\mathbb{E}\left[{X^k}\right]} &= \displaystyle\int_{-\infty}^{\infty}\color{blue}{X^k}\,\,\color{green}{\text{pdf}}\,\,\,dx\tag{1}\end{align} The moment generating function, $$M_X(t):=\mathbb E\big[e^{tX}\big],$$ is a way to walk around this integral (Eq.1) by, instead, carrying out: \begin{align} \large \color{blue}{\mathbb{E}\left[e^{\,tX}\right]}&=\displaystyle \int_{-\infty}^{\infty}\color{blue}{e^{tX}}\,\color{green}{\text{pdf}}\, dx\tag{2}\end{align} Why? Because it's easier and there is a fantastic property of the MGF that can be seen by expanding the Maclaurin series of $\color{blue}{e^{\,tX}}$ $$e^{tX}=1+\frac{ X }{1!}\, t +\frac{ X^{2} }{2!}t^{2} +\frac{ X^{3} }{3!} t^{3} +\cdots$$ Taking the expectation of both sides of this power series: $$\begin{align} M_X(t) &= \color{blue}{\mathbb{E}\left[e^{\,tX}\right]} \\[1.5ex] &=1 + \frac{\color{red}{\mathbb{E} \left[X\right]}}{1!} \, t \, + \frac{\color{red}{\mathbb{E} \left[X^2\right]}}{2!} \, t^2 \, + \frac{\color{red}{\mathbb{E} \left[X^3\right]}}{3!} \, t^3 \, + \cdots\tag{3} \end{align}$$ the raw moments appear "perched" on this polynomial "clothesline", ready to be culled by simply differentiating $k$ times and evaluating at zero once we go through the easier integration (in eq. (2)) just once for all moments! The fact that it is an easier integration is most apparent when the pdf is an exponential. To recover the $k$-th moment: $$M_X^{(k)}(0)=\frac{d^k}{dt^k}M_X(t)\Bigr|_{t=0}$$ The fact that eventually there is a need to differentiate makes it a not a free lunch - in the end it is a two-sided Laplace transform of the pdf with a changed sign in the exponent: $$\mathcal L \{\text{pdf}(x)\}(s) =\int_{-\infty}^{\infty}e^{-sx}\text{pdf}(x) dx$$ such that $$M_X(t)=\mathcal L\{\text{pdf}(x)\}(-s)\tag 4.$$ This, in effect, gives us a physics avenue to the intuition. The Laplace transform is acting on the $\color{green}{\text{pdf}}$ and decomposing it into moments. The similarity to a Fourier transform is inescapable: a FT maps a function to a new function on the real line, and Laplace maps a function to a new function on the complex plane. The Fourier transform expresses a function or signal as a series of frequencies, while the Laplace transform resolves a function into its moments. In fact, a different way of obtaining moments is through a Fourier transform (characteristic function). The exponential term in the Laplace transform is in general of the form $e^{-st}$ with $s=\sigma + i\,\omega$, corresponding to the real exponentials and imaginary sinusoidals, and yielding plots such as this: [From The Scientist and Engineer's Guide to Signal Processing by Steven W. Smith] Therefore the $M_X(t)$ function decomposes the $\text{pdf}$ somehow into its "constituent frequencies" when $\sigma=0.$ From eq. (4): \begin{align}\require{cancel} M_X(t)&=\mathbb E\big[e^{-sX}\big]\\[2ex] &=\displaystyle \int_{-\infty}^{\infty}{e^{-sx}}\,\text{pdf}(x)\, dx\\[2ex] &=\displaystyle \int_{-\infty}^{\infty}{e^{-(\sigma+i\omega)x}}\,\text{pdf}(x)\, dx\\[2ex] &=\displaystyle \int_{-\infty}^{\infty}\cancel{e^{-\sigma x}}\,\color{red}{e^{-i\omega x}\,\text{pdf}(x)\, dx} \end{align} which leaves us with the improper integral of the part of the expression in red, corresponding to the Fourier transform of the pdf. In general, the intuition of the Laplace transform poles of a function would be that they provide information of the exponential (decay) and frequency components of the function (in this case, the pdf). In response to the question under comments about the switching from $X^k$ to $e^{tx}$, this is a completely strategic move: one expression does not follow from the other. Here is an analogy: We have a car of our own and we are free to drive into the city every time we need to take care of some business (read, integrating Eq $(1)$ no matter how tough for every separate, single moment). Instead, we can do something completely different: we can drive to the nearest subway station (read, solve Eq $(2)$ just once), and from there use public transportation to reach every single place we need to visit (read, get any $k$ derivative of the integral in Eq $(2)$ to extract whichever $k$-th moment we need, knowing (thanks to Eq $(3)$) that all the moments are "hiding" in there and isolated by differentiating and evaluating at $0$.
How would you explain Moment Generating Function(MGF) in layman's terms? Let's assume that an equation-free intuition is not possible, and still insist on boiling down the math to the very essentials to get an idea of what's going on: we are trying to obtain the statistica
11,085
How would you explain Moment Generating Function(MGF) in layman's terms?
In the most layman terms it's a way to encode all characteristics of the probability distribution into one short phrase. For instance, if I know that MGF of the distribution is $$M(t)=e^{t\mu+1/2\sigma^2t^2}$$ I can find out the mean of this distribution by taking first term of Taylor expansion: $$\left. \frac d {dt}M(t) \right|_{t=0}=\mu+\sigma^2t \Bigg|_{t=0}=\mu$$ If you know what you're doing it's much faster than taking the expectation of the probability function. Moreover, since this MGF encodes everything about the distribution, if you know how to manipulate the function, you can apply operations on all characteristics of the distribution at once! Why don't we always use MGF? First, it's not in every situation the MGF is the easiest tool. Second, MGF doesn't always exist. Above layman Suppose you have a standard normal distribution. You can express everything you know about it by stating its PDF: $$f(x)=\frac 1 {\sqrt{2\pi}}e^{-x^2/2}$$ You can calculate its moment such as mean and standard deviation, and use it on transformed variables and functions on random normals etc. You can think of the MGF of normal distribution as an alternative to PDF. It contains the same amount of information. I already showed how to obtain the mean. Why do we need an alternative way? As I wrote, sometimes it's just more convenient. For instance, try calculating the variance of the standard normal from PDF: $$\sigma^2=\int_{-\infty}^\infty x^2\frac 1 {\sqrt{2\pi}}e^{-x^2/2} \, dx=\text{?}$$ It's not that difficult, but it's much easier to do it with MGF $M(t)=e^{t^2/2}$: $$\sigma^2= \left. \frac {d^2} {dt^2}M(t) \right|_{t=0} = \left. \frac d {dt} t \, \right|_{t=0}=1$$
How would you explain Moment Generating Function(MGF) in layman's terms?
In the most layman terms it's a way to encode all characteristics of the probability distribution into one short phrase. For instance, if I know that MGF of the distribution is $$M(t)=e^{t\mu+1/2\sigm
How would you explain Moment Generating Function(MGF) in layman's terms? In the most layman terms it's a way to encode all characteristics of the probability distribution into one short phrase. For instance, if I know that MGF of the distribution is $$M(t)=e^{t\mu+1/2\sigma^2t^2}$$ I can find out the mean of this distribution by taking first term of Taylor expansion: $$\left. \frac d {dt}M(t) \right|_{t=0}=\mu+\sigma^2t \Bigg|_{t=0}=\mu$$ If you know what you're doing it's much faster than taking the expectation of the probability function. Moreover, since this MGF encodes everything about the distribution, if you know how to manipulate the function, you can apply operations on all characteristics of the distribution at once! Why don't we always use MGF? First, it's not in every situation the MGF is the easiest tool. Second, MGF doesn't always exist. Above layman Suppose you have a standard normal distribution. You can express everything you know about it by stating its PDF: $$f(x)=\frac 1 {\sqrt{2\pi}}e^{-x^2/2}$$ You can calculate its moment such as mean and standard deviation, and use it on transformed variables and functions on random normals etc. You can think of the MGF of normal distribution as an alternative to PDF. It contains the same amount of information. I already showed how to obtain the mean. Why do we need an alternative way? As I wrote, sometimes it's just more convenient. For instance, try calculating the variance of the standard normal from PDF: $$\sigma^2=\int_{-\infty}^\infty x^2\frac 1 {\sqrt{2\pi}}e^{-x^2/2} \, dx=\text{?}$$ It's not that difficult, but it's much easier to do it with MGF $M(t)=e^{t^2/2}$: $$\sigma^2= \left. \frac {d^2} {dt^2}M(t) \right|_{t=0} = \left. \frac d {dt} t \, \right|_{t=0}=1$$
How would you explain Moment Generating Function(MGF) in layman's terms? In the most layman terms it's a way to encode all characteristics of the probability distribution into one short phrase. For instance, if I know that MGF of the distribution is $$M(t)=e^{t\mu+1/2\sigm
11,086
Weibull Distribution v/s Gamma Distribution
Both the gamma and Weibull distributions can be seen as generalisations of the exponential distribution. If we look at the exponential distribution as describing the waiting time of a Poisson process (the time we have to wait until an event happens, if that event is equally likely to occur in any time interval), then the $\Gamma(k, \theta)$ distribution describes the time we have to wait for $k$ independent events to occur. On the other hand, the Weibull distribution effectively describes the time we have to wait for one event to occur, if that event becomes more or less likely with time. Here the $k$ parameter describes how quickly the probability ramps up (proportional to $t^{k-1}$). We can see the difference in effect by looking at the pdfs of the two distributions. Ignoring all the normalising constants: $$ f_{\Gamma}(x) \propto x^{k-1} \exp\left(-\frac{x}{\theta}\right) \\ f_{W}(x) \propto x^{k-1} \exp\left(-\left(\frac{x}{\lambda}\right)^k\right) $$ As you can see from this, the pdf for the Weibull distribution drops off much more quickly (for $k > 1$) or slowly (for $k < 1$) than the gamma distribution. In the case where $k = 1$, they both reduce to the exponential distribution.
Weibull Distribution v/s Gamma Distribution
Both the gamma and Weibull distributions can be seen as generalisations of the exponential distribution. If we look at the exponential distribution as describing the waiting time of a Poisson process
Weibull Distribution v/s Gamma Distribution Both the gamma and Weibull distributions can be seen as generalisations of the exponential distribution. If we look at the exponential distribution as describing the waiting time of a Poisson process (the time we have to wait until an event happens, if that event is equally likely to occur in any time interval), then the $\Gamma(k, \theta)$ distribution describes the time we have to wait for $k$ independent events to occur. On the other hand, the Weibull distribution effectively describes the time we have to wait for one event to occur, if that event becomes more or less likely with time. Here the $k$ parameter describes how quickly the probability ramps up (proportional to $t^{k-1}$). We can see the difference in effect by looking at the pdfs of the two distributions. Ignoring all the normalising constants: $$ f_{\Gamma}(x) \propto x^{k-1} \exp\left(-\frac{x}{\theta}\right) \\ f_{W}(x) \propto x^{k-1} \exp\left(-\left(\frac{x}{\lambda}\right)^k\right) $$ As you can see from this, the pdf for the Weibull distribution drops off much more quickly (for $k > 1$) or slowly (for $k < 1$) than the gamma distribution. In the case where $k = 1$, they both reduce to the exponential distribution.
Weibull Distribution v/s Gamma Distribution Both the gamma and Weibull distributions can be seen as generalisations of the exponential distribution. If we look at the exponential distribution as describing the waiting time of a Poisson process
11,087
What's the most pain-free way to fit logistic growth curves in R?
See the nls() function. It has a self starting logistic curve model function via SSlogis(). E.g. from the ?nls help page DNase1 <- subset(DNase, Run == 1) ## using a selfStart model fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), DNase1) I suggest you read the help pages for these functions and probably the linked references if possible to find out more.
What's the most pain-free way to fit logistic growth curves in R?
See the nls() function. It has a self starting logistic curve model function via SSlogis(). E.g. from the ?nls help page DNase1 <- subset(DNase, Run == 1) ## using a selfStart model fm1DNase1 <
What's the most pain-free way to fit logistic growth curves in R? See the nls() function. It has a self starting logistic curve model function via SSlogis(). E.g. from the ?nls help page DNase1 <- subset(DNase, Run == 1) ## using a selfStart model fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), DNase1) I suggest you read the help pages for these functions and probably the linked references if possible to find out more.
What's the most pain-free way to fit logistic growth curves in R? See the nls() function. It has a self starting logistic curve model function via SSlogis(). E.g. from the ?nls help page DNase1 <- subset(DNase, Run == 1) ## using a selfStart model fm1DNase1 <
11,088
What's the most pain-free way to fit logistic growth curves in R?
I had the same question a little while ago. This is what I found: Fox and Weisberg wrote a great supplemental article using the nls function (both with and without the self-starting option mentioned by Gavin). It can be found here. From that article, I ended up writing a function for my class to use when fitting a logistic curve to their data: ### Log fit - be sure to use quotes around the variable names in ### the call log.fit <- function(dep, ind, yourdata){ #Self-starting ... y <- yourdata[, dep] x <- yourdata[, ind] log.ss <- nls(y ~ SSlogis(x, phi1, phi2, phi3)) #C C <- summary(log.ss)$coef[1] #a A <- exp((summary(log.ss)$coef[2]) * (1/summary(log.ss)$coef[3])) #k K <- (1 / summary(log.ss)$coef[3]) plot(y ~ x, main = "Logistic Function", xlab=ind, ylab=dep) lines(0:max(x), predict(log.ss, data.frame(x=0:max(x))), col="red") r1 <- sum((x - mean(x))^2) r2 <- sum(residuals(log.ss)^2) r_sq <- (r1 - r2) / r1 out <- data.frame(cbind(c(C=C, a=A, k=K, R.value=sqrt(r_sq)))) names(out)[1] <- "Logistic Curve" return(out) }
What's the most pain-free way to fit logistic growth curves in R?
I had the same question a little while ago. This is what I found: Fox and Weisberg wrote a great supplemental article using the nls function (both with and without the self-starting option mentioned b
What's the most pain-free way to fit logistic growth curves in R? I had the same question a little while ago. This is what I found: Fox and Weisberg wrote a great supplemental article using the nls function (both with and without the self-starting option mentioned by Gavin). It can be found here. From that article, I ended up writing a function for my class to use when fitting a logistic curve to their data: ### Log fit - be sure to use quotes around the variable names in ### the call log.fit <- function(dep, ind, yourdata){ #Self-starting ... y <- yourdata[, dep] x <- yourdata[, ind] log.ss <- nls(y ~ SSlogis(x, phi1, phi2, phi3)) #C C <- summary(log.ss)$coef[1] #a A <- exp((summary(log.ss)$coef[2]) * (1/summary(log.ss)$coef[3])) #k K <- (1 / summary(log.ss)$coef[3]) plot(y ~ x, main = "Logistic Function", xlab=ind, ylab=dep) lines(0:max(x), predict(log.ss, data.frame(x=0:max(x))), col="red") r1 <- sum((x - mean(x))^2) r2 <- sum(residuals(log.ss)^2) r_sq <- (r1 - r2) / r1 out <- data.frame(cbind(c(C=C, a=A, k=K, R.value=sqrt(r_sq)))) names(out)[1] <- "Logistic Curve" return(out) }
What's the most pain-free way to fit logistic growth curves in R? I had the same question a little while ago. This is what I found: Fox and Weisberg wrote a great supplemental article using the nls function (both with and without the self-starting option mentioned b
11,089
What is Connectionist Temporal Classification (CTC)?
You have a dataset containing: images I1, I2, ... ground truth texts T1, T2, ... for the images I1, I2, ... So your dataset could look something like that: A Neural Network (NN) outputs a score for each possible horizontal position (often called time-step t in the literature) of the image. This looks something like this for a image with width 2 (t0, t1) and 2 possible characters ("a", "b"): | t0 | t1 --+-----+---- a | 0.1 | 0.6 b | 0.9 | 0.4 To train such a NN, you must specify for each image where a character of the ground truth text is positioned in the image. As an example, think of an image containing the text "Hello". You must now specify where the "H" starts and ends (e.g. "H" starts at the 10th pixel and goes until the 25th pixel). The same for "e", "l, ... That sounds boring and is a hard work for large datasets. Even if you managed to annotate a complete dataset in this way, there is another problem. The NN outputs the scores for each character at each time-step, see the table I've shown above for a toy example. We could now take the most likely character per time-step, this is "b" and "a" in the toy example. Now think of a larger text, e.g. "Hello". If the writer has a writing style which uses much space in horizontal position, each character would occupy multiple time-steps. Taking the most probable character per time-step, this could give us a text like "HHHHHHHHeeeellllllllloooo". How should we transform this text into the correct output? Remove each duplicate character? This yields "Helo", which is not correct. So, we would need some clever postprocessing. CTC solves both problems: you can train the network from pairs (I, T) without having to specify at which position a character occurs using the CTC loss you don't have to postprocess the output, as a CTC decoder transforms the NN output into the final text How is this achieved? introduce a special character (CTC-blank, denoted as "-" in this text) to indicate that no character is seen at a given time-step modify the ground truth text T to T' by inserting CTC-blanks and by repeating characters in in all possible ways we know the image, we know the text, but we don't know where the text is positioned. So, let's just try all possible positions of the text "Hi----", "-Hi---", "--Hi--", ... we also don't know how much space each character occupies in the image. So let's also try all possible alignments by allowing characters to repeat like "HHi----", "HHHi---", "HHHHi--", ... do you see a problem here? Of course, if we allow a character to repeat multiple times, how do we handle real duplicate characters like the "l" in "Hello"? Well, just always insert a blank in between in these situations, that is e.g. "Hel-lo" or "Heeellll-------llo" calculate score for each possible T' (that is for each transformation and each combination of these), sum over all scores which yields the loss for the pair (I, T) decoding is easy: pick character with highest score for each time step, e.g. "HHHHHH-eeeellll-lll--oo---", throw away duplicate characters "H-el-l-o", throw away blanks "Hello", and we are done. To illustrate this, have a look at the following image. It is in the context of speech recognition, however, text recognition is just the same. Decoding yields the same text for both speakers, even though alignment and position of the character differs. Further reading: an intuitive introduction: https://medium.com/@harald_scheidl/intuitively-understanding-connectionist-temporal-classification-3797e43a86c (mirror) a more in-depth introduction: https://distill.pub/2017/ctc (mirror) Python implementation which you can use to "play" around with CTC decoders to get a better understanding of how it works: https://github.com/githubharald/CTCDecoder and, of course, the paper Graves, Alex, Santiago Fernández, Faustino Gomez, and Jürgen Schmidhuber. "Connectionist temporal classification: labelling unsegmented sequence data with recurrent neural networks." In Proceedings of the 23rd international conference on Machine learning, pp. 369-376. ACM, 2006.
What is Connectionist Temporal Classification (CTC)?
You have a dataset containing: images I1, I2, ... ground truth texts T1, T2, ... for the images I1, I2, ... So your dataset could look something like that: A Neural Network (NN) outputs a score for
What is Connectionist Temporal Classification (CTC)? You have a dataset containing: images I1, I2, ... ground truth texts T1, T2, ... for the images I1, I2, ... So your dataset could look something like that: A Neural Network (NN) outputs a score for each possible horizontal position (often called time-step t in the literature) of the image. This looks something like this for a image with width 2 (t0, t1) and 2 possible characters ("a", "b"): | t0 | t1 --+-----+---- a | 0.1 | 0.6 b | 0.9 | 0.4 To train such a NN, you must specify for each image where a character of the ground truth text is positioned in the image. As an example, think of an image containing the text "Hello". You must now specify where the "H" starts and ends (e.g. "H" starts at the 10th pixel and goes until the 25th pixel). The same for "e", "l, ... That sounds boring and is a hard work for large datasets. Even if you managed to annotate a complete dataset in this way, there is another problem. The NN outputs the scores for each character at each time-step, see the table I've shown above for a toy example. We could now take the most likely character per time-step, this is "b" and "a" in the toy example. Now think of a larger text, e.g. "Hello". If the writer has a writing style which uses much space in horizontal position, each character would occupy multiple time-steps. Taking the most probable character per time-step, this could give us a text like "HHHHHHHHeeeellllllllloooo". How should we transform this text into the correct output? Remove each duplicate character? This yields "Helo", which is not correct. So, we would need some clever postprocessing. CTC solves both problems: you can train the network from pairs (I, T) without having to specify at which position a character occurs using the CTC loss you don't have to postprocess the output, as a CTC decoder transforms the NN output into the final text How is this achieved? introduce a special character (CTC-blank, denoted as "-" in this text) to indicate that no character is seen at a given time-step modify the ground truth text T to T' by inserting CTC-blanks and by repeating characters in in all possible ways we know the image, we know the text, but we don't know where the text is positioned. So, let's just try all possible positions of the text "Hi----", "-Hi---", "--Hi--", ... we also don't know how much space each character occupies in the image. So let's also try all possible alignments by allowing characters to repeat like "HHi----", "HHHi---", "HHHHi--", ... do you see a problem here? Of course, if we allow a character to repeat multiple times, how do we handle real duplicate characters like the "l" in "Hello"? Well, just always insert a blank in between in these situations, that is e.g. "Hel-lo" or "Heeellll-------llo" calculate score for each possible T' (that is for each transformation and each combination of these), sum over all scores which yields the loss for the pair (I, T) decoding is easy: pick character with highest score for each time step, e.g. "HHHHHH-eeeellll-lll--oo---", throw away duplicate characters "H-el-l-o", throw away blanks "Hello", and we are done. To illustrate this, have a look at the following image. It is in the context of speech recognition, however, text recognition is just the same. Decoding yields the same text for both speakers, even though alignment and position of the character differs. Further reading: an intuitive introduction: https://medium.com/@harald_scheidl/intuitively-understanding-connectionist-temporal-classification-3797e43a86c (mirror) a more in-depth introduction: https://distill.pub/2017/ctc (mirror) Python implementation which you can use to "play" around with CTC decoders to get a better understanding of how it works: https://github.com/githubharald/CTCDecoder and, of course, the paper Graves, Alex, Santiago Fernández, Faustino Gomez, and Jürgen Schmidhuber. "Connectionist temporal classification: labelling unsegmented sequence data with recurrent neural networks." In Proceedings of the 23rd international conference on Machine learning, pp. 369-376. ACM, 2006.
What is Connectionist Temporal Classification (CTC)? You have a dataset containing: images I1, I2, ... ground truth texts T1, T2, ... for the images I1, I2, ... So your dataset could look something like that: A Neural Network (NN) outputs a score for
11,090
Analyse ACF and PACF plots
Looking at your ACF and PACF is useful in the full context of your analysis as well. Your Ljung-Box Q-statistic; p-value; confidence interval, ACF and PACF should be viewed together. For instance the Q test here: acf, ci, Q, pvalue = tsa.acf(res1.resid, nlags=4, confint=95, qstat=True, unbiased=True) Here - our Q test for autocorrelation is an overall gut check of our graphical interpretation. Draft notes on Time Series analysis in Statsmodels: http://conference.scipy.org/proceedings/scipy2011/pdfs/statsmodels.pdf
Analyse ACF and PACF plots
Looking at your ACF and PACF is useful in the full context of your analysis as well. Your Ljung-Box Q-statistic; p-value; confidence interval, ACF and PACF should be viewed together. For instance the
Analyse ACF and PACF plots Looking at your ACF and PACF is useful in the full context of your analysis as well. Your Ljung-Box Q-statistic; p-value; confidence interval, ACF and PACF should be viewed together. For instance the Q test here: acf, ci, Q, pvalue = tsa.acf(res1.resid, nlags=4, confint=95, qstat=True, unbiased=True) Here - our Q test for autocorrelation is an overall gut check of our graphical interpretation. Draft notes on Time Series analysis in Statsmodels: http://conference.scipy.org/proceedings/scipy2011/pdfs/statsmodels.pdf
Analyse ACF and PACF plots Looking at your ACF and PACF is useful in the full context of your analysis as well. Your Ljung-Box Q-statistic; p-value; confidence interval, ACF and PACF should be viewed together. For instance the
11,091
Analyse ACF and PACF plots
The sole reliance on the ACF and PACF using tools suggested in the mid 60's is sometimes but seldomly correct except for simulated data. Model Identification tools like AIC/BIC almost never correctly identify a useful model but rather show what happens when you don't read the small print regarding the assumptions. I would suggest that you start as simply as possible BUT not too simply and estimate a tentative model ; AR(1) as suggested by Glen_b . The residuals/analysis from this tentative model can be used to compute yet another ACF and PACF suggesting potential model augmentation or model simplification. Note that interpretation ala your references REQUIRE that the current series/residuals are free of any deterministic structure i.e. Pulses, Level Shifts, Local Time Trends and Seasonal Pulses and furthermore that the series has constant error variance and that the parameters of the tentative model are invariant over time. If you wish you can post your data and I will attempt to help you form a useful model. EDIT AFTER DATA WAS REPORTED : 365 values were delivered and analyzed, yielding the following AR(1) model with identified Pulses and 2 Level Shifts . . note that this had been a popular guess . The residuals from this model are plotted here . There is a suggestion of variance hetero-scedasticity but this is a symptom and one needs to find the correct cure which we will ultimately find. Proceeding the acf of the residuals shown here exhibits a suggestion of model inadequacy. A closer look at the table of the acf of the residuals is here suggesting structure at lags 7 and 14. Putting the the two clues together ( sample size of 365 and significant weekly i.e. lag 7 structure ) I decided to investigate whether or not this was indeed daily data. New users often omit very important information when they define their data on the mistaken premise that the computer should be smart enough to figure everything out. Note that the lag 7 and lag 14 clues were swamped in the OP'S ACF and PACF plots. The presence of deterministic structure in the residuals increase the error variance thus suppressing the acf. Once the outliers/pulses/level shifts were identified the acf revealed the presence of an autoregressive structure /daily indicators which then needed to be accounted for. I then analyzed the data allowing the software to proceed with the clue that it was daily data. With only 365 values it is not possible to properly construct models containing seasonal/holiday predictors BUT that is possible with more than 1 year of data. The model that was found is presented here containing 5 daily dummies , two Level Shifts , a number of pulses and an arima model of the form (1,0,0)(1,0,0) . The plot of the residuals no longer evidences the non-constancy structure as a better model is in place. . The acf of the residuals is much cleaner . The Actual /Cleansed graph highlights the unusual pulse points. . THe lesson here is that when one analyzed the data without the critical piece of information that it was a daily time series there were a ton of pulses reflecting an inadequate representation (or perhaps the advanced knowledge of the daily clue ) . The Actual/Fit and Forecast is presented here . It would be interesting to see what others would do with the same data set. Note that all analyses were conducted in a hands-free mode using software that is commercially available.
Analyse ACF and PACF plots
The sole reliance on the ACF and PACF using tools suggested in the mid 60's is sometimes but seldomly correct except for simulated data. Model Identification tools like AIC/BIC almost never correctly
Analyse ACF and PACF plots The sole reliance on the ACF and PACF using tools suggested in the mid 60's is sometimes but seldomly correct except for simulated data. Model Identification tools like AIC/BIC almost never correctly identify a useful model but rather show what happens when you don't read the small print regarding the assumptions. I would suggest that you start as simply as possible BUT not too simply and estimate a tentative model ; AR(1) as suggested by Glen_b . The residuals/analysis from this tentative model can be used to compute yet another ACF and PACF suggesting potential model augmentation or model simplification. Note that interpretation ala your references REQUIRE that the current series/residuals are free of any deterministic structure i.e. Pulses, Level Shifts, Local Time Trends and Seasonal Pulses and furthermore that the series has constant error variance and that the parameters of the tentative model are invariant over time. If you wish you can post your data and I will attempt to help you form a useful model. EDIT AFTER DATA WAS REPORTED : 365 values were delivered and analyzed, yielding the following AR(1) model with identified Pulses and 2 Level Shifts . . note that this had been a popular guess . The residuals from this model are plotted here . There is a suggestion of variance hetero-scedasticity but this is a symptom and one needs to find the correct cure which we will ultimately find. Proceeding the acf of the residuals shown here exhibits a suggestion of model inadequacy. A closer look at the table of the acf of the residuals is here suggesting structure at lags 7 and 14. Putting the the two clues together ( sample size of 365 and significant weekly i.e. lag 7 structure ) I decided to investigate whether or not this was indeed daily data. New users often omit very important information when they define their data on the mistaken premise that the computer should be smart enough to figure everything out. Note that the lag 7 and lag 14 clues were swamped in the OP'S ACF and PACF plots. The presence of deterministic structure in the residuals increase the error variance thus suppressing the acf. Once the outliers/pulses/level shifts were identified the acf revealed the presence of an autoregressive structure /daily indicators which then needed to be accounted for. I then analyzed the data allowing the software to proceed with the clue that it was daily data. With only 365 values it is not possible to properly construct models containing seasonal/holiday predictors BUT that is possible with more than 1 year of data. The model that was found is presented here containing 5 daily dummies , two Level Shifts , a number of pulses and an arima model of the form (1,0,0)(1,0,0) . The plot of the residuals no longer evidences the non-constancy structure as a better model is in place. . The acf of the residuals is much cleaner . The Actual /Cleansed graph highlights the unusual pulse points. . THe lesson here is that when one analyzed the data without the critical piece of information that it was a daily time series there were a ton of pulses reflecting an inadequate representation (or perhaps the advanced knowledge of the daily clue ) . The Actual/Fit and Forecast is presented here . It would be interesting to see what others would do with the same data set. Note that all analyses were conducted in a hands-free mode using software that is commercially available.
Analyse ACF and PACF plots The sole reliance on the ACF and PACF using tools suggested in the mid 60's is sometimes but seldomly correct except for simulated data. Model Identification tools like AIC/BIC almost never correctly
11,092
Analyse ACF and PACF plots
It looks to me like you're counting the spikes at lag 0. Your PACF shows one reasonably large spike at lag 1, suggesting AR(1). This will of course induce a geometric-like decrease in the ACF (which, broadly speaking, you see). You seem to be trying to fit the same dependence twice - both as AR and MA. I'd have just tried AR(1) on that to start with and seen if there was anything left worth worrying over.
Analyse ACF and PACF plots
It looks to me like you're counting the spikes at lag 0. Your PACF shows one reasonably large spike at lag 1, suggesting AR(1). This will of course induce a geometric-like decrease in the ACF (which,
Analyse ACF and PACF plots It looks to me like you're counting the spikes at lag 0. Your PACF shows one reasonably large spike at lag 1, suggesting AR(1). This will of course induce a geometric-like decrease in the ACF (which, broadly speaking, you see). You seem to be trying to fit the same dependence twice - both as AR and MA. I'd have just tried AR(1) on that to start with and seen if there was anything left worth worrying over.
Analyse ACF and PACF plots It looks to me like you're counting the spikes at lag 0. Your PACF shows one reasonably large spike at lag 1, suggesting AR(1). This will of course induce a geometric-like decrease in the ACF (which,
11,093
How do you see a Markov chain is irreducible?
Here are three examples (taken from Greenberg, Introduction to Bayesian Econometrics, if I remember correctly) for transition matrices, the first two for the reducible case, the last for the irreducible one. \begin{eqnarray*} P_1 &=& \left( \begin{array}{cccc} 0.5 & 0.5 & 0 & 0 \\ 0.9 & 0.1 & 0 & 0 \\ 0 & 0 & 0.2 & 0.8 \\ 0 & 0 & 0.7 & 0.3 \end{array} \right) \\\\ P_2 &=& \left( \begin{array}{cccc} 0.1 & 0.1 & 0.4 & 0.4 \\ 0.5 & 0.1 & 0.1 & 0.3 \\ 0.2 & 0.4 & 0.2 & 0.2 \\ 0 & 0 & 0 & 1% \end{array} \right) \end{eqnarray*} For $P_1$, when you are in state 3 or 4, you will stay there, and the same for states 1 and 2. There is no way to get from state 1 to state 3 or 4, for example. For $P_2$, you can get to any state from states 1 to 3, but once you are in state 4, you will stay there. $$P_3=\left( \begin{array}{cccccc} 0.5 & 0.5 & 0 & 0 & 0 & 0 \\ 0.9 & 0 & 0 & 0 & 0 & 0.1 \\ 0 & 0 & 0 & 0.8 & 0 & 0.2 \\ 0.7 & 0 & 0.1 & 0 & 0.2 & 0 \\ 0 & 0 & 0 & 0.1 & 0.9 & 0 \\ 0.9 & 0 & 0 & 0 & 0.1 & 0% \end{array} \right)$$ For this example, you may start in any state and can still reach any other state, although not necessarily in one step.
How do you see a Markov chain is irreducible?
Here are three examples (taken from Greenberg, Introduction to Bayesian Econometrics, if I remember correctly) for transition matrices, the first two for the reducible case, the last for the irreducib
How do you see a Markov chain is irreducible? Here are three examples (taken from Greenberg, Introduction to Bayesian Econometrics, if I remember correctly) for transition matrices, the first two for the reducible case, the last for the irreducible one. \begin{eqnarray*} P_1 &=& \left( \begin{array}{cccc} 0.5 & 0.5 & 0 & 0 \\ 0.9 & 0.1 & 0 & 0 \\ 0 & 0 & 0.2 & 0.8 \\ 0 & 0 & 0.7 & 0.3 \end{array} \right) \\\\ P_2 &=& \left( \begin{array}{cccc} 0.1 & 0.1 & 0.4 & 0.4 \\ 0.5 & 0.1 & 0.1 & 0.3 \\ 0.2 & 0.4 & 0.2 & 0.2 \\ 0 & 0 & 0 & 1% \end{array} \right) \end{eqnarray*} For $P_1$, when you are in state 3 or 4, you will stay there, and the same for states 1 and 2. There is no way to get from state 1 to state 3 or 4, for example. For $P_2$, you can get to any state from states 1 to 3, but once you are in state 4, you will stay there. $$P_3=\left( \begin{array}{cccccc} 0.5 & 0.5 & 0 & 0 & 0 & 0 \\ 0.9 & 0 & 0 & 0 & 0 & 0.1 \\ 0 & 0 & 0 & 0.8 & 0 & 0.2 \\ 0.7 & 0 & 0.1 & 0 & 0.2 & 0 \\ 0 & 0 & 0 & 0.1 & 0.9 & 0 \\ 0.9 & 0 & 0 & 0 & 0.1 & 0% \end{array} \right)$$ For this example, you may start in any state and can still reach any other state, although not necessarily in one step.
How do you see a Markov chain is irreducible? Here are three examples (taken from Greenberg, Introduction to Bayesian Econometrics, if I remember correctly) for transition matrices, the first two for the reducible case, the last for the irreducib
11,094
How do you see a Markov chain is irreducible?
The state $j$ is said to be accessible from a state $i$ (usually denoted by $i \to j$) if there exists some $n\geq 0$ such that: $$p^n_{ij}=\mathbb P(X_n=j\mid X_0=i) > 0$$ That is, one can get from the state $i$ to the state $j$ in $n$ steps with probability $p^n_{ij}$. If both $i\to j$ and $j\to i$ hold true then the states $i$ and $j$ communicate (usually denoted by $i\leftrightarrow j$). Therefore, the Markov chain is irreducible if each two states communicate.
How do you see a Markov chain is irreducible?
The state $j$ is said to be accessible from a state $i$ (usually denoted by $i \to j$) if there exists some $n\geq 0$ such that: $$p^n_{ij}=\mathbb P(X_n=j\mid X_0=i) > 0$$ That is, one can get from
How do you see a Markov chain is irreducible? The state $j$ is said to be accessible from a state $i$ (usually denoted by $i \to j$) if there exists some $n\geq 0$ such that: $$p^n_{ij}=\mathbb P(X_n=j\mid X_0=i) > 0$$ That is, one can get from the state $i$ to the state $j$ in $n$ steps with probability $p^n_{ij}$. If both $i\to j$ and $j\to i$ hold true then the states $i$ and $j$ communicate (usually denoted by $i\leftrightarrow j$). Therefore, the Markov chain is irreducible if each two states communicate.
How do you see a Markov chain is irreducible? The state $j$ is said to be accessible from a state $i$ (usually denoted by $i \to j$) if there exists some $n\geq 0$ such that: $$p^n_{ij}=\mathbb P(X_n=j\mid X_0=i) > 0$$ That is, one can get from
11,095
How do you see a Markov chain is irreducible?
Some of the existing answers seem to be incorrect to me. As cited in Stochastic Processes by J. Medhi (page 79, edition 4), a Markov chain is irreducible if it does not contain any proper 'closed' subset other than the state space. So if in your transition probability matrix, there is a subset of states such that you cannot 'reach' (or access) any other states apart from those states, then the Markov chain is reducible. Otherwise the Markov chain is irreducible.
How do you see a Markov chain is irreducible?
Some of the existing answers seem to be incorrect to me. As cited in Stochastic Processes by J. Medhi (page 79, edition 4), a Markov chain is irreducible if it does not contain any proper 'closed' s
How do you see a Markov chain is irreducible? Some of the existing answers seem to be incorrect to me. As cited in Stochastic Processes by J. Medhi (page 79, edition 4), a Markov chain is irreducible if it does not contain any proper 'closed' subset other than the state space. So if in your transition probability matrix, there is a subset of states such that you cannot 'reach' (or access) any other states apart from those states, then the Markov chain is reducible. Otherwise the Markov chain is irreducible.
How do you see a Markov chain is irreducible? Some of the existing answers seem to be incorrect to me. As cited in Stochastic Processes by J. Medhi (page 79, edition 4), a Markov chain is irreducible if it does not contain any proper 'closed' s
11,096
How do you see a Markov chain is irreducible?
Let $i$ and $j$ be two distinct states of a Markov Chain. If there is some positive probability for the process to go from state $i$ to state $j$, whatever be the number of steps(say 1, 2, 3$\cdots$), then we say that state $j$ is accessible from state $i$. Notationally, we express this as $i\rightarrow j$. In terms of probability, it is expressed as follows: a state $j$ is accessible from state $i$, if there exists an integer $m>0$ such that $p_{ij}^{(m)}>0$. Similarly, we say that, $j\rightarrow i$, if there exists an integer $n>0$ such that $p_{ji}^{(n)}>0$. Now, if both $i\rightarrow j$ and $j\rightarrow i$ are true, then we say that the states $i$ and $j$ communicate with each other, and is notationally expressed as $i \leftrightarrow j$. In terms of probability, this means that, there exists two integers $m>0,\;\; n>0$ such that $p_{ij}^{(m)}>0$ and $p_{ji}^{(n)}>0$. If all the states in the Markov Chain belong to one closed communicating class, then the chain is called an irreducible Markov chain. Irreducibility is a property of the chain. In an irreducible Markov Chain, the process can go from any state to any state, whatever be the number of steps it requires.
How do you see a Markov chain is irreducible?
Let $i$ and $j$ be two distinct states of a Markov Chain. If there is some positive probability for the process to go from state $i$ to state $j$, whatever be the number of steps(say 1, 2, 3$\cdots$)
How do you see a Markov chain is irreducible? Let $i$ and $j$ be two distinct states of a Markov Chain. If there is some positive probability for the process to go from state $i$ to state $j$, whatever be the number of steps(say 1, 2, 3$\cdots$), then we say that state $j$ is accessible from state $i$. Notationally, we express this as $i\rightarrow j$. In terms of probability, it is expressed as follows: a state $j$ is accessible from state $i$, if there exists an integer $m>0$ such that $p_{ij}^{(m)}>0$. Similarly, we say that, $j\rightarrow i$, if there exists an integer $n>0$ such that $p_{ji}^{(n)}>0$. Now, if both $i\rightarrow j$ and $j\rightarrow i$ are true, then we say that the states $i$ and $j$ communicate with each other, and is notationally expressed as $i \leftrightarrow j$. In terms of probability, this means that, there exists two integers $m>0,\;\; n>0$ such that $p_{ij}^{(m)}>0$ and $p_{ji}^{(n)}>0$. If all the states in the Markov Chain belong to one closed communicating class, then the chain is called an irreducible Markov chain. Irreducibility is a property of the chain. In an irreducible Markov Chain, the process can go from any state to any state, whatever be the number of steps it requires.
How do you see a Markov chain is irreducible? Let $i$ and $j$ be two distinct states of a Markov Chain. If there is some positive probability for the process to go from state $i$ to state $j$, whatever be the number of steps(say 1, 2, 3$\cdots$)
11,097
How do you see a Markov chain is irreducible?
First a word of warning : never look at a matrix unless you have a serious reason to do so : the only one I can think of is checking for mistakenly typed digits, or reading in a textbook. If $P$ is your transition matrix, compute $\exp(P)$. If all entries are nonzero, then the matrix is irreducible. Otherwise, it's reducible. If $P$ is too large, compute $P^n$ with $n$ as large as you can. Same test, slightly less accurate. Irreducibility means : you can go from any state to any other state in a finite number of steps. In Christoph Hanck's example $P_3$, you can't go directly from state 1 to state 6, but you can go 1 -> 2 -> 6
How do you see a Markov chain is irreducible?
First a word of warning : never look at a matrix unless you have a serious reason to do so : the only one I can think of is checking for mistakenly typed digits, or reading in a textbook. If $P$ is yo
How do you see a Markov chain is irreducible? First a word of warning : never look at a matrix unless you have a serious reason to do so : the only one I can think of is checking for mistakenly typed digits, or reading in a textbook. If $P$ is your transition matrix, compute $\exp(P)$. If all entries are nonzero, then the matrix is irreducible. Otherwise, it's reducible. If $P$ is too large, compute $P^n$ with $n$ as large as you can. Same test, slightly less accurate. Irreducibility means : you can go from any state to any other state in a finite number of steps. In Christoph Hanck's example $P_3$, you can't go directly from state 1 to state 6, but you can go 1 -> 2 -> 6
How do you see a Markov chain is irreducible? First a word of warning : never look at a matrix unless you have a serious reason to do so : the only one I can think of is checking for mistakenly typed digits, or reading in a textbook. If $P$ is yo
11,098
What does "fiducial" mean (in the context of statistics)?
The fiducial argument is to interpret likelihood as a probability. Edit: not exactly, see the answer of @Sextus for more details. Even if likelihood measures the plausibility of an event, it does not satisfy the axioms of probability measures (in particular there is no guarantee that it sums to 1), which is one of the reasons this concept was never so successful. Let's give an example. Imagine that you want to estimate a parameter, say the half-life $\lambda$ of a radioactive element. You take a couple of measurements, say $(x_1, \ldots, x_n)$ from which you try to infer the value of $\lambda$. In the view of the traditional or frequentist approach, $\lambda$ is not a random quantity. It is an unknown constant with likelihood function $\lambda^n \prod_{i=1}^n e^{-\lambda x_i} = \lambda^n e^{-\lambda(x_1+\ldots+x_n)}$. In the view of the Bayesian approach, $\lambda$ is a random variable with a prior distribution; the measurements $(x_1, \ldots, x_n)$ are needed to deduce the posterior distribution. For instance, if my prior belief about the value of lambda is well represented by the density distribution $2.3 \cdot e^{-2.3\lambda}$, the joint distribution is the product of the two, i.e. $2.3 \cdot \lambda^n e^{-\lambda(2.3+x_1+\ldots+x_n) }$. The posterior is the distribution of $\lambda$ given the measurements, which is computed with Bayes formula. In this case, $\lambda$ has a Gamma distribution with parameters $n$ and $2.3+x_1+\ldots+x_n$. In the view of fiducial inference, $\lambda$ is also a random variable but it does not have a prior distribution, just a fiducial distribution that depends only on $(x_1, \ldots, x_n)$. To follow up on the example above, the fiducial distribution is $\lambda^n e^{-\lambda(x_1+\ldots+x_n)}$. This is the same as the likelihood, except that it is now interpreted as a probability. With proper scaling, it is a Gamma distribution with parameters $n$ and $x_1+\ldots+x_n$. Those differences have most noticeable effects in the context of confidence interval estimation. A 95% confidence interval in the classical sense is a construction that has 95% chance of containing the target value before any data is collected. However, for a fiducial statistician, a 95% confidence interval is a set that has 95% chance of containing the target value (which is a typical misinterpretation of the students of the frequentist approach).
What does "fiducial" mean (in the context of statistics)?
The fiducial argument is to interpret likelihood as a probability. Edit: not exactly, see the answer of @Sextus for more details. Even if likelihood measures the plausibility of an event, it does not
What does "fiducial" mean (in the context of statistics)? The fiducial argument is to interpret likelihood as a probability. Edit: not exactly, see the answer of @Sextus for more details. Even if likelihood measures the plausibility of an event, it does not satisfy the axioms of probability measures (in particular there is no guarantee that it sums to 1), which is one of the reasons this concept was never so successful. Let's give an example. Imagine that you want to estimate a parameter, say the half-life $\lambda$ of a radioactive element. You take a couple of measurements, say $(x_1, \ldots, x_n)$ from which you try to infer the value of $\lambda$. In the view of the traditional or frequentist approach, $\lambda$ is not a random quantity. It is an unknown constant with likelihood function $\lambda^n \prod_{i=1}^n e^{-\lambda x_i} = \lambda^n e^{-\lambda(x_1+\ldots+x_n)}$. In the view of the Bayesian approach, $\lambda$ is a random variable with a prior distribution; the measurements $(x_1, \ldots, x_n)$ are needed to deduce the posterior distribution. For instance, if my prior belief about the value of lambda is well represented by the density distribution $2.3 \cdot e^{-2.3\lambda}$, the joint distribution is the product of the two, i.e. $2.3 \cdot \lambda^n e^{-\lambda(2.3+x_1+\ldots+x_n) }$. The posterior is the distribution of $\lambda$ given the measurements, which is computed with Bayes formula. In this case, $\lambda$ has a Gamma distribution with parameters $n$ and $2.3+x_1+\ldots+x_n$. In the view of fiducial inference, $\lambda$ is also a random variable but it does not have a prior distribution, just a fiducial distribution that depends only on $(x_1, \ldots, x_n)$. To follow up on the example above, the fiducial distribution is $\lambda^n e^{-\lambda(x_1+\ldots+x_n)}$. This is the same as the likelihood, except that it is now interpreted as a probability. With proper scaling, it is a Gamma distribution with parameters $n$ and $x_1+\ldots+x_n$. Those differences have most noticeable effects in the context of confidence interval estimation. A 95% confidence interval in the classical sense is a construction that has 95% chance of containing the target value before any data is collected. However, for a fiducial statistician, a 95% confidence interval is a set that has 95% chance of containing the target value (which is a typical misinterpretation of the students of the frequentist approach).
What does "fiducial" mean (in the context of statistics)? The fiducial argument is to interpret likelihood as a probability. Edit: not exactly, see the answer of @Sextus for more details. Even if likelihood measures the plausibility of an event, it does not
11,099
What does "fiducial" mean (in the context of statistics)?
Several well-known statisticians try to rekindle an interest in Fisher's fiducial argument. Bradley Efron: (I cannot copy even small quotes from google books), the topic is also treated in Bradley Efron 2. He says something to the effect of (not a direct quote): Fiducial inference, sometimes considered Fisher's largest error, can be Fisher largest hit for the future. So there are people thinking that Fiducial ideas will come back. A complete book devoted to the topic (by some of my former professors) is Schweder, T. & Hjort, N. L. (2016). Confidence, Likelihood, Probability: Statistical Inference with Confidence Distributions. Cambridge University Press. They propose to change terminology from "fiducial distribution" to "confidence distribution". I even at some point tried to make a new tag here confidence-distribution. But somebody mistakenly made that a tag synonym for confidence-interval. Grrrr (If made a synonym, it should be to fiducial.)
What does "fiducial" mean (in the context of statistics)?
Several well-known statisticians try to rekindle an interest in Fisher's fiducial argument. Bradley Efron: (I cannot copy even small quotes from google books), the topic is also treated in Bradley
What does "fiducial" mean (in the context of statistics)? Several well-known statisticians try to rekindle an interest in Fisher's fiducial argument. Bradley Efron: (I cannot copy even small quotes from google books), the topic is also treated in Bradley Efron 2. He says something to the effect of (not a direct quote): Fiducial inference, sometimes considered Fisher's largest error, can be Fisher largest hit for the future. So there are people thinking that Fiducial ideas will come back. A complete book devoted to the topic (by some of my former professors) is Schweder, T. & Hjort, N. L. (2016). Confidence, Likelihood, Probability: Statistical Inference with Confidence Distributions. Cambridge University Press. They propose to change terminology from "fiducial distribution" to "confidence distribution". I even at some point tried to make a new tag here confidence-distribution. But somebody mistakenly made that a tag synonym for confidence-interval. Grrrr (If made a synonym, it should be to fiducial.)
What does "fiducial" mean (in the context of statistics)? Several well-known statisticians try to rekindle an interest in Fisher's fiducial argument. Bradley Efron: (I cannot copy even small quotes from google books), the topic is also treated in Bradley
11,100
What does "fiducial" mean (in the context of statistics)?
In the answer from gui11aume it is stated that The fiducial argument is to interpret likelihood as a probability. However, there is a subtle difference between the fiducial distribution and the likelihood function. If $F(\hat\theta; \theta)$ is the cumulative distribution function of some parameter estimate $\hat\theta$ given the true parameter $\theta$ then the fiducial/confidence distribution is $\frac{d}{d\theta}F(\hat\theta,\theta)$ whereas the likelihood function is $\frac{d}{d\hat\theta}F(\hat\theta,\theta)$.* The fiducial argument is to inverse the interpretation of the probability statement described by the cumulative distribution function. An example is described in this question The basic logic of constructing a confidence interval The way of constructing the confidence interval in that question, by using the cumulative distribution function, is equivalent to constructing a fiducial distribution. So this specific** type of confidence interval and related confidence distribution is what is meant by the fiducial distribution and fiducial probability. And, it is much more around then we think; it is only not named fiducial interval and overtaken by the more general confidence interval. Another reason why 'fiducial' is less popular is because of the difference in the philosophical interpretation and attempts to have a more Bayesian interpretation than frequentist interpretation. The fiducial intervals were supposed to contain the parameter 95% of the time but they only do so from a specific point of view: Why does a 95% Confidence Interval (CI) not imply a 95% chance of containing the mean? * For some types of cases like a rate parameter or a location parameter, the fiducial distribution coincides with the likelihood distribution because in those cases $\frac{d}{d\theta}F(\hat\theta,\theta) \propto \frac{d}{d\hat\theta}F(\hat\theta,\theta)$. But the fiducial distribution does not transform in the same way when we re-express the parameters (it scales more like a probability distribution function). For instance, the fiducial distribution for estimating $\sigma$ in a normal distribution is not the same as the likelihood function. ** Note 'specific'. The fiducial distribution is a confidence distribution, but not every confidence distribution is a fiducial distribution.
What does "fiducial" mean (in the context of statistics)?
In the answer from gui11aume it is stated that The fiducial argument is to interpret likelihood as a probability. However, there is a subtle difference between the fiducial distribution and the like
What does "fiducial" mean (in the context of statistics)? In the answer from gui11aume it is stated that The fiducial argument is to interpret likelihood as a probability. However, there is a subtle difference between the fiducial distribution and the likelihood function. If $F(\hat\theta; \theta)$ is the cumulative distribution function of some parameter estimate $\hat\theta$ given the true parameter $\theta$ then the fiducial/confidence distribution is $\frac{d}{d\theta}F(\hat\theta,\theta)$ whereas the likelihood function is $\frac{d}{d\hat\theta}F(\hat\theta,\theta)$.* The fiducial argument is to inverse the interpretation of the probability statement described by the cumulative distribution function. An example is described in this question The basic logic of constructing a confidence interval The way of constructing the confidence interval in that question, by using the cumulative distribution function, is equivalent to constructing a fiducial distribution. So this specific** type of confidence interval and related confidence distribution is what is meant by the fiducial distribution and fiducial probability. And, it is much more around then we think; it is only not named fiducial interval and overtaken by the more general confidence interval. Another reason why 'fiducial' is less popular is because of the difference in the philosophical interpretation and attempts to have a more Bayesian interpretation than frequentist interpretation. The fiducial intervals were supposed to contain the parameter 95% of the time but they only do so from a specific point of view: Why does a 95% Confidence Interval (CI) not imply a 95% chance of containing the mean? * For some types of cases like a rate parameter or a location parameter, the fiducial distribution coincides with the likelihood distribution because in those cases $\frac{d}{d\theta}F(\hat\theta,\theta) \propto \frac{d}{d\hat\theta}F(\hat\theta,\theta)$. But the fiducial distribution does not transform in the same way when we re-express the parameters (it scales more like a probability distribution function). For instance, the fiducial distribution for estimating $\sigma$ in a normal distribution is not the same as the likelihood function. ** Note 'specific'. The fiducial distribution is a confidence distribution, but not every confidence distribution is a fiducial distribution.
What does "fiducial" mean (in the context of statistics)? In the answer from gui11aume it is stated that The fiducial argument is to interpret likelihood as a probability. However, there is a subtle difference between the fiducial distribution and the like