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
31,001
Is overfitted model with higher AUC on test sample better than not overfitted one
This will depend on how your training and test sets are composed. If the test set is rather big and reflects the "application case" data diversity correctly, I would not argue like this. But if the test data is rather small, you could of course achieve some good or bad results by chance. Using more test data would be helpful is such cases (or using a bigger portion of the total data available - if possible). Further, training results should be obtained using some inner partitioning (e.g. repeated cross validation), which tests on data the model has not seen before. The performance and performance spread across those results shows you how your model usually performs, and how likely it is to just obtain better or worse results. Using such a procedure, I would not consider any test results that are better than your CV results to be realistic. You should probably also look at and compare the CV performance and performance spread of both models. And: keep in mind that if your training data is rather small compared to your test data, your training results might still be noticeably better than your test results and real application case results.
Is overfitted model with higher AUC on test sample better than not overfitted one
This will depend on how your training and test sets are composed. If the test set is rather big and reflects the "application case" data diversity correctly, I would not argue like this. But if the t
Is overfitted model with higher AUC on test sample better than not overfitted one This will depend on how your training and test sets are composed. If the test set is rather big and reflects the "application case" data diversity correctly, I would not argue like this. But if the test data is rather small, you could of course achieve some good or bad results by chance. Using more test data would be helpful is such cases (or using a bigger portion of the total data available - if possible). Further, training results should be obtained using some inner partitioning (e.g. repeated cross validation), which tests on data the model has not seen before. The performance and performance spread across those results shows you how your model usually performs, and how likely it is to just obtain better or worse results. Using such a procedure, I would not consider any test results that are better than your CV results to be realistic. You should probably also look at and compare the CV performance and performance spread of both models. And: keep in mind that if your training data is rather small compared to your test data, your training results might still be noticeably better than your test results and real application case results.
Is overfitted model with higher AUC on test sample better than not overfitted one This will depend on how your training and test sets are composed. If the test set is rather big and reflects the "application case" data diversity correctly, I would not argue like this. But if the t
31,002
Is overfitted model with higher AUC on test sample better than not overfitted one
If the focus is purely on predictive accuracy, then the overfitted model is most probably better. Take e.g. a random forest: On the training data set, by construction, it extremely overfits. Still the results on the test data set are often quite reasonable (and the test performance close to the stated out-of-bag performance). This works only if the test data set reflects "real cases" and the assumptions of the underlying models are met reasonably.
Is overfitted model with higher AUC on test sample better than not overfitted one
If the focus is purely on predictive accuracy, then the overfitted model is most probably better. Take e.g. a random forest: On the training data set, by construction, it extremely overfits. Still the
Is overfitted model with higher AUC on test sample better than not overfitted one If the focus is purely on predictive accuracy, then the overfitted model is most probably better. Take e.g. a random forest: On the training data set, by construction, it extremely overfits. Still the results on the test data set are often quite reasonable (and the test performance close to the stated out-of-bag performance). This works only if the test data set reflects "real cases" and the assumptions of the underlying models are met reasonably.
Is overfitted model with higher AUC on test sample better than not overfitted one If the focus is purely on predictive accuracy, then the overfitted model is most probably better. Take e.g. a random forest: On the training data set, by construction, it extremely overfits. Still the
31,003
Is overfitted model with higher AUC on test sample better than not overfitted one
It's quite possible (and in certain situations) to be overfitting on the test set as well. Properly fit models should achieve approximately similar cross validated performance on both the training and test datasets. Best practices would be to also hold out another portion of the dataset that is only used once: to assess the performance of the model on data it hasn't seen at all. If you're using the test set to build the model iteratively, say adding a feature then seeing how it validates on the test set, you're giving the model information about the test set. Specifically you're biasing your results on the test set to be higher (that is, you're overfitting) if you tune the model based on its test set performance.
Is overfitted model with higher AUC on test sample better than not overfitted one
It's quite possible (and in certain situations) to be overfitting on the test set as well. Properly fit models should achieve approximately similar cross validated performance on both the training and
Is overfitted model with higher AUC on test sample better than not overfitted one It's quite possible (and in certain situations) to be overfitting on the test set as well. Properly fit models should achieve approximately similar cross validated performance on both the training and test datasets. Best practices would be to also hold out another portion of the dataset that is only used once: to assess the performance of the model on data it hasn't seen at all. If you're using the test set to build the model iteratively, say adding a feature then seeing how it validates on the test set, you're giving the model information about the test set. Specifically you're biasing your results on the test set to be higher (that is, you're overfitting) if you tune the model based on its test set performance.
Is overfitted model with higher AUC on test sample better than not overfitted one It's quite possible (and in certain situations) to be overfitting on the test set as well. Properly fit models should achieve approximately similar cross validated performance on both the training and
31,004
Weighted least square weights definition: R lm function vs. $\mathbf W \mathbf A\mathbf x=\mathbf W \mathbf b$
As you can see from the mathematical expressions for your calculations, you are obtaining $$((WA)^\prime (WA))^{-1} \; ((WA)^\prime (Wb)) = (A^\prime W^2 A)^{-1} (A^\prime W^2 b).$$ Evidently your weights are $W^2$, not $W$. Thus you should be comparing your answer to the output of > lm(form, mtcars, weights=w^2) Coefficients: wt hp disp 14.12980 0.08391 -0.16446 The agreement is perfect (to within floating point error--internally, R uses a numerically more stable algorithm.)
Weighted least square weights definition: R lm function vs. $\mathbf W \mathbf A\mathbf x=\mathbf W
As you can see from the mathematical expressions for your calculations, you are obtaining $$((WA)^\prime (WA))^{-1} \; ((WA)^\prime (Wb)) = (A^\prime W^2 A)^{-1} (A^\prime W^2 b).$$ Evidently your wei
Weighted least square weights definition: R lm function vs. $\mathbf W \mathbf A\mathbf x=\mathbf W \mathbf b$ As you can see from the mathematical expressions for your calculations, you are obtaining $$((WA)^\prime (WA))^{-1} \; ((WA)^\prime (Wb)) = (A^\prime W^2 A)^{-1} (A^\prime W^2 b).$$ Evidently your weights are $W^2$, not $W$. Thus you should be comparing your answer to the output of > lm(form, mtcars, weights=w^2) Coefficients: wt hp disp 14.12980 0.08391 -0.16446 The agreement is perfect (to within floating point error--internally, R uses a numerically more stable algorithm.)
Weighted least square weights definition: R lm function vs. $\mathbf W \mathbf A\mathbf x=\mathbf W As you can see from the mathematical expressions for your calculations, you are obtaining $$((WA)^\prime (WA))^{-1} \; ((WA)^\prime (Wb)) = (A^\prime W^2 A)^{-1} (A^\prime W^2 b).$$ Evidently your wei
31,005
Classification accuracy increasing while overfitting
I think this reflects the nature of your data whereby you can get increasing accuracy at the expense of the more useful measure of loss. By way of explanation imagine that your data is the stock market and you want to classify up or down days for the purpose of investing. In this scenario not all days are of equal value - a relatively few days will make or break your investing career - and increasing the classification accuracy of the days that have have little or no movement is irrelevant to your desired outcome of making a profit. It would be much better to have pretty poor accuracy in aggregate but actually be highly accurate in predicting the few days when the market makes monster moves.
Classification accuracy increasing while overfitting
I think this reflects the nature of your data whereby you can get increasing accuracy at the expense of the more useful measure of loss. By way of explanation imagine that your data is the stock mark
Classification accuracy increasing while overfitting I think this reflects the nature of your data whereby you can get increasing accuracy at the expense of the more useful measure of loss. By way of explanation imagine that your data is the stock market and you want to classify up or down days for the purpose of investing. In this scenario not all days are of equal value - a relatively few days will make or break your investing career - and increasing the classification accuracy of the days that have have little or no movement is irrelevant to your desired outcome of making a profit. It would be much better to have pretty poor accuracy in aggregate but actually be highly accurate in predicting the few days when the market makes monster moves.
Classification accuracy increasing while overfitting I think this reflects the nature of your data whereby you can get increasing accuracy at the expense of the more useful measure of loss. By way of explanation imagine that your data is the stock mark
31,006
Classification accuracy increasing while overfitting
I think it can be that even though the "spread" between classification and validation accuracy starts increasing, all of them keep increasing for many epochs. You can be sure of being in overfitting regime only when generalization performance really starts to decrease, so that the validation error curve becomes a U plot. So I wouldn't necessarily infer an overfitting problem from the graph above. What is strange is the corresponding loss graph below. There I would see a very clear overfitting starting around epoch 3000, but it seems that increase in validation loss doesn't reflect in decrease in validation classification. That is a bit strange. What loss function are you using? It could be that the class clusters are very compact in your case so there is not really much difference between training and test samples, so overfitting doesn't show easily. But that loss graph is suspicious..
Classification accuracy increasing while overfitting
I think it can be that even though the "spread" between classification and validation accuracy starts increasing, all of them keep increasing for many epochs. You can be sure of being in overfitting
Classification accuracy increasing while overfitting I think it can be that even though the "spread" between classification and validation accuracy starts increasing, all of them keep increasing for many epochs. You can be sure of being in overfitting regime only when generalization performance really starts to decrease, so that the validation error curve becomes a U plot. So I wouldn't necessarily infer an overfitting problem from the graph above. What is strange is the corresponding loss graph below. There I would see a very clear overfitting starting around epoch 3000, but it seems that increase in validation loss doesn't reflect in decrease in validation classification. That is a bit strange. What loss function are you using? It could be that the class clusters are very compact in your case so there is not really much difference between training and test samples, so overfitting doesn't show easily. But that loss graph is suspicious..
Classification accuracy increasing while overfitting I think it can be that even though the "spread" between classification and validation accuracy starts increasing, all of them keep increasing for many epochs. You can be sure of being in overfitting
31,007
Example of computing the expectation of a discrete RV using Riemann-Stieltjes integral?
Since you don't sound like you've done much with the integral, I'm going to discuss this in very elementary (and slightly handwavy) fashion that should convey something of what happens. However, you may want to start with a reminder, by taking a look at the definition of a Stieltjes integral, see, for example Mathworld or Wikipedia. Doing the integrals properly involves considering the limit in the definition, and on the occasions where it's not otherwise obvious, that's really what you need to do. If the distribution is purely discrete then $dF$ is 0 except at the jumps, where it's $p(x)$ -- so for discrete cases the integral is literally the usual sum. Just as an example, consider a Bernoulli(0.4). So for this example, $E(X)=\int_{-\infty}^{\infty}\,x\,dF = \sum_x x\,p(x)$. (That's not just "they're equal in value" but "those things are different ways of expressing the same thing"; I should probably use a more appropriate symbol.) So here $dF$ is $0$ everywhere but at $x=0$ (where $dF$ is $0.6$) and $x=1$ (where it's $0.4$). So that expression is just $0\cdot 0.6 + 1 \cdot 0.4$. While unifying discrete and continuous formulas is neat, it's not really where the greater part of its value comes in to my mind. I see more value in the fact that it applies to cases where you have neither discrete nor continuous random variables -- and there are many instances where that's something you encounter with actual data, so it's not some esoteric theoretical issue. Having notation that can smoothly deal with those "neither discrete nor continuous" cases as well as with the discrete and continuous special cases all at the same time, that's where there's some real benefit. Take a nice simple case that's neither, for example, a distribution of daily rainfall for a given month and location, perhaps modelled as a mixture of a probability of $0.6$ of zero rain, and non-zero rain amounts being lognormal$(\mu,\sigma^2)$ (where $\mu=1.384$,and $\sigma=1.823$) (which might be referred to as a "zero-inflated lognormal" model) Then in this case, an integral such as that for the expectation, $E(X)=\int_{-\infty}^{\infty} x \, dF$ can be dealt with quite easily, because it works like the discrete definition up to and at that jump (only adding $x.p(x)$ at the jump, which turns out to add $0$ to the integral, since all that $0.6$ probability was at $x=0$) and then in this case everywhere above $0$ (because the function is nice enough that Stieltjes is the same as ordinary Riemann) the rest works like a Riemann integral of $x\cdot f(x)$ above $0$, as long as we keep in mind that $dF$ is smaller than it would be for the lognormal (above $0$ you can see $F$ is "squished up" relative to a pure-lognormal cdf), exactly accounting for the probability ($0.4$) of exceeding $0$ here. Of course, this works nicely for more than just $g(x)=x$; I'm just taking simple cases to show a little of what's going on. (whuber pointed to a nice example in comments, where he does an MGF calculation for a non-simple problem, where the distribution ends up as a mixed distribution) Even just with these very nice functions (where you can treat them like Riemann where they're continuous, which is a subset of the cases covered by Stieltjes) there's infinities of cases in such mixtures (rather than just 'discrete' or 'continuous') that can be handled by this one notation. A useful reference that uses this integral widely for showing or discussing a variety of results is Advanced Theory of Statistics (Kendall and Stuart -- or in more recent editions, Stuart and Ord). Don't let the title scare you, it's a very readable book. So if you (for example) play around with integrals while looking at say a Chebyshev inequality, you're not just doing a discrete case and a continuous case at the same time ... you're covering any distribution the Stieltjes integral works for -- so if you wonder about what happens in Chebyshev if you have a distribution like say that rainfall one, lo, it's all taken care of by that same development. And if tomorrow, your friend turns up with a zero-one inflated beta, well, you already covered that as well. And so on ... [If you get into a situation where you can't immediately see what the integral means, go back to the definition and follow it through.] (This nice integral can be replaced by things that are capable of handling even broader situations - for statistical purposes, generally to the Lebesgue or Lesbesgue-Stieltjes integral)
Example of computing the expectation of a discrete RV using Riemann-Stieltjes integral?
Since you don't sound like you've done much with the integral, I'm going to discuss this in very elementary (and slightly handwavy) fashion that should convey something of what happens. However, you m
Example of computing the expectation of a discrete RV using Riemann-Stieltjes integral? Since you don't sound like you've done much with the integral, I'm going to discuss this in very elementary (and slightly handwavy) fashion that should convey something of what happens. However, you may want to start with a reminder, by taking a look at the definition of a Stieltjes integral, see, for example Mathworld or Wikipedia. Doing the integrals properly involves considering the limit in the definition, and on the occasions where it's not otherwise obvious, that's really what you need to do. If the distribution is purely discrete then $dF$ is 0 except at the jumps, where it's $p(x)$ -- so for discrete cases the integral is literally the usual sum. Just as an example, consider a Bernoulli(0.4). So for this example, $E(X)=\int_{-\infty}^{\infty}\,x\,dF = \sum_x x\,p(x)$. (That's not just "they're equal in value" but "those things are different ways of expressing the same thing"; I should probably use a more appropriate symbol.) So here $dF$ is $0$ everywhere but at $x=0$ (where $dF$ is $0.6$) and $x=1$ (where it's $0.4$). So that expression is just $0\cdot 0.6 + 1 \cdot 0.4$. While unifying discrete and continuous formulas is neat, it's not really where the greater part of its value comes in to my mind. I see more value in the fact that it applies to cases where you have neither discrete nor continuous random variables -- and there are many instances where that's something you encounter with actual data, so it's not some esoteric theoretical issue. Having notation that can smoothly deal with those "neither discrete nor continuous" cases as well as with the discrete and continuous special cases all at the same time, that's where there's some real benefit. Take a nice simple case that's neither, for example, a distribution of daily rainfall for a given month and location, perhaps modelled as a mixture of a probability of $0.6$ of zero rain, and non-zero rain amounts being lognormal$(\mu,\sigma^2)$ (where $\mu=1.384$,and $\sigma=1.823$) (which might be referred to as a "zero-inflated lognormal" model) Then in this case, an integral such as that for the expectation, $E(X)=\int_{-\infty}^{\infty} x \, dF$ can be dealt with quite easily, because it works like the discrete definition up to and at that jump (only adding $x.p(x)$ at the jump, which turns out to add $0$ to the integral, since all that $0.6$ probability was at $x=0$) and then in this case everywhere above $0$ (because the function is nice enough that Stieltjes is the same as ordinary Riemann) the rest works like a Riemann integral of $x\cdot f(x)$ above $0$, as long as we keep in mind that $dF$ is smaller than it would be for the lognormal (above $0$ you can see $F$ is "squished up" relative to a pure-lognormal cdf), exactly accounting for the probability ($0.4$) of exceeding $0$ here. Of course, this works nicely for more than just $g(x)=x$; I'm just taking simple cases to show a little of what's going on. (whuber pointed to a nice example in comments, where he does an MGF calculation for a non-simple problem, where the distribution ends up as a mixed distribution) Even just with these very nice functions (where you can treat them like Riemann where they're continuous, which is a subset of the cases covered by Stieltjes) there's infinities of cases in such mixtures (rather than just 'discrete' or 'continuous') that can be handled by this one notation. A useful reference that uses this integral widely for showing or discussing a variety of results is Advanced Theory of Statistics (Kendall and Stuart -- or in more recent editions, Stuart and Ord). Don't let the title scare you, it's a very readable book. So if you (for example) play around with integrals while looking at say a Chebyshev inequality, you're not just doing a discrete case and a continuous case at the same time ... you're covering any distribution the Stieltjes integral works for -- so if you wonder about what happens in Chebyshev if you have a distribution like say that rainfall one, lo, it's all taken care of by that same development. And if tomorrow, your friend turns up with a zero-one inflated beta, well, you already covered that as well. And so on ... [If you get into a situation where you can't immediately see what the integral means, go back to the definition and follow it through.] (This nice integral can be replaced by things that are capable of handling even broader situations - for statistical purposes, generally to the Lebesgue or Lesbesgue-Stieltjes integral)
Example of computing the expectation of a discrete RV using Riemann-Stieltjes integral? Since you don't sound like you've done much with the integral, I'm going to discuss this in very elementary (and slightly handwavy) fashion that should convey something of what happens. However, you m
31,008
How to determine the critical values of ACF?
Based on this source, it looks like under the null the autocorrelation is asymptoticaly standard normal. The 5% critical values of the autocorrelation at any given lag $d$ ($d \neq 0$) are $$\pm \frac{1.96}{\sqrt{T-d}}$$ where $T$ is the sample size. In your case, $T=1000$, so the critical values for lag 1 are $\pm \frac{1.96}{\sqrt{1000-1}} \approx 0.06201$, for lag 2 are $\pm \frac{1.96}{\sqrt{1000-2}} \approx 0.06204$, and so on. Mind also a note from another source: Additionally, in small sample conditions ... this test may be overly conservative such that the null hypothesis is rejected (residuals indicated as non-white) less often than indicated by the chosen significance level (Lutkepohl, 2006). However, it is not likely to be relevant for a sample as large as 1000. Related question: "How is the confidence interval calculated for the ACF function?".
How to determine the critical values of ACF?
Based on this source, it looks like under the null the autocorrelation is asymptoticaly standard normal. The 5% critical values of the autocorrelation at any given lag $d$ ($d \neq 0$) are $$\pm \frac
How to determine the critical values of ACF? Based on this source, it looks like under the null the autocorrelation is asymptoticaly standard normal. The 5% critical values of the autocorrelation at any given lag $d$ ($d \neq 0$) are $$\pm \frac{1.96}{\sqrt{T-d}}$$ where $T$ is the sample size. In your case, $T=1000$, so the critical values for lag 1 are $\pm \frac{1.96}{\sqrt{1000-1}} \approx 0.06201$, for lag 2 are $\pm \frac{1.96}{\sqrt{1000-2}} \approx 0.06204$, and so on. Mind also a note from another source: Additionally, in small sample conditions ... this test may be overly conservative such that the null hypothesis is rejected (residuals indicated as non-white) less often than indicated by the chosen significance level (Lutkepohl, 2006). However, it is not likely to be relevant for a sample as large as 1000. Related question: "How is the confidence interval calculated for the ACF function?".
How to determine the critical values of ACF? Based on this source, it looks like under the null the autocorrelation is asymptoticaly standard normal. The 5% critical values of the autocorrelation at any given lag $d$ ($d \neq 0$) are $$\pm \frac
31,009
How to determine the critical values of ACF?
Since the standard deviation of the acf is approximately = 1/SQRT(NOB) it is so approximate that it is practically useless for large sample sizes . If your "reason" for obtaining critical values is to automatically identify the form of the ARIMA model , you can stop right now ! . Identification of a reasonable starting model for the ARIMA structure is better conducted via approaches like the Inverse Autocorrelation Function http://www.jstor.org/stable/2982488?seq=1#page_scan_tab_contents which is the basis of how AUTOBOX (a piece of software that I have helped develop) effectively solves the riddle.
How to determine the critical values of ACF?
Since the standard deviation of the acf is approximately = 1/SQRT(NOB) it is so approximate that it is practically useless for large sample sizes . If your "reason" for obtaining critical values is to
How to determine the critical values of ACF? Since the standard deviation of the acf is approximately = 1/SQRT(NOB) it is so approximate that it is practically useless for large sample sizes . If your "reason" for obtaining critical values is to automatically identify the form of the ARIMA model , you can stop right now ! . Identification of a reasonable starting model for the ARIMA structure is better conducted via approaches like the Inverse Autocorrelation Function http://www.jstor.org/stable/2982488?seq=1#page_scan_tab_contents which is the basis of how AUTOBOX (a piece of software that I have helped develop) effectively solves the riddle.
How to determine the critical values of ACF? Since the standard deviation of the acf is approximately = 1/SQRT(NOB) it is so approximate that it is practically useless for large sample sizes . If your "reason" for obtaining critical values is to
31,010
Correcting for autocorrelation in simple linear regressions in R
Autocorrelated errors signal model misspecification. Ideally, model errors should be $i.i.d.$ and thus should have no patterns in them. If they do, there is some information left unextracted; some more modelling can be done to extract the pattern. There are two ways of dealing with the problem of autocorrelated errors. Leave the model specification as is but expand confidence intervals around the regression coefficients to account for the violation of the model assumption of non-autocorrelated errors. This can be motivated by the wish to retain the original model that may be directly derived from theory and/or have a nice interpretation. This can be done by using heteroskedasticity and autocorrelation (HAC) robust standard errors, e.g. by Newey and West (1987). HAC standard errors (as an alternative to the regular standard errors) should be available in any major statistical software package; they seem to be quite popular among practitioners, perhaps because they provide an easy solution. Pros: easy to use; can retain the original model. Cons: wider confidence intervals $\rightarrow$ lower precision, less power (harder to reject null hypotheses); model is misspecified; less accurate forecasting (due to neglecting the autocorrelation in model errors). Change the model specification to obtain non-autocorrelated errors. For example, run a regression with ARMA errors (easy to implement by arima or auto.arima functions in R including the regressors via the parameter xreg) or -- as DJohnson suggested -- include lags of dependent variable as regressors. Pros: narrower confidence intervals $\rightarrow$ higher precision, more power (easier to reject null hypotheses); model is correctly specified (unless there are other faults, which may quite often be true); more accurate forecasting. Cons: requires more work; cannot retain the original model. I side with Francis Diebold's forceful argumentation (in his blog post "The HAC Emperor has no Clothes") that 2. is the way to go. References: Newey, Whitney K; West, Kenneth D (1987). "A Simple, Positive Semi-definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix". Econometrica 55 (3): 703–708. doi:10.2307/1913610
Correcting for autocorrelation in simple linear regressions in R
Autocorrelated errors signal model misspecification. Ideally, model errors should be $i.i.d.$ and thus should have no patterns in them. If they do, there is some information left unextracted; some mor
Correcting for autocorrelation in simple linear regressions in R Autocorrelated errors signal model misspecification. Ideally, model errors should be $i.i.d.$ and thus should have no patterns in them. If they do, there is some information left unextracted; some more modelling can be done to extract the pattern. There are two ways of dealing with the problem of autocorrelated errors. Leave the model specification as is but expand confidence intervals around the regression coefficients to account for the violation of the model assumption of non-autocorrelated errors. This can be motivated by the wish to retain the original model that may be directly derived from theory and/or have a nice interpretation. This can be done by using heteroskedasticity and autocorrelation (HAC) robust standard errors, e.g. by Newey and West (1987). HAC standard errors (as an alternative to the regular standard errors) should be available in any major statistical software package; they seem to be quite popular among practitioners, perhaps because they provide an easy solution. Pros: easy to use; can retain the original model. Cons: wider confidence intervals $\rightarrow$ lower precision, less power (harder to reject null hypotheses); model is misspecified; less accurate forecasting (due to neglecting the autocorrelation in model errors). Change the model specification to obtain non-autocorrelated errors. For example, run a regression with ARMA errors (easy to implement by arima or auto.arima functions in R including the regressors via the parameter xreg) or -- as DJohnson suggested -- include lags of dependent variable as regressors. Pros: narrower confidence intervals $\rightarrow$ higher precision, more power (easier to reject null hypotheses); model is correctly specified (unless there are other faults, which may quite often be true); more accurate forecasting. Cons: requires more work; cannot retain the original model. I side with Francis Diebold's forceful argumentation (in his blog post "The HAC Emperor has no Clothes") that 2. is the way to go. References: Newey, Whitney K; West, Kenneth D (1987). "A Simple, Positive Semi-definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix". Econometrica 55 (3): 703–708. doi:10.2307/1913610
Correcting for autocorrelation in simple linear regressions in R Autocorrelated errors signal model misspecification. Ideally, model errors should be $i.i.d.$ and thus should have no patterns in them. If they do, there is some information left unextracted; some mor
31,011
Correcting for autocorrelation in simple linear regressions in R
The link to this presentation develops several intuitive approaches to correcting for autocorrelation when tests show that it exists. Most of these methods are for AR(1) or first-order processes and include: Adding/deleting variables, e.g., including 1-period lags of the response Increasing the temporal period, e.g., from daily to weekly, and so on Adjusting the errors by first differencing and multiplying by the autocorrelation coefficient, rho (apologies for my lack of Latex skills but the formula is on page 17 of the link): http://personal.rhul.ac.uk/uhte/006/ec2203/Lecture%2018_Autocorrelation&DynamicModels.pdf If none of these "simple" solutions work, then to your point, the methods become increasingly complex and in at least some cases, the "cure" can be worse than the "disease" it is attempting to fix
Correcting for autocorrelation in simple linear regressions in R
The link to this presentation develops several intuitive approaches to correcting for autocorrelation when tests show that it exists. Most of these methods are for AR(1) or first-order processes and i
Correcting for autocorrelation in simple linear regressions in R The link to this presentation develops several intuitive approaches to correcting for autocorrelation when tests show that it exists. Most of these methods are for AR(1) or first-order processes and include: Adding/deleting variables, e.g., including 1-period lags of the response Increasing the temporal period, e.g., from daily to weekly, and so on Adjusting the errors by first differencing and multiplying by the autocorrelation coefficient, rho (apologies for my lack of Latex skills but the formula is on page 17 of the link): http://personal.rhul.ac.uk/uhte/006/ec2203/Lecture%2018_Autocorrelation&DynamicModels.pdf If none of these "simple" solutions work, then to your point, the methods become increasingly complex and in at least some cases, the "cure" can be worse than the "disease" it is attempting to fix
Correcting for autocorrelation in simple linear regressions in R The link to this presentation develops several intuitive approaches to correcting for autocorrelation when tests show that it exists. Most of these methods are for AR(1) or first-order processes and i
31,012
Correlation between continuous data and count data
I'd say there are at least 3 decent options that would make sense for you: Polyserial Correlation - This would be the most exotic of the 3 options and involves an approximation of a latent, continuous variable used to build the discrete variable ($N_i$ in your case) as well as a maximum likelihood estimation procedure for the most likely $\rho$ that could result between that latent continuous variable and the real one, $X_i$, when treated as bivariate normal samples (example implementation in R: polycor). There are several references to this idea out there, but this is the original publication on the subject from 1974: Estimation of the Correlation Between a Continuous and a Discrete Variable. Nonparametric Correlation - Spearman's Rank Correlation Coefficient is likely a good option in this case. The calculation for Spearman's Rho works based on the ranks of the values of each variable rather than the values themselves which makes it more widely applicable in the presence of nonlinear relationships or mixed datatypes. Modeling - I know you mentioned in the comments that you're not trying to do any kind of modeling, but I still think a parameter estimate or two from a well-fitting, functional relationship between the two variables is a whole lot more informative than any correlation coefficient you'll find (unless the discrete variable was really created from one half of a bivariate normal distribution's values -- which I'd doubt). To answer your question more directly, calculating $\rho$ as usual (assuming you mean the product-moment correlation coefficient by that) would likely have the properties you'd expect, or at least it would get bigger as the linear dependence between the variables grows. However, a statistical test of significance of the correlation would not be valid as one of the assumptions required for such a test is bivariate normality and that's clearly not true if one of the variables is discrete. Significance testing with a nonparametric correlation coefficient (e.g. Spearman's) would be possible though and it would be easy to find well-documented implementations of that in any language.
Correlation between continuous data and count data
I'd say there are at least 3 decent options that would make sense for you: Polyserial Correlation - This would be the most exotic of the 3 options and involves an approximation of a latent, continuo
Correlation between continuous data and count data I'd say there are at least 3 decent options that would make sense for you: Polyserial Correlation - This would be the most exotic of the 3 options and involves an approximation of a latent, continuous variable used to build the discrete variable ($N_i$ in your case) as well as a maximum likelihood estimation procedure for the most likely $\rho$ that could result between that latent continuous variable and the real one, $X_i$, when treated as bivariate normal samples (example implementation in R: polycor). There are several references to this idea out there, but this is the original publication on the subject from 1974: Estimation of the Correlation Between a Continuous and a Discrete Variable. Nonparametric Correlation - Spearman's Rank Correlation Coefficient is likely a good option in this case. The calculation for Spearman's Rho works based on the ranks of the values of each variable rather than the values themselves which makes it more widely applicable in the presence of nonlinear relationships or mixed datatypes. Modeling - I know you mentioned in the comments that you're not trying to do any kind of modeling, but I still think a parameter estimate or two from a well-fitting, functional relationship between the two variables is a whole lot more informative than any correlation coefficient you'll find (unless the discrete variable was really created from one half of a bivariate normal distribution's values -- which I'd doubt). To answer your question more directly, calculating $\rho$ as usual (assuming you mean the product-moment correlation coefficient by that) would likely have the properties you'd expect, or at least it would get bigger as the linear dependence between the variables grows. However, a statistical test of significance of the correlation would not be valid as one of the assumptions required for such a test is bivariate normality and that's clearly not true if one of the variables is discrete. Significance testing with a nonparametric correlation coefficient (e.g. Spearman's) would be possible though and it would be easy to find well-documented implementations of that in any language.
Correlation between continuous data and count data I'd say there are at least 3 decent options that would make sense for you: Polyserial Correlation - This would be the most exotic of the 3 options and involves an approximation of a latent, continuo
31,013
Why do Decision Trees/rpart prefer to choose continuous over categorical variables?
Yes, classical decision tree algorithms - e.g., CART (as implemented in rpart) or C4.5 - are biased towards variables with many possible splits. The reason is that they use exhaustive search over all possible splits in all possible variables without accounting for finding larger improvements by "chance" when searching over more splits. This is addressed by various decision tree algorithms based on statistical inference, pioneered by Loh and co-workers: Loh WY, Shih YS (1997). "Split Selection Methods for Classification Trees." Statistica Sinica, 7, 815-840. Loh WY (2002). "Regression Trees with Unbiased Variable Selection and Interaction Detection." Statistica Sinica, 12, 361-386. Hothorn T, Hornik K, Zeileis A (2006). "Unbiased Recursive Partitioning: A Conditional Inference Framework." Journal of Computational and Graphical Statistics, 15(3), 651-674. In R the partykit package (successor to the party package) implements several unbiased decision tree algorithms. Specifically, ctree() (Hothorn et al. 2006) should be easy to try for you as an alternative for rpart. Having said that: It is, of course, possible that even when using an unbiased decision tree algorithm none of the categorical variables appear in the tree because they are not relevant (or not relevant after adjusting for the continuous ones as suggested by @gung).
Why do Decision Trees/rpart prefer to choose continuous over categorical variables?
Yes, classical decision tree algorithms - e.g., CART (as implemented in rpart) or C4.5 - are biased towards variables with many possible splits. The reason is that they use exhaustive search over all
Why do Decision Trees/rpart prefer to choose continuous over categorical variables? Yes, classical decision tree algorithms - e.g., CART (as implemented in rpart) or C4.5 - are biased towards variables with many possible splits. The reason is that they use exhaustive search over all possible splits in all possible variables without accounting for finding larger improvements by "chance" when searching over more splits. This is addressed by various decision tree algorithms based on statistical inference, pioneered by Loh and co-workers: Loh WY, Shih YS (1997). "Split Selection Methods for Classification Trees." Statistica Sinica, 7, 815-840. Loh WY (2002). "Regression Trees with Unbiased Variable Selection and Interaction Detection." Statistica Sinica, 12, 361-386. Hothorn T, Hornik K, Zeileis A (2006). "Unbiased Recursive Partitioning: A Conditional Inference Framework." Journal of Computational and Graphical Statistics, 15(3), 651-674. In R the partykit package (successor to the party package) implements several unbiased decision tree algorithms. Specifically, ctree() (Hothorn et al. 2006) should be easy to try for you as an alternative for rpart. Having said that: It is, of course, possible that even when using an unbiased decision tree algorithm none of the categorical variables appear in the tree because they are not relevant (or not relevant after adjusting for the continuous ones as suggested by @gung).
Why do Decision Trees/rpart prefer to choose continuous over categorical variables? Yes, classical decision tree algorithms - e.g., CART (as implemented in rpart) or C4.5 - are biased towards variables with many possible splits. The reason is that they use exhaustive search over all
31,014
Stochastic Gradient Descent vs Online Gradient Descent
Apparently, different authors have different ideas about stochastic gradient descent. Bishop says: On-line gradient descent, also known as sequential gradient descent or stochastic gradient descent, makes an update to the weight vector based on one data point at a time… Whereas, [2] describes that as subgradient descent, and gives a more general definition for stochastic gradient descent: In stochastic gradient descent we do not require the update direction to be based exactly on the gradient. Instead, we allow the direction to be a random vector and only require that its expected value at each iteration will equal the gradient direction. Or, more generally, we require that the expected value of the random vector will be a subgradient of the function at the current vector. Shalev-Shwartz, S., & Ben-David, S. (2014). Understanding Machine Learning: From Theory to Algorithms. Cambridge University Press.
Stochastic Gradient Descent vs Online Gradient Descent
Apparently, different authors have different ideas about stochastic gradient descent. Bishop says: On-line gradient descent, also known as sequential gradient descent or stochastic gradient descen
Stochastic Gradient Descent vs Online Gradient Descent Apparently, different authors have different ideas about stochastic gradient descent. Bishop says: On-line gradient descent, also known as sequential gradient descent or stochastic gradient descent, makes an update to the weight vector based on one data point at a time… Whereas, [2] describes that as subgradient descent, and gives a more general definition for stochastic gradient descent: In stochastic gradient descent we do not require the update direction to be based exactly on the gradient. Instead, we allow the direction to be a random vector and only require that its expected value at each iteration will equal the gradient direction. Or, more generally, we require that the expected value of the random vector will be a subgradient of the function at the current vector. Shalev-Shwartz, S., & Ben-David, S. (2014). Understanding Machine Learning: From Theory to Algorithms. Cambridge University Press.
Stochastic Gradient Descent vs Online Gradient Descent Apparently, different authors have different ideas about stochastic gradient descent. Bishop says: On-line gradient descent, also known as sequential gradient descent or stochastic gradient descen
31,015
Stochastic Gradient Descent vs Online Gradient Descent
As an example, let's place ourselves in the context of Linear/Logistic Regression. Let's assume you have $N$ samples in your training set. You want to use loop once through those samples to learn the coefficients of your model. Stochastic Gradient Descent: you would randomly select one of those training samples at each iteration to update your coefficients. Online Gradient Descent: you would use the "most recent" sample at each iteration. There is no stochasticity as you deterministically select your sample. In industry, where datasets are large, we train "live" by using the most recent samples as soon as they arrive to update the coefficients.
Stochastic Gradient Descent vs Online Gradient Descent
As an example, let's place ourselves in the context of Linear/Logistic Regression. Let's assume you have $N$ samples in your training set. You want to use loop once through those samples to learn the
Stochastic Gradient Descent vs Online Gradient Descent As an example, let's place ourselves in the context of Linear/Logistic Regression. Let's assume you have $N$ samples in your training set. You want to use loop once through those samples to learn the coefficients of your model. Stochastic Gradient Descent: you would randomly select one of those training samples at each iteration to update your coefficients. Online Gradient Descent: you would use the "most recent" sample at each iteration. There is no stochasticity as you deterministically select your sample. In industry, where datasets are large, we train "live" by using the most recent samples as soon as they arrive to update the coefficients.
Stochastic Gradient Descent vs Online Gradient Descent As an example, let's place ourselves in the context of Linear/Logistic Regression. Let's assume you have $N$ samples in your training set. You want to use loop once through those samples to learn the
31,016
Stochastic Gradient Descent vs Online Gradient Descent
Online Gradient Descent is essentially the same as stochastic gradient descent; the name online emphasizes we are not solving a batch problem, but rather predicting on a sequence of examples that need not be IID.
Stochastic Gradient Descent vs Online Gradient Descent
Online Gradient Descent is essentially the same as stochastic gradient descent; the name online emphasizes we are not solving a batch problem, but rather predicting on a sequence of examples that need
Stochastic Gradient Descent vs Online Gradient Descent Online Gradient Descent is essentially the same as stochastic gradient descent; the name online emphasizes we are not solving a batch problem, but rather predicting on a sequence of examples that need not be IID.
Stochastic Gradient Descent vs Online Gradient Descent Online Gradient Descent is essentially the same as stochastic gradient descent; the name online emphasizes we are not solving a batch problem, but rather predicting on a sequence of examples that need
31,017
Assigning Weights to An Averaged Forecast
The answers to your questions in order How Many Models Usually as many as you want, but this can be limited by the amount of data you have. Also depends on the method you are using to derive the weights (which I explain more below) How to Assign Weights There are many, here are the five most popular off the top of my head, though non of them use Mean absolute error. Equal Weights for all models pros: Simple, easy to implement Often outperforms more complex techniques You can, in theory, add as many models as you want cons: May be too oversimplified No inherent method for ranking models References Aiolfi, M. and A. Timmermann (2006), “Persistence in Forecasting Performance and Conditional Combination Strategies”, Journal of Econometrics, 35 (1-2), 31-53. Manescu, Cristiana, and Ine Van Robays. "Forecasting the Brent oil price: addressing time-variation in forecast performance." (2014). Inverse Mean Square Forecast Error (MSFE) ratio: For $M$ models the combined, $h$-step ahead forecast is $$ \hat y_{t+h}=\sum_{m=1}^{M} w_{m,h,t}\hat y_{t+h,m},\;\;\;w_{m,h,t}=\frac{(1/msfe_{m,h,t})^k}{\sum_{j=1}^M (1/msfe_{j,h,t})^k} $$ where $\hat y_{t+h,m}$ is the point forecast forecast for $h$ steps ahead at time $t$ from model $m$. In most applications $k=1$. pros: Firm theoretical backing It's been around for a while and is well accepted in the literature You can, in theory, add as many models as you want cons: Based solely on point estimate forecasts, does not consider entire forecast distribution (i.e. most applied models will give us an entire parametric distribution for the forecast, the normal distribution is common, $y_{t+h,m} \sim N(\hat y_{t+h,m},\sigma_{t+h,m})$. many argue that not utilizing this additional parametric information by only considering $\hat y_{t+h,m}$ results in sub-optimal forecasts) References Bates, John M., and Clive WJ Granger. "The combination of forecasts." Or (1969): 451-468. Massimiliano Marcellino, . "Forecast pooling for short time series of macroeconomic variables," Working Papers 212, IGIER (Innocenzo Gasparini Institute for Economic Research), Bocconi University (2002). Bayesian Forecast Combination: For point estimate forecast combination the formula is $$ \hat y_{t+h}=\sum_{m=1}^M w(m|y_1,...,y_t) \hat y_{t+h,m} $$ and the combined forecast distribution is $$ f(y_{t+h}|y_1,...,y_t)=\sum_{m=1}^M w(m|y_1,...,y_t) f_m(y_{t+h}|y_1,...,y_t)$$ where $f_m$ is the $m$th model forecast distribution (a pdf). The weights $w(m|y_1,...,y_t)$ are such that $\sum_{m=1}^{M} w(m|y_1,...,y_t)=1$ and $ w(m|y_1,...,y_t)>0$ for all $m$. The weights can be calculated as either the traditional posterior probability of each $m$ model via Bayesian Model Averaging (in-sample technique similar to BIC, but scaled) or from scaling the predictive likelihood (out-of-sample predictive density) of each model. I forgo showing exactly how to calculate the weights for brevity. If you are curious see references pros: Considers the entire forecast distribution when calculating weights, not just the point forecast You can, in theory, add as many models as you want cons: Requires knowledge of Bayesian inference and estimation which can be quite involved Assumes that at least one of the $m$ models is the true data generating process, which is a strong assumption. Requires the researcher to specify priors for the parameters in each forecasting model in addition to a discrete prior over all $m$ models References Hoeting, Jennifer A., et al. "Bayesian model averaging." In Proceedings of the AAAI Workshop on Integrating Multiple Learned Models. 1998. Eklund, Jana, and Sune Karlsson. "Forecast combination and model averaging using predictive measures." Econometric Reviews 26.2-4 (2007): 329-363. Andersson, Michael K., and Sune Karlsson. "Bayesian forecast combination for VAR models." Bayesian Econometrics (2008): 501-524. Optimal Prediction Pools: Same Idea as Bayesian forecast except that the weights are found by maximizing the following "score function" (WLOG assume h=1) $$ \max_{\mathbf{w}}\sum_{i=1}^{t}\ln\bigg[\sum_{m=1}^{M} w_m f_m(y_i;y_1,...,y_{i-1})\bigg] \quad{(1)}$$ $$s.t.\;\;\sum_{m=1}^{M} w_m=1\;and\; w_m \geq 0\; \forall m $$ where $f_m$ is the predictive density/likelihood of model $m$ that can be calculated with either Bayesian or frequentest methodology (see references for more information on this). pros: Considers the entire forecast distribution when calculating weights, not just the point forecast Can be implemented using either frequentest or Bayesian techniques and is usually simpler to estimate than traditional Bayesian forecasting combination Unlike traditional Bayesian forecast combination it does not need to assume one of the $m$ models is the true data generating process cons: because equation (1) requires numeric optimization, the amount of models you can include is limited by the amount of data you have available. Further, if some models produce highly correlated forecasts, equation (1) may be very challenging to optimize References Geweke, John, and Gianni Amisano. "Optimal prediction pools." Journal of Econometrics 164.1 (2011): 130-141. Durham, Garland, and John Geweke. "Improving asset price prediction when all models are false." Journal of Financial Econometrics 12.2 (2014): 278-306. Various other point estimate based techniques: (1) an ordinary-least squared estimate of the weights obtained by regressing the actual realized values on the point estimate forecasts ($y_{t+h}=\beta_0 +w_1\hat y_{t+h,1}+...+w_M\hat y_{t+h,M}+u_{t+h}$),(2) trimming approaches that drop the worst performing models form an equally weighted combination, (3) set the weights equal to the percentage of times a forecast has the minimum MSFE, etc. pros and cons: vary depending on technique References Timmermann, A. (2006), “Forecast Combinations”, Handbook of Economic Forecasting, 1, 135–196. Are Any of the Forecasting Models Redundant/Excludable The Holt-Winters models are likly to be similar so maybe throw a couple of those out. Averaging forecasts is like diversifying a financial portfolio, you want your models to be diverse. With some of the above averaging techniques it doesn't hurt to include redundant models, with others it does. You can also find a friendly introduction here, with couple of more good ways to average forecasts (Constrained Least Squares for example) along with an R implementation.
Assigning Weights to An Averaged Forecast
The answers to your questions in order How Many Models Usually as many as you want, but this can be limited by the amount of data you have. Also depends on the method you are using to derive the weig
Assigning Weights to An Averaged Forecast The answers to your questions in order How Many Models Usually as many as you want, but this can be limited by the amount of data you have. Also depends on the method you are using to derive the weights (which I explain more below) How to Assign Weights There are many, here are the five most popular off the top of my head, though non of them use Mean absolute error. Equal Weights for all models pros: Simple, easy to implement Often outperforms more complex techniques You can, in theory, add as many models as you want cons: May be too oversimplified No inherent method for ranking models References Aiolfi, M. and A. Timmermann (2006), “Persistence in Forecasting Performance and Conditional Combination Strategies”, Journal of Econometrics, 35 (1-2), 31-53. Manescu, Cristiana, and Ine Van Robays. "Forecasting the Brent oil price: addressing time-variation in forecast performance." (2014). Inverse Mean Square Forecast Error (MSFE) ratio: For $M$ models the combined, $h$-step ahead forecast is $$ \hat y_{t+h}=\sum_{m=1}^{M} w_{m,h,t}\hat y_{t+h,m},\;\;\;w_{m,h,t}=\frac{(1/msfe_{m,h,t})^k}{\sum_{j=1}^M (1/msfe_{j,h,t})^k} $$ where $\hat y_{t+h,m}$ is the point forecast forecast for $h$ steps ahead at time $t$ from model $m$. In most applications $k=1$. pros: Firm theoretical backing It's been around for a while and is well accepted in the literature You can, in theory, add as many models as you want cons: Based solely on point estimate forecasts, does not consider entire forecast distribution (i.e. most applied models will give us an entire parametric distribution for the forecast, the normal distribution is common, $y_{t+h,m} \sim N(\hat y_{t+h,m},\sigma_{t+h,m})$. many argue that not utilizing this additional parametric information by only considering $\hat y_{t+h,m}$ results in sub-optimal forecasts) References Bates, John M., and Clive WJ Granger. "The combination of forecasts." Or (1969): 451-468. Massimiliano Marcellino, . "Forecast pooling for short time series of macroeconomic variables," Working Papers 212, IGIER (Innocenzo Gasparini Institute for Economic Research), Bocconi University (2002). Bayesian Forecast Combination: For point estimate forecast combination the formula is $$ \hat y_{t+h}=\sum_{m=1}^M w(m|y_1,...,y_t) \hat y_{t+h,m} $$ and the combined forecast distribution is $$ f(y_{t+h}|y_1,...,y_t)=\sum_{m=1}^M w(m|y_1,...,y_t) f_m(y_{t+h}|y_1,...,y_t)$$ where $f_m$ is the $m$th model forecast distribution (a pdf). The weights $w(m|y_1,...,y_t)$ are such that $\sum_{m=1}^{M} w(m|y_1,...,y_t)=1$ and $ w(m|y_1,...,y_t)>0$ for all $m$. The weights can be calculated as either the traditional posterior probability of each $m$ model via Bayesian Model Averaging (in-sample technique similar to BIC, but scaled) or from scaling the predictive likelihood (out-of-sample predictive density) of each model. I forgo showing exactly how to calculate the weights for brevity. If you are curious see references pros: Considers the entire forecast distribution when calculating weights, not just the point forecast You can, in theory, add as many models as you want cons: Requires knowledge of Bayesian inference and estimation which can be quite involved Assumes that at least one of the $m$ models is the true data generating process, which is a strong assumption. Requires the researcher to specify priors for the parameters in each forecasting model in addition to a discrete prior over all $m$ models References Hoeting, Jennifer A., et al. "Bayesian model averaging." In Proceedings of the AAAI Workshop on Integrating Multiple Learned Models. 1998. Eklund, Jana, and Sune Karlsson. "Forecast combination and model averaging using predictive measures." Econometric Reviews 26.2-4 (2007): 329-363. Andersson, Michael K., and Sune Karlsson. "Bayesian forecast combination for VAR models." Bayesian Econometrics (2008): 501-524. Optimal Prediction Pools: Same Idea as Bayesian forecast except that the weights are found by maximizing the following "score function" (WLOG assume h=1) $$ \max_{\mathbf{w}}\sum_{i=1}^{t}\ln\bigg[\sum_{m=1}^{M} w_m f_m(y_i;y_1,...,y_{i-1})\bigg] \quad{(1)}$$ $$s.t.\;\;\sum_{m=1}^{M} w_m=1\;and\; w_m \geq 0\; \forall m $$ where $f_m$ is the predictive density/likelihood of model $m$ that can be calculated with either Bayesian or frequentest methodology (see references for more information on this). pros: Considers the entire forecast distribution when calculating weights, not just the point forecast Can be implemented using either frequentest or Bayesian techniques and is usually simpler to estimate than traditional Bayesian forecasting combination Unlike traditional Bayesian forecast combination it does not need to assume one of the $m$ models is the true data generating process cons: because equation (1) requires numeric optimization, the amount of models you can include is limited by the amount of data you have available. Further, if some models produce highly correlated forecasts, equation (1) may be very challenging to optimize References Geweke, John, and Gianni Amisano. "Optimal prediction pools." Journal of Econometrics 164.1 (2011): 130-141. Durham, Garland, and John Geweke. "Improving asset price prediction when all models are false." Journal of Financial Econometrics 12.2 (2014): 278-306. Various other point estimate based techniques: (1) an ordinary-least squared estimate of the weights obtained by regressing the actual realized values on the point estimate forecasts ($y_{t+h}=\beta_0 +w_1\hat y_{t+h,1}+...+w_M\hat y_{t+h,M}+u_{t+h}$),(2) trimming approaches that drop the worst performing models form an equally weighted combination, (3) set the weights equal to the percentage of times a forecast has the minimum MSFE, etc. pros and cons: vary depending on technique References Timmermann, A. (2006), “Forecast Combinations”, Handbook of Economic Forecasting, 1, 135–196. Are Any of the Forecasting Models Redundant/Excludable The Holt-Winters models are likly to be similar so maybe throw a couple of those out. Averaging forecasts is like diversifying a financial portfolio, you want your models to be diverse. With some of the above averaging techniques it doesn't hurt to include redundant models, with others it does. You can also find a friendly introduction here, with couple of more good ways to average forecasts (Constrained Least Squares for example) along with an R implementation.
Assigning Weights to An Averaged Forecast The answers to your questions in order How Many Models Usually as many as you want, but this can be limited by the amount of data you have. Also depends on the method you are using to derive the weig
31,018
Assigning Weights to An Averaged Forecast
Souds like an article about creating ensembles. The number of models is a bit of your own judgement. If it adds some predictive value, you can add any number of models. But computation time is a big factor. But if you have 11 models I would first see if I can calculate the correlation between the models. Models that have a high correlation do not add much. You are better off adding a worse, but low-correlated, model. Here is also depends on your judgement. All the Holtwinters models will have a high correlation with each other. You might want to ditch a few of these. A good article on ensembles is written by MLWave
Assigning Weights to An Averaged Forecast
Souds like an article about creating ensembles. The number of models is a bit of your own judgement. If it adds some predictive value, you can add any number of models. But computation time is a big
Assigning Weights to An Averaged Forecast Souds like an article about creating ensembles. The number of models is a bit of your own judgement. If it adds some predictive value, you can add any number of models. But computation time is a big factor. But if you have 11 models I would first see if I can calculate the correlation between the models. Models that have a high correlation do not add much. You are better off adding a worse, but low-correlated, model. Here is also depends on your judgement. All the Holtwinters models will have a high correlation with each other. You might want to ditch a few of these. A good article on ensembles is written by MLWave
Assigning Weights to An Averaged Forecast Souds like an article about creating ensembles. The number of models is a bit of your own judgement. If it adds some predictive value, you can add any number of models. But computation time is a big
31,019
A strange step on a proof about the distribution of quadratic forms
(9.9.6) states that$${\mathbf {AB}}=\{\mathbf{\Gamma_{11}'\Lambda_{11}}\}\mathbf{\Gamma_{11}\Gamma_{21}'}\{\mathbf{\Lambda_{22}\Gamma_{21}}\}={\mathbf U}\mathbf{\Gamma_{11}\Gamma_{21}'}{\mathbf V}$$Hence multiplying left and right by $\mathbf{U}'$ and $\mathbf{V}'$, we get $$\mathbf{U}'{\mathbf {AB}}\mathbf{V}'=\mathbf{U}'{\mathbf U}\mathbf{\Gamma_{11}\Gamma_{21}'}{\mathbf V}\mathbf{V}'$$and $$(\mathbf{U}'{\mathbf U})^{-1}\mathbf{U}'{\mathbf {AB}}\mathbf{V}'({\mathbf V}\mathbf{V}')^{-1}=\mathbf{\Gamma_{11}\Gamma_{21}'}$$I see no reason for the inner $\mathbf{U}'$ and $\mathbf{V}'$ to vanish so I would bet on a typo. However the conclusion remains the same, namely that $$\mathbf{\Gamma_{11}\Gamma_{21}'}=0$$ if and only if$$\mathbf{{AB}}=0$$
A strange step on a proof about the distribution of quadratic forms
(9.9.6) states that$${\mathbf {AB}}=\{\mathbf{\Gamma_{11}'\Lambda_{11}}\}\mathbf{\Gamma_{11}\Gamma_{21}'}\{\mathbf{\Lambda_{22}\Gamma_{21}}\}={\mathbf U}\mathbf{\Gamma_{11}\Gamma_{21}'}{\mathbf V}$$He
A strange step on a proof about the distribution of quadratic forms (9.9.6) states that$${\mathbf {AB}}=\{\mathbf{\Gamma_{11}'\Lambda_{11}}\}\mathbf{\Gamma_{11}\Gamma_{21}'}\{\mathbf{\Lambda_{22}\Gamma_{21}}\}={\mathbf U}\mathbf{\Gamma_{11}\Gamma_{21}'}{\mathbf V}$$Hence multiplying left and right by $\mathbf{U}'$ and $\mathbf{V}'$, we get $$\mathbf{U}'{\mathbf {AB}}\mathbf{V}'=\mathbf{U}'{\mathbf U}\mathbf{\Gamma_{11}\Gamma_{21}'}{\mathbf V}\mathbf{V}'$$and $$(\mathbf{U}'{\mathbf U})^{-1}\mathbf{U}'{\mathbf {AB}}\mathbf{V}'({\mathbf V}\mathbf{V}')^{-1}=\mathbf{\Gamma_{11}\Gamma_{21}'}$$I see no reason for the inner $\mathbf{U}'$ and $\mathbf{V}'$ to vanish so I would bet on a typo. However the conclusion remains the same, namely that $$\mathbf{\Gamma_{11}\Gamma_{21}'}=0$$ if and only if$$\mathbf{{AB}}=0$$
A strange step on a proof about the distribution of quadratic forms (9.9.6) states that$${\mathbf {AB}}=\{\mathbf{\Gamma_{11}'\Lambda_{11}}\}\mathbf{\Gamma_{11}\Gamma_{21}'}\{\mathbf{\Lambda_{22}\Gamma_{21}}\}={\mathbf U}\mathbf{\Gamma_{11}\Gamma_{21}'}{\mathbf V}$$He
31,020
A strange step on a proof about the distribution of quadratic forms
I contacted the author Professor Joseph W. McKean who achknowledged the mistake and very kindly offered the correction. I am posting it here, in case anybody else studying on his or her own is in need of it. After (9.9.6) write: Let $\mathbf{U}$ denote the matrix in the first set of braces. Note that $\mathbf{U}$ has full column rank, so its kernel is null; i.e., its kernel consists of the vector $\mathbf{0}$. Let $\mathbf{V}$ denote the matrix in the second set of braces. Note that $\mathbf{V}$ has full row rank, hence the kernel of $\mathbf{V}^{\prime}$ is null. For the proof then, suppose $\mathbf{AB}=\mathbf{0}$. Then $$\mathbf{U}\left[\mathbf{\Gamma}_{11}\mathbf{\Gamma}_{21}^{\prime}\mathbf{V}\right]=\mathbf{0}$$ Because the kernel of $\mathbf{U}$ is null this implies that each column of the matrix in the brackets is $\mathbf{0}$. This implies that $$\mathbf{V}^{\prime} \left[ \mathbf{\Gamma}_{21} \mathbf{\Gamma}_{11} \right]=\mathbf{0}$$ In the same way, because the kernel of $\mathbf{V}^{\prime}$ is null we have $\mathbf{\Gamma}_{11} \mathbf{\Gamma}_{21}^{\prime}=\mathbf{0}$. Hence by $\left(9.9.5 \right)$... (and the proof continues for the other direction)
A strange step on a proof about the distribution of quadratic forms
I contacted the author Professor Joseph W. McKean who achknowledged the mistake and very kindly offered the correction. I am posting it here, in case anybody else studying on his or her own is in need
A strange step on a proof about the distribution of quadratic forms I contacted the author Professor Joseph W. McKean who achknowledged the mistake and very kindly offered the correction. I am posting it here, in case anybody else studying on his or her own is in need of it. After (9.9.6) write: Let $\mathbf{U}$ denote the matrix in the first set of braces. Note that $\mathbf{U}$ has full column rank, so its kernel is null; i.e., its kernel consists of the vector $\mathbf{0}$. Let $\mathbf{V}$ denote the matrix in the second set of braces. Note that $\mathbf{V}$ has full row rank, hence the kernel of $\mathbf{V}^{\prime}$ is null. For the proof then, suppose $\mathbf{AB}=\mathbf{0}$. Then $$\mathbf{U}\left[\mathbf{\Gamma}_{11}\mathbf{\Gamma}_{21}^{\prime}\mathbf{V}\right]=\mathbf{0}$$ Because the kernel of $\mathbf{U}$ is null this implies that each column of the matrix in the brackets is $\mathbf{0}$. This implies that $$\mathbf{V}^{\prime} \left[ \mathbf{\Gamma}_{21} \mathbf{\Gamma}_{11} \right]=\mathbf{0}$$ In the same way, because the kernel of $\mathbf{V}^{\prime}$ is null we have $\mathbf{\Gamma}_{11} \mathbf{\Gamma}_{21}^{\prime}=\mathbf{0}$. Hence by $\left(9.9.5 \right)$... (and the proof continues for the other direction)
A strange step on a proof about the distribution of quadratic forms I contacted the author Professor Joseph W. McKean who achknowledged the mistake and very kindly offered the correction. I am posting it here, in case anybody else studying on his or her own is in need
31,021
Fisher exact test on paired data
You need McNemar's test (http://en.wikipedia.org/wiki/McNemar%27s_test , http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3346204/). Following is an example: 1300 pts and 1300 matched controls are studied. The smoking status is tabled as follows: Normal |no |yes| Cancer|No |1000|40 | |Yes |200 |60 | Each entry of the table shows information about a CASE-CONTROL PAIR: 1000 means in 1000 case-control pairs, neither was a smoker. 40 is the number of case-control pairs where control was smoker and cancer patient was not, and so on. Following R code can be used to generate this table and do McNemar's Test. mat = as.table(rbind(c(1000, 40), c( 200, 60) )) colnames(mat) <- rownames(mat) <- c("Nonsmoker", "Smoker") names(dimnames(mat)) = c("Cancer", "Normal") mat # Normal # Nonsmoker Smoker # Cancer # Nonsmoker 1000 40 # Smoker 200 60 mcnemar.test(mat) # McNemar's Chi-squared test with continuity correction # #data: mat #McNemar's chi-squared = 105.34, df = 1, p-value < 2.2e-16 McNemar's test is also used to assess effect of an intervention on a binary outcome variable. The pair of before-after outcome is tabled and tested as above. Edit: Extending example given by @gung , if smoking status is listed in your dataframe mydf as follows: pairID cancer control 1 1 1 2 1 1 3 1 0 ... McNemars test can be done with following R commands: > tt = with(mydf, table(cancer, control)) > tt control cancer 0 1 0 5 1 1 3 2 > mcnemar.test(tt) McNemar`s Chi-squared test with continuity correction data: tt McNemar`s chi-squared = 0.25, df = 1, p-value = 0.6171
Fisher exact test on paired data
You need McNemar's test (http://en.wikipedia.org/wiki/McNemar%27s_test , http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3346204/). Following is an example: 1300 pts and 1300 matched controls are studied
Fisher exact test on paired data You need McNemar's test (http://en.wikipedia.org/wiki/McNemar%27s_test , http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3346204/). Following is an example: 1300 pts and 1300 matched controls are studied. The smoking status is tabled as follows: Normal |no |yes| Cancer|No |1000|40 | |Yes |200 |60 | Each entry of the table shows information about a CASE-CONTROL PAIR: 1000 means in 1000 case-control pairs, neither was a smoker. 40 is the number of case-control pairs where control was smoker and cancer patient was not, and so on. Following R code can be used to generate this table and do McNemar's Test. mat = as.table(rbind(c(1000, 40), c( 200, 60) )) colnames(mat) <- rownames(mat) <- c("Nonsmoker", "Smoker") names(dimnames(mat)) = c("Cancer", "Normal") mat # Normal # Nonsmoker Smoker # Cancer # Nonsmoker 1000 40 # Smoker 200 60 mcnemar.test(mat) # McNemar's Chi-squared test with continuity correction # #data: mat #McNemar's chi-squared = 105.34, df = 1, p-value < 2.2e-16 McNemar's test is also used to assess effect of an intervention on a binary outcome variable. The pair of before-after outcome is tabled and tested as above. Edit: Extending example given by @gung , if smoking status is listed in your dataframe mydf as follows: pairID cancer control 1 1 1 2 1 1 3 1 0 ... McNemars test can be done with following R commands: > tt = with(mydf, table(cancer, control)) > tt control cancer 0 1 0 5 1 1 3 2 > mcnemar.test(tt) McNemar`s Chi-squared test with continuity correction data: tt McNemar`s chi-squared = 0.25, df = 1, p-value = 0.6171
Fisher exact test on paired data You need McNemar's test (http://en.wikipedia.org/wiki/McNemar%27s_test , http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3346204/). Following is an example: 1300 pts and 1300 matched controls are studied
31,022
Fisher exact test on paired data
You are right that Fisher's exact test is inappropriate for your data. You will have to re-form your contingency table. The new table will be for pairs, thus it will appear to have half as many data represented (in your case 40 instead of 80). For example, imagine your data looked like this (each set of paired subjects is in its own row, and 1 indicates a smoker): cancer control 1 1 1 1 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 Then your old contingency table might have been: cancer control smoker 5 3 non 6 8 Your new contingency table will look like this: control cancer smoker non smoker 2 3 non 1 5 The first contingency table summed to 22 (the number of total subjects in your study), but the second contingency table sums to 11 (the number of matched pairs). With your data represented this way, what you are interested in is if the marginal proportions are the same. The test for that is McNemar's test. I have explained McNemar's test here and here.
Fisher exact test on paired data
You are right that Fisher's exact test is inappropriate for your data. You will have to re-form your contingency table. The new table will be for pairs, thus it will appear to have half as many data
Fisher exact test on paired data You are right that Fisher's exact test is inappropriate for your data. You will have to re-form your contingency table. The new table will be for pairs, thus it will appear to have half as many data represented (in your case 40 instead of 80). For example, imagine your data looked like this (each set of paired subjects is in its own row, and 1 indicates a smoker): cancer control 1 1 1 1 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 Then your old contingency table might have been: cancer control smoker 5 3 non 6 8 Your new contingency table will look like this: control cancer smoker non smoker 2 3 non 1 5 The first contingency table summed to 22 (the number of total subjects in your study), but the second contingency table sums to 11 (the number of matched pairs). With your data represented this way, what you are interested in is if the marginal proportions are the same. The test for that is McNemar's test. I have explained McNemar's test here and here.
Fisher exact test on paired data You are right that Fisher's exact test is inappropriate for your data. You will have to re-form your contingency table. The new table will be for pairs, thus it will appear to have half as many data
31,023
Fisher exact test on paired data
it should not be necessary to use a paired test. the matching of the populations ascertains that the distribution of covaraites (age, ...) is the same in the two populatoins so it doesn't "distort" the picture. the test compares the means of the populations so a pairing of individuals is not necessary. this is only required for "repeated" measurements, e.g., comparing menas before and after treatment of the same population.
Fisher exact test on paired data
it should not be necessary to use a paired test. the matching of the populations ascertains that the distribution of covaraites (age, ...) is the same in the two populatoins so it doesn't "distort" th
Fisher exact test on paired data it should not be necessary to use a paired test. the matching of the populations ascertains that the distribution of covaraites (age, ...) is the same in the two populatoins so it doesn't "distort" the picture. the test compares the means of the populations so a pairing of individuals is not necessary. this is only required for "repeated" measurements, e.g., comparing menas before and after treatment of the same population.
Fisher exact test on paired data it should not be necessary to use a paired test. the matching of the populations ascertains that the distribution of covaraites (age, ...) is the same in the two populatoins so it doesn't "distort" th
31,024
Fisher exact test on paired data
Yes and no: probably your case falls under the Pearce (2015) case: the point in the article is that the variables you use to select the control should be controlled for in the study and not in the test. That could be difficult due to the N=80. Hope this help :)
Fisher exact test on paired data
Yes and no: probably your case falls under the Pearce (2015) case: the point in the article is that the variables you use to select the control should be controlled for in the study and not in the tes
Fisher exact test on paired data Yes and no: probably your case falls under the Pearce (2015) case: the point in the article is that the variables you use to select the control should be controlled for in the study and not in the test. That could be difficult due to the N=80. Hope this help :)
Fisher exact test on paired data Yes and no: probably your case falls under the Pearce (2015) case: the point in the article is that the variables you use to select the control should be controlled for in the study and not in the tes
31,025
Calculating the mutual information between two histograms
According to wikipedia, mutual information of two random variables may be calculated using the following formula: $$ I(X;Y) = \sum_{y \in Y} \sum_{x \in X} p(x,y) \log{ \left(\frac{p(x,y)}{p(x)\,p(y)} \right) } $$ If I pick up your code from this: [co1, ce1] = hist(randpoints1, bins); [co2, ce2] = hist(randpoints2, bins); We can solve this the following way: % calculate each marginal pmf from the histogram bin counts p1 = co1/sum(co1); p2 = co2/sum(co2); % calculate joint pmf assuming independence of variables p12_indep = bsxfun(@times, p1.', p2); % sample the joint pmf directly using hist3 p12_joint = hist3([randpoints1', randpoints2'], [bins, bins])/points; % using the wikipedia formula for mutual information dI12 = p12_joint.*log(p12_joint./p12_indep); % mutual info at each bin I12 = nansum(dI12(:)); % sum of all mutual information I12 for the random variables that you generate, is quite low (~0.01), which is not surprising, since you generate them independently. Plotting the independence assumed distribution and the joint distribution side by side shows how similar they are: If, on the other hand, we introduce dependence by generating randpoints2 to have some component of randpoints1, like this for example: randpoints2 = 0.5*(sigma2.*randn(1, points) + mu2 + randpoints1); I12 becomes much larger (~0.25) and represents the larger mutual information that these variables now share. Plotting the above distributions again shows a clear (would be clearer with more points and bins of course) difference between joint pmf that assumes independence and a pmf that's generated by sampling the variables simultaneously. The code I used to plot I12: figure; subplot(121); pcolor(p12_indep); axis square; xlabel('Var2'); ylabel('Var1'); title('Independent: P(Var1)*P(Var2)'); subplot(122); pcolor(p12_joint); axis square; xlabel('Var2'); ylabel('Var1'); title('Joint: P(Var1,Var2)');
Calculating the mutual information between two histograms
According to wikipedia, mutual information of two random variables may be calculated using the following formula: $$ I(X;Y) = \sum_{y \in Y} \sum_{x \in X} p(x,y) \log{ \left(\frac
Calculating the mutual information between two histograms According to wikipedia, mutual information of two random variables may be calculated using the following formula: $$ I(X;Y) = \sum_{y \in Y} \sum_{x \in X} p(x,y) \log{ \left(\frac{p(x,y)}{p(x)\,p(y)} \right) } $$ If I pick up your code from this: [co1, ce1] = hist(randpoints1, bins); [co2, ce2] = hist(randpoints2, bins); We can solve this the following way: % calculate each marginal pmf from the histogram bin counts p1 = co1/sum(co1); p2 = co2/sum(co2); % calculate joint pmf assuming independence of variables p12_indep = bsxfun(@times, p1.', p2); % sample the joint pmf directly using hist3 p12_joint = hist3([randpoints1', randpoints2'], [bins, bins])/points; % using the wikipedia formula for mutual information dI12 = p12_joint.*log(p12_joint./p12_indep); % mutual info at each bin I12 = nansum(dI12(:)); % sum of all mutual information I12 for the random variables that you generate, is quite low (~0.01), which is not surprising, since you generate them independently. Plotting the independence assumed distribution and the joint distribution side by side shows how similar they are: If, on the other hand, we introduce dependence by generating randpoints2 to have some component of randpoints1, like this for example: randpoints2 = 0.5*(sigma2.*randn(1, points) + mu2 + randpoints1); I12 becomes much larger (~0.25) and represents the larger mutual information that these variables now share. Plotting the above distributions again shows a clear (would be clearer with more points and bins of course) difference between joint pmf that assumes independence and a pmf that's generated by sampling the variables simultaneously. The code I used to plot I12: figure; subplot(121); pcolor(p12_indep); axis square; xlabel('Var2'); ylabel('Var1'); title('Independent: P(Var1)*P(Var2)'); subplot(122); pcolor(p12_joint); axis square; xlabel('Var2'); ylabel('Var1'); title('Joint: P(Var1,Var2)');
Calculating the mutual information between two histograms According to wikipedia, mutual information of two random variables may be calculated using the following formula: $$ I(X;Y) = \sum_{y \in Y} \sum_{x \in X} p(x,y) \log{ \left(\frac
31,026
Calculating the mutual information between two histograms
A blog post entitled, “Entropy in machine learning” dated May 6, 2019 (https://amethix.com/entropy-in-machine-learning/) gave a very good explanation and summary of the concepts of Mutual Information, KL Divergence and their relationships to Entropy. It had many informative references and it provided useful Python code supporting their explanations. The code that they provided used the numpy.histogram method to create the inputs for the sklearn.metrics. mutual_info_score while never displaying the actual histograms. You can very easily modify it to display the histograms that you need then use the MI as needed. The code and references that they provided as also very enlighting. You might also benefit from their explanation and use of code to calculate KL Divergence. # Import libraries import pandas as pd import numpy as np from scipy.stats import iqr from numpy import histogram2d from sklearn.metrics import mutual_info_score # Read dataset about breast cancer detection df = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/00451/dataR2.csv") # Separate input and targets target = df['Classification'] df.drop(['Classification'], axis=1, inplace=True) # Define mutual information function def minfo(x, y): # Compute mutual information between x and y bins_x = max(2,int(2*iqr(x)*len(x)**-(1/3))) # use Freedman-Diaconis's Rule of thumb bins_y = max(2,int(2*iqr(y)*len(y)**-(1/3))) c_xy = histogram2d(x, y, [bins_x,bins_y])[0] mi = mutual_info_score(None, None, contingency=c_xy) return mi # Build MI matrix num_features = df.shape[1] MI_matrix = np.zeros((num_features,num_features)) for i,col_i in enumerate(df): for j,col_j in enumerate(df): MI_matrix[i,j] = minfo(df[col_i],df[col_j]) MI_df = pd.DataFrame(MI_matrix,columns = df.columns, index = df.columns) print(MI_df) I find this post, along with the explanation and code provided in the first answer above when combined, to offer a very interesting solution.
Calculating the mutual information between two histograms
A blog post entitled, “Entropy in machine learning” dated May 6, 2019 (https://amethix.com/entropy-in-machine-learning/) gave a very good explanation and summary of the concepts of Mutual Information,
Calculating the mutual information between two histograms A blog post entitled, “Entropy in machine learning” dated May 6, 2019 (https://amethix.com/entropy-in-machine-learning/) gave a very good explanation and summary of the concepts of Mutual Information, KL Divergence and their relationships to Entropy. It had many informative references and it provided useful Python code supporting their explanations. The code that they provided used the numpy.histogram method to create the inputs for the sklearn.metrics. mutual_info_score while never displaying the actual histograms. You can very easily modify it to display the histograms that you need then use the MI as needed. The code and references that they provided as also very enlighting. You might also benefit from their explanation and use of code to calculate KL Divergence. # Import libraries import pandas as pd import numpy as np from scipy.stats import iqr from numpy import histogram2d from sklearn.metrics import mutual_info_score # Read dataset about breast cancer detection df = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/00451/dataR2.csv") # Separate input and targets target = df['Classification'] df.drop(['Classification'], axis=1, inplace=True) # Define mutual information function def minfo(x, y): # Compute mutual information between x and y bins_x = max(2,int(2*iqr(x)*len(x)**-(1/3))) # use Freedman-Diaconis's Rule of thumb bins_y = max(2,int(2*iqr(y)*len(y)**-(1/3))) c_xy = histogram2d(x, y, [bins_x,bins_y])[0] mi = mutual_info_score(None, None, contingency=c_xy) return mi # Build MI matrix num_features = df.shape[1] MI_matrix = np.zeros((num_features,num_features)) for i,col_i in enumerate(df): for j,col_j in enumerate(df): MI_matrix[i,j] = minfo(df[col_i],df[col_j]) MI_df = pd.DataFrame(MI_matrix,columns = df.columns, index = df.columns) print(MI_df) I find this post, along with the explanation and code provided in the first answer above when combined, to offer a very interesting solution.
Calculating the mutual information between two histograms A blog post entitled, “Entropy in machine learning” dated May 6, 2019 (https://amethix.com/entropy-in-machine-learning/) gave a very good explanation and summary of the concepts of Mutual Information,
31,027
Explain the croston method of R
Note that Croston's method does not forecast "likely" periods with nonzero demands. It assumes that all periods are equally likely to exhibit demand. It separately smoothes the inter-demand interval and nonzero demands via Exponential Smoothing, but updates both only when there is nonzero demand. The in-sample fit and the point forecast then essentially is the ratio of smoothed nonzero demand, divided by the inter-demand interval (unless there is some kind of Syntetos-Boylan bias correction going on). x$frc.in is the in-sample demand rate. This is the in-sample estimate of average demand - as above, this is the ratio of the current value of smoothed nonzero demands, divided by the current value of smoothed inter-demand interval lengths. If you look closely, you see that this does not change during periods with zero demand... because Croston's method only updates (smoothes) its estimates for the inter-demand interval and for the nonzero demand when there is nonzero demand. x$frc.out is the out-of-sample demand rate, i.e., the forecast for average demand. As you see, it is constant, because Croston's method does not provide for out-of-sample dynamics like trend or seasonality. x$weights are the optimized smoothing weights for smoothing the inter-demand interval and nonzero demand component. Originally, Croston used only a single (pre-set) weight for smoothing; Kourentzes apparently optimizes both weights separately. (I am not familiar with the reference given on the help page - it may be useful for you to read it, though.) Here is your time series, with the in-sample fit in red and the forecast in green: bar <- crost(t) plot(t,xlim=c(1,4.1)) lines(ts(bar$frc.in,frequency=52),col="red") lines(ts(bar$frc.out,frequency=52,start=c(3,49)),col="green") Now, looking at your data v, Croston's method is quite obviously inappropriate. Although you do have many zeros, your time series is not intermittent in any meaningful sense. Instead, it is obviously seasonal, with periods of nonzero demand alternating with periods of zero demand in a yearly pattern. I'd much more recommend using a method that explicitly models this seasonality, like stlf() in the forecast package. Its forecasts will go negative, so you need to truncate them at zero, that is, set all negative point forecasts to 0. pmax() is helpful here. Of course, prediction intervals from stlf() don't make much sense, since their calculation does not respect nonnegativity constraints, but I assume that you are mostly interested in point forecasts, anyway. For instance: foo <- stlf(t) foo$mean <- pmax(foo$mean,0) # truncate at zero plot(foo)
Explain the croston method of R
Note that Croston's method does not forecast "likely" periods with nonzero demands. It assumes that all periods are equally likely to exhibit demand. It separately smoothes the inter-demand interval a
Explain the croston method of R Note that Croston's method does not forecast "likely" periods with nonzero demands. It assumes that all periods are equally likely to exhibit demand. It separately smoothes the inter-demand interval and nonzero demands via Exponential Smoothing, but updates both only when there is nonzero demand. The in-sample fit and the point forecast then essentially is the ratio of smoothed nonzero demand, divided by the inter-demand interval (unless there is some kind of Syntetos-Boylan bias correction going on). x$frc.in is the in-sample demand rate. This is the in-sample estimate of average demand - as above, this is the ratio of the current value of smoothed nonzero demands, divided by the current value of smoothed inter-demand interval lengths. If you look closely, you see that this does not change during periods with zero demand... because Croston's method only updates (smoothes) its estimates for the inter-demand interval and for the nonzero demand when there is nonzero demand. x$frc.out is the out-of-sample demand rate, i.e., the forecast for average demand. As you see, it is constant, because Croston's method does not provide for out-of-sample dynamics like trend or seasonality. x$weights are the optimized smoothing weights for smoothing the inter-demand interval and nonzero demand component. Originally, Croston used only a single (pre-set) weight for smoothing; Kourentzes apparently optimizes both weights separately. (I am not familiar with the reference given on the help page - it may be useful for you to read it, though.) Here is your time series, with the in-sample fit in red and the forecast in green: bar <- crost(t) plot(t,xlim=c(1,4.1)) lines(ts(bar$frc.in,frequency=52),col="red") lines(ts(bar$frc.out,frequency=52,start=c(3,49)),col="green") Now, looking at your data v, Croston's method is quite obviously inappropriate. Although you do have many zeros, your time series is not intermittent in any meaningful sense. Instead, it is obviously seasonal, with periods of nonzero demand alternating with periods of zero demand in a yearly pattern. I'd much more recommend using a method that explicitly models this seasonality, like stlf() in the forecast package. Its forecasts will go negative, so you need to truncate them at zero, that is, set all negative point forecasts to 0. pmax() is helpful here. Of course, prediction intervals from stlf() don't make much sense, since their calculation does not respect nonnegativity constraints, but I assume that you are mostly interested in point forecasts, anyway. For instance: foo <- stlf(t) foo$mean <- pmax(foo$mean,0) # truncate at zero plot(foo)
Explain the croston method of R Note that Croston's method does not forecast "likely" periods with nonzero demands. It assumes that all periods are equally likely to exhibit demand. It separately smoothes the inter-demand interval a
31,028
How to find which variables are most correlated with the first principal component?
Summary: if the original variables were standardized, then you should simply look at the first principal axis (rotation in the R terminology) and select variables with highest absolute values. Consider dataset $\mathbf{X}$ with centered variables in columns and $N$ data points in rows. Performing PCA of this dataset amounts to singular value decomposition $\mathbf{X} = \mathbf{U} \mathbf{S} \mathbf{V}^\top$. Here columns of $\mathbf{V}$ are principal axes, $\mathbf{S}$ is a diagonal matrix with singular values, and columns of $\mathbf{U}$ are principal components scaled to unit norm. Standardized PCs are given by $\sqrt{N-1}\mathbf{U}$. PCs themselves (also known as "scores") are given by columns of $\mathbf{US}$. Note that covariance matrix is given by $\frac{1}{N-1}\mathbf{X}^\top \mathbf{X} = \mathbf{V}\frac{\mathbf{S}^2}{{N-1}}\mathbf{V}^\top=\mathbf{VEV}^\top$, so principal axes $\mathbf{V}$ are eigenvectors of the covariance matrix and $\mathbf E=\frac{\mathbf S^2}{N-1}$ are its eigenvalues. We can now compute cross-covariance matrix between original variables and standardized PCs: $$\frac{1}{N-1}\mathbf{X}^\top(\sqrt{N-1}\mathbf{U}) = \frac{1}{\sqrt{N-1}}\mathbf{V}\mathbf{S}\mathbf{U}^\top\mathbf{U} = \mathbf{V}\frac{\mathbf{S}}{\sqrt{N-1}}=\mathbf{V}\sqrt{\mathbf E}=\mathbf{L}.$$ This matrix is called loadings matrix: it is given by the eigenvectors of the covariance matrix scaled by the square roots of the respective eigenvalues. Cross-correlation matrix between original variables and PCs is given by the same expression divided by the standard deviations of the original variables (by definition of correlation). If the original variables were standardized prior to performing PCA (i.e. PCA was performed on the correlation matrix) they are all equal to $1$. In this last case the cross-correlation matrix is again given simply by $\mathbf{L}$. You are only interested in the top correlations with the first PC, which means that you should look at the first column of $\mathbf{L}$ and select variables with highest absolute values. But notice that the first column of $\mathbf{L}$ is equal to the first column of $\mathbf{V}$, up to a scaling factor (given by the square root of the first eigenvalue of the covariance matrix). So equivalently, you can look at the first column of $\mathbf{V}$ (i.e. the first principal axis, or rotation in the R terminology) and select variables with highest absolute values. But again, this is only true if the original variables were standardized.
How to find which variables are most correlated with the first principal component?
Summary: if the original variables were standardized, then you should simply look at the first principal axis (rotation in the R terminology) and select variables with highest absolute values. Consid
How to find which variables are most correlated with the first principal component? Summary: if the original variables were standardized, then you should simply look at the first principal axis (rotation in the R terminology) and select variables with highest absolute values. Consider dataset $\mathbf{X}$ with centered variables in columns and $N$ data points in rows. Performing PCA of this dataset amounts to singular value decomposition $\mathbf{X} = \mathbf{U} \mathbf{S} \mathbf{V}^\top$. Here columns of $\mathbf{V}$ are principal axes, $\mathbf{S}$ is a diagonal matrix with singular values, and columns of $\mathbf{U}$ are principal components scaled to unit norm. Standardized PCs are given by $\sqrt{N-1}\mathbf{U}$. PCs themselves (also known as "scores") are given by columns of $\mathbf{US}$. Note that covariance matrix is given by $\frac{1}{N-1}\mathbf{X}^\top \mathbf{X} = \mathbf{V}\frac{\mathbf{S}^2}{{N-1}}\mathbf{V}^\top=\mathbf{VEV}^\top$, so principal axes $\mathbf{V}$ are eigenvectors of the covariance matrix and $\mathbf E=\frac{\mathbf S^2}{N-1}$ are its eigenvalues. We can now compute cross-covariance matrix between original variables and standardized PCs: $$\frac{1}{N-1}\mathbf{X}^\top(\sqrt{N-1}\mathbf{U}) = \frac{1}{\sqrt{N-1}}\mathbf{V}\mathbf{S}\mathbf{U}^\top\mathbf{U} = \mathbf{V}\frac{\mathbf{S}}{\sqrt{N-1}}=\mathbf{V}\sqrt{\mathbf E}=\mathbf{L}.$$ This matrix is called loadings matrix: it is given by the eigenvectors of the covariance matrix scaled by the square roots of the respective eigenvalues. Cross-correlation matrix between original variables and PCs is given by the same expression divided by the standard deviations of the original variables (by definition of correlation). If the original variables were standardized prior to performing PCA (i.e. PCA was performed on the correlation matrix) they are all equal to $1$. In this last case the cross-correlation matrix is again given simply by $\mathbf{L}$. You are only interested in the top correlations with the first PC, which means that you should look at the first column of $\mathbf{L}$ and select variables with highest absolute values. But notice that the first column of $\mathbf{L}$ is equal to the first column of $\mathbf{V}$, up to a scaling factor (given by the square root of the first eigenvalue of the covariance matrix). So equivalently, you can look at the first column of $\mathbf{V}$ (i.e. the first principal axis, or rotation in the R terminology) and select variables with highest absolute values. But again, this is only true if the original variables were standardized.
How to find which variables are most correlated with the first principal component? Summary: if the original variables were standardized, then you should simply look at the first principal axis (rotation in the R terminology) and select variables with highest absolute values. Consid
31,029
How to find which variables are most correlated with the first principal component?
I got some more clarification on the problem after reading this link on correlations between the principal components and the original variables It appears to me it is same as finding those variables which contribute mostly to the principal component. So after scaling/z-transform , variable values that are 1.5σ away from mean(σ equals one and mean zero in this case) were considered most important contributors. so the following lines of code will do the job I guess: rot1.scaled <- scale(pca.object$rotation[,1]) names( which(rot1.scaled[,1] > 1.5 | rot1.scaled[,1] < -1.5) ) In another way of selecting, if I choose the Top 'N' contributing genes, the code would be: topN <- 5 load.rot <- pca.object$rotation names(load.rot[,1][order(abs(load.rot[,1]),decreasing=TRUE)][1:topN]) Please correct me if I'm wrong.
How to find which variables are most correlated with the first principal component?
I got some more clarification on the problem after reading this link on correlations between the principal components and the original variables It appears to me it is same as finding those variables
How to find which variables are most correlated with the first principal component? I got some more clarification on the problem after reading this link on correlations between the principal components and the original variables It appears to me it is same as finding those variables which contribute mostly to the principal component. So after scaling/z-transform , variable values that are 1.5σ away from mean(σ equals one and mean zero in this case) were considered most important contributors. so the following lines of code will do the job I guess: rot1.scaled <- scale(pca.object$rotation[,1]) names( which(rot1.scaled[,1] > 1.5 | rot1.scaled[,1] < -1.5) ) In another way of selecting, if I choose the Top 'N' contributing genes, the code would be: topN <- 5 load.rot <- pca.object$rotation names(load.rot[,1][order(abs(load.rot[,1]),decreasing=TRUE)][1:topN]) Please correct me if I'm wrong.
How to find which variables are most correlated with the first principal component? I got some more clarification on the problem after reading this link on correlations between the principal components and the original variables It appears to me it is same as finding those variables
31,030
Why people often optimize the determinant of $(X'\Sigma X)^{-1}$
As a design criterion, to minimize the determinant of $(X'\Sigma^{-1} X)^{-1}$, which is the same as maximizing the determinant of $(X'\Sigma^{-1} X)$, is known as D-optimal experimental design. The determinant of a covariance matrix is known as the generalized variance, so we are minimizing the generalized variance. Other functionals of the covariance matrix could be used as a criterion, but what you propose (minimizing sum of its elements) does not make much sense. The D-optimality criterion has the big practical advantage of being invariant under linear transformations of the regressor variables, which is a big practical advantage. Invariance means that the optimality is not influenced by such things as choice of measurements units, (such as m or k m). With non-invariant optimality criteria the result could depend on such irrelevant things as choice of measurement units. If you search this site for "D-optimal" you will find other relevant posts!
Why people often optimize the determinant of $(X'\Sigma X)^{-1}$
As a design criterion, to minimize the determinant of $(X'\Sigma^{-1} X)^{-1}$, which is the same as maximizing the determinant of $(X'\Sigma^{-1} X)$, is known as D-optimal experimental design. The
Why people often optimize the determinant of $(X'\Sigma X)^{-1}$ As a design criterion, to minimize the determinant of $(X'\Sigma^{-1} X)^{-1}$, which is the same as maximizing the determinant of $(X'\Sigma^{-1} X)$, is known as D-optimal experimental design. The determinant of a covariance matrix is known as the generalized variance, so we are minimizing the generalized variance. Other functionals of the covariance matrix could be used as a criterion, but what you propose (minimizing sum of its elements) does not make much sense. The D-optimality criterion has the big practical advantage of being invariant under linear transformations of the regressor variables, which is a big practical advantage. Invariance means that the optimality is not influenced by such things as choice of measurements units, (such as m or k m). With non-invariant optimality criteria the result could depend on such irrelevant things as choice of measurement units. If you search this site for "D-optimal" you will find other relevant posts!
Why people often optimize the determinant of $(X'\Sigma X)^{-1}$ As a design criterion, to minimize the determinant of $(X'\Sigma^{-1} X)^{-1}$, which is the same as maximizing the determinant of $(X'\Sigma^{-1} X)$, is known as D-optimal experimental design. The
31,031
Imputing missing observation in multivariate time series
A good reference to solve your problem is the book "Time Series Analysis and Its Applications: With R Examples" by Robert H. Shumway and David S. Stoffer. A chapter is dedicated to the imputation of missing observations in multiple time-series analysis. Applications with code in R are also provided.
Imputing missing observation in multivariate time series
A good reference to solve your problem is the book "Time Series Analysis and Its Applications: With R Examples" by Robert H. Shumway and David S. Stoffer. A chapter is dedicated to the imputation of m
Imputing missing observation in multivariate time series A good reference to solve your problem is the book "Time Series Analysis and Its Applications: With R Examples" by Robert H. Shumway and David S. Stoffer. A chapter is dedicated to the imputation of missing observations in multiple time-series analysis. Applications with code in R are also provided.
Imputing missing observation in multivariate time series A good reference to solve your problem is the book "Time Series Analysis and Its Applications: With R Examples" by Robert H. Shumway and David S. Stoffer. A chapter is dedicated to the imputation of m
31,032
Imputing missing observation in multivariate time series
There is otherwise the package mtsdi for multivariate time series, it seems to offer an EM algorithm taking into account time auto-correlation and within variables correlation. This package seems promising, although there appear to be a few implementation problems, I ran into one and there is another one reported here: https://stackoverflow.com/questions/29472532/arima-method-in-mtsdi
Imputing missing observation in multivariate time series
There is otherwise the package mtsdi for multivariate time series, it seems to offer an EM algorithm taking into account time auto-correlation and within variables correlation. This package seems pro
Imputing missing observation in multivariate time series There is otherwise the package mtsdi for multivariate time series, it seems to offer an EM algorithm taking into account time auto-correlation and within variables correlation. This package seems promising, although there appear to be a few implementation problems, I ran into one and there is another one reported here: https://stackoverflow.com/questions/29472532/arima-method-in-mtsdi
Imputing missing observation in multivariate time series There is otherwise the package mtsdi for multivariate time series, it seems to offer an EM algorithm taking into account time auto-correlation and within variables correlation. This package seems pro
31,033
Imputing missing observation in multivariate time series
That most imputation packages don't work, has to do with their underlying algorithms. Imputation is done by employing inter-attribute correlations to estimate the missing values. An easy understandable example: You have attributes A,B,C,D. In row 20 attribute D is missing. From the past data the algorithm knows, when A is value x1 and B is value x2 and C is value x3 then the value of D is most likly x4. If now all four attributes are missing, the algorithm can not work. What algorithms being able to deal with this need to do is to consider information of other rows, to solve this problem. The concrete problem could be fixed with one of this approaches: Use Amelia options: lag, leads, polytime (if you do not use these options it is doing nothing time series specific) Impute each column seperatly with imputeTS package (that is a package explicitly for time series imputation - but does not support multivariate datasets) Use imputeTS to impute each column, but then restore all NAs (except the rows where all values are missing), then use an imputation package like Amelia to impute the rest (better than option 2 if you think the inter-attribute correlations are stronger than the inter-time correlation)
Imputing missing observation in multivariate time series
That most imputation packages don't work, has to do with their underlying algorithms. Imputation is done by employing inter-attribute correlations to estimate the missing values. An easy understandabl
Imputing missing observation in multivariate time series That most imputation packages don't work, has to do with their underlying algorithms. Imputation is done by employing inter-attribute correlations to estimate the missing values. An easy understandable example: You have attributes A,B,C,D. In row 20 attribute D is missing. From the past data the algorithm knows, when A is value x1 and B is value x2 and C is value x3 then the value of D is most likly x4. If now all four attributes are missing, the algorithm can not work. What algorithms being able to deal with this need to do is to consider information of other rows, to solve this problem. The concrete problem could be fixed with one of this approaches: Use Amelia options: lag, leads, polytime (if you do not use these options it is doing nothing time series specific) Impute each column seperatly with imputeTS package (that is a package explicitly for time series imputation - but does not support multivariate datasets) Use imputeTS to impute each column, but then restore all NAs (except the rows where all values are missing), then use an imputation package like Amelia to impute the rest (better than option 2 if you think the inter-attribute correlations are stronger than the inter-time correlation)
Imputing missing observation in multivariate time series That most imputation packages don't work, has to do with their underlying algorithms. Imputation is done by employing inter-attribute correlations to estimate the missing values. An easy understandabl
31,034
Imputing missing observation in multivariate time series
Using an state-space model is an alternative. You might want to check packages such as dlm, KFAS, or others.
Imputing missing observation in multivariate time series
Using an state-space model is an alternative. You might want to check packages such as dlm, KFAS, or others.
Imputing missing observation in multivariate time series Using an state-space model is an alternative. You might want to check packages such as dlm, KFAS, or others.
Imputing missing observation in multivariate time series Using an state-space model is an alternative. You might want to check packages such as dlm, KFAS, or others.
31,035
Selection of k knots in regression smoothing spline equivalent to k categorical variables?
Great question. I believe that the answer to the question you ask - "is the penalized smoothing spline equivalent to running a ridge regression or lasso" - is yes. There are a number of sources out there that can provide commentary & perspective. One place that you may want to start with is this PDF link. As is noted in the notes: "Fitting a smoothing spline model amounts to performing a form of ridge regression in a basis for natural splines." If you are looking for some general reading, you might enjoy checking out this excellent paper on Penalized Regressions: The Bridge Versus the Lasso. This might help answer the question of whether the penalized smoothing spline is exactly equivalent - though it provides more general perspective. I do find it interesting as they compared different techniques to each other, specifically a new bridge regression model with the LASSO, as well as Ridge Regression. Another more tactical place to check might be the package notes for the smooth.spline package in R. Note that they hint at the relationship here, by observing that: "with these definitions, where the B-spline basis representation can be stated as f = X c (i.e., c is the vector of spline coefficients), the penalized log likelihood is $L = (y - f)^T W (y - f) + \lambda c^T \Sigma c$, and hence $c$ is the solution of the (ridge regression) $(X^T W X + \lambda \Sigma) c = X^T W y$."
Selection of k knots in regression smoothing spline equivalent to k categorical variables?
Great question. I believe that the answer to the question you ask - "is the penalized smoothing spline equivalent to running a ridge regression or lasso" - is yes. There are a number of sources out th
Selection of k knots in regression smoothing spline equivalent to k categorical variables? Great question. I believe that the answer to the question you ask - "is the penalized smoothing spline equivalent to running a ridge regression or lasso" - is yes. There are a number of sources out there that can provide commentary & perspective. One place that you may want to start with is this PDF link. As is noted in the notes: "Fitting a smoothing spline model amounts to performing a form of ridge regression in a basis for natural splines." If you are looking for some general reading, you might enjoy checking out this excellent paper on Penalized Regressions: The Bridge Versus the Lasso. This might help answer the question of whether the penalized smoothing spline is exactly equivalent - though it provides more general perspective. I do find it interesting as they compared different techniques to each other, specifically a new bridge regression model with the LASSO, as well as Ridge Regression. Another more tactical place to check might be the package notes for the smooth.spline package in R. Note that they hint at the relationship here, by observing that: "with these definitions, where the B-spline basis representation can be stated as f = X c (i.e., c is the vector of spline coefficients), the penalized log likelihood is $L = (y - f)^T W (y - f) + \lambda c^T \Sigma c$, and hence $c$ is the solution of the (ridge regression) $(X^T W X + \lambda \Sigma) c = X^T W y$."
Selection of k knots in regression smoothing spline equivalent to k categorical variables? Great question. I believe that the answer to the question you ask - "is the penalized smoothing spline equivalent to running a ridge regression or lasso" - is yes. There are a number of sources out th
31,036
Selection of k knots in regression smoothing spline equivalent to k categorical variables?
I am not sure you really want so many knots, given the plot. It looks like you may have some small samples at particular ages; the peak at 74 and the 0 values at low and high end make little sense. Given the authority of the source you site, perhaps you want restricted cubic splines instead, with a much smaller number of knots?
Selection of k knots in regression smoothing spline equivalent to k categorical variables?
I am not sure you really want so many knots, given the plot. It looks like you may have some small samples at particular ages; the peak at 74 and the 0 values at low and high end make little sense. G
Selection of k knots in regression smoothing spline equivalent to k categorical variables? I am not sure you really want so many knots, given the plot. It looks like you may have some small samples at particular ages; the peak at 74 and the 0 values at low and high end make little sense. Given the authority of the source you site, perhaps you want restricted cubic splines instead, with a much smaller number of knots?
Selection of k knots in regression smoothing spline equivalent to k categorical variables? I am not sure you really want so many knots, given the plot. It looks like you may have some small samples at particular ages; the peak at 74 and the 0 values at low and high end make little sense. G
31,037
Selection of k knots in regression smoothing spline equivalent to k categorical variables?
I'm late to this discussion, but look at the chart of the data ... that apparent spikeyness in the data over age 70 isn't a true reflection of age-related risk, it's a symptom of sparse data and some randomness. You would not want to model that using one-knot-per-year, that would certainly lead to overfitting the noise. Also, you're going to find a very different pattern if you look at female vs male. Most of the peak in the age 15-30 range is going to be Obstetrics.
Selection of k knots in regression smoothing spline equivalent to k categorical variables?
I'm late to this discussion, but look at the chart of the data ... that apparent spikeyness in the data over age 70 isn't a true reflection of age-related risk, it's a symptom of sparse data and some
Selection of k knots in regression smoothing spline equivalent to k categorical variables? I'm late to this discussion, but look at the chart of the data ... that apparent spikeyness in the data over age 70 isn't a true reflection of age-related risk, it's a symptom of sparse data and some randomness. You would not want to model that using one-knot-per-year, that would certainly lead to overfitting the noise. Also, you're going to find a very different pattern if you look at female vs male. Most of the peak in the age 15-30 range is going to be Obstetrics.
Selection of k knots in regression smoothing spline equivalent to k categorical variables? I'm late to this discussion, but look at the chart of the data ... that apparent spikeyness in the data over age 70 isn't a true reflection of age-related risk, it's a symptom of sparse data and some
31,038
Explaining Gaussian Processes
Well, the details of the answer will depend on how much you know about random processes in general. If you know that a random process is a collection of random variables, then a Gaussian process is one in which all the random variables are Gaussian (a.k.a. normal) random variables; more strongly, they are jointly Gaussian random variables. In an answer on dsp.SE, I wrote in part Finally, suppose that a stochastic process is assumed to be a Gaussian process ("proving" this with any reasonable degree of confidence is not a trivial task). This means that for each $t$, $X(t)$ is a Gaussian random variable and for all positive integers $n \geq 2$ and choices of $n$ time instants $t_1$, $t_2$, $\ldots, t_n$, the $N$ random variables $X(t_1)$, $X(t_2)$, $\ldots, X(t_n)$ are jointly Gaussian random variables. Now a joint Gaussian density function is completely determined by the means, variances, and covariances of the random variables, and in this case, knowing the mean function $\mu_X(t) = E[X(t)]$ (it need not be a constant as is required for wide-sense-stationarity) and the autocorrelation function $R_X(t_1, t_2) = E[X(t_1)X(t_2)]$ for all $t_1, t_2$ (it need not depend only on $t_1-t_2$ as is required for wide-sense-stationarity) is sufficient to determine the statistics of the process completely. If none of this makes sense to you, try reading the full answer on dsp.SE.
Explaining Gaussian Processes
Well, the details of the answer will depend on how much you know about random processes in general. If you know that a random process is a collection of random variables, then a Gaussian process is o
Explaining Gaussian Processes Well, the details of the answer will depend on how much you know about random processes in general. If you know that a random process is a collection of random variables, then a Gaussian process is one in which all the random variables are Gaussian (a.k.a. normal) random variables; more strongly, they are jointly Gaussian random variables. In an answer on dsp.SE, I wrote in part Finally, suppose that a stochastic process is assumed to be a Gaussian process ("proving" this with any reasonable degree of confidence is not a trivial task). This means that for each $t$, $X(t)$ is a Gaussian random variable and for all positive integers $n \geq 2$ and choices of $n$ time instants $t_1$, $t_2$, $\ldots, t_n$, the $N$ random variables $X(t_1)$, $X(t_2)$, $\ldots, X(t_n)$ are jointly Gaussian random variables. Now a joint Gaussian density function is completely determined by the means, variances, and covariances of the random variables, and in this case, knowing the mean function $\mu_X(t) = E[X(t)]$ (it need not be a constant as is required for wide-sense-stationarity) and the autocorrelation function $R_X(t_1, t_2) = E[X(t_1)X(t_2)]$ for all $t_1, t_2$ (it need not depend only on $t_1-t_2$ as is required for wide-sense-stationarity) is sufficient to determine the statistics of the process completely. If none of this makes sense to you, try reading the full answer on dsp.SE.
Explaining Gaussian Processes Well, the details of the answer will depend on how much you know about random processes in general. If you know that a random process is a collection of random variables, then a Gaussian process is o
31,039
Explaining Gaussian Processes
This short tutorial by Eden : Gaussian Processes for Regression: A Quick Introduction, is the simplest and most direct material I can think of for getting out quickly somewhat up to speed with GPs, it should take you less that an hour or two I think. Somewhat longer is the excellent tutorial paper by Williams : Prediction with Gaussian processes: From linear regression to linear prediction and beyond. Finally the "ultimate" general resource is the Gaussian Process Web site; it has tutorials, papers categorized by field of applications, software implementations, etc. And if you are into lectures, check the 2006 round of lectures in Bletchley Park. Lots of big names (eg. MacKey, Williams, Rasmussen, etc.) and a variety of applications span. (In general the Videolectures web site has tones of material on ML stuff.) (and clearly +1 to Dilip; that's a great post on the DSP-SE web site!)
Explaining Gaussian Processes
This short tutorial by Eden : Gaussian Processes for Regression: A Quick Introduction, is the simplest and most direct material I can think of for getting out quickly somewhat up to speed with GPs, it
Explaining Gaussian Processes This short tutorial by Eden : Gaussian Processes for Regression: A Quick Introduction, is the simplest and most direct material I can think of for getting out quickly somewhat up to speed with GPs, it should take you less that an hour or two I think. Somewhat longer is the excellent tutorial paper by Williams : Prediction with Gaussian processes: From linear regression to linear prediction and beyond. Finally the "ultimate" general resource is the Gaussian Process Web site; it has tutorials, papers categorized by field of applications, software implementations, etc. And if you are into lectures, check the 2006 round of lectures in Bletchley Park. Lots of big names (eg. MacKey, Williams, Rasmussen, etc.) and a variety of applications span. (In general the Videolectures web site has tones of material on ML stuff.) (and clearly +1 to Dilip; that's a great post on the DSP-SE web site!)
Explaining Gaussian Processes This short tutorial by Eden : Gaussian Processes for Regression: A Quick Introduction, is the simplest and most direct material I can think of for getting out quickly somewhat up to speed with GPs, it
31,040
Explaining Gaussian Processes
I am working on Gaussian processes in my Ph.D. and yes, it was very confusing in beginning. I would strongly recommend this YouTube video lecture as the best resource to understand Gaussian processes from a regression perspective.
Explaining Gaussian Processes
I am working on Gaussian processes in my Ph.D. and yes, it was very confusing in beginning. I would strongly recommend this YouTube video lecture as the best resource to understand Gaussian processes
Explaining Gaussian Processes I am working on Gaussian processes in my Ph.D. and yes, it was very confusing in beginning. I would strongly recommend this YouTube video lecture as the best resource to understand Gaussian processes from a regression perspective.
Explaining Gaussian Processes I am working on Gaussian processes in my Ph.D. and yes, it was very confusing in beginning. I would strongly recommend this YouTube video lecture as the best resource to understand Gaussian processes
31,041
time series is obviously periodic, but seasonal decomposition is not working in R [closed]
Don't use as.ts(). Do this (note: the parameter is called start, not begin): a.ts <- ts(a, frequency=12, start=c(1980,1))
time series is obviously periodic, but seasonal decomposition is not working in R [closed]
Don't use as.ts(). Do this (note: the parameter is called start, not begin): a.ts <- ts(a, frequency=12, start=c(1980,1))
time series is obviously periodic, but seasonal decomposition is not working in R [closed] Don't use as.ts(). Do this (note: the parameter is called start, not begin): a.ts <- ts(a, frequency=12, start=c(1980,1))
time series is obviously periodic, but seasonal decomposition is not working in R [closed] Don't use as.ts(). Do this (note: the parameter is called start, not begin): a.ts <- ts(a, frequency=12, start=c(1980,1))
31,042
GLM for proportion data in r [closed]
The Stata command will show error because the glm statement used specifies a logistic regression with 1/0 as outcome. You should see an error message "note: PercentageFemale has noninteger values." However, your R command is correctly specified. Since you didn't provide data, let's start with a replicable example in R: library(MASS) data(menarche) out <- glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial(logit), data=menarche) summary(out) # Export into Stata data library(foreign) write.dta(menarche, "c:\\temp\\menarche.dta") And the outcome is: [PRINTOUT SNIPPED FOR SPACE] Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -21.22639 0.77068 -27.54 <2e-16 *** Age 1.63197 0.05895 27.68 <2e-16 *** --- [PRINTOUT SNIPPED FOR SPACE] Now, to replicate that in Stata. First let's get the error: gen pm = Menarche / Total glm pm Age, link(logit) family(binomial) Results: . glm pm Age, link(logit) family(binomial) note: pm has noninteger values [SNIPPED FOR SPACE] AIC = .5990425 Log likelihood = -5.488031242 BIC = -73.81271 ------------------------------------------------------------------------------ | OIM pm | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Age | 1.608169 .6215021 2.59 0.010 .390047 2.826291 _cons | -20.91168 8.111063 -2.58 0.010 -36.80907 -5.014291 ------------------------------------------------------------------------------ The results do not agree. And also notice the error message on line 2. To make Stata talk to the format of your data set, use blogit. Notice that while in R, it's the number of yes and number of no; in Stata, it's the number of yes followed by the number of total: blogit Menarche Total Age Here are the results that go with R: Logistic regression for grouped data Number of obs = 3918 LR chi2(1) = 3667.18 Prob > chi2 = 0.0000 Log likelihood = -819.65237 Pseudo R2 = 0.6911 ------------------------------------------------------------------------------ _outcome | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Age | 1.631968 .0589532 27.68 0.000 1.516422 1.747514 _cons | -21.22639 .7706859 -27.54 0.000 -22.73691 -19.71588 ------------------------------------------------------------------------------
GLM for proportion data in r [closed]
The Stata command will show error because the glm statement used specifies a logistic regression with 1/0 as outcome. You should see an error message "note: PercentageFemale has noninteger values." Ho
GLM for proportion data in r [closed] The Stata command will show error because the glm statement used specifies a logistic regression with 1/0 as outcome. You should see an error message "note: PercentageFemale has noninteger values." However, your R command is correctly specified. Since you didn't provide data, let's start with a replicable example in R: library(MASS) data(menarche) out <- glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial(logit), data=menarche) summary(out) # Export into Stata data library(foreign) write.dta(menarche, "c:\\temp\\menarche.dta") And the outcome is: [PRINTOUT SNIPPED FOR SPACE] Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -21.22639 0.77068 -27.54 <2e-16 *** Age 1.63197 0.05895 27.68 <2e-16 *** --- [PRINTOUT SNIPPED FOR SPACE] Now, to replicate that in Stata. First let's get the error: gen pm = Menarche / Total glm pm Age, link(logit) family(binomial) Results: . glm pm Age, link(logit) family(binomial) note: pm has noninteger values [SNIPPED FOR SPACE] AIC = .5990425 Log likelihood = -5.488031242 BIC = -73.81271 ------------------------------------------------------------------------------ | OIM pm | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Age | 1.608169 .6215021 2.59 0.010 .390047 2.826291 _cons | -20.91168 8.111063 -2.58 0.010 -36.80907 -5.014291 ------------------------------------------------------------------------------ The results do not agree. And also notice the error message on line 2. To make Stata talk to the format of your data set, use blogit. Notice that while in R, it's the number of yes and number of no; in Stata, it's the number of yes followed by the number of total: blogit Menarche Total Age Here are the results that go with R: Logistic regression for grouped data Number of obs = 3918 LR chi2(1) = 3667.18 Prob > chi2 = 0.0000 Log likelihood = -819.65237 Pseudo R2 = 0.6911 ------------------------------------------------------------------------------ _outcome | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Age | 1.631968 .0589532 27.68 0.000 1.516422 1.747514 _cons | -21.22639 .7706859 -27.54 0.000 -22.73691 -19.71588 ------------------------------------------------------------------------------
GLM for proportion data in r [closed] The Stata command will show error because the glm statement used specifies a logistic regression with 1/0 as outcome. You should see an error message "note: PercentageFemale has noninteger values." Ho
31,043
Cluster analysis on panel data
I would reshape wide so each year's data is its own variable and then cluster. This will group countries that follow similar timepaths for your 6 variables. Try something like this in Stata: reshape wide var@1 var@2 var@3 var@4 var@5 var@6, i(country) j(year); cluster kmeans var*1 var*2 var*3 var*4 var*6, k(4) name(test1)
Cluster analysis on panel data
I would reshape wide so each year's data is its own variable and then cluster. This will group countries that follow similar timepaths for your 6 variables. Try something like this in Stata: reshape w
Cluster analysis on panel data I would reshape wide so each year's data is its own variable and then cluster. This will group countries that follow similar timepaths for your 6 variables. Try something like this in Stata: reshape wide var@1 var@2 var@3 var@4 var@5 var@6, i(country) j(year); cluster kmeans var*1 var*2 var*3 var*4 var*6, k(4) name(test1)
Cluster analysis on panel data I would reshape wide so each year's data is its own variable and then cluster. This will group countries that follow similar timepaths for your 6 variables. Try something like this in Stata: reshape w
31,044
Cluster analysis on panel data
I have done this several times before (clustering with panel data) and my approach has been to aggregate information over time to create a dataset with one row per country. The aggregate variables could be means over the 4 years or min or max or something else. Results are difficult to interpret if you use every year as a data point for every country. For example, what does it mean if a country falls in each of the four clusters over the four years? This is simple to do with data.table in R. An example: require(data.table) ClusterData = data.table(PanelDataSet)[, list(MeanVar1 = mean(var1) , MeanVar2 = mean(var2) #create the aggregate variables ... ) , by = country] #name the variable to aggregate Then convert to a matrix (needed for the kmeans function in R) x = as.matrix(DLQData[,c("MeanVar1", "MeanVar2", ... ), with = FALSE]) Next, standardize the matrix using the scale() function. Then you are ready to cluster!
Cluster analysis on panel data
I have done this several times before (clustering with panel data) and my approach has been to aggregate information over time to create a dataset with one row per country. The aggregate variables cou
Cluster analysis on panel data I have done this several times before (clustering with panel data) and my approach has been to aggregate information over time to create a dataset with one row per country. The aggregate variables could be means over the 4 years or min or max or something else. Results are difficult to interpret if you use every year as a data point for every country. For example, what does it mean if a country falls in each of the four clusters over the four years? This is simple to do with data.table in R. An example: require(data.table) ClusterData = data.table(PanelDataSet)[, list(MeanVar1 = mean(var1) , MeanVar2 = mean(var2) #create the aggregate variables ... ) , by = country] #name the variable to aggregate Then convert to a matrix (needed for the kmeans function in R) x = as.matrix(DLQData[,c("MeanVar1", "MeanVar2", ... ), with = FALSE]) Next, standardize the matrix using the scale() function. Then you are ready to cluster!
Cluster analysis on panel data I have done this several times before (clustering with panel data) and my approach has been to aggregate information over time to create a dataset with one row per country. The aggregate variables cou
31,045
Cluster analysis on panel data
I saw something like this in the paper available at the following link: http://www.ersj.eu/repec/ers/papers/12_1_p2.pdf basically, they pooled the data and run a pca and subsequent cluster analysis by considering the observations as independent.
Cluster analysis on panel data
I saw something like this in the paper available at the following link: http://www.ersj.eu/repec/ers/papers/12_1_p2.pdf basically, they pooled the data and run a pca and subsequent cluster analysis by
Cluster analysis on panel data I saw something like this in the paper available at the following link: http://www.ersj.eu/repec/ers/papers/12_1_p2.pdf basically, they pooled the data and run a pca and subsequent cluster analysis by considering the observations as independent.
Cluster analysis on panel data I saw something like this in the paper available at the following link: http://www.ersj.eu/repec/ers/papers/12_1_p2.pdf basically, they pooled the data and run a pca and subsequent cluster analysis by
31,046
Does a big difference in sample sizes together with a difference in variances matter for a t-test (or permutation test)?
As far as I know, when the variances are not equal, I can use Welch–Satterthwaite equation, my question is can I still use this equation although there is really a big difference between two samples? Or is there a certain limit for the difference between two samples? The use of a scaled chi-square distribution with degrees of freedom from the Welch–Satterthwaite equation for the estimate of the variance of the difference in sample means is merely an approximation - the approximation is better under some circumstances than others. In fact, I think any approach to this problem will be approximate in one way or another; this is the famous Behrens-Fisher problem. As it says at the upper right in the link there, only approximate solutions are known. So the short answer is it's essentially never exactly correct -- and you can use it any time you like --- if you can tolerate the fact that your significance levels and p-values are inexact as a result; as for how far you can be out and still be happy to use it depends on you. Some people are much more tolerant of approximate significance levels and p-values than others* *(in the situations that I tend to use hypothesis tests, as long as I know the direction and some sense of a bound on the extent of the effect, I tend to be pretty tolerant of significance levels different from nominal; but if I were trying to publish a scientific result in a journal, I'd probably document the likely impact of the approximation - via simulation - in more detail.) So how does the approximation behave? All distributions are normal: The Welch test gives quite close to the right significance levels when the sample sizes are close to equal (on the other hand, the equal variance t-test also does fairly well when the sample sizes are equal, generally having only a moderate inflation of the significance level at smaller sample sizes). Type I error rates become smaller than nominal ('conservative') as the group sizes become more unequal. This affects both the Welch and the ordinary two sample test in the same direction. Power can also be low. Distributions are skew: If the distributions are skew, the effects on both significance level and power can be more substantial, and you must be much more wary (with skewness and unequal variances, I often lean toward using GLMs, as long as the variances seem likely to relate to the mean in an appropriate way - e.g. if spread increases with mean, a Gamma GLM may work well) This document discusses a small simulation study of the Welch test, the ordinary t-test and a permutation test under equal and unequal variances, and normal distributions and a skewed distributions. It recommended: the test with Welch correction is useful when the data are normal, sample sizes are small, and the variances are heterogeneous. This seems broadly consistent with what I've read at other times. However, in a later section, reading the details of the simulation results more deeply, they go on to say: avoid the Welch-corrected t-test in the most extreme cases of sample size inequality (lower power) Though that advice is based on very small sample sizes in the smaller sample. It was not carried out at the sort of sample sizes you have. [When in doubt about the likely behavior of some procedure in some particular circumstance, I like run my own simulations. It's so easy in R that it's often a matter of only a couple of minutes - including coding, simulation runs and analysis of results - to get a good idea of the properties).] I think that with one very large sample, and one medium sample size, as you have, there should still be relatively little problem applying Welch test. I'll double check with a simulation, right now. My simulation results: I used your sample sizes. These simulations are under normality. First -- how badly is the test affected when $H_0$ is true? a. The group with the large sample has 3 times the population standard deviation of the small one. The Welch test achieves very close to the nominal type 1 error rate. The equal-variance t-test really doesn't; its significance levels are very very low, almost zero. b. The group with the small sample has 3 times the population standard deviation of the large on. The Welch test achieves very close to the nominal type 1 error rate. The equal-variance t-test doesn't; its significance levels are inflated. In fact the equal-variance test was so badly affected, that I wouldn't use it at all; there would be little point in comparing power without adjusting for the difference in the significance levels. With such a large sample size (meaning the uncertainty in its mean is relatively very small), another possibility presents itself: to do a one-sample test against the mean of the large sample as if it were fixed. It turns out that when the smaller population standard deviation was in the larger sample, significance levels were very close to nominal. It works relatively well in this case. When the larger population standard deviation was in the larger sample, type 1 error rates were somewhat inflated (this looks to be the opposite direction from the effect on the Welch test). A discussion of permutation tests AdamO and I got into a discussion about an issue I have with permutation tests for this situation (different population variances in a test for location difference). He asked me for a simulation, so I'll do it here. The link to the paper I gave above also does simulations for the permutation test that seem to be broadly consistent with my findings. The basic problem is in the two sample test of location with unequal variance, under the null the observations are not exchangeable. We cannot interchange labels without significantly affecting the results. For example, imagine we had 334 observations where there was a 90% chance of having an $A$ label, and coming from a normal distribution with $\sigma=1$ and a 10% chance of having a $B$ label and coming from a normal distribution with $\sigma=3$. Further imagine that $\mu_A=\mu_B$. The observations are not exchangeable - in spite of most observations coming from sample $A$, the largest and smallest few observations are much more likely to have come from sample B than sample A and the middle observations are much more likely to have come from sample A (far more than the 90% chance they should have in the observations were exchangeable). This issue affects the distribution of p-values under the null. (However, if the sample sizes are equal, the effect is quite small.) Let's see this with a simulation, as requested. My code isn't especially fancy but it gets the job done. I simulate equal means for the sample sizes mentioned in the question, under three cases: 1) equal variance 2) the larger sample comes from a population with larger standard deviation (3 times as big as the other) 3) the smaller sample comes from a population with larger variance (3 times as big) One of the things we're interested in with hypothesis tests is 'if I keep sampling these populations and do this test many times, what is my type I error rate'? We can compute this here. The procedure consists of drawing normal samples fitting the above conditions, with the same mean, and then computing the quantile of the sample in the permutation distribution. Because we do this many times, this involves simulating many samples, and then within each sample, resampling many relabellings of the data to get the permutation distribution conditional on that sample. For every simulated sample I get a single p-value (by comparing the difference in means on the original sample with the permutation distribution for that specific sample). With many such samples, I get a distribution of p-values. This tell us the probability, given two populations with the same mean, we are to draw a sample where we reject the null (this is the Type I error rate). Here's the code for one such simulation (case 2 above): nperms <- 3000; nsamps <- 3000 n1 <- 310; n2 <- 34; ni12 <- 1/n1+1/n2 s1 <- 3; s2 <- 1 simpv <- function(n1,n2,s1,s2,nperms) { x <- rnorm(n1,s = s1);y <- rnorm(n2,s = s2) sdiff <- mean(x)-mean(y) xy <- c(x,y) sn1 <- sum(xy)/n1 diffs <- replicate(nperms,sn1-sum(sample(xy,n2))*ni12) sum(sdiff<diffs)/nperms } pvs1big <- replicate(nsamps,simpv(n1,n2,s1,s2,nperms)) For the other two cases the code is the same, except I changed the s1= and s2= (and also changed what I stored the p-values in). For case 1, s1=1; s2=1 and for case 3 s1=1; s2=3 Now under the null, the distribution of p-values should be essentially uniform or we don't have the advertised type I error rate. (As performed the p-values are effectively for 1 tailed tests, but you can see what would happen for a two tailed test by looking at both ends of the distribution of p-values. They happen to be symmetric, so it doesn't matter.) Here are the results. Case 1 is at the top left. In this case the values are exchangeable, and we see a pretty uniform-looking distribution of p-values. Case 2 is at the top right. In this case, the larger sample has the larger variance and we see that the p-values are concentrated toward the center. We are much less likely to reject a null case at typical significance levels than we think we should. That is, the type I error rate is much lower than the nominal rate. Case 3 is at the bottom right. In this case, the smaller sample has the larger variance, and we see that the p-values are concentrated at the two ends - under the null, we are much more likely to reject than we think we should. The significance level is much higher than the nominal rate. Discussion of the Behrens Fisher problem in Good The Good Book mentioned by AdamO does discuss this problem on p54-57. He refers to a result of Romano that states that the permutation test is asymptotically exact providing they have equal sample sizes. Here, of course, they don't - rather than 50-50 they're roughly 90-10. And when I simulate the equal sample size case (I tried n1=n2=34) the p-value distribution wasn't far off uniform** -- it was off a small amount but not enough to worry about. This is pretty well known and borne out by a number of published simulation studies. **(I haven't included the code, but it's trivial to adapt the above code to do it - just change n1 to be 34) Good says the behavior in the equal sample size case works down to quite small sample sizes. I believe him! What about a bootstrap test? So what if we were to try a bootstrap test instead of a permutation test? With a bootstrap test*, my objections no longer hold. *e.g. one approach might be to construct a CI for the difference in means and reject at the 5% level if a 95% interval for the mean doesn't include 0 With a bootstrap test, we're no longer required to be able to relabel across samples -- we can resample within the samples we have and still get a suitable CI for the difference in means. With some of the usual procedures to improve the properties of the bootstrap, such a test might work very well at these sample sizes.
Does a big difference in sample sizes together with a difference in variances matter for a t-test (o
As far as I know, when the variances are not equal, I can use Welch–Satterthwaite equation, my question is can I still use this equation although there is really a big difference between two samples?
Does a big difference in sample sizes together with a difference in variances matter for a t-test (or permutation test)? As far as I know, when the variances are not equal, I can use Welch–Satterthwaite equation, my question is can I still use this equation although there is really a big difference between two samples? Or is there a certain limit for the difference between two samples? The use of a scaled chi-square distribution with degrees of freedom from the Welch–Satterthwaite equation for the estimate of the variance of the difference in sample means is merely an approximation - the approximation is better under some circumstances than others. In fact, I think any approach to this problem will be approximate in one way or another; this is the famous Behrens-Fisher problem. As it says at the upper right in the link there, only approximate solutions are known. So the short answer is it's essentially never exactly correct -- and you can use it any time you like --- if you can tolerate the fact that your significance levels and p-values are inexact as a result; as for how far you can be out and still be happy to use it depends on you. Some people are much more tolerant of approximate significance levels and p-values than others* *(in the situations that I tend to use hypothesis tests, as long as I know the direction and some sense of a bound on the extent of the effect, I tend to be pretty tolerant of significance levels different from nominal; but if I were trying to publish a scientific result in a journal, I'd probably document the likely impact of the approximation - via simulation - in more detail.) So how does the approximation behave? All distributions are normal: The Welch test gives quite close to the right significance levels when the sample sizes are close to equal (on the other hand, the equal variance t-test also does fairly well when the sample sizes are equal, generally having only a moderate inflation of the significance level at smaller sample sizes). Type I error rates become smaller than nominal ('conservative') as the group sizes become more unequal. This affects both the Welch and the ordinary two sample test in the same direction. Power can also be low. Distributions are skew: If the distributions are skew, the effects on both significance level and power can be more substantial, and you must be much more wary (with skewness and unequal variances, I often lean toward using GLMs, as long as the variances seem likely to relate to the mean in an appropriate way - e.g. if spread increases with mean, a Gamma GLM may work well) This document discusses a small simulation study of the Welch test, the ordinary t-test and a permutation test under equal and unequal variances, and normal distributions and a skewed distributions. It recommended: the test with Welch correction is useful when the data are normal, sample sizes are small, and the variances are heterogeneous. This seems broadly consistent with what I've read at other times. However, in a later section, reading the details of the simulation results more deeply, they go on to say: avoid the Welch-corrected t-test in the most extreme cases of sample size inequality (lower power) Though that advice is based on very small sample sizes in the smaller sample. It was not carried out at the sort of sample sizes you have. [When in doubt about the likely behavior of some procedure in some particular circumstance, I like run my own simulations. It's so easy in R that it's often a matter of only a couple of minutes - including coding, simulation runs and analysis of results - to get a good idea of the properties).] I think that with one very large sample, and one medium sample size, as you have, there should still be relatively little problem applying Welch test. I'll double check with a simulation, right now. My simulation results: I used your sample sizes. These simulations are under normality. First -- how badly is the test affected when $H_0$ is true? a. The group with the large sample has 3 times the population standard deviation of the small one. The Welch test achieves very close to the nominal type 1 error rate. The equal-variance t-test really doesn't; its significance levels are very very low, almost zero. b. The group with the small sample has 3 times the population standard deviation of the large on. The Welch test achieves very close to the nominal type 1 error rate. The equal-variance t-test doesn't; its significance levels are inflated. In fact the equal-variance test was so badly affected, that I wouldn't use it at all; there would be little point in comparing power without adjusting for the difference in the significance levels. With such a large sample size (meaning the uncertainty in its mean is relatively very small), another possibility presents itself: to do a one-sample test against the mean of the large sample as if it were fixed. It turns out that when the smaller population standard deviation was in the larger sample, significance levels were very close to nominal. It works relatively well in this case. When the larger population standard deviation was in the larger sample, type 1 error rates were somewhat inflated (this looks to be the opposite direction from the effect on the Welch test). A discussion of permutation tests AdamO and I got into a discussion about an issue I have with permutation tests for this situation (different population variances in a test for location difference). He asked me for a simulation, so I'll do it here. The link to the paper I gave above also does simulations for the permutation test that seem to be broadly consistent with my findings. The basic problem is in the two sample test of location with unequal variance, under the null the observations are not exchangeable. We cannot interchange labels without significantly affecting the results. For example, imagine we had 334 observations where there was a 90% chance of having an $A$ label, and coming from a normal distribution with $\sigma=1$ and a 10% chance of having a $B$ label and coming from a normal distribution with $\sigma=3$. Further imagine that $\mu_A=\mu_B$. The observations are not exchangeable - in spite of most observations coming from sample $A$, the largest and smallest few observations are much more likely to have come from sample B than sample A and the middle observations are much more likely to have come from sample A (far more than the 90% chance they should have in the observations were exchangeable). This issue affects the distribution of p-values under the null. (However, if the sample sizes are equal, the effect is quite small.) Let's see this with a simulation, as requested. My code isn't especially fancy but it gets the job done. I simulate equal means for the sample sizes mentioned in the question, under three cases: 1) equal variance 2) the larger sample comes from a population with larger standard deviation (3 times as big as the other) 3) the smaller sample comes from a population with larger variance (3 times as big) One of the things we're interested in with hypothesis tests is 'if I keep sampling these populations and do this test many times, what is my type I error rate'? We can compute this here. The procedure consists of drawing normal samples fitting the above conditions, with the same mean, and then computing the quantile of the sample in the permutation distribution. Because we do this many times, this involves simulating many samples, and then within each sample, resampling many relabellings of the data to get the permutation distribution conditional on that sample. For every simulated sample I get a single p-value (by comparing the difference in means on the original sample with the permutation distribution for that specific sample). With many such samples, I get a distribution of p-values. This tell us the probability, given two populations with the same mean, we are to draw a sample where we reject the null (this is the Type I error rate). Here's the code for one such simulation (case 2 above): nperms <- 3000; nsamps <- 3000 n1 <- 310; n2 <- 34; ni12 <- 1/n1+1/n2 s1 <- 3; s2 <- 1 simpv <- function(n1,n2,s1,s2,nperms) { x <- rnorm(n1,s = s1);y <- rnorm(n2,s = s2) sdiff <- mean(x)-mean(y) xy <- c(x,y) sn1 <- sum(xy)/n1 diffs <- replicate(nperms,sn1-sum(sample(xy,n2))*ni12) sum(sdiff<diffs)/nperms } pvs1big <- replicate(nsamps,simpv(n1,n2,s1,s2,nperms)) For the other two cases the code is the same, except I changed the s1= and s2= (and also changed what I stored the p-values in). For case 1, s1=1; s2=1 and for case 3 s1=1; s2=3 Now under the null, the distribution of p-values should be essentially uniform or we don't have the advertised type I error rate. (As performed the p-values are effectively for 1 tailed tests, but you can see what would happen for a two tailed test by looking at both ends of the distribution of p-values. They happen to be symmetric, so it doesn't matter.) Here are the results. Case 1 is at the top left. In this case the values are exchangeable, and we see a pretty uniform-looking distribution of p-values. Case 2 is at the top right. In this case, the larger sample has the larger variance and we see that the p-values are concentrated toward the center. We are much less likely to reject a null case at typical significance levels than we think we should. That is, the type I error rate is much lower than the nominal rate. Case 3 is at the bottom right. In this case, the smaller sample has the larger variance, and we see that the p-values are concentrated at the two ends - under the null, we are much more likely to reject than we think we should. The significance level is much higher than the nominal rate. Discussion of the Behrens Fisher problem in Good The Good Book mentioned by AdamO does discuss this problem on p54-57. He refers to a result of Romano that states that the permutation test is asymptotically exact providing they have equal sample sizes. Here, of course, they don't - rather than 50-50 they're roughly 90-10. And when I simulate the equal sample size case (I tried n1=n2=34) the p-value distribution wasn't far off uniform** -- it was off a small amount but not enough to worry about. This is pretty well known and borne out by a number of published simulation studies. **(I haven't included the code, but it's trivial to adapt the above code to do it - just change n1 to be 34) Good says the behavior in the equal sample size case works down to quite small sample sizes. I believe him! What about a bootstrap test? So what if we were to try a bootstrap test instead of a permutation test? With a bootstrap test*, my objections no longer hold. *e.g. one approach might be to construct a CI for the difference in means and reject at the 5% level if a 95% interval for the mean doesn't include 0 With a bootstrap test, we're no longer required to be able to relabel across samples -- we can resample within the samples we have and still get a suitable CI for the difference in means. With some of the usual procedures to improve the properties of the bootstrap, such a test might work very well at these sample sizes.
Does a big difference in sample sizes together with a difference in variances matter for a t-test (o As far as I know, when the variances are not equal, I can use Welch–Satterthwaite equation, my question is can I still use this equation although there is really a big difference between two samples?
31,047
Does a big difference in sample sizes together with a difference in variances matter for a t-test (or permutation test)?
One option, prompted by @Glen_b's response is a permutation test in which exposures (the group labels) are randomly permuted to obtain the sampling distribution of the test statistic under the null hypothesis, regardless of the parametric distribution of the data themselves. ## example of permutation test set.seed(1) men <- rexp(30, 1.3) women <- rexp(300, 0.8) stacked <- c(men, women) labels <- c(rep('m', 30), rep('w', 300)) o.diff <- diff(tapply(stacked, labels, mean)) d.null <- replicate(5000, { diff(tapply(stacked, sample(labels), mean)) }) b <- hist(d.null, plot=FALSE) col <- ifelse(b$breaks > o.diff, 'green', 'white') plot(b, col=col) text(o.diff, par()$yaxp[2], paste0('P - value = ', mean(d.null > o.diff))) abline(v=o.diff)
Does a big difference in sample sizes together with a difference in variances matter for a t-test (o
One option, prompted by @Glen_b's response is a permutation test in which exposures (the group labels) are randomly permuted to obtain the sampling distribution of the test statistic under the null hy
Does a big difference in sample sizes together with a difference in variances matter for a t-test (or permutation test)? One option, prompted by @Glen_b's response is a permutation test in which exposures (the group labels) are randomly permuted to obtain the sampling distribution of the test statistic under the null hypothesis, regardless of the parametric distribution of the data themselves. ## example of permutation test set.seed(1) men <- rexp(30, 1.3) women <- rexp(300, 0.8) stacked <- c(men, women) labels <- c(rep('m', 30), rep('w', 300)) o.diff <- diff(tapply(stacked, labels, mean)) d.null <- replicate(5000, { diff(tapply(stacked, sample(labels), mean)) }) b <- hist(d.null, plot=FALSE) col <- ifelse(b$breaks > o.diff, 'green', 'white') plot(b, col=col) text(o.diff, par()$yaxp[2], paste0('P - value = ', mean(d.null > o.diff))) abline(v=o.diff)
Does a big difference in sample sizes together with a difference in variances matter for a t-test (o One option, prompted by @Glen_b's response is a permutation test in which exposures (the group labels) are randomly permuted to obtain the sampling distribution of the test statistic under the null hy
31,048
How do statisticians determine which distribution is appropriate for different statistical tests?
The full answer to your question would be a full semester math-theory statistics course (which would be a good idea for you to take if you are really interested). But a short and partial set of answers are: Generally we start with the normal distribution, it has been found to be a reasonable approximation for many real world situations and the Central Limit theorem (and others) tell us that it is an even better approximation when looking at the means of simple random samples (bigger sample size leads to better approximation by the normal). So the normal is often the default distribution to consider if there is not a reason to believe that it will not be a reasonable approximation. Though with modern computers it is easier now to use non-parametric or other tools and we do not need to depend on the normal as much (but history/inertia/etc. keeps us using normal based methods). If you square a variable that comes from a standard normal distribution then it follows a Chi-squared distribution. If you add together variables from a Chi-squared you get another Chi-squared (degrees of freedom change), so that means that the variance (scaled) follows a Chi-squared. It also works out that a function of the likelihood ratio follows a Chi-squared distribution asymptotically if the null is true and other assumptions hold. A standard normal divided by the square root of a chi-squared (and some scaling parameters) follows a t-distribution, so the common t-statistic (under the null hypothesis) follows the t. The ratio of 2 Chis-squareds (divided by degrees of freedom and other considerations) follows an F-distribution. The anova F tests are based on the ratio of 2 estimates of the same variance (under the null) and since variances follow a Chi-squared, the ratio follows an F (under the null and assumptions holding). Smart people worked out these rules so that the rest of us can apply them. A full math/stat course will give more of the history and derivations (and possibly more of the alternatives), this was just meant as a quick overview of the more common tests and distributions.
How do statisticians determine which distribution is appropriate for different statistical tests?
The full answer to your question would be a full semester math-theory statistics course (which would be a good idea for you to take if you are really interested). But a short and partial set of answer
How do statisticians determine which distribution is appropriate for different statistical tests? The full answer to your question would be a full semester math-theory statistics course (which would be a good idea for you to take if you are really interested). But a short and partial set of answers are: Generally we start with the normal distribution, it has been found to be a reasonable approximation for many real world situations and the Central Limit theorem (and others) tell us that it is an even better approximation when looking at the means of simple random samples (bigger sample size leads to better approximation by the normal). So the normal is often the default distribution to consider if there is not a reason to believe that it will not be a reasonable approximation. Though with modern computers it is easier now to use non-parametric or other tools and we do not need to depend on the normal as much (but history/inertia/etc. keeps us using normal based methods). If you square a variable that comes from a standard normal distribution then it follows a Chi-squared distribution. If you add together variables from a Chi-squared you get another Chi-squared (degrees of freedom change), so that means that the variance (scaled) follows a Chi-squared. It also works out that a function of the likelihood ratio follows a Chi-squared distribution asymptotically if the null is true and other assumptions hold. A standard normal divided by the square root of a chi-squared (and some scaling parameters) follows a t-distribution, so the common t-statistic (under the null hypothesis) follows the t. The ratio of 2 Chis-squareds (divided by degrees of freedom and other considerations) follows an F-distribution. The anova F tests are based on the ratio of 2 estimates of the same variance (under the null) and since variances follow a Chi-squared, the ratio follows an F (under the null and assumptions holding). Smart people worked out these rules so that the rest of us can apply them. A full math/stat course will give more of the history and derivations (and possibly more of the alternatives), this was just meant as a quick overview of the more common tests and distributions.
How do statisticians determine which distribution is appropriate for different statistical tests? The full answer to your question would be a full semester math-theory statistics course (which would be a good idea for you to take if you are really interested). But a short and partial set of answer
31,049
How do statisticians determine which distribution is appropriate for different statistical tests?
A different way to answer your question is the following sequential thinking that I would like to illustrate with a simple example: 1) Whats the null hypothesis related to the question of interest? E.g. in US, the average income is $6000 per month. 2) How can we measure the deviance from the null hypothesis based on available data? First try: $T =$ Average income. The further away from 6000, the less plausible the null hypothesis is and the more we should reject it. 3) Find the distribution of $T$ if the null hypothesis is true. This "null distribution" is the basis for the test decision. In our example, if the sample is large, the Central Limit Theorem tells us that $T$ is approximately normally distributed with mean 6000 and standard deviation $\sigma/\sqrt{n}$, where $\sigma$ is the true standard deviation of the income in US. We know $n$ and $\sigma$ can be estimated by the sample standard deviation $\hat \sigma$. Principally, we could now lean back and use this result to find test decisions. However, because we statisticians are nice, we usually try to modify the test statistic to keep the null distribution free of as much data dependent information as possible. In our simple example, we could use $$ T' = (T-6000)/(\hat \sigma/\sqrt{n}) $$ instead of $T$. This modified test statistic $T'$ is always approximately standard normal if the null hypothesis is true. No matter the sample size, the hypothesised mean and the standard deviation, the test decision is always based on the same critical values (like $\pm 1.96$). This is the famous one-sample Z-test.
How do statisticians determine which distribution is appropriate for different statistical tests?
A different way to answer your question is the following sequential thinking that I would like to illustrate with a simple example: 1) Whats the null hypothesis related to the question of interest? E.
How do statisticians determine which distribution is appropriate for different statistical tests? A different way to answer your question is the following sequential thinking that I would like to illustrate with a simple example: 1) Whats the null hypothesis related to the question of interest? E.g. in US, the average income is $6000 per month. 2) How can we measure the deviance from the null hypothesis based on available data? First try: $T =$ Average income. The further away from 6000, the less plausible the null hypothesis is and the more we should reject it. 3) Find the distribution of $T$ if the null hypothesis is true. This "null distribution" is the basis for the test decision. In our example, if the sample is large, the Central Limit Theorem tells us that $T$ is approximately normally distributed with mean 6000 and standard deviation $\sigma/\sqrt{n}$, where $\sigma$ is the true standard deviation of the income in US. We know $n$ and $\sigma$ can be estimated by the sample standard deviation $\hat \sigma$. Principally, we could now lean back and use this result to find test decisions. However, because we statisticians are nice, we usually try to modify the test statistic to keep the null distribution free of as much data dependent information as possible. In our simple example, we could use $$ T' = (T-6000)/(\hat \sigma/\sqrt{n}) $$ instead of $T$. This modified test statistic $T'$ is always approximately standard normal if the null hypothesis is true. No matter the sample size, the hypothesised mean and the standard deviation, the test decision is always based on the same critical values (like $\pm 1.96$). This is the famous one-sample Z-test.
How do statisticians determine which distribution is appropriate for different statistical tests? A different way to answer your question is the following sequential thinking that I would like to illustrate with a simple example: 1) Whats the null hypothesis related to the question of interest? E.
31,050
How do statisticians determine which distribution is appropriate for different statistical tests?
There are only three reality based distributions. (1) The Binomial (2) The Multinomial (3) Abraham De Moivre's approximator to the binomial. The other distributions are 'derived' expressions with very limited dynamic range and very little contact with reality. Example. A statistician will tell you your data fits to a Poisson Distribution. He will actually believe the Poisson distribution has some kind of 'stand alone' reality. Truth is, the Poisson Distribution approximates the binomial for very small and very large amounts of skew. Now that we all have computers there is no reason to call upon approximators. But, sadly, old habits die hard.
How do statisticians determine which distribution is appropriate for different statistical tests?
There are only three reality based distributions. (1) The Binomial (2) The Multinomial (3) Abraham De Moivre's approximator to the binomial. The other distributions are 'derived' expressions with very
How do statisticians determine which distribution is appropriate for different statistical tests? There are only three reality based distributions. (1) The Binomial (2) The Multinomial (3) Abraham De Moivre's approximator to the binomial. The other distributions are 'derived' expressions with very limited dynamic range and very little contact with reality. Example. A statistician will tell you your data fits to a Poisson Distribution. He will actually believe the Poisson distribution has some kind of 'stand alone' reality. Truth is, the Poisson Distribution approximates the binomial for very small and very large amounts of skew. Now that we all have computers there is no reason to call upon approximators. But, sadly, old habits die hard.
How do statisticians determine which distribution is appropriate for different statistical tests? There are only three reality based distributions. (1) The Binomial (2) The Multinomial (3) Abraham De Moivre's approximator to the binomial. The other distributions are 'derived' expressions with very
31,051
Non-normality in residuals
One way you can add a "test-like flavour" to your graph is to add confidence bounds around them. In Stata I would do this like so: sysuse nlsw88, clear gen lnw = ln(wage) reg lnw i.race grade c.ttl_exp##c.ttl_exp union predict resid if e(sample), resid qenvnormal resid, mean(0) sd(`e(rmse)') overall reps(20000) gen(lb ub) qplot resid lb ub, ms(oh none ..) c(. l l) /// lc(gs10 ..) legend(off) ytitle("residual") /// trscale(`e(rmse)' * invnormal(@)) /// xtitle(Normal quantiles)
Non-normality in residuals
One way you can add a "test-like flavour" to your graph is to add confidence bounds around them. In Stata I would do this like so: sysuse nlsw88, clear gen lnw = ln(wage) reg lnw i.race grade c.ttl_e
Non-normality in residuals One way you can add a "test-like flavour" to your graph is to add confidence bounds around them. In Stata I would do this like so: sysuse nlsw88, clear gen lnw = ln(wage) reg lnw i.race grade c.ttl_exp##c.ttl_exp union predict resid if e(sample), resid qenvnormal resid, mean(0) sd(`e(rmse)') overall reps(20000) gen(lb ub) qplot resid lb ub, ms(oh none ..) c(. l l) /// lc(gs10 ..) legend(off) ytitle("residual") /// trscale(`e(rmse)' * invnormal(@)) /// xtitle(Normal quantiles)
Non-normality in residuals One way you can add a "test-like flavour" to your graph is to add confidence bounds around them. In Stata I would do this like so: sysuse nlsw88, clear gen lnw = ln(wage) reg lnw i.race grade c.ttl_e
31,052
Non-normality in residuals
One thing to keep in mind when examining these qq plots is that the tails will tend to deviate from the line even if the underlying distribution is truly normal and no matter how big the N is. This is implied in Maarten's answer. This is because as N gets larger and larger the tails will be farther and farther out and rarer and rarer events. There will therefore always be very little data in the tails and they will always be much more variable. If the bulk of your line is where expected and only the tails deviate then you can generally ignore them. One way I use to help students learn how to assess their qq plots for normality is generate random samples from a distribution known to be normal and examine those samples. There are exercises where they generate samples of various sizes to see what happens as N changes and also ones where they take a real sample distribution and compare it to random samples of the same size. The TeachingDemos package of R has a test for normality that uses a similar kind of technique. # R example - change the 1000 to whatever N you would like to examine # run several times y <- rnorm(1000); qqnorm(y); qqline(y)
Non-normality in residuals
One thing to keep in mind when examining these qq plots is that the tails will tend to deviate from the line even if the underlying distribution is truly normal and no matter how big the N is. This i
Non-normality in residuals One thing to keep in mind when examining these qq plots is that the tails will tend to deviate from the line even if the underlying distribution is truly normal and no matter how big the N is. This is implied in Maarten's answer. This is because as N gets larger and larger the tails will be farther and farther out and rarer and rarer events. There will therefore always be very little data in the tails and they will always be much more variable. If the bulk of your line is where expected and only the tails deviate then you can generally ignore them. One way I use to help students learn how to assess their qq plots for normality is generate random samples from a distribution known to be normal and examine those samples. There are exercises where they generate samples of various sizes to see what happens as N changes and also ones where they take a real sample distribution and compare it to random samples of the same size. The TeachingDemos package of R has a test for normality that uses a similar kind of technique. # R example - change the 1000 to whatever N you would like to examine # run several times y <- rnorm(1000); qqnorm(y); qqline(y)
Non-normality in residuals One thing to keep in mind when examining these qq plots is that the tails will tend to deviate from the line even if the underlying distribution is truly normal and no matter how big the N is. This i
31,053
Why is the decision boundary for K-means clustering linear?
There are linear and non-linear classification problems. In a linear problem, you can draw lines, planes or hyperplanes (depending on the number of dimensions in your problem) in order to classify all your data points correctly. In a non-linear problem, you can't do that. As you know, lines, planes or hyperplanes are called decision boundaries. K-means clustering produces a Voronoi diagram which consists of linear decision boundaries. For example, this presentation depicts the clusters, the decision boundaries (slide 34) and describes briefly the Voronoi diagrams, so you can see the similarities. On the other hand, neural networks depending on the number of hidden layers are able to deal with problems with non-linear decision boundaries. Finally, support vector machines in principle are capable of dealing with linear problems since they depend on finding hyperplanes. However, using the kernel trick, support vector machines can transform a non-linear problem into a linear problem (in a higher dimensional space)
Why is the decision boundary for K-means clustering linear?
There are linear and non-linear classification problems. In a linear problem, you can draw lines, planes or hyperplanes (depending on the number of dimensions in your problem) in order to classify all
Why is the decision boundary for K-means clustering linear? There are linear and non-linear classification problems. In a linear problem, you can draw lines, planes or hyperplanes (depending on the number of dimensions in your problem) in order to classify all your data points correctly. In a non-linear problem, you can't do that. As you know, lines, planes or hyperplanes are called decision boundaries. K-means clustering produces a Voronoi diagram which consists of linear decision boundaries. For example, this presentation depicts the clusters, the decision boundaries (slide 34) and describes briefly the Voronoi diagrams, so you can see the similarities. On the other hand, neural networks depending on the number of hidden layers are able to deal with problems with non-linear decision boundaries. Finally, support vector machines in principle are capable of dealing with linear problems since they depend on finding hyperplanes. However, using the kernel trick, support vector machines can transform a non-linear problem into a linear problem (in a higher dimensional space)
Why is the decision boundary for K-means clustering linear? There are linear and non-linear classification problems. In a linear problem, you can draw lines, planes or hyperplanes (depending on the number of dimensions in your problem) in order to classify all
31,054
Why is the decision boundary for K-means clustering linear?
points on decision boundary will be equidistant from both the centers C1 and C2. So you have
Why is the decision boundary for K-means clustering linear?
points on decision boundary will be equidistant from both the centers C1 and C2. So you have
Why is the decision boundary for K-means clustering linear? points on decision boundary will be equidistant from both the centers C1 and C2. So you have
Why is the decision boundary for K-means clustering linear? points on decision boundary will be equidistant from both the centers C1 and C2. So you have
31,055
Multivariate Laplace distribution
It is often the case that there's more than one multivariate choice that seems to correspond to some univariate density - there's not always a natural one; hence we have papers with titles like "A multivariate exponential distribution", rather than "The multivariate exponential distribution". The same is likely to be the case for the Laplace- it depends on which properties you wish to carry over and which properties are not so crucial, as well as what kinds of dependence structures you want to support. There's an example of one such multivariate distribution in this paper - Torbjørn Eltoft, Taesu Kim, and Te-Won Lee (2006) On the Multivariate Laplace Distribution IEEE Signal Processing Letters, Vol. 13, No. 5, May - which in the paper takes this form (I have not checked their algebra!): $$p_\mathbf{Y}(\mathbf{y}) = \frac{1}{(2\pi)^{(d/2)}} \frac{2}{\lambda} \frac{K_{(d/2)-1}\left(\sqrt{\frac{2}{\lambda}q(\mathbf{y})}\right)}{\left(\sqrt{\frac{\lambda}{2}q(\mathbf{y})}\right)^{(d/2)-1}}$$ where $$q(\mathbf{y})= (\mathbf{y-\mu})^t\Gamma^{-1}(\mathbf{y-\mu})$$ with $\mu$ being the location vector, positive definite $\Gamma$ taking the role of a multivariate 'scale' akin to a variance-covariance matrix and where $K_m(x)$ denotes the modified Bessel function of the second kind and order $m$, evaluated at $x$. There are three different Multivariate Laplace distributions mentioned on page 2 of in this paper (pdf), which itself discusses an asymmetric multivariate Laplace distribution If you're only looking to have Laplace marginal distributions, and want general forms of association between them, you may want to look into copulas. Besides some introductory papers (some are mentioned there), the books by Nelsen and by Joe are fairly readable.
Multivariate Laplace distribution
It is often the case that there's more than one multivariate choice that seems to correspond to some univariate density - there's not always a natural one; hence we have papers with titles like "A mul
Multivariate Laplace distribution It is often the case that there's more than one multivariate choice that seems to correspond to some univariate density - there's not always a natural one; hence we have papers with titles like "A multivariate exponential distribution", rather than "The multivariate exponential distribution". The same is likely to be the case for the Laplace- it depends on which properties you wish to carry over and which properties are not so crucial, as well as what kinds of dependence structures you want to support. There's an example of one such multivariate distribution in this paper - Torbjørn Eltoft, Taesu Kim, and Te-Won Lee (2006) On the Multivariate Laplace Distribution IEEE Signal Processing Letters, Vol. 13, No. 5, May - which in the paper takes this form (I have not checked their algebra!): $$p_\mathbf{Y}(\mathbf{y}) = \frac{1}{(2\pi)^{(d/2)}} \frac{2}{\lambda} \frac{K_{(d/2)-1}\left(\sqrt{\frac{2}{\lambda}q(\mathbf{y})}\right)}{\left(\sqrt{\frac{\lambda}{2}q(\mathbf{y})}\right)^{(d/2)-1}}$$ where $$q(\mathbf{y})= (\mathbf{y-\mu})^t\Gamma^{-1}(\mathbf{y-\mu})$$ with $\mu$ being the location vector, positive definite $\Gamma$ taking the role of a multivariate 'scale' akin to a variance-covariance matrix and where $K_m(x)$ denotes the modified Bessel function of the second kind and order $m$, evaluated at $x$. There are three different Multivariate Laplace distributions mentioned on page 2 of in this paper (pdf), which itself discusses an asymmetric multivariate Laplace distribution If you're only looking to have Laplace marginal distributions, and want general forms of association between them, you may want to look into copulas. Besides some introductory papers (some are mentioned there), the books by Nelsen and by Joe are fairly readable.
Multivariate Laplace distribution It is often the case that there's more than one multivariate choice that seems to correspond to some univariate density - there's not always a natural one; hence we have papers with titles like "A mul
31,056
Multivariate Laplace distribution
For those who wish to see how the multivariate Laplace looks like in the two-dimensional case, I've attached a histogram of Laplace with mean 0 and scale 1 and identity covariance, using Wolfram Mathematica code The generating code is: y= RandomVariate[LaplaceDistribution[],100000]; x= RandomVariate[LaplaceDistribution[],100000]; Histogram3D[Thread[{x,y}],{75,75}, PDF]
Multivariate Laplace distribution
For those who wish to see how the multivariate Laplace looks like in the two-dimensional case, I've attached a histogram of Laplace with mean 0 and scale 1 and identity covariance, using Wolfram Mathe
Multivariate Laplace distribution For those who wish to see how the multivariate Laplace looks like in the two-dimensional case, I've attached a histogram of Laplace with mean 0 and scale 1 and identity covariance, using Wolfram Mathematica code The generating code is: y= RandomVariate[LaplaceDistribution[],100000]; x= RandomVariate[LaplaceDistribution[],100000]; Histogram3D[Thread[{x,y}],{75,75}, PDF]
Multivariate Laplace distribution For those who wish to see how the multivariate Laplace looks like in the two-dimensional case, I've attached a histogram of Laplace with mean 0 and scale 1 and identity covariance, using Wolfram Mathe
31,057
Multivariate Laplace distribution
The following result is useful to understand how the multivariate Laplace looks like: The symmetric multivariate Laplace with covariance matrix $\Sigma$ can be represented as $X\simeq \sqrt{W} \times Y$, where $Y\simeq \mathcal{N}_d(0,\Sigma)$ is multivariate Gaussian with covariance $\Sigma$, and $W$ is an exponential random variable of mean 1, and independent of $Y$ (cf. Theorem 6.3.1 from this book). Note that the 2 components of a bivariate Laplace are not independent (even in the case where correlation $\rho=0$). import random import numpy as np rho = .8 Sigma = [[1,rho], [rho,1]] chol = np.linalg.cholesky(Sigma) # multivariate laplace = sqrt(W) * N(0,Sigma) gaussian_points = [chol.dot([random.gauss(0,1),random.gauss(0,1)]) for k in range(2000)] sqrt_exponential_draws = [np.sqrt(random.expovariate(1)) for k in range(2000)] bivariate_laplace = [sqrt_exponential_draws[k]*gaussian_points[k] for k in range(2000)]
Multivariate Laplace distribution
The following result is useful to understand how the multivariate Laplace looks like: The symmetric multivariate Laplace with covariance matrix $\Sigma$ can be represented as $X\simeq \sqrt{W} \times
Multivariate Laplace distribution The following result is useful to understand how the multivariate Laplace looks like: The symmetric multivariate Laplace with covariance matrix $\Sigma$ can be represented as $X\simeq \sqrt{W} \times Y$, where $Y\simeq \mathcal{N}_d(0,\Sigma)$ is multivariate Gaussian with covariance $\Sigma$, and $W$ is an exponential random variable of mean 1, and independent of $Y$ (cf. Theorem 6.3.1 from this book). Note that the 2 components of a bivariate Laplace are not independent (even in the case where correlation $\rho=0$). import random import numpy as np rho = .8 Sigma = [[1,rho], [rho,1]] chol = np.linalg.cholesky(Sigma) # multivariate laplace = sqrt(W) * N(0,Sigma) gaussian_points = [chol.dot([random.gauss(0,1),random.gauss(0,1)]) for k in range(2000)] sqrt_exponential_draws = [np.sqrt(random.expovariate(1)) for k in range(2000)] bivariate_laplace = [sqrt_exponential_draws[k]*gaussian_points[k] for k in range(2000)]
Multivariate Laplace distribution The following result is useful to understand how the multivariate Laplace looks like: The symmetric multivariate Laplace with covariance matrix $\Sigma$ can be represented as $X\simeq \sqrt{W} \times
31,058
Regression to the mean puzzle
I happen to be reading that book. You have not adequately transcribed the key information. It says that "all stores are similar in size and merchandise selection, but their sales differ because of location, competition and random factors." That is key, especially that last bit. Random factors are necessary for regression to the mean to occur (if sales grew by a fixed amount, then the 10% gain equally dispersed across stores would be right).
Regression to the mean puzzle
I happen to be reading that book. You have not adequately transcribed the key information. It says that "all stores are similar in size and merchandise selection, but their sales differ because of loc
Regression to the mean puzzle I happen to be reading that book. You have not adequately transcribed the key information. It says that "all stores are similar in size and merchandise selection, but their sales differ because of location, competition and random factors." That is key, especially that last bit. Random factors are necessary for regression to the mean to occur (if sales grew by a fixed amount, then the 10% gain equally dispersed across stores would be right).
Regression to the mean puzzle I happen to be reading that book. You have not adequately transcribed the key information. It says that "all stores are similar in size and merchandise selection, but their sales differ because of loc
31,059
Regression to the mean puzzle
With so few data points, the answer will be almost entirely dictated by the prior (or implied equivalent). If the author has seen a lot this kind of data before, they may well have good reason to think their answer is more likely to be correct, given their past observations. I think it's a stretch to suggest this is an example of regression to the mean though, at least not without specifying some more information. For instance, are the stores in comparable locations or not? If they are and there are no other obvious differences between the stores then we may feel justified in thinking they are part of a comparable population and we can think about regression to the mean. If there are obvious differences between the stores that could explain a systematic difference in sales, then it becomes less sensible to do so.
Regression to the mean puzzle
With so few data points, the answer will be almost entirely dictated by the prior (or implied equivalent). If the author has seen a lot this kind of data before, they may well have good reason to thin
Regression to the mean puzzle With so few data points, the answer will be almost entirely dictated by the prior (or implied equivalent). If the author has seen a lot this kind of data before, they may well have good reason to think their answer is more likely to be correct, given their past observations. I think it's a stretch to suggest this is an example of regression to the mean though, at least not without specifying some more information. For instance, are the stores in comparable locations or not? If they are and there are no other obvious differences between the stores then we may feel justified in thinking they are part of a comparable population and we can think about regression to the mean. If there are obvious differences between the stores that could explain a systematic difference in sales, then it becomes less sensible to do so.
Regression to the mean puzzle With so few data points, the answer will be almost entirely dictated by the prior (or implied equivalent). If the author has seen a lot this kind of data before, they may well have good reason to thin
31,060
Regression to the mean puzzle
I think a better (hypothetical) illustration might be something like this: Store 2011 2012 1 100 ? 2 180 ? 3 190 ? 4 210 ? 5 235 ? 6 300 ? Barring systematic reasons we'd expect the worst performer (from random causes) to not be so again. And so also for the best performer. Hence with 10% average growth I'd expect #1 to do better than 110 and #6 to do worse than 330. I feel the iffy part is the assumptions. It is very rare IMHO that the laggard of the pack is truly just a random fluke and not some underlying heterogeneity.
Regression to the mean puzzle
I think a better (hypothetical) illustration might be something like this: Store 2011 2012 1 100 ? 2 180 ? 3 190 ? 4 210 ? 5 235 ? 6
Regression to the mean puzzle I think a better (hypothetical) illustration might be something like this: Store 2011 2012 1 100 ? 2 180 ? 3 190 ? 4 210 ? 5 235 ? 6 300 ? Barring systematic reasons we'd expect the worst performer (from random causes) to not be so again. And so also for the best performer. Hence with 10% average growth I'd expect #1 to do better than 110 and #6 to do worse than 330. I feel the iffy part is the assumptions. It is very rare IMHO that the laggard of the pack is truly just a random fluke and not some underlying heterogeneity.
Regression to the mean puzzle I think a better (hypothetical) illustration might be something like this: Store 2011 2012 1 100 ? 2 180 ? 3 190 ? 4 210 ? 5 235 ? 6
31,061
Regression to the mean puzzle
I know this is a very old post, but I came across the very same question reading the book now. Unfortunately, it seems that many of those posting replies above did not have the book available for reference. I believe this example is effectively the one mistake in an otherwise perfect book. MSIS above states "Regression to the mean happens only when difference is fully explained by random factors". I think it would be more accurate to say that regression to the mean will always happen when random factors are present, yet only a difference that is excluively the result of random factors can be used to predict the direction, and possibly even the magnitude, of a regression to the mean. Insofar as in the example in the book the differences are the result of "location, competition and random factors", and we have no way to discern between them, the observed differences between the stores seem to me to have no predictive value. Contrary to what the book holds, we can only ignore them. In other words, time series information does not matter only if the deviation from the mean is purely random. Please correct me if I'm wrong. (The store with the highest sales, possibly located at the town's central station, may have had the worst result in x years, while the one with the lowest, possibly located right next to the town's dumpster, had its best performance ever; there is no way to know)
Regression to the mean puzzle
I know this is a very old post, but I came across the very same question reading the book now. Unfortunately, it seems that many of those posting replies above did not have the book available for refe
Regression to the mean puzzle I know this is a very old post, but I came across the very same question reading the book now. Unfortunately, it seems that many of those posting replies above did not have the book available for reference. I believe this example is effectively the one mistake in an otherwise perfect book. MSIS above states "Regression to the mean happens only when difference is fully explained by random factors". I think it would be more accurate to say that regression to the mean will always happen when random factors are present, yet only a difference that is excluively the result of random factors can be used to predict the direction, and possibly even the magnitude, of a regression to the mean. Insofar as in the example in the book the differences are the result of "location, competition and random factors", and we have no way to discern between them, the observed differences between the stores seem to me to have no predictive value. Contrary to what the book holds, we can only ignore them. In other words, time series information does not matter only if the deviation from the mean is purely random. Please correct me if I'm wrong. (The store with the highest sales, possibly located at the town's central station, may have had the worst result in x years, while the one with the lowest, possibly located right next to the town's dumpster, had its best performance ever; there is no way to know)
Regression to the mean puzzle I know this is a very old post, but I came across the very same question reading the book now. Unfortunately, it seems that many of those posting replies above did not have the book available for refe
31,062
What are the advantages of Multiple Kernel Learning (MKL) methods?
There are two advantages (or rather two use-cases): For every application of SVMs, a user has to choose which kernel to use and sometimes even have to design their own kernel matrices. Is it possible to alleviate choosing kernels or specialized kernel designs? MKL was a step towards that. The second case IMHO is by far a more compelling case. Consider that your data input is a video data + cc. The feature representation of each video consists of video features, audio features and text features. Such a data is known as multi-modal data. Each set of these features may require a different notion of similarity (a different kernel). Instead of building a specialized kernel for such applications, is it possible to just define kernel for each of these modes and linearly combine them?
What are the advantages of Multiple Kernel Learning (MKL) methods?
There are two advantages (or rather two use-cases): For every application of SVMs, a user has to choose which kernel to use and sometimes even have to design their own kernel matrices. Is it possibl
What are the advantages of Multiple Kernel Learning (MKL) methods? There are two advantages (or rather two use-cases): For every application of SVMs, a user has to choose which kernel to use and sometimes even have to design their own kernel matrices. Is it possible to alleviate choosing kernels or specialized kernel designs? MKL was a step towards that. The second case IMHO is by far a more compelling case. Consider that your data input is a video data + cc. The feature representation of each video consists of video features, audio features and text features. Such a data is known as multi-modal data. Each set of these features may require a different notion of similarity (a different kernel). Instead of building a specialized kernel for such applications, is it possible to just define kernel for each of these modes and linearly combine them?
What are the advantages of Multiple Kernel Learning (MKL) methods? There are two advantages (or rather two use-cases): For every application of SVMs, a user has to choose which kernel to use and sometimes even have to design their own kernel matrices. Is it possibl
31,063
How to investigate a 3-way interaction?
I was afraid this was going to be a continuous $\times$ continuous $\times$ categorical interaction... OK, here goes - first, we create some toy data (foo is a binary predictor, bar and baz are continuous, dv is the dependent variable): set.seed(1) obs <- data.frame(foo=sample(c("A","B"),size=100,replace=TRUE), bar=sample(1:10,size=100,replace=TRUE), baz=sample(1:10,size=100,replace=TRUE), dv=rnorm(100)) We then fit the model and look at the three-way interaction: model <- lm(dv~foo*bar*baz,data=obs) anova(update(model,.~.-foo:bar:baz),model) Now, for understanding the interaction, we plot the fits. The problem is that we have three independent variables, so we would really need a 4d plot, which is rather hard to do ;-). In our case, we can simply plot the fits against bar and baz in two separate plots, one for each level of foo. First calculate the fits: fit.A <- data.frame(foo="A",bar=rep(1:10,10),baz=rep(1:10,each=10)) fit.A$pred <- predict(model,newdata=fit.A) fit.B <- data.frame(foo="B",bar=rep(1:10,10),baz=rep(1:10,each=10)) fit.B$pred <- predict(model,newdata=fit.B) Next, plot the two 3d plots side by side, taking care to use the same scaling for the $z$ axis to be able to compare the plots: par(mfrow=c(1,2),mai=c(0,0.1,0.2,0)+.02) persp(x=1:10,y=1:10,z=matrix(fit.A$pred,nrow=10,ncol=10,byrow=TRUE), xlab="bar",ylab="baz",zlab="fit",main="foo = A",zlim=c(-.8,1.1)) persp(x=1:10,y=1:10,z=matrix(fit.B$pred,nrow=10,ncol=10,byrow=TRUE), xlab="bar",ylab="baz",zlab="fit",main="foo = B",zlim=c(-.8,1.1)) Result: We see how the way the fit depends on (both!) bar and baz depends on the value of foo, and we can start to describe and interpret the fitted relationship. Yes, this is hard to digest. Three-way interactions always are... Statistics are easy, interpretation is hard... Look at ?persp to see how you can prettify the graph. Browsing the R Graph Gallery may also be inspirational.
How to investigate a 3-way interaction?
I was afraid this was going to be a continuous $\times$ continuous $\times$ categorical interaction... OK, here goes - first, we create some toy data (foo is a binary predictor, bar and baz are contin
How to investigate a 3-way interaction? I was afraid this was going to be a continuous $\times$ continuous $\times$ categorical interaction... OK, here goes - first, we create some toy data (foo is a binary predictor, bar and baz are continuous, dv is the dependent variable): set.seed(1) obs <- data.frame(foo=sample(c("A","B"),size=100,replace=TRUE), bar=sample(1:10,size=100,replace=TRUE), baz=sample(1:10,size=100,replace=TRUE), dv=rnorm(100)) We then fit the model and look at the three-way interaction: model <- lm(dv~foo*bar*baz,data=obs) anova(update(model,.~.-foo:bar:baz),model) Now, for understanding the interaction, we plot the fits. The problem is that we have three independent variables, so we would really need a 4d plot, which is rather hard to do ;-). In our case, we can simply plot the fits against bar and baz in two separate plots, one for each level of foo. First calculate the fits: fit.A <- data.frame(foo="A",bar=rep(1:10,10),baz=rep(1:10,each=10)) fit.A$pred <- predict(model,newdata=fit.A) fit.B <- data.frame(foo="B",bar=rep(1:10,10),baz=rep(1:10,each=10)) fit.B$pred <- predict(model,newdata=fit.B) Next, plot the two 3d plots side by side, taking care to use the same scaling for the $z$ axis to be able to compare the plots: par(mfrow=c(1,2),mai=c(0,0.1,0.2,0)+.02) persp(x=1:10,y=1:10,z=matrix(fit.A$pred,nrow=10,ncol=10,byrow=TRUE), xlab="bar",ylab="baz",zlab="fit",main="foo = A",zlim=c(-.8,1.1)) persp(x=1:10,y=1:10,z=matrix(fit.B$pred,nrow=10,ncol=10,byrow=TRUE), xlab="bar",ylab="baz",zlab="fit",main="foo = B",zlim=c(-.8,1.1)) Result: We see how the way the fit depends on (both!) bar and baz depends on the value of foo, and we can start to describe and interpret the fitted relationship. Yes, this is hard to digest. Three-way interactions always are... Statistics are easy, interpretation is hard... Look at ?persp to see how you can prettify the graph. Browsing the R Graph Gallery may also be inspirational.
How to investigate a 3-way interaction? I was afraid this was going to be a continuous $\times$ continuous $\times$ categorical interaction... OK, here goes - first, we create some toy data (foo is a binary predictor, bar and baz are contin
31,064
How to investigate a 3-way interaction?
+1 to comments above about graphing interaction. An initial approach to thinking about a three-way interaction is that it is saying that the pattern of results contained in the interaction between A and B depends upon the level/value of C. The following is framed in a linear regression kind of framework, but conceptually similar to e.g. logistic regression. This assumes that you're happy with thinking about two-way interactions, of course :-) Let's say there are three predictors, A (continuous), B (categorical), and C (categorical). A two way A*B interaction would indicate that the slope of A (relating to the outcome) depends on the level of B to which an individual belongs. In this context, a three way A*B*C interaction would indicate that the A*B interaction (previously discussed differential slopes of A on the outcome according to group of B) depends on the group of C to which one belongs... Things are much more complex if there are two continuous/ordinal predictors in the interaction (usually too complex to conceptualise: I would be interested to hear others' opinions on this.)
How to investigate a 3-way interaction?
+1 to comments above about graphing interaction. An initial approach to thinking about a three-way interaction is that it is saying that the pattern of results contained in the interaction between A a
How to investigate a 3-way interaction? +1 to comments above about graphing interaction. An initial approach to thinking about a three-way interaction is that it is saying that the pattern of results contained in the interaction between A and B depends upon the level/value of C. The following is framed in a linear regression kind of framework, but conceptually similar to e.g. logistic regression. This assumes that you're happy with thinking about two-way interactions, of course :-) Let's say there are three predictors, A (continuous), B (categorical), and C (categorical). A two way A*B interaction would indicate that the slope of A (relating to the outcome) depends on the level of B to which an individual belongs. In this context, a three way A*B*C interaction would indicate that the A*B interaction (previously discussed differential slopes of A on the outcome according to group of B) depends on the group of C to which one belongs... Things are much more complex if there are two continuous/ordinal predictors in the interaction (usually too complex to conceptualise: I would be interested to hear others' opinions on this.)
How to investigate a 3-way interaction? +1 to comments above about graphing interaction. An initial approach to thinking about a three-way interaction is that it is saying that the pattern of results contained in the interaction between A a
31,065
How to investigate a 3-way interaction?
Often it helps to plot the relationships and see how things change when you change one of the variables. A couple of tools in R that help with these plots are Predict.Plot and TkPredict functions in the TeachingDemos package.
How to investigate a 3-way interaction?
Often it helps to plot the relationships and see how things change when you change one of the variables. A couple of tools in R that help with these plots are Predict.Plot and TkPredict functions in
How to investigate a 3-way interaction? Often it helps to plot the relationships and see how things change when you change one of the variables. A couple of tools in R that help with these plots are Predict.Plot and TkPredict functions in the TeachingDemos package.
How to investigate a 3-way interaction? Often it helps to plot the relationships and see how things change when you change one of the variables. A couple of tools in R that help with these plots are Predict.Plot and TkPredict functions in
31,066
Choosing between logistic regression and Mann Whitney/t-tests
The answer to question 1 will depend on your research question, and who the audience are for the result. If your research question points to talking about differences in b based on the profile of A, then that will obviously help frame your summary. In an epidemiological study, even if you're not sampling based on A (independent variable as exposed/unexposed status) it would still make sense to use this classification as an independent variable [exposure] and the continuous variable as a dependent variable [outcome]. It sounds like you already know the answer to this. You should also consider how you might interpret the result in terms of presenting the results to others (and interpreting it yourself). A continuous-variable-as-dependent variable [outcome] model would have a mean difference (or similar) as one summary; a dichotomous-variable-as-outcome model would have an odds ratio (ratio of increased odds per one unit of the continuous variable, which could be scaled to give e.g. relative increase per five kilos of additional weight for likelihood of type II diabetes.) My experience from consulting settings and explaining this to people is that the former (difference in means) is generally more easy to explain to other people than the latter (odds ratio per one unit difference of continuous independent variable.) For your question 2, if you want to run a multivariable model, where you're controlling for covariates, then it will help to choose dependent/independent variables at the start. It's probably best to stick with the same method from univariate to multivariable analysis, rather than changing between the two approaches, just from ease of explanation. Final note on this latter point: from a hypothesis testing perspective, a logistic regression with a continuous independent variable [exposure] and [single] dichotomous dependent variable should return the same p-value as an unpaired t-test assuming unequal variance with the variables reversed (from memory -- I'm not entirely sure if this is always true though.)
Choosing between logistic regression and Mann Whitney/t-tests
The answer to question 1 will depend on your research question, and who the audience are for the result. If your research question points to talking about differences in b based on the profile of A, t
Choosing between logistic regression and Mann Whitney/t-tests The answer to question 1 will depend on your research question, and who the audience are for the result. If your research question points to talking about differences in b based on the profile of A, then that will obviously help frame your summary. In an epidemiological study, even if you're not sampling based on A (independent variable as exposed/unexposed status) it would still make sense to use this classification as an independent variable [exposure] and the continuous variable as a dependent variable [outcome]. It sounds like you already know the answer to this. You should also consider how you might interpret the result in terms of presenting the results to others (and interpreting it yourself). A continuous-variable-as-dependent variable [outcome] model would have a mean difference (or similar) as one summary; a dichotomous-variable-as-outcome model would have an odds ratio (ratio of increased odds per one unit of the continuous variable, which could be scaled to give e.g. relative increase per five kilos of additional weight for likelihood of type II diabetes.) My experience from consulting settings and explaining this to people is that the former (difference in means) is generally more easy to explain to other people than the latter (odds ratio per one unit difference of continuous independent variable.) For your question 2, if you want to run a multivariable model, where you're controlling for covariates, then it will help to choose dependent/independent variables at the start. It's probably best to stick with the same method from univariate to multivariable analysis, rather than changing between the two approaches, just from ease of explanation. Final note on this latter point: from a hypothesis testing perspective, a logistic regression with a continuous independent variable [exposure] and [single] dichotomous dependent variable should return the same p-value as an unpaired t-test assuming unequal variance with the variables reversed (from memory -- I'm not entirely sure if this is always true though.)
Choosing between logistic regression and Mann Whitney/t-tests The answer to question 1 will depend on your research question, and who the audience are for the result. If your research question points to talking about differences in b based on the profile of A, t
31,067
Choosing between logistic regression and Mann Whitney/t-tests
The Wilcoxon-Mann-Whitney test is a special case of the proportional odds ordinal logistic model so you could say there is no need to turn the model around to use logistic regression. But the fundamental issue in choosing the model is to determine which variables make sense to adjust for.
Choosing between logistic regression and Mann Whitney/t-tests
The Wilcoxon-Mann-Whitney test is a special case of the proportional odds ordinal logistic model so you could say there is no need to turn the model around to use logistic regression. But the fundame
Choosing between logistic regression and Mann Whitney/t-tests The Wilcoxon-Mann-Whitney test is a special case of the proportional odds ordinal logistic model so you could say there is no need to turn the model around to use logistic regression. But the fundamental issue in choosing the model is to determine which variables make sense to adjust for.
Choosing between logistic regression and Mann Whitney/t-tests The Wilcoxon-Mann-Whitney test is a special case of the proportional odds ordinal logistic model so you could say there is no need to turn the model around to use logistic regression. But the fundame
31,068
Choosing between logistic regression and Mann Whitney/t-tests
That's an attempt of a partial answer: I'd use a Mann Whitney test because it makes less assumptions. The logistic regression assumes a close form (namely logit) for the relationship between these two variables). Moreover, logistic regression assumes that $Y$ is Bernoulli given $X$: if this is not the case (e.g., an a priori number of samples with $Y=1$ and $Y=0$ as in a case-control study) was selected, I'm not sure if the results (such as p-values) would still hold. However, I already saw many people doing this. On the other hand, Mann Whitney does not seem to have problems with this, i.e., it holds whether or not it is a case-control study.
Choosing between logistic regression and Mann Whitney/t-tests
That's an attempt of a partial answer: I'd use a Mann Whitney test because it makes less assumptions. The logistic regression assumes a close form (namely logit) for the relationship between these two
Choosing between logistic regression and Mann Whitney/t-tests That's an attempt of a partial answer: I'd use a Mann Whitney test because it makes less assumptions. The logistic regression assumes a close form (namely logit) for the relationship between these two variables). Moreover, logistic regression assumes that $Y$ is Bernoulli given $X$: if this is not the case (e.g., an a priori number of samples with $Y=1$ and $Y=0$ as in a case-control study) was selected, I'm not sure if the results (such as p-values) would still hold. However, I already saw many people doing this. On the other hand, Mann Whitney does not seem to have problems with this, i.e., it holds whether or not it is a case-control study.
Choosing between logistic regression and Mann Whitney/t-tests That's an attempt of a partial answer: I'd use a Mann Whitney test because it makes less assumptions. The logistic regression assumes a close form (namely logit) for the relationship between these two
31,069
Choosing between logistic regression and Mann Whitney/t-tests
As with many questions, the answer depends on your underlying purpose in carrying out the analysis. If you are interested in not only showing that there is a significant association between a dichotomous variable A and a continuous variable b, but also in being able to compute the expected likelihood of the event recorded in variable A, then you want to use the logistic regression, as this approach provides you with a regression equation. In addition, the logistic regression in the bivariate case of A and b can be extended to the multivariate case of predicting A from b and numerous other independent variables for the purpose of controlling for covariates, testing mediational models, examining interactions, and all of the other good things we can do with multiple regression. Having said that, you should probably consider the link function relating the dichotomous variable A with the continuous variable B. Logistic regression used a logit link, which is more appropriate when the probability of the outcome is very high or low, while a probit link may be more appropriate when the probablity of the event is closer to .5 Choosing the link function that is appropriate for your data is important for building a good regression model. Some further information on link functions can be found at the following links: http://www.stat.ufl.edu/CourseINFO/STA6167/logistregSFLM.pdf http://www.norusis.com/pdf/ASPC_v13.pdf
Choosing between logistic regression and Mann Whitney/t-tests
As with many questions, the answer depends on your underlying purpose in carrying out the analysis. If you are interested in not only showing that there is a significant association between a dichotom
Choosing between logistic regression and Mann Whitney/t-tests As with many questions, the answer depends on your underlying purpose in carrying out the analysis. If you are interested in not only showing that there is a significant association between a dichotomous variable A and a continuous variable b, but also in being able to compute the expected likelihood of the event recorded in variable A, then you want to use the logistic regression, as this approach provides you with a regression equation. In addition, the logistic regression in the bivariate case of A and b can be extended to the multivariate case of predicting A from b and numerous other independent variables for the purpose of controlling for covariates, testing mediational models, examining interactions, and all of the other good things we can do with multiple regression. Having said that, you should probably consider the link function relating the dichotomous variable A with the continuous variable B. Logistic regression used a logit link, which is more appropriate when the probability of the outcome is very high or low, while a probit link may be more appropriate when the probablity of the event is closer to .5 Choosing the link function that is appropriate for your data is important for building a good regression model. Some further information on link functions can be found at the following links: http://www.stat.ufl.edu/CourseINFO/STA6167/logistregSFLM.pdf http://www.norusis.com/pdf/ASPC_v13.pdf
Choosing between logistic regression and Mann Whitney/t-tests As with many questions, the answer depends on your underlying purpose in carrying out the analysis. If you are interested in not only showing that there is a significant association between a dichotom
31,070
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$?
There's a subtle issue here that is not mentioned in the question regarding estimation of the standard deviation of $\overline{x}$'s sampling distribution. Suppose you have a sample from a population with mean $\mu$ and variance $\sigma^2$. When $\sigma^2$ is known, $${\rm SE}(\overline{x}) = \sigma/\sqrt{n}$$ is exactly the standard deviation of the sample mean. In practice, you usually don't know $\sigma^2$, so you instead plug in the sample variance $\hat\sigma$ to use $${\rm SE}(\overline{x}) = \hat\sigma/\sqrt{n}$$ to estimate the standard deviation of $\overline{x}$. This distinction is actually important - when the variance is unknown, this additional uncertainty must be incorporated into the hypothesis test. This is why, even when the sample is normally distributed, the test statistic has a $t$-distribution (which has longer tails) instead of a normal distribution when $\sigma$ is unknown. Is it correct to say that $t=(\overline{x}−μ)/SE(\overline{x})$ follows a normal distribution for ANY population (not just normally distributed), as long as the samples sizes are significant in size (by means of the central limit theorem) This is almost correct. The population must have finite variance (i.e. not have tails that are "too long") for this to be the case. Even when the population does have a finite variance, the population distribution can have a large effect on how long until the CLT "kicks in". For shorter tailed distributions this convergence is faster. For long-tailed distributions it can take quite a while (e.g. see my example here). Note that since we're talking about a "large sample" result here, this is true regardless of whether or not you know $\sigma$ since $\hat \sigma$ gets closer to the true $\sigma$ as the sample size increases. And, is it correct that t follows a t-distribution when the sample size is small, but then the population only if the population is normally distributed, because the central limit theorem does not apply? Again, assuming we're in the "$\sigma$ is unknown" world, $t$ only follows a $t$-distribution when the sample is normally distributed, which I think is what you're saying here. Related to what I said in the beginning, if $\sigma$ is known, then $t$ will have a (exact) normal distribution if the sample is normally distributed. To summarize: If $\sigma$ is known, and the population is normally distributed: $t$ has a normal distribution. If $\sigma$ is unknown, and the population is normally distributed: $t$ has a $t$-distribution. If the population is not normally distributed but meets the regularity requirements of the CLT: $t$ has an approximate normal distribution whether or not $\sigma$ is known. That is, the distribution of $t$ converges to a normal distribution as the sample size increases.
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$?
There's a subtle issue here that is not mentioned in the question regarding estimation of the standard deviation of $\overline{x}$'s sampling distribution. Suppose you have a sample from a population
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$? There's a subtle issue here that is not mentioned in the question regarding estimation of the standard deviation of $\overline{x}$'s sampling distribution. Suppose you have a sample from a population with mean $\mu$ and variance $\sigma^2$. When $\sigma^2$ is known, $${\rm SE}(\overline{x}) = \sigma/\sqrt{n}$$ is exactly the standard deviation of the sample mean. In practice, you usually don't know $\sigma^2$, so you instead plug in the sample variance $\hat\sigma$ to use $${\rm SE}(\overline{x}) = \hat\sigma/\sqrt{n}$$ to estimate the standard deviation of $\overline{x}$. This distinction is actually important - when the variance is unknown, this additional uncertainty must be incorporated into the hypothesis test. This is why, even when the sample is normally distributed, the test statistic has a $t$-distribution (which has longer tails) instead of a normal distribution when $\sigma$ is unknown. Is it correct to say that $t=(\overline{x}−μ)/SE(\overline{x})$ follows a normal distribution for ANY population (not just normally distributed), as long as the samples sizes are significant in size (by means of the central limit theorem) This is almost correct. The population must have finite variance (i.e. not have tails that are "too long") for this to be the case. Even when the population does have a finite variance, the population distribution can have a large effect on how long until the CLT "kicks in". For shorter tailed distributions this convergence is faster. For long-tailed distributions it can take quite a while (e.g. see my example here). Note that since we're talking about a "large sample" result here, this is true regardless of whether or not you know $\sigma$ since $\hat \sigma$ gets closer to the true $\sigma$ as the sample size increases. And, is it correct that t follows a t-distribution when the sample size is small, but then the population only if the population is normally distributed, because the central limit theorem does not apply? Again, assuming we're in the "$\sigma$ is unknown" world, $t$ only follows a $t$-distribution when the sample is normally distributed, which I think is what you're saying here. Related to what I said in the beginning, if $\sigma$ is known, then $t$ will have a (exact) normal distribution if the sample is normally distributed. To summarize: If $\sigma$ is known, and the population is normally distributed: $t$ has a normal distribution. If $\sigma$ is unknown, and the population is normally distributed: $t$ has a $t$-distribution. If the population is not normally distributed but meets the regularity requirements of the CLT: $t$ has an approximate normal distribution whether or not $\sigma$ is known. That is, the distribution of $t$ converges to a normal distribution as the sample size increases.
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$? There's a subtle issue here that is not mentioned in the question regarding estimation of the standard deviation of $\overline{x}$'s sampling distribution. Suppose you have a sample from a population
31,071
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$?
No the standard error of the mean would be related to the chi square distribution not the normal when sampling froma normal distribution. It is the sample mean normalized by the the samplestandard error that is approximately normal by the CLT and has a t distribution when the true mean is zero and the data are normally distributed.
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$?
No the standard error of the mean would be related to the chi square distribution not the normal when sampling froma normal distribution. It is the sample mean normalized by the the samplestandard er
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$? No the standard error of the mean would be related to the chi square distribution not the normal when sampling froma normal distribution. It is the sample mean normalized by the the samplestandard error that is approximately normal by the CLT and has a t distribution when the true mean is zero and the data are normally distributed.
When is the distribution of $(\overline{x}-\mu)/{\rm SE}(\overline{x})$ normal and when is it $t$? No the standard error of the mean would be related to the chi square distribution not the normal when sampling froma normal distribution. It is the sample mean normalized by the the samplestandard er
31,072
Generate sets of values with high correlation coefficient
You can for example generate data from a bivariate normal distribution. The off-diagonal entry of the variance-covariance matrix is the covariance. In R, this can readily be done with rmvnorm. Example Generate $1000$ realisations from $X=(X_{1}, X_{2})' \sim N(\mu, \Sigma)$ with $$\mu = (-1, 5)', \quad \Sigma_{11} = V(X_{1}) = 0.7, \quad \Sigma_{22}= V(X_{2}) = 0.1$$ and $\Sigma_{12} = \Sigma_{21} = \textrm{Cov}(X_1, X_2)$ such that $\textrm{Cor}(X_{1}, X_{2})=0.85$. > #------load the package------ > library(mvtnorm) > #---------------------------- > > #------compute the covariance such that cor(X1, X2) = 0.85------ > covariance <- 0.85 * sqrt(0.7) * sqrt(0.1) > #--------------------------------------------------------------- > > #------variance-covariance matrix------ > sigma <- matrix(c(0.7, covariance, covariance, 0.1), nrow=2, byrow=TRUE) > sigma [,1] [,2] [1,] 0.7000000 0.2248889 [2,] 0.2248889 0.1000000 > #-------------------------------------- > > #------data generation------ > test <- rmvnorm(n=1000, mean=c(-1, 5), sigma=sigma) > #--------------------------- > > #------compute the empirical correlation on this particular data------ > cor(test[, 1], test[, 2]) [1] 0.8478849 > #--------------------------------------------------------------------- $$$$ NB: You can also generate data according to a linear regression model: $X_2 = a + bX_1 + \epsilon$.
Generate sets of values with high correlation coefficient
You can for example generate data from a bivariate normal distribution. The off-diagonal entry of the variance-covariance matrix is the covariance. In R, this can readily be done with rmvnorm. Example
Generate sets of values with high correlation coefficient You can for example generate data from a bivariate normal distribution. The off-diagonal entry of the variance-covariance matrix is the covariance. In R, this can readily be done with rmvnorm. Example Generate $1000$ realisations from $X=(X_{1}, X_{2})' \sim N(\mu, \Sigma)$ with $$\mu = (-1, 5)', \quad \Sigma_{11} = V(X_{1}) = 0.7, \quad \Sigma_{22}= V(X_{2}) = 0.1$$ and $\Sigma_{12} = \Sigma_{21} = \textrm{Cov}(X_1, X_2)$ such that $\textrm{Cor}(X_{1}, X_{2})=0.85$. > #------load the package------ > library(mvtnorm) > #---------------------------- > > #------compute the covariance such that cor(X1, X2) = 0.85------ > covariance <- 0.85 * sqrt(0.7) * sqrt(0.1) > #--------------------------------------------------------------- > > #------variance-covariance matrix------ > sigma <- matrix(c(0.7, covariance, covariance, 0.1), nrow=2, byrow=TRUE) > sigma [,1] [,2] [1,] 0.7000000 0.2248889 [2,] 0.2248889 0.1000000 > #-------------------------------------- > > #------data generation------ > test <- rmvnorm(n=1000, mean=c(-1, 5), sigma=sigma) > #--------------------------- > > #------compute the empirical correlation on this particular data------ > cor(test[, 1], test[, 2]) [1] 0.8478849 > #--------------------------------------------------------------------- $$$$ NB: You can also generate data according to a linear regression model: $X_2 = a + bX_1 + \epsilon$.
Generate sets of values with high correlation coefficient You can for example generate data from a bivariate normal distribution. The off-diagonal entry of the variance-covariance matrix is the covariance. In R, this can readily be done with rmvnorm. Example
31,073
Generate sets of values with high correlation coefficient
Others have given you code. Here is an idea behind that. Generate $X$, and then let $Y = X+Z$, where $Z$ is independent of $X$. If $var(Z)$ is small compared with $var(X)$ then the correlation between $X$ and $Y$ will be high. If $var(Z)$ is large compared with $var(X)$ then the correlation between $X$ and $Y$ will be low.
Generate sets of values with high correlation coefficient
Others have given you code. Here is an idea behind that. Generate $X$, and then let $Y = X+Z$, where $Z$ is independent of $X$. If $var(Z)$ is small compared with $var(X)$ then the correlation betwee
Generate sets of values with high correlation coefficient Others have given you code. Here is an idea behind that. Generate $X$, and then let $Y = X+Z$, where $Z$ is independent of $X$. If $var(Z)$ is small compared with $var(X)$ then the correlation between $X$ and $Y$ will be high. If $var(Z)$ is large compared with $var(X)$ then the correlation between $X$ and $Y$ will be low.
Generate sets of values with high correlation coefficient Others have given you code. Here is an idea behind that. Generate $X$, and then let $Y = X+Z$, where $Z$ is independent of $X$. If $var(Z)$ is small compared with $var(X)$ then the correlation betwee
31,074
Generate sets of values with high correlation coefficient
library("MASS") highCor<-matrix(c(1,0.9,0.9,1),2,2) lowCor<-matrix(c(1,0.1,0.1,1),2,2) x_hc<-mvrnorm(100,rep(0,2),highCor) x_lc<-mvrnorm(100,rep(0,2),lowCor) plot(rbind(x_hc,x_lc),type="n") points(x_lc,pch=16,col="green")#low correlation in green points(x_hc,pch=16,col="blue") #high correlation in blue
Generate sets of values with high correlation coefficient
library("MASS") highCor<-matrix(c(1,0.9,0.9,1),2,2) lowCor<-matrix(c(1,0.1,0.1,1),2,2) x_hc<-mvrnorm(100,rep(0,2),highCor) x_lc<-mvrnorm(100,rep(0,2),lowCor) plot(rbind(x_hc,x_lc),type="n") points(x_l
Generate sets of values with high correlation coefficient library("MASS") highCor<-matrix(c(1,0.9,0.9,1),2,2) lowCor<-matrix(c(1,0.1,0.1,1),2,2) x_hc<-mvrnorm(100,rep(0,2),highCor) x_lc<-mvrnorm(100,rep(0,2),lowCor) plot(rbind(x_hc,x_lc),type="n") points(x_lc,pch=16,col="green")#low correlation in green points(x_hc,pch=16,col="blue") #high correlation in blue
Generate sets of values with high correlation coefficient library("MASS") highCor<-matrix(c(1,0.9,0.9,1),2,2) lowCor<-matrix(c(1,0.1,0.1,1),2,2) x_hc<-mvrnorm(100,rep(0,2),highCor) x_lc<-mvrnorm(100,rep(0,2),lowCor) plot(rbind(x_hc,x_lc),type="n") points(x_l
31,075
Generate sets of values with high correlation coefficient
Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more. The answers given here as well as the checked answer to the previous post give you a lot of valid ways to do this. My suggestion would have been the same as the NB given above by ocram. Take a linear function $Y=a+bX$ and add an error term $N(0, σ)$ with a small value for the standard deviation $σ$. This will generate a pair of random variables with a high correlation. To generate a pair of variables with low correlation just take a large value for $σ^2$.
Generate sets of values with high correlation coefficient
Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more. The answers given he
Generate sets of values with high correlation coefficient Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more. The answers given here as well as the checked answer to the previous post give you a lot of valid ways to do this. My suggestion would have been the same as the NB given above by ocram. Take a linear function $Y=a+bX$ and add an error term $N(0, σ)$ with a small value for the standard deviation $σ$. This will generate a pair of random variables with a high correlation. To generate a pair of variables with low correlation just take a large value for $σ^2$.
Generate sets of values with high correlation coefficient Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more. The answers given he
31,076
Multi class LDA vs 2 class LDA
I think that Multi-class LDA classifier always (well, in most practical tasks) out-performs 2 class LDA. And I will try to describe why. Have a look at the example dataset: You have three classes here. And let's say you want to build one-vs-other classifier with LDA for the blue class. The estimated mean for class "blue" is zero, but the estimated mean for class "other" is zero as well. And the covariance is the same from the definition of LDA. That means that LDA will respond with the label that has more elements. And it will never return class "blue" at all! For Multi-class LDA it will manage to find the right classes perfectly. The background about this is that the mixture of Gaussians is not a Gaussian any more in most cases. So this assumption of LDA fails. And I must say it is really difficult to come up with an example of a dataset where every class is Gaussian, and they still Gaussian after we join them. That's why I would highly recommend to use Multi-class LDA. Hope it will help!
Multi class LDA vs 2 class LDA
I think that Multi-class LDA classifier always (well, in most practical tasks) out-performs 2 class LDA. And I will try to describe why. Have a look at the example dataset: You have three classes her
Multi class LDA vs 2 class LDA I think that Multi-class LDA classifier always (well, in most practical tasks) out-performs 2 class LDA. And I will try to describe why. Have a look at the example dataset: You have three classes here. And let's say you want to build one-vs-other classifier with LDA for the blue class. The estimated mean for class "blue" is zero, but the estimated mean for class "other" is zero as well. And the covariance is the same from the definition of LDA. That means that LDA will respond with the label that has more elements. And it will never return class "blue" at all! For Multi-class LDA it will manage to find the right classes perfectly. The background about this is that the mixture of Gaussians is not a Gaussian any more in most cases. So this assumption of LDA fails. And I must say it is really difficult to come up with an example of a dataset where every class is Gaussian, and they still Gaussian after we join them. That's why I would highly recommend to use Multi-class LDA. Hope it will help!
Multi class LDA vs 2 class LDA I think that Multi-class LDA classifier always (well, in most practical tasks) out-performs 2 class LDA. And I will try to describe why. Have a look at the example dataset: You have three classes her
31,077
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance function
Yes. There is a very efficient (linear time) algorithm, and the intuition for it comes directly from the uniformly-sampled case. Suppose we have a partition of $[0,T]$ such that $0=t_0 < t_1 < t_2 < \cdots < t_n = T$. Uniformly sampled case In this case we have $t_i = i \Delta$ where $\Delta = T/n$. Let $X_i := X(t_i)$ denote the value of the discretely sampled process at time $t_i$. It is easy to see that the $X_i$ form an AR(1) process with correlation $\rho = \exp(-\Delta)$. Hence, we can generate a sample path $\{X_t\}$ for the partition as follows $$ X_{i+1} = \rho X_i + \sqrt{1-\rho^2} Z_{i+1} \>, $$ where $Z_i$ are iid $\mathcal N(0,1)$ and $X_0 = Z_0$. General case We might then imagine that it could be possible to do this for a general partition. In particular, let $\Delta_i = t_{i+1} - t_i$ and $\rho_i = \exp(-\Delta_i)$. We have that $$ \gamma(t_i,t_{i+1}) = \rho_i \>, $$ and so we might guess that $$ X_{i+1} = \rho_i X_i + \sqrt{1-\rho_i^2} Z_{i+1} \>. $$ Indeed, $\mathbb E X_{i+1} X_i = \rho_i$ and so we at least have the correlation with the neighboring term correct. The result now follows by telescoping via the tower property of conditional expectation. Namely, $$ \newcommand{\e}{\mathbb E} \e X_i X_{i-\ell} = \e( \e(X_i X_{i-\ell} \mid X_{i-1} )) = \rho_{i-1} \mathbb E X_{i-1} X_{i-\ell} = \cdots = \prod_{k=1}^\ell \rho_{i-k} \>, $$ and the product telescopes in the following way $$ \prod_{k=1}^\ell \rho_{i-k} = \exp\Big(-\sum_{k=1}^\ell \Delta_{i-k}\Big) = \exp(t_{i-\ell} - t_i) = \gamma(t_{i-\ell},t_i) \>. $$ This proves the result. Hence the process can be generated on an arbitrary partition from a sequence of iid $\mathcal N(0,1)$ random variables in $O(n)$ time where $n$ is the size of the partition. NB: This is an exact sampling technique in that it provides a sampled version of the desired process with the exactly correct finite-dimensional distributions. This is in contrast to Euler (and other) discretization schemes for more general SDEs, which incur a bias due to the approximation via discretization.
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance functio
Yes. There is a very efficient (linear time) algorithm, and the intuition for it comes directly from the uniformly-sampled case. Suppose we have a partition of $[0,T]$ such that $0=t_0 < t_1 < t_2 < \
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance function Yes. There is a very efficient (linear time) algorithm, and the intuition for it comes directly from the uniformly-sampled case. Suppose we have a partition of $[0,T]$ such that $0=t_0 < t_1 < t_2 < \cdots < t_n = T$. Uniformly sampled case In this case we have $t_i = i \Delta$ where $\Delta = T/n$. Let $X_i := X(t_i)$ denote the value of the discretely sampled process at time $t_i$. It is easy to see that the $X_i$ form an AR(1) process with correlation $\rho = \exp(-\Delta)$. Hence, we can generate a sample path $\{X_t\}$ for the partition as follows $$ X_{i+1} = \rho X_i + \sqrt{1-\rho^2} Z_{i+1} \>, $$ where $Z_i$ are iid $\mathcal N(0,1)$ and $X_0 = Z_0$. General case We might then imagine that it could be possible to do this for a general partition. In particular, let $\Delta_i = t_{i+1} - t_i$ and $\rho_i = \exp(-\Delta_i)$. We have that $$ \gamma(t_i,t_{i+1}) = \rho_i \>, $$ and so we might guess that $$ X_{i+1} = \rho_i X_i + \sqrt{1-\rho_i^2} Z_{i+1} \>. $$ Indeed, $\mathbb E X_{i+1} X_i = \rho_i$ and so we at least have the correlation with the neighboring term correct. The result now follows by telescoping via the tower property of conditional expectation. Namely, $$ \newcommand{\e}{\mathbb E} \e X_i X_{i-\ell} = \e( \e(X_i X_{i-\ell} \mid X_{i-1} )) = \rho_{i-1} \mathbb E X_{i-1} X_{i-\ell} = \cdots = \prod_{k=1}^\ell \rho_{i-k} \>, $$ and the product telescopes in the following way $$ \prod_{k=1}^\ell \rho_{i-k} = \exp\Big(-\sum_{k=1}^\ell \Delta_{i-k}\Big) = \exp(t_{i-\ell} - t_i) = \gamma(t_{i-\ell},t_i) \>. $$ This proves the result. Hence the process can be generated on an arbitrary partition from a sequence of iid $\mathcal N(0,1)$ random variables in $O(n)$ time where $n$ is the size of the partition. NB: This is an exact sampling technique in that it provides a sampled version of the desired process with the exactly correct finite-dimensional distributions. This is in contrast to Euler (and other) discretization schemes for more general SDEs, which incur a bias due to the approximation via discretization.
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance functio Yes. There is a very efficient (linear time) algorithm, and the intuition for it comes directly from the uniformly-sampled case. Suppose we have a partition of $[0,T]$ such that $0=t_0 < t_1 < t_2 < \
31,078
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance function
Calculate the decomposed covariance matrix by incomplete Cholesky decomposition or any other matrix decomposition technique. Decomposed matrix should be TxM, where M is only a fraction of T. http://en.wikipedia.org/wiki/Incomplete_Cholesky_factorization
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance functio
Calculate the decomposed covariance matrix by incomplete Cholesky decomposition or any other matrix decomposition technique. Decomposed matrix should be TxM, where M is only a fraction of T. http://en
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance function Calculate the decomposed covariance matrix by incomplete Cholesky decomposition or any other matrix decomposition technique. Decomposed matrix should be TxM, where M is only a fraction of T. http://en.wikipedia.org/wiki/Incomplete_Cholesky_factorization
Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance functio Calculate the decomposed covariance matrix by incomplete Cholesky decomposition or any other matrix decomposition technique. Decomposed matrix should be TxM, where M is only a fraction of T. http://en
31,079
Split plot in R
The major difference between split plot design and other designs such as completely randomized design and variations of block designs is the nesting structure of subjects, that is, when the observations are from obtained from the same subject (experimental unit) more than once. This leads to a correlation structure within a subject in split plot design which is different from correlation structure in a block. Let's take an example picture of data set from a simple split-plot design (below). This is a study of dietary composition on health, four diets were randomly assigned to 12 subjects, all of similar health status. Baseline blood pressure was established, and one measure of health was blood pressure change after two weeks. Blood pressure was measured in the morning and the evening. (The example is copied from Casella's Statistical Design book example 5.1) $$ \begin{array}{r|ccccc|l} ~ & \text{Diet} 1 & \text{Diet} 2 & \text{Diet}3 & \text{Diet}4 \\\hline ~ & \text{Subject} & \text{Subject} & \text{Subject} &\text{Subject}\\ ~ & 1 \, 2 \, 3 & 4 \, 5 \, 6 & 7 \, 8 \, 9 & 10 \, 11 \, 12\\\hline \text{Morning} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \text{Evening} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \hline \end{array} $$ A few important things to note: There are 12 experimental units (12 subjects) On these 12 units we observe 24 data points ( $2 \times 4 \times 3$), denoted by $x$ This is so because we take two observations on the same subject, first in the morning and second in the evening This means that the two observations on a subject are from the same experimental unit. Therefore, the this is not true replication. Because the observations are taken from the same subject in the course of time, there must be some correlation between the two observations. Note that this is different from a two way ANOVA with Diet and Time as the factors. A two way ANOVA will have observations like this: $$ \begin{array}{r|ccccc|l} ~ & \text{Diet} 1 & \text{Diet} 2 & \text{Diet}3 & \text{Diet}4 \\\hline \text{Morning} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \text{Evening} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \hline \end{array} $$ each of the $x$s here are different subjects. This illustrates the concept of nesting. That is, subjects 1, 2, 3 are nested in Diet 1. - The whole plots, the experimental units at the whole plot (Diet) level (the Subjects) act as blocks for the split plot treatment (Morning- Evening) The model for this split plot design is: $$ Y_{ijk} = \mu + \tau_i + S_{ij} + \gamma_{k} + (\tau \gamma)_{ik} + \epsilon_{ijk}, $$ where $$ Y_{ijk} = \text{the response to diet i of subject j at time k,} $$ $$ \tau_i = \text{diet i effect} $$ $$ S_{ij} = \text{subject j's effect in diet i (whole plot error)} $$ $$ (\tau \gamma)_{ik} = \text{the interaction of diet i and time j} $$ $$ \epsilon_{ijk} = \text{split plot error} $$ Once you have the model well-formulated, writing in R aov form is trivial: splitPltMdl <- aov(bloodPressure ~ Diet + ## Diet effect Error(Subject/Diet) + ## nesting of Subject in Diet Time*Diet, ## interaction of Time and Diet data = dietData)
Split plot in R
The major difference between split plot design and other designs such as completely randomized design and variations of block designs is the nesting structure of subjects, that is, when the observatio
Split plot in R The major difference between split plot design and other designs such as completely randomized design and variations of block designs is the nesting structure of subjects, that is, when the observations are from obtained from the same subject (experimental unit) more than once. This leads to a correlation structure within a subject in split plot design which is different from correlation structure in a block. Let's take an example picture of data set from a simple split-plot design (below). This is a study of dietary composition on health, four diets were randomly assigned to 12 subjects, all of similar health status. Baseline blood pressure was established, and one measure of health was blood pressure change after two weeks. Blood pressure was measured in the morning and the evening. (The example is copied from Casella's Statistical Design book example 5.1) $$ \begin{array}{r|ccccc|l} ~ & \text{Diet} 1 & \text{Diet} 2 & \text{Diet}3 & \text{Diet}4 \\\hline ~ & \text{Subject} & \text{Subject} & \text{Subject} &\text{Subject}\\ ~ & 1 \, 2 \, 3 & 4 \, 5 \, 6 & 7 \, 8 \, 9 & 10 \, 11 \, 12\\\hline \text{Morning} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \text{Evening} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \hline \end{array} $$ A few important things to note: There are 12 experimental units (12 subjects) On these 12 units we observe 24 data points ( $2 \times 4 \times 3$), denoted by $x$ This is so because we take two observations on the same subject, first in the morning and second in the evening This means that the two observations on a subject are from the same experimental unit. Therefore, the this is not true replication. Because the observations are taken from the same subject in the course of time, there must be some correlation between the two observations. Note that this is different from a two way ANOVA with Diet and Time as the factors. A two way ANOVA will have observations like this: $$ \begin{array}{r|ccccc|l} ~ & \text{Diet} 1 & \text{Diet} 2 & \text{Diet}3 & \text{Diet}4 \\\hline \text{Morning} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \text{Evening} & x \, x \, x & x \, x \, x & x \, x \, x & x \, x \, x\\ \hline \end{array} $$ each of the $x$s here are different subjects. This illustrates the concept of nesting. That is, subjects 1, 2, 3 are nested in Diet 1. - The whole plots, the experimental units at the whole plot (Diet) level (the Subjects) act as blocks for the split plot treatment (Morning- Evening) The model for this split plot design is: $$ Y_{ijk} = \mu + \tau_i + S_{ij} + \gamma_{k} + (\tau \gamma)_{ik} + \epsilon_{ijk}, $$ where $$ Y_{ijk} = \text{the response to diet i of subject j at time k,} $$ $$ \tau_i = \text{diet i effect} $$ $$ S_{ij} = \text{subject j's effect in diet i (whole plot error)} $$ $$ (\tau \gamma)_{ik} = \text{the interaction of diet i and time j} $$ $$ \epsilon_{ijk} = \text{split plot error} $$ Once you have the model well-formulated, writing in R aov form is trivial: splitPltMdl <- aov(bloodPressure ~ Diet + ## Diet effect Error(Subject/Diet) + ## nesting of Subject in Diet Time*Diet, ## interaction of Time and Diet data = dietData)
Split plot in R The major difference between split plot design and other designs such as completely randomized design and variations of block designs is the nesting structure of subjects, that is, when the observatio
31,080
Which R package to use to calculate component parameters for a mixture model
Try mixdist Here's an example: library(mixdist) #Build data vector "x" as a mixture of data from 3 Normal Distributions x1 <- rnorm(1000, mean=0, sd=2.0) x2 <- rnorm(500, mean=9, sd=1.5) x3 <- rnorm(300, mean=13, sd=1.0) x <- c(x1, x2, x3) #Plot a histogram (you'll play around with the value for "breaks" as #you zero-in on the fit). Then build a data frame that has the #bucket midpoints and counts. breaks <- 30 his <- hist(x, breaks=breaks) df <- data.frame(mid=his$mids, cou=his$counts) head(df) #The above Histogram shows 3 peaks that might be represented by 3 Normal #Distributions. Guess at the 3 Means in Ascending Order, with a guess for #the associated 3 Sigmas and fit the distribution. guemea <- c(3, 11, 14) guesig <- c(1, 1, 1) guedis <- "norm" (fitpro <- mix(as.mixdata(df), mixparam(mu=guemea, sigma=guesig), dist=guedis)) #Plot the results plot(fitpro, main="Fit a Probability Distribution") grid() legend("topright", lty=1, lwd=c(1, 1, 2), c("Original Distribution to be Fit", "Individual Fitted Distributions", "Fitted Distributions Combined"), col=c("blue", "red", rgb(0.2, 0.7, 0.2)), bg="white") =========================== Parameters: pi mu sigma 1 0.5533 -0.565 1.9671 2 0.2907 8.570 1.6169 3 0.1561 12.725 0.9987 Distribution: [1] "norm" Constraints: conpi conmu consigma "NONE" "NONE" "NONE"
Which R package to use to calculate component parameters for a mixture model
Try mixdist Here's an example: library(mixdist) #Build data vector "x" as a mixture of data from 3 Normal Distributions x1 <- rnorm(1000, mean=0, sd=2.0) x2 <- rnorm(500, mean=9, sd=1.5) x3
Which R package to use to calculate component parameters for a mixture model Try mixdist Here's an example: library(mixdist) #Build data vector "x" as a mixture of data from 3 Normal Distributions x1 <- rnorm(1000, mean=0, sd=2.0) x2 <- rnorm(500, mean=9, sd=1.5) x3 <- rnorm(300, mean=13, sd=1.0) x <- c(x1, x2, x3) #Plot a histogram (you'll play around with the value for "breaks" as #you zero-in on the fit). Then build a data frame that has the #bucket midpoints and counts. breaks <- 30 his <- hist(x, breaks=breaks) df <- data.frame(mid=his$mids, cou=his$counts) head(df) #The above Histogram shows 3 peaks that might be represented by 3 Normal #Distributions. Guess at the 3 Means in Ascending Order, with a guess for #the associated 3 Sigmas and fit the distribution. guemea <- c(3, 11, 14) guesig <- c(1, 1, 1) guedis <- "norm" (fitpro <- mix(as.mixdata(df), mixparam(mu=guemea, sigma=guesig), dist=guedis)) #Plot the results plot(fitpro, main="Fit a Probability Distribution") grid() legend("topright", lty=1, lwd=c(1, 1, 2), c("Original Distribution to be Fit", "Individual Fitted Distributions", "Fitted Distributions Combined"), col=c("blue", "red", rgb(0.2, 0.7, 0.2)), bg="white") =========================== Parameters: pi mu sigma 1 0.5533 -0.565 1.9671 2 0.2907 8.570 1.6169 3 0.1561 12.725 0.9987 Distribution: [1] "norm" Constraints: conpi conmu consigma "NONE" "NONE" "NONE"
Which R package to use to calculate component parameters for a mixture model Try mixdist Here's an example: library(mixdist) #Build data vector "x" as a mixture of data from 3 Normal Distributions x1 <- rnorm(1000, mean=0, sd=2.0) x2 <- rnorm(500, mean=9, sd=1.5) x3
31,081
Which R package to use to calculate component parameters for a mixture model
Package Mclust is nice. The mclust function fits a mixture of normals distribution to data. You can automatically choose the number of components based on BIC (mclustmodel) or specify the number of components. There is also no need to convert your data into a data frame. Also, package Mixtools and the function normalmixEM fits a mixture of normals. Update: I recently discovered the mixAK package and the NMixMCMC function and it is terrific. It has many options, including RJMCMC for component selection, right left censoring, etc...
Which R package to use to calculate component parameters for a mixture model
Package Mclust is nice. The mclust function fits a mixture of normals distribution to data. You can automatically choose the number of components based on BIC (mclustmodel) or specify the number of
Which R package to use to calculate component parameters for a mixture model Package Mclust is nice. The mclust function fits a mixture of normals distribution to data. You can automatically choose the number of components based on BIC (mclustmodel) or specify the number of components. There is also no need to convert your data into a data frame. Also, package Mixtools and the function normalmixEM fits a mixture of normals. Update: I recently discovered the mixAK package and the NMixMCMC function and it is terrific. It has many options, including RJMCMC for component selection, right left censoring, etc...
Which R package to use to calculate component parameters for a mixture model Package Mclust is nice. The mclust function fits a mixture of normals distribution to data. You can automatically choose the number of components based on BIC (mclustmodel) or specify the number of
31,082
How to calculate the hat matrix for logistic regression in R?
For logistic regression $\pi$ is calculated using formula $$\pi=\frac{1}{1+\exp(-X\beta)}$$ So diagonal values of $V$ can be calculated in the following manner: pi <- 1/(1+exp(-X%*%beta)) v <- sqrt(pi*(1-pi)) Now multiplying by diagonal matrix from left means that each row is multiplied by corresponding element from diagonal. Which in R can be achieved using simple multiplication: VX <- X*v Then H can be calculated in the following way: H <- VX%*%solve(crossprod(VX,VX),t(VX)) Note Since $V$ contains standard deviations I suspect that the correct formula for $H$ is $$H=VX(X'V^2X)^{-1}X'V$$ The example code works for this formula.
How to calculate the hat matrix for logistic regression in R?
For logistic regression $\pi$ is calculated using formula $$\pi=\frac{1}{1+\exp(-X\beta)}$$ So diagonal values of $V$ can be calculated in the following manner: pi <- 1/(1+exp(-X%*%beta)) v <- sqrt(pi
How to calculate the hat matrix for logistic regression in R? For logistic regression $\pi$ is calculated using formula $$\pi=\frac{1}{1+\exp(-X\beta)}$$ So diagonal values of $V$ can be calculated in the following manner: pi <- 1/(1+exp(-X%*%beta)) v <- sqrt(pi*(1-pi)) Now multiplying by diagonal matrix from left means that each row is multiplied by corresponding element from diagonal. Which in R can be achieved using simple multiplication: VX <- X*v Then H can be calculated in the following way: H <- VX%*%solve(crossprod(VX,VX),t(VX)) Note Since $V$ contains standard deviations I suspect that the correct formula for $H$ is $$H=VX(X'V^2X)^{-1}X'V$$ The example code works for this formula.
How to calculate the hat matrix for logistic regression in R? For logistic regression $\pi$ is calculated using formula $$\pi=\frac{1}{1+\exp(-X\beta)}$$ So diagonal values of $V$ can be calculated in the following manner: pi <- 1/(1+exp(-X%*%beta)) v <- sqrt(pi
31,083
Reducing false positive rate
Regarding first (and second) question: A general approach to reduce misclassifications error by iteratively training models and reweighting rows (based on classification error) is Boosting. I think you might find that technique interesting. Regarding second question: The question sounds a little bit naive to me (but I maybe did not understand your true intention), since reducing misclassification error = improving model performance is one of the challenges in Data Mining / Machine Learning. So if there were a general all-time working strategy, we all would have been replaced by machines (earlier than we will anyways). So I think that yes, the general approach here is educated trial and error. I suggest this question, Better Classification of default in logistic regression, which may give you some ideas for both questioning and model improvement. I suggest to play around a little bit and then come back to ask more specific questions. General questions regarding model improvement are hard to answer without data and/or additional information of the circumstances. Good luck !
Reducing false positive rate
Regarding first (and second) question: A general approach to reduce misclassifications error by iteratively training models and reweighting rows (based on classification error) is Boosting. I think yo
Reducing false positive rate Regarding first (and second) question: A general approach to reduce misclassifications error by iteratively training models and reweighting rows (based on classification error) is Boosting. I think you might find that technique interesting. Regarding second question: The question sounds a little bit naive to me (but I maybe did not understand your true intention), since reducing misclassification error = improving model performance is one of the challenges in Data Mining / Machine Learning. So if there were a general all-time working strategy, we all would have been replaced by machines (earlier than we will anyways). So I think that yes, the general approach here is educated trial and error. I suggest this question, Better Classification of default in logistic regression, which may give you some ideas for both questioning and model improvement. I suggest to play around a little bit and then come back to ask more specific questions. General questions regarding model improvement are hard to answer without data and/or additional information of the circumstances. Good luck !
Reducing false positive rate Regarding first (and second) question: A general approach to reduce misclassifications error by iteratively training models and reweighting rows (based on classification error) is Boosting. I think yo
31,084
Reducing false positive rate
What you can do if you do not find the weight option is create the same effect yourself, by increasing the amount of the positives, for example you can give as an input to the algorithm 2 times each of the known positives an leave the negatives as they where. You can even increase it 10 times, it is a matter of experimenting to get as near as you can to the best possible result.
Reducing false positive rate
What you can do if you do not find the weight option is create the same effect yourself, by increasing the amount of the positives, for example you can give as an input to the algorithm 2 times each o
Reducing false positive rate What you can do if you do not find the weight option is create the same effect yourself, by increasing the amount of the positives, for example you can give as an input to the algorithm 2 times each of the known positives an leave the negatives as they where. You can even increase it 10 times, it is a matter of experimenting to get as near as you can to the best possible result.
Reducing false positive rate What you can do if you do not find the weight option is create the same effect yourself, by increasing the amount of the positives, for example you can give as an input to the algorithm 2 times each o
31,085
Reducing false positive rate
Under Model Selection, choose "Validation Misclassification" as your model selection criterion. This will select the model with the lowest misclassification rate. Or use the profit/loss matrix and attach a cost function to your false positive or false negative.
Reducing false positive rate
Under Model Selection, choose "Validation Misclassification" as your model selection criterion. This will select the model with the lowest misclassification rate. Or use the profit/loss matrix and att
Reducing false positive rate Under Model Selection, choose "Validation Misclassification" as your model selection criterion. This will select the model with the lowest misclassification rate. Or use the profit/loss matrix and attach a cost function to your false positive or false negative.
Reducing false positive rate Under Model Selection, choose "Validation Misclassification" as your model selection criterion. This will select the model with the lowest misclassification rate. Or use the profit/loss matrix and att
31,086
Reducing false positive rate
Yes, it is called as the cutoff under the assess tab. You have to run the whole thing once to check the graphs to decide your optimal cut off (i.e., more true positive or more true negatives based on all rates). Place the cut off module after each model (regression, tree, etc), and check the results for that module. You can then change the user specified value of the cutoff point to get the exact rate for the TP/TN or the overall symmetric misclassification rate. Then run the whole thing again.
Reducing false positive rate
Yes, it is called as the cutoff under the assess tab. You have to run the whole thing once to check the graphs to decide your optimal cut off (i.e., more true positive or more true negatives based on
Reducing false positive rate Yes, it is called as the cutoff under the assess tab. You have to run the whole thing once to check the graphs to decide your optimal cut off (i.e., more true positive or more true negatives based on all rates). Place the cut off module after each model (regression, tree, etc), and check the results for that module. You can then change the user specified value of the cutoff point to get the exact rate for the TP/TN or the overall symmetric misclassification rate. Then run the whole thing again.
Reducing false positive rate Yes, it is called as the cutoff under the assess tab. You have to run the whole thing once to check the graphs to decide your optimal cut off (i.e., more true positive or more true negatives based on
31,087
Why doesn't R output for a paired t-test match the formula for a confidence interval in the t-distribution?
0.5547 is not the $t$ you are looking for. The $t$ you want to use in the equation is the critical value for the $t$-distribution with 8 degrees of freedom (n - 1). qt(0.975, 8) = 2.262 So mean(a-b) + c(-1,1)*(qt(0.975, 8))*(sd(a-b))/sqrt(9) [1] -0.7016018 1.1460462 which matches the output from t.test(). It's nice to check these calculations by hand sometimes to make sure you know where all the numbers are coming from.
Why doesn't R output for a paired t-test match the formula for a confidence interval in the t-distri
0.5547 is not the $t$ you are looking for. The $t$ you want to use in the equation is the critical value for the $t$-distribution with 8 degrees of freedom (n - 1). qt(0.975, 8) = 2.262 So mean(a-b)
Why doesn't R output for a paired t-test match the formula for a confidence interval in the t-distribution? 0.5547 is not the $t$ you are looking for. The $t$ you want to use in the equation is the critical value for the $t$-distribution with 8 degrees of freedom (n - 1). qt(0.975, 8) = 2.262 So mean(a-b) + c(-1,1)*(qt(0.975, 8))*(sd(a-b))/sqrt(9) [1] -0.7016018 1.1460462 which matches the output from t.test(). It's nice to check these calculations by hand sometimes to make sure you know where all the numbers are coming from.
Why doesn't R output for a paired t-test match the formula for a confidence interval in the t-distri 0.5547 is not the $t$ you are looking for. The $t$ you want to use in the equation is the critical value for the $t$-distribution with 8 degrees of freedom (n - 1). qt(0.975, 8) = 2.262 So mean(a-b)
31,088
Expectation as a minimizer of the loss function
Gneiting (2011, JASA): Subject to weak regularity conditions, a scoring function for a real-valued predictand is consistent for the mean functional if and only if it is a Bregman function, that is, of the form $$ S(x,y) = \phi(y)-\phi(x)-\phi'(x)(y-x), $$ where $\phi$ is a convex function with subgradient $\phi'$ (Savage, 1971, JASA). Here $S$ is a scoring function, $x$ is a point prediction, and $y$ is an observation. Gneiting (2011) gives more pointers to literature in his section 3.1.
Expectation as a minimizer of the loss function
Gneiting (2011, JASA): Subject to weak regularity conditions, a scoring function for a real-valued predictand is consistent for the mean functional if and only if it is a Bregman function, that is, o
Expectation as a minimizer of the loss function Gneiting (2011, JASA): Subject to weak regularity conditions, a scoring function for a real-valued predictand is consistent for the mean functional if and only if it is a Bregman function, that is, of the form $$ S(x,y) = \phi(y)-\phi(x)-\phi'(x)(y-x), $$ where $\phi$ is a convex function with subgradient $\phi'$ (Savage, 1971, JASA). Here $S$ is a scoring function, $x$ is a point prediction, and $y$ is an observation. Gneiting (2011) gives more pointers to literature in his section 3.1.
Expectation as a minimizer of the loss function Gneiting (2011, JASA): Subject to weak regularity conditions, a scoring function for a real-valued predictand is consistent for the mean functional if and only if it is a Bregman function, that is, o
31,089
Distribution of half-life from radioactive decay
You ask about the distribution of an order statistic $X_{(k)}$ of $N$ independent and identically distributed random variables $X_1, X_2, \ldots, X_N$ and $k=N/2$ when $N$ is even and $k=(N+1)/2$ when $N$ is odd. Because this order statistic is the median when $N$ is odd and otherwise is a median, I will refer to it henceforth as the "median." When the common distribution function $F$ has a density $F^\prime = f,$ the order statistic has a density, too, given by $$f_{k;X}(x) = \binom{N}{k-1;1;N-k}\, F^{k-1}(x) f(x) (1-F(x))^{N-k}.$$ By choosing time units in which the half-life is $1$, the exponential distribution function is $F(x) = 1 - e^{-x},$ whence $f(x) = e^{-x}$ and therefore $$f_{k;X}(x) = \frac{N!}{(k-1)!(N-k)!} e^{-(N-k+1)x}\left(1 - e^{-x}\right)^{k-1}.$$ One way to understand this is to express it in terms of $U = e^{-X}$ (which, incidentally, has a Uniform$[0,1]$ distribution). The density of $U$ is $$f_{k;U}(u) \ \propto\ u^{N-k}(1-u)^{k-1},$$ immediately recognizable as that of a Beta$(N+1-k, k)$ distribution. Thus, $X_{(k)}$ is seen as the (negative) logarithm of a Beta variable. Here, for example, are histograms of the median of $N=12$ Exponential variables (from 40,000 simulations) and its negative exponential on which, in red, graphs of $f_{k;X}$ and $f_{k;U}$ have been overlaid to demonstrate the correctness of this analysis. At this point you can apply what is known about the Beta distribution to determine in great detail anything you like about the distribution of $X_{(k)},$ so I won't belabor the point. Instead, consult the references, including the following CV threads: For more about the distributions of medians generally, see https://stats.stackexchange.com/a/160148/919. For a detailed analysis of how such distributions approach a Normal distribution as $N$ increases, see https://stats.stackexchange.com/a/86804/919. Use this for accurate approximations when $N \gg 10$ or so. See https://stats.stackexchange.com/a/225990/919 for a sketch of how the initial formula for $f_k$ can be derived.
Distribution of half-life from radioactive decay
You ask about the distribution of an order statistic $X_{(k)}$ of $N$ independent and identically distributed random variables $X_1, X_2, \ldots, X_N$ and $k=N/2$ when $N$ is even and $k=(N+1)/2$ when
Distribution of half-life from radioactive decay You ask about the distribution of an order statistic $X_{(k)}$ of $N$ independent and identically distributed random variables $X_1, X_2, \ldots, X_N$ and $k=N/2$ when $N$ is even and $k=(N+1)/2$ when $N$ is odd. Because this order statistic is the median when $N$ is odd and otherwise is a median, I will refer to it henceforth as the "median." When the common distribution function $F$ has a density $F^\prime = f,$ the order statistic has a density, too, given by $$f_{k;X}(x) = \binom{N}{k-1;1;N-k}\, F^{k-1}(x) f(x) (1-F(x))^{N-k}.$$ By choosing time units in which the half-life is $1$, the exponential distribution function is $F(x) = 1 - e^{-x},$ whence $f(x) = e^{-x}$ and therefore $$f_{k;X}(x) = \frac{N!}{(k-1)!(N-k)!} e^{-(N-k+1)x}\left(1 - e^{-x}\right)^{k-1}.$$ One way to understand this is to express it in terms of $U = e^{-X}$ (which, incidentally, has a Uniform$[0,1]$ distribution). The density of $U$ is $$f_{k;U}(u) \ \propto\ u^{N-k}(1-u)^{k-1},$$ immediately recognizable as that of a Beta$(N+1-k, k)$ distribution. Thus, $X_{(k)}$ is seen as the (negative) logarithm of a Beta variable. Here, for example, are histograms of the median of $N=12$ Exponential variables (from 40,000 simulations) and its negative exponential on which, in red, graphs of $f_{k;X}$ and $f_{k;U}$ have been overlaid to demonstrate the correctness of this analysis. At this point you can apply what is known about the Beta distribution to determine in great detail anything you like about the distribution of $X_{(k)},$ so I won't belabor the point. Instead, consult the references, including the following CV threads: For more about the distributions of medians generally, see https://stats.stackexchange.com/a/160148/919. For a detailed analysis of how such distributions approach a Normal distribution as $N$ increases, see https://stats.stackexchange.com/a/86804/919. Use this for accurate approximations when $N \gg 10$ or so. See https://stats.stackexchange.com/a/225990/919 for a sketch of how the initial formula for $f_k$ can be derived.
Distribution of half-life from radioactive decay You ask about the distribution of an order statistic $X_{(k)}$ of $N$ independent and identically distributed random variables $X_1, X_2, \ldots, X_N$ and $k=N/2$ when $N$ is even and $k=(N+1)/2$ when
31,090
What are differences between industrial statistics and social science statistics/econometrics that are potential stumbling blocks?
Firstly, good on you for reflecting on past errors in your consulting work. You obviously care a lot about giving good advice to your clients, and your self-criticism is likely to make you a good practitioner in the long run. People hiring graduate students as statistical consultants ought to be aware that you get what you pay for, and they are hiring someone who is still in their formal education phase. Statistical theory ought to be thought of as a single body of knowledge on inference, prediction, etc. While it contains a number of different philosophies, methodologies and models, the whole point of the field is that it abstracts away from particular applied problems, and is therefore applicable to any of the sciences when they involve inference, prediction, etc. Statistical theory is (or at least ought to be) the same across applied fields, but there is certainly a difference in emphasis and applications in different applied fields, due to the different kinds of questions and information constraints. Irrespective of the particular fields you are working in, here are some crucial things to bear in mind. Always consider/scrutinise the sampling method: Some fields have data that is collected through nice sampling methods that accord with simple statistical model assumptions, so it is easy to get complacent if you practice exclusively in a field like this. For consulting work, it is important to remind yourself that you must consider/scrutinise the sampling method, in case it raises issues (e.g., informative sampling problems). In econometric work, many of the variables under study are macroeconomic estimates from large-scale survey work, where the estimates use a lot of underlying data (e.g., data from a census, tax agency, etc.). In the social sciences much of the research is based on smaller-scale surveys or other small-scale sampling methods, and sometimes these do not involve properly randomised sampling. Make sure you always turn your mind to the sampling method when you meet a new statistical problem. Be mindful of the distinction between causal inference versus predictive inference: In predictive inference we only care about the predictive accuracy of a model/method, and we do not care much if an intermediary statistical association is estimated poorly or whether a statistical association is due to a causal relationship or not. In general, these problems are "easy". Contrarily, in causal inference we care about the causal effect of variables and so it then becomes important to consider whether specific parameters in a model are estimated well, and whether any statistical association detected is due to a causal relation or not. Generally this involves having knowledge of experimental theory, particularly the distinction between controlled and uncontrolled experiments. Causal inferences can be made from randomised controlled experiments, and in uncontrolled cases we usually fall back on trying to "control" for unobserved confounding factors using regression methods. Learn as much as you can about experimental methodology, and also learn to judge how well (or badly) uncontrolled experiments can make causal inferences through controlling for confounding variables. Always consider problems of "over-fitting": Your general tendency to include model terms even if they don't pass individual "inclusion tests" (and your general skepticism of stepwise regression) is quite reasonable in my view, and accords well with the wisdom of the profession. Methods like that often lead to "over-fitting", so it is often reasonable to throw in a bunch of model terms and keep them in the model even if some look like they might be irrelevant. Keep an eye on the "big picture": Sometimes in consulting work (particularly in the social sciences) statisticians can agonise over squeezing every last drop of information out of a small sample, and questions of whether to include or exclude a single model term then seem like a big deal. If you find this is happening, it may be a sign that the sample size is too small to give reliable and robust inferences (without a heavy dependence on model choices) and the best advice may be that your client should get more data. Sometimes statisticians are loath to propose more data as the answer to a problem, since the essence of our subject is to make the best possible inferences/predictions from what information we have, but in some cases the sample size is the "big picture" and the inclusion/exclusion of a model term is the "small picture".
What are differences between industrial statistics and social science statistics/econometrics that a
Firstly, good on you for reflecting on past errors in your consulting work. You obviously care a lot about giving good advice to your clients, and your self-criticism is likely to make you a good pra
What are differences between industrial statistics and social science statistics/econometrics that are potential stumbling blocks? Firstly, good on you for reflecting on past errors in your consulting work. You obviously care a lot about giving good advice to your clients, and your self-criticism is likely to make you a good practitioner in the long run. People hiring graduate students as statistical consultants ought to be aware that you get what you pay for, and they are hiring someone who is still in their formal education phase. Statistical theory ought to be thought of as a single body of knowledge on inference, prediction, etc. While it contains a number of different philosophies, methodologies and models, the whole point of the field is that it abstracts away from particular applied problems, and is therefore applicable to any of the sciences when they involve inference, prediction, etc. Statistical theory is (or at least ought to be) the same across applied fields, but there is certainly a difference in emphasis and applications in different applied fields, due to the different kinds of questions and information constraints. Irrespective of the particular fields you are working in, here are some crucial things to bear in mind. Always consider/scrutinise the sampling method: Some fields have data that is collected through nice sampling methods that accord with simple statistical model assumptions, so it is easy to get complacent if you practice exclusively in a field like this. For consulting work, it is important to remind yourself that you must consider/scrutinise the sampling method, in case it raises issues (e.g., informative sampling problems). In econometric work, many of the variables under study are macroeconomic estimates from large-scale survey work, where the estimates use a lot of underlying data (e.g., data from a census, tax agency, etc.). In the social sciences much of the research is based on smaller-scale surveys or other small-scale sampling methods, and sometimes these do not involve properly randomised sampling. Make sure you always turn your mind to the sampling method when you meet a new statistical problem. Be mindful of the distinction between causal inference versus predictive inference: In predictive inference we only care about the predictive accuracy of a model/method, and we do not care much if an intermediary statistical association is estimated poorly or whether a statistical association is due to a causal relationship or not. In general, these problems are "easy". Contrarily, in causal inference we care about the causal effect of variables and so it then becomes important to consider whether specific parameters in a model are estimated well, and whether any statistical association detected is due to a causal relation or not. Generally this involves having knowledge of experimental theory, particularly the distinction between controlled and uncontrolled experiments. Causal inferences can be made from randomised controlled experiments, and in uncontrolled cases we usually fall back on trying to "control" for unobserved confounding factors using regression methods. Learn as much as you can about experimental methodology, and also learn to judge how well (or badly) uncontrolled experiments can make causal inferences through controlling for confounding variables. Always consider problems of "over-fitting": Your general tendency to include model terms even if they don't pass individual "inclusion tests" (and your general skepticism of stepwise regression) is quite reasonable in my view, and accords well with the wisdom of the profession. Methods like that often lead to "over-fitting", so it is often reasonable to throw in a bunch of model terms and keep them in the model even if some look like they might be irrelevant. Keep an eye on the "big picture": Sometimes in consulting work (particularly in the social sciences) statisticians can agonise over squeezing every last drop of information out of a small sample, and questions of whether to include or exclude a single model term then seem like a big deal. If you find this is happening, it may be a sign that the sample size is too small to give reliable and robust inferences (without a heavy dependence on model choices) and the best advice may be that your client should get more data. Sometimes statisticians are loath to propose more data as the answer to a problem, since the essence of our subject is to make the best possible inferences/predictions from what information we have, but in some cases the sample size is the "big picture" and the inclusion/exclusion of a model term is the "small picture".
What are differences between industrial statistics and social science statistics/econometrics that a Firstly, good on you for reflecting on past errors in your consulting work. You obviously care a lot about giving good advice to your clients, and your self-criticism is likely to make you a good pra
31,091
What are differences between industrial statistics and social science statistics/econometrics that are potential stumbling blocks?
I assume by "industrial" statistics you mean 'applied' statistics, where the theory behind it is not as relevant. But as the above reply says, all fields of statistics SHOULD be more-or-less the same, although some emphasize different things than others. My own work is kind of in-between academic, social-science-type of statistics and applied industrial statistics. I do a lot of data exploration (biomedical data) and often end up doing regressions and things in an attempt to both explain and predict outcomes. My advice is do indeed include variables in your regression models that may not be statistically significant IF they improve model fit (or if taking them out reduces model fit). Two little diagnostics I make use of (talking about linear regression here) is the R-squared value and the standard error of the regression. The R-squared shows how much the predictors explain the outcome variable, i.e., how well one accounts for the other. If you keep adding variables into your model, the R-squared ALWAYS goes up, even if those variables have no real value and don't predict things any better. The standard error of the regression is the average deviation from the regression line that your outcome variables have; i.e., how "tight" the points are around the line. Both are often overlooked in regression, and both are very useful. Some other tips of the trade: Sample size matters a lot; often a result won't be significant NOT because of the effect size, but because of the sample size. Become familiar with statistical power (to detect a significant result) and use it in your reports as necessary to larger sample sizes in the future and to qualify your results. Graph your results. And intermediate steps. A picture is worth a thousand words. And that includes getting skilled with graphing in your software. Learn new techniques often. There are free and paid forums and statistical learning sites on-line. Use them. As Julia Child said, "learn every time you cook." And in statistics, you are cooking numbers! Scan the literature and see how others are presenting their results; you'll get good ideas for data presentation at least. Keep improving your writing. The write-up of your results is vital. People hear what they want to hear sometimes, so learn to phrase things carefully, especially any caveats or assumptions or violations of assumptions about the statistical models you use (which isn't always a deal-breaker). 4a) Publish something once in a while, even if it's just a minor technical finding or example in your field with a colleague as co-author. It boosts your credibility and is helpful to get your next job. And keep your resume updated at all times. Keep it simple. The simplest solutions (for example in regression) are often the best for practical utility. Learn bootstrapping. I've just become familiar with it and it is intriguing. It may be quite useful for small samples. Learn TWO statistical software packages. I don't know what field you're in exactly, but I recommend R and SAS as one of them. (I'm an SPSS man myself, but I could probably earn literally twice as much money doing the same kind of work if I had learned SAS instead. They don't teach you those lessons in graduate school).
What are differences between industrial statistics and social science statistics/econometrics that a
I assume by "industrial" statistics you mean 'applied' statistics, where the theory behind it is not as relevant. But as the above reply says, all fields of statistics SHOULD be more-or-less the same
What are differences between industrial statistics and social science statistics/econometrics that are potential stumbling blocks? I assume by "industrial" statistics you mean 'applied' statistics, where the theory behind it is not as relevant. But as the above reply says, all fields of statistics SHOULD be more-or-less the same, although some emphasize different things than others. My own work is kind of in-between academic, social-science-type of statistics and applied industrial statistics. I do a lot of data exploration (biomedical data) and often end up doing regressions and things in an attempt to both explain and predict outcomes. My advice is do indeed include variables in your regression models that may not be statistically significant IF they improve model fit (or if taking them out reduces model fit). Two little diagnostics I make use of (talking about linear regression here) is the R-squared value and the standard error of the regression. The R-squared shows how much the predictors explain the outcome variable, i.e., how well one accounts for the other. If you keep adding variables into your model, the R-squared ALWAYS goes up, even if those variables have no real value and don't predict things any better. The standard error of the regression is the average deviation from the regression line that your outcome variables have; i.e., how "tight" the points are around the line. Both are often overlooked in regression, and both are very useful. Some other tips of the trade: Sample size matters a lot; often a result won't be significant NOT because of the effect size, but because of the sample size. Become familiar with statistical power (to detect a significant result) and use it in your reports as necessary to larger sample sizes in the future and to qualify your results. Graph your results. And intermediate steps. A picture is worth a thousand words. And that includes getting skilled with graphing in your software. Learn new techniques often. There are free and paid forums and statistical learning sites on-line. Use them. As Julia Child said, "learn every time you cook." And in statistics, you are cooking numbers! Scan the literature and see how others are presenting their results; you'll get good ideas for data presentation at least. Keep improving your writing. The write-up of your results is vital. People hear what they want to hear sometimes, so learn to phrase things carefully, especially any caveats or assumptions or violations of assumptions about the statistical models you use (which isn't always a deal-breaker). 4a) Publish something once in a while, even if it's just a minor technical finding or example in your field with a colleague as co-author. It boosts your credibility and is helpful to get your next job. And keep your resume updated at all times. Keep it simple. The simplest solutions (for example in regression) are often the best for practical utility. Learn bootstrapping. I've just become familiar with it and it is intriguing. It may be quite useful for small samples. Learn TWO statistical software packages. I don't know what field you're in exactly, but I recommend R and SAS as one of them. (I'm an SPSS man myself, but I could probably earn literally twice as much money doing the same kind of work if I had learned SAS instead. They don't teach you those lessons in graduate school).
What are differences between industrial statistics and social science statistics/econometrics that a I assume by "industrial" statistics you mean 'applied' statistics, where the theory behind it is not as relevant. But as the above reply says, all fields of statistics SHOULD be more-or-less the same
31,092
What is the difference between Consistency and Identification?
Revisiting the definition of identification. Although your definition of consistency is fine, I think you're defining identification in a somewhat odd way, especially with regards to the usage of "if we have enough data." Although we can loosely think about identification as having "infinite data," I'd suggest you instead consider a scenario where you know the true distribution of the observed data. In this sense, let $P$ denote the true distribution of observed data where $P \in \mathcal{P} \equiv \{P_{\theta} : \theta \in \Theta\}$. We are interested in $\theta$ or some function $f(\theta)$. Since $P \in \mathcal{P}$, we know that there exists some $\theta \in \Theta$ such that $P = P_{\theta}$. However, given $P$, we cannot distinguish $\theta$ from any other $\theta'$ such that $P = P_{\theta'}$. In words, this is saying that given $P$, we may not 'know' enough about $\theta$ to uniquely pin it down. To illustrate when this can happen, suppose we observed $P = N(a+b,\sigma^2)$, so that $\theta = (a,b,\sigma^2)$, and we are interested in $f(\theta) = (a,b)$. Given $P$, I cannot uniquely pin down $f(\theta)$, because even though I know $a+b$, I can choose any $f(\theta) = (\theta_1,\theta_2)$ such that $\theta_1 + \theta_2 = a+b$. To make things super concrete, suppose $a = -1,b=1$ so that $a+b = 0$. Then both $(-1,1)$ and $(0,0)$ are consistent with $P$. Hence, even fully knowing the distribution $P$ does not give me enough to pin down the 'true' value of $(a,b)$. In general, given $P$ and $\mathcal{P}$, the best we can say about $\theta$ is that $\theta \in \Theta^*(P)$ where $$\Theta^*(P) \equiv \{\theta \in \Theta : P_\theta = P\}.$$ This is simply defining $\Theta^*(P)$ to be the set of all $\theta$ that agree with the observed distribution $P$. We call this the identified set. We then say that $\theta$ is identified if $\Theta^*(P)$ is a singleton for all $P \in \mathcal{P}$. Here, by singleton, we are saying that given $P$, we can uniquely pin down $\theta$. We similarly define these terms for $f(\theta)$. Relationship between identification and consistency. It should hopefully be somewhat clear from the above that identification and consistency are closely related. In particular, if $\theta$ is not identified, then it follows that consistent estimators cannot exist for $\theta$. Why? Well suppose that we had a consistent estimator $\hat{\theta}$. Because it is consistent, it should converge to all values in $\Theta^*(P)$. Since $\theta$ is not identified, then there are values $\tilde{\theta},\bar{\theta} \in \Theta^*(P)$ such that $\tilde{\theta} \neq \bar{\theta}$, and $\hat{\theta}$ cannot converge to two distinct values! Conversely, if $\theta$ is identified, then consistent estimators may exist, though do not have to. Though most of the time, there will exist a consistent estimator (by appealing to law of large numbers, continuous mapping theorem, and so on), but exceptions exist (i.e., the mean for Pareto distributions with $\alpha < 1$).
What is the difference between Consistency and Identification?
Revisiting the definition of identification. Although your definition of consistency is fine, I think you're defining identification in a somewhat odd way, especially with regards to the usage of "if
What is the difference between Consistency and Identification? Revisiting the definition of identification. Although your definition of consistency is fine, I think you're defining identification in a somewhat odd way, especially with regards to the usage of "if we have enough data." Although we can loosely think about identification as having "infinite data," I'd suggest you instead consider a scenario where you know the true distribution of the observed data. In this sense, let $P$ denote the true distribution of observed data where $P \in \mathcal{P} \equiv \{P_{\theta} : \theta \in \Theta\}$. We are interested in $\theta$ or some function $f(\theta)$. Since $P \in \mathcal{P}$, we know that there exists some $\theta \in \Theta$ such that $P = P_{\theta}$. However, given $P$, we cannot distinguish $\theta$ from any other $\theta'$ such that $P = P_{\theta'}$. In words, this is saying that given $P$, we may not 'know' enough about $\theta$ to uniquely pin it down. To illustrate when this can happen, suppose we observed $P = N(a+b,\sigma^2)$, so that $\theta = (a,b,\sigma^2)$, and we are interested in $f(\theta) = (a,b)$. Given $P$, I cannot uniquely pin down $f(\theta)$, because even though I know $a+b$, I can choose any $f(\theta) = (\theta_1,\theta_2)$ such that $\theta_1 + \theta_2 = a+b$. To make things super concrete, suppose $a = -1,b=1$ so that $a+b = 0$. Then both $(-1,1)$ and $(0,0)$ are consistent with $P$. Hence, even fully knowing the distribution $P$ does not give me enough to pin down the 'true' value of $(a,b)$. In general, given $P$ and $\mathcal{P}$, the best we can say about $\theta$ is that $\theta \in \Theta^*(P)$ where $$\Theta^*(P) \equiv \{\theta \in \Theta : P_\theta = P\}.$$ This is simply defining $\Theta^*(P)$ to be the set of all $\theta$ that agree with the observed distribution $P$. We call this the identified set. We then say that $\theta$ is identified if $\Theta^*(P)$ is a singleton for all $P \in \mathcal{P}$. Here, by singleton, we are saying that given $P$, we can uniquely pin down $\theta$. We similarly define these terms for $f(\theta)$. Relationship between identification and consistency. It should hopefully be somewhat clear from the above that identification and consistency are closely related. In particular, if $\theta$ is not identified, then it follows that consistent estimators cannot exist for $\theta$. Why? Well suppose that we had a consistent estimator $\hat{\theta}$. Because it is consistent, it should converge to all values in $\Theta^*(P)$. Since $\theta$ is not identified, then there are values $\tilde{\theta},\bar{\theta} \in \Theta^*(P)$ such that $\tilde{\theta} \neq \bar{\theta}$, and $\hat{\theta}$ cannot converge to two distinct values! Conversely, if $\theta$ is identified, then consistent estimators may exist, though do not have to. Though most of the time, there will exist a consistent estimator (by appealing to law of large numbers, continuous mapping theorem, and so on), but exceptions exist (i.e., the mean for Pareto distributions with $\alpha < 1$).
What is the difference between Consistency and Identification? Revisiting the definition of identification. Although your definition of consistency is fine, I think you're defining identification in a somewhat odd way, especially with regards to the usage of "if
31,093
Which ML algorithm can learn non-linear interaction effects?
Any universal approximators can do it. You need a term like $A(\beta_A+\beta_{A\times C}\times C)$ to appear, so the interaction between $A$ and $C$ suffices. $$A\times C = \frac{(A+C)^2-A^2-C^2}{2}$$ If you have an universal approximator, it can (locally) approximate the quadratic form somewhere in its formulation, giving you the interaction without explicitly multiplying $A$ and $C$. Then, the only thing that matters is selecting a universal approximator. Neural Networks are in general universal approximator, and so are kernel machines with infinite dimensional kernel spaces (like the radial basis function, for example) too. On neural networks, if you have as inputs $A,B,C$, then with two hidden layers and the square as the activation function you already achieves the possibility of interactions. Consider the column vector $x = [A, B, C]$: $$\hat y = W_2\sigma (W_1 x+b_1)+b_ 2$$ $W_1 x$ passes weighted sums of the initial features, $h_1 = \sigma(W_1 x+b_1)$ square them and finally $W_2h_1+b_ 2$ makes weighted sums of the squared items.
Which ML algorithm can learn non-linear interaction effects?
Any universal approximators can do it. You need a term like $A(\beta_A+\beta_{A\times C}\times C)$ to appear, so the interaction between $A$ and $C$ suffices. $$A\times C = \frac{(A+C)^2-A^2-C^2}{2}$$
Which ML algorithm can learn non-linear interaction effects? Any universal approximators can do it. You need a term like $A(\beta_A+\beta_{A\times C}\times C)$ to appear, so the interaction between $A$ and $C$ suffices. $$A\times C = \frac{(A+C)^2-A^2-C^2}{2}$$ If you have an universal approximator, it can (locally) approximate the quadratic form somewhere in its formulation, giving you the interaction without explicitly multiplying $A$ and $C$. Then, the only thing that matters is selecting a universal approximator. Neural Networks are in general universal approximator, and so are kernel machines with infinite dimensional kernel spaces (like the radial basis function, for example) too. On neural networks, if you have as inputs $A,B,C$, then with two hidden layers and the square as the activation function you already achieves the possibility of interactions. Consider the column vector $x = [A, B, C]$: $$\hat y = W_2\sigma (W_1 x+b_1)+b_ 2$$ $W_1 x$ passes weighted sums of the initial features, $h_1 = \sigma(W_1 x+b_1)$ square them and finally $W_2h_1+b_ 2$ makes weighted sums of the squared items.
Which ML algorithm can learn non-linear interaction effects? Any universal approximators can do it. You need a term like $A(\beta_A+\beta_{A\times C}\times C)$ to appear, so the interaction between $A$ and $C$ suffices. $$A\times C = \frac{(A+C)^2-A^2-C^2}{2}$$
31,094
Which ML algorithm can learn non-linear interaction effects?
MARS (Multivariate Adaptive Regression Splines) are able to detect automatically non-linear interactions between explanatory variables without manually adding them in the model
Which ML algorithm can learn non-linear interaction effects?
MARS (Multivariate Adaptive Regression Splines) are able to detect automatically non-linear interactions between explanatory variables without manually adding them in the model
Which ML algorithm can learn non-linear interaction effects? MARS (Multivariate Adaptive Regression Splines) are able to detect automatically non-linear interactions between explanatory variables without manually adding them in the model
Which ML algorithm can learn non-linear interaction effects? MARS (Multivariate Adaptive Regression Splines) are able to detect automatically non-linear interactions between explanatory variables without manually adding them in the model
31,095
Which ML algorithm can learn non-linear interaction effects?
Perhaps you can add polynomial interaction terms with some high orders and use lasso regression? You can get some clue from the coefficients of these terms. That being said, ML algorithms are usually for prediction instead of estimating the effects.
Which ML algorithm can learn non-linear interaction effects?
Perhaps you can add polynomial interaction terms with some high orders and use lasso regression? You can get some clue from the coefficients of these terms. That being said, ML algorithms are usually
Which ML algorithm can learn non-linear interaction effects? Perhaps you can add polynomial interaction terms with some high orders and use lasso regression? You can get some clue from the coefficients of these terms. That being said, ML algorithms are usually for prediction instead of estimating the effects.
Which ML algorithm can learn non-linear interaction effects? Perhaps you can add polynomial interaction terms with some high orders and use lasso regression? You can get some clue from the coefficients of these terms. That being said, ML algorithms are usually
31,096
Which ML algorithm can learn non-linear interaction effects?
If you need explicit and interpretable interactions you should use MARS of 2nd or 3rd degree. If you need explicit but not interpretable interactions (you will not be able to extract the interaction features after fitting the model) you could use SVM with polynomial kernels. If you are ok with implicit and flexible interactions, as Firebug said, you can use a universal approximator such as a Neural Network with non-linear activations. I guess you could also use SVM with radial basis kernel for this purpose, as it is also a universal approximator, however, I am not completely sure of how would be this model able to model interactions (I posted a question specifically for this matter that has not been answered yet).
Which ML algorithm can learn non-linear interaction effects?
If you need explicit and interpretable interactions you should use MARS of 2nd or 3rd degree. If you need explicit but not interpretable interactions (you will not be able to extract the interaction f
Which ML algorithm can learn non-linear interaction effects? If you need explicit and interpretable interactions you should use MARS of 2nd or 3rd degree. If you need explicit but not interpretable interactions (you will not be able to extract the interaction features after fitting the model) you could use SVM with polynomial kernels. If you are ok with implicit and flexible interactions, as Firebug said, you can use a universal approximator such as a Neural Network with non-linear activations. I guess you could also use SVM with radial basis kernel for this purpose, as it is also a universal approximator, however, I am not completely sure of how would be this model able to model interactions (I posted a question specifically for this matter that has not been answered yet).
Which ML algorithm can learn non-linear interaction effects? If you need explicit and interpretable interactions you should use MARS of 2nd or 3rd degree. If you need explicit but not interpretable interactions (you will not be able to extract the interaction f
31,097
Alternatives to the null hypothesis significance testing framework
Neither Fisher nor Neyman and Pearson proposed a "null hypothesis significance testing framework". Instead, Fisher demonstrated the significance testing framework and Neyman and Pearson later demonstrated the hypothesis testing framework. They are not the same and they are not similar in their objectives. The significance testing framework attempts to quantify the evidence in the data against a null hypothesis, and uses a continuous p-value. The hypothesis testing procedure entails a decision to reject or not reject the null hypothesis and it does not use a p-value. The NHST hybrid that you ask about is an incoherent mixture of two incompatible approaches. Neither Fisher nor Neyman and Pearson would be happy to have their names attached. Please see this paper for a more complete explanation: https://link.springer.com/chapter/10.1007/164_2019_286
Alternatives to the null hypothesis significance testing framework
Neither Fisher nor Neyman and Pearson proposed a "null hypothesis significance testing framework". Instead, Fisher demonstrated the significance testing framework and Neyman and Pearson later demonstr
Alternatives to the null hypothesis significance testing framework Neither Fisher nor Neyman and Pearson proposed a "null hypothesis significance testing framework". Instead, Fisher demonstrated the significance testing framework and Neyman and Pearson later demonstrated the hypothesis testing framework. They are not the same and they are not similar in their objectives. The significance testing framework attempts to quantify the evidence in the data against a null hypothesis, and uses a continuous p-value. The hypothesis testing procedure entails a decision to reject or not reject the null hypothesis and it does not use a p-value. The NHST hybrid that you ask about is an incoherent mixture of two incompatible approaches. Neither Fisher nor Neyman and Pearson would be happy to have their names attached. Please see this paper for a more complete explanation: https://link.springer.com/chapter/10.1007/164_2019_286
Alternatives to the null hypothesis significance testing framework Neither Fisher nor Neyman and Pearson proposed a "null hypothesis significance testing framework". Instead, Fisher demonstrated the significance testing framework and Neyman and Pearson later demonstr
31,098
What topics in statistics are easier to understand if I understand the central limit theorem?
This is actually a very controversial subject. In my career I've noticed that people who understand the CLT often have worse understanding of what is really important when it comes to real-world data. And too often they don't take the time to do simple simulations that show that the CLT can require far greater sample sizes to work than they thought. The idea of large sample theory and asymptotics is not appealing once you get comfortable with the Bayesian paradigm, which focuses on exact inference using flexible models. For example, the Bayesian t-test has parameters for two things we don't know: the ratio of the variances in the two populations, and a parameter for the degree of non-normality in the true unknown distribution. Bayesian posterior inference is exact at all sample sizes and will account for unequal variance and non-normality, and in addition will give you the probability of non-normality. This is explained in my BBR course in section 5.9.3 of the course notes. Another way to get around any need for normality is to use semiparametric models which encompass basic nonparametric tests as special cases. This is also discussed in BBR.
What topics in statistics are easier to understand if I understand the central limit theorem?
This is actually a very controversial subject. In my career I've noticed that people who understand the CLT often have worse understanding of what is really important when it comes to real-world data
What topics in statistics are easier to understand if I understand the central limit theorem? This is actually a very controversial subject. In my career I've noticed that people who understand the CLT often have worse understanding of what is really important when it comes to real-world data. And too often they don't take the time to do simple simulations that show that the CLT can require far greater sample sizes to work than they thought. The idea of large sample theory and asymptotics is not appealing once you get comfortable with the Bayesian paradigm, which focuses on exact inference using flexible models. For example, the Bayesian t-test has parameters for two things we don't know: the ratio of the variances in the two populations, and a parameter for the degree of non-normality in the true unknown distribution. Bayesian posterior inference is exact at all sample sizes and will account for unequal variance and non-normality, and in addition will give you the probability of non-normality. This is explained in my BBR course in section 5.9.3 of the course notes. Another way to get around any need for normality is to use semiparametric models which encompass basic nonparametric tests as special cases. This is also discussed in BBR.
What topics in statistics are easier to understand if I understand the central limit theorem? This is actually a very controversial subject. In my career I've noticed that people who understand the CLT often have worse understanding of what is really important when it comes to real-world data
31,099
What topics in statistics are easier to understand if I understand the central limit theorem?
It's important to understand where distributions come from, when a particular distribution is an appropriate model, what conditions are assumed by a particular model, how different models are approximations of others, etc. For instance, with the Central Limit Theorem, the underlying distribution needs to have a finite standard deviation, and it's generally restricted to IID samples. Understanding the CLT helps you understand how the assumption of IID is used, and how it can be relaxed. Understanding how quickly it converges and what affects the convergence will help you understand things like that more skew will increase the time it takes to converge to a normal distribution, and with a highly skewed distribution a Poisson distribution may be a better model. Understanding when to use a normal or Poisson or student-t or $\chi2$, etc. is an important skill.
What topics in statistics are easier to understand if I understand the central limit theorem?
It's important to understand where distributions come from, when a particular distribution is an appropriate model, what conditions are assumed by a particular model, how different models are approxim
What topics in statistics are easier to understand if I understand the central limit theorem? It's important to understand where distributions come from, when a particular distribution is an appropriate model, what conditions are assumed by a particular model, how different models are approximations of others, etc. For instance, with the Central Limit Theorem, the underlying distribution needs to have a finite standard deviation, and it's generally restricted to IID samples. Understanding the CLT helps you understand how the assumption of IID is used, and how it can be relaxed. Understanding how quickly it converges and what affects the convergence will help you understand things like that more skew will increase the time it takes to converge to a normal distribution, and with a highly skewed distribution a Poisson distribution may be a better model. Understanding when to use a normal or Poisson or student-t or $\chi2$, etc. is an important skill.
What topics in statistics are easier to understand if I understand the central limit theorem? It's important to understand where distributions come from, when a particular distribution is an appropriate model, what conditions are assumed by a particular model, how different models are approxim
31,100
What topics in statistics are easier to understand if I understand the central limit theorem?
Your question runs to the heart of the difference between education and training. Instead of statistics, consider pharmacy and medicine. A pharmacist has to have extensive coursework in chemistry and biology, yet their primary function or their nearly exclusive function is to count manufactured pills. Very few pharmacists compound drugs anymore. And, while their advising role couldn’t be substituted for by someone else, most of their advice is repetitive. Likewise, for a general practitioner, in terms of frequency of behaviors, their most-used skills are taking blood pressure, looking in your mouth, and taking your pulse. That is hardly a good use for the calculus, chemistry, biology, and higher-end medical training that they received. Indeed, the reason that physician assistants and pharmacy assistants exist in U.S. medicine is that most things of importance can be trained into a person and do not need higher-end reasoning. The Central Limit Theorem is that sort of thing. If you completely skipped it, you could still do a t-test, estimate a Bayesian posterior density, find the sample median, or perform the Kolmogorov-Smirnov test. For 95% of the applications out there, you would be skilled enough, and you would be competent enough to provide advice to others as well. The difficulty would happen when you believed you knew what to do, but you were wrong. For example, there are distributions where the assumptions of the Central Limit Theorem are strongly violated, and the sample mean is without meaning at all. In some areas of knowledge, that is a common problem. In other areas, it is never a problem. The Central Limit Theorem, at its most basic application, lets you know that sampling distributions exist as a concept. At the advanced level, it will keep your work from imploding. EDIT For The Comments Consider prices set in a double auction, $p_1$ and $p_2$ with quantities $q_1$ and $q_2$. Return is defined as $$r_1=\frac{p_2}{p_1}\times\frac{q_2}{q_1}-1.$$ Let us define $R=r+1$. For brevity, let us ignore dividends and when $q_2=0$ due to bankruptcy and when $q_2^j=kq_1^j$ and for mergers, or this will go on for about forty pages. In a double auction there is no winner's curse, so the rational action of each actor is to bid their expectation as to its value. Again, for brevity as this is not required if we can go on for forty pages, let us assume there are very many actors. The limit book, which in later operations will be scaled by the variance, should be normally distributed around an equilibrium price $p^*$. Ignoring stock splits and stock dividends, $q_1=q_2$, so $$R=\frac{p_2}{p_1}.$$ Now, noting that $R$ is a slope, we can find the ratio distribution of the slopes. Unfortunately, if you do that in Cartesian coordinates around $(0,0)$ you end up with a messy mixture distribution of a Cauchy distribution and a distribution with finite variance. It isn't useful, at least in economics, because it requires data that could not be reached because the necessary extra data was never recorded. However, if you integrate around the equilibrium prices $(p^*_1,p^*_2)$ and formally account for the cost of liquidity and the effect of bankruptcy, then you end up with a distribution that looks like real world data. Note that $\Re^2$ is not an ordered set, so the idea of $(0,0)$ is a bit arbitrary. You would then transform the distribution by adding back in the equilibrium return of $\frac{p_2^*}{p_1^*}.$ It is easier if you think about this as a vector in polar coordinates. The distribution of the slopes of the vector of bivariate shocks $(\epsilon_1,\epsilon_2)$ has no mean or variance. The shocks, individually, are normally distributed. As a visual example, consider the distribution of daily returns for Carnival Cruise Lines below. The process gets complex when you consider annual returns instead because equity returns are not scale-invariant. You can see multi-week long shifts in the location of the supply and demand curves and those long shifts can be observed in annual returns sometimes as multiple peaks or splits in the scale parameter. The red line is the fitted line. Because the distribution lacks a first moment, standard tools such as least-squares will produce spurious results. That is the source of the failure of models like the Capital Asset Pricing Model or Ito models such as Black-Scholes, or time-series tools like GARCH to fail in validation over the population of data. In fact, when Fama and MacBeth decisively falsified models like the CAPM in 1973, one would have thought they would have gone away. Indeed, the third to the last paragraph in Black and Scholes seminal paper on options pricing states they tested their model and it failed to pass validation. Likewise, the paper introducing GARCH as a concept tested the tool on equity returns and found the assumptions so strongly violated that they stated it shouldn't be used for equities. However, what every economist learns is that $\hat{\beta}=(X'X)^{-1}(X'Y)$ and it or a cousin, such as FGLS, fills the literature. The Central Limit Theorem doesn't apply to a range of real data types, other than equity securities. If you do not know that, your field can produce 3800 papers on one small anomaly in options pricing as finance has. Just a final note on the picture above, it is possible to improve the fit. The solution I used was a bit crude but vastly superior to assuming normality. Hundreds of thousands of hours have been spent in research in finance, financial economics, and macroeconomics by ignoring the fact that returns are not data. Prices are data. Volumes are data. Returns are a statistic and a function of prices, volumes, and dividends. It is no more proper to assume a statistic's distribution than it would be proper to assume the sampling distribution of the difference of two means is the $\chi^2$ distribution because you didn't check to see if that was correct. You can find examples of this type of phenomenon in physics, hydrology, biology and medicine. The Central Limit Theorem not only says what happens when it works, but it also sets the conditions of when it does not work. It is both a blessing and a warning. You are correct, there are practical limitations on the CLT, but technicians never know that. Personally, I have yet to be given an infinitely large data set. My guess is that my laptop is happier with that state of affairs anyway.
What topics in statistics are easier to understand if I understand the central limit theorem?
Your question runs to the heart of the difference between education and training. Instead of statistics, consider pharmacy and medicine. A pharmacist has to have extensive coursework in chemistry and
What topics in statistics are easier to understand if I understand the central limit theorem? Your question runs to the heart of the difference between education and training. Instead of statistics, consider pharmacy and medicine. A pharmacist has to have extensive coursework in chemistry and biology, yet their primary function or their nearly exclusive function is to count manufactured pills. Very few pharmacists compound drugs anymore. And, while their advising role couldn’t be substituted for by someone else, most of their advice is repetitive. Likewise, for a general practitioner, in terms of frequency of behaviors, their most-used skills are taking blood pressure, looking in your mouth, and taking your pulse. That is hardly a good use for the calculus, chemistry, biology, and higher-end medical training that they received. Indeed, the reason that physician assistants and pharmacy assistants exist in U.S. medicine is that most things of importance can be trained into a person and do not need higher-end reasoning. The Central Limit Theorem is that sort of thing. If you completely skipped it, you could still do a t-test, estimate a Bayesian posterior density, find the sample median, or perform the Kolmogorov-Smirnov test. For 95% of the applications out there, you would be skilled enough, and you would be competent enough to provide advice to others as well. The difficulty would happen when you believed you knew what to do, but you were wrong. For example, there are distributions where the assumptions of the Central Limit Theorem are strongly violated, and the sample mean is without meaning at all. In some areas of knowledge, that is a common problem. In other areas, it is never a problem. The Central Limit Theorem, at its most basic application, lets you know that sampling distributions exist as a concept. At the advanced level, it will keep your work from imploding. EDIT For The Comments Consider prices set in a double auction, $p_1$ and $p_2$ with quantities $q_1$ and $q_2$. Return is defined as $$r_1=\frac{p_2}{p_1}\times\frac{q_2}{q_1}-1.$$ Let us define $R=r+1$. For brevity, let us ignore dividends and when $q_2=0$ due to bankruptcy and when $q_2^j=kq_1^j$ and for mergers, or this will go on for about forty pages. In a double auction there is no winner's curse, so the rational action of each actor is to bid their expectation as to its value. Again, for brevity as this is not required if we can go on for forty pages, let us assume there are very many actors. The limit book, which in later operations will be scaled by the variance, should be normally distributed around an equilibrium price $p^*$. Ignoring stock splits and stock dividends, $q_1=q_2$, so $$R=\frac{p_2}{p_1}.$$ Now, noting that $R$ is a slope, we can find the ratio distribution of the slopes. Unfortunately, if you do that in Cartesian coordinates around $(0,0)$ you end up with a messy mixture distribution of a Cauchy distribution and a distribution with finite variance. It isn't useful, at least in economics, because it requires data that could not be reached because the necessary extra data was never recorded. However, if you integrate around the equilibrium prices $(p^*_1,p^*_2)$ and formally account for the cost of liquidity and the effect of bankruptcy, then you end up with a distribution that looks like real world data. Note that $\Re^2$ is not an ordered set, so the idea of $(0,0)$ is a bit arbitrary. You would then transform the distribution by adding back in the equilibrium return of $\frac{p_2^*}{p_1^*}.$ It is easier if you think about this as a vector in polar coordinates. The distribution of the slopes of the vector of bivariate shocks $(\epsilon_1,\epsilon_2)$ has no mean or variance. The shocks, individually, are normally distributed. As a visual example, consider the distribution of daily returns for Carnival Cruise Lines below. The process gets complex when you consider annual returns instead because equity returns are not scale-invariant. You can see multi-week long shifts in the location of the supply and demand curves and those long shifts can be observed in annual returns sometimes as multiple peaks or splits in the scale parameter. The red line is the fitted line. Because the distribution lacks a first moment, standard tools such as least-squares will produce spurious results. That is the source of the failure of models like the Capital Asset Pricing Model or Ito models such as Black-Scholes, or time-series tools like GARCH to fail in validation over the population of data. In fact, when Fama and MacBeth decisively falsified models like the CAPM in 1973, one would have thought they would have gone away. Indeed, the third to the last paragraph in Black and Scholes seminal paper on options pricing states they tested their model and it failed to pass validation. Likewise, the paper introducing GARCH as a concept tested the tool on equity returns and found the assumptions so strongly violated that they stated it shouldn't be used for equities. However, what every economist learns is that $\hat{\beta}=(X'X)^{-1}(X'Y)$ and it or a cousin, such as FGLS, fills the literature. The Central Limit Theorem doesn't apply to a range of real data types, other than equity securities. If you do not know that, your field can produce 3800 papers on one small anomaly in options pricing as finance has. Just a final note on the picture above, it is possible to improve the fit. The solution I used was a bit crude but vastly superior to assuming normality. Hundreds of thousands of hours have been spent in research in finance, financial economics, and macroeconomics by ignoring the fact that returns are not data. Prices are data. Volumes are data. Returns are a statistic and a function of prices, volumes, and dividends. It is no more proper to assume a statistic's distribution than it would be proper to assume the sampling distribution of the difference of two means is the $\chi^2$ distribution because you didn't check to see if that was correct. You can find examples of this type of phenomenon in physics, hydrology, biology and medicine. The Central Limit Theorem not only says what happens when it works, but it also sets the conditions of when it does not work. It is both a blessing and a warning. You are correct, there are practical limitations on the CLT, but technicians never know that. Personally, I have yet to be given an infinitely large data set. My guess is that my laptop is happier with that state of affairs anyway.
What topics in statistics are easier to understand if I understand the central limit theorem? Your question runs to the heart of the difference between education and training. Instead of statistics, consider pharmacy and medicine. A pharmacist has to have extensive coursework in chemistry and