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
|
---|---|---|---|---|---|---|
50,801 |
Forecasting demographic census
|
I don't know about the first point. But for the second one, autoregressive (AR) functions could be simple. I would really chose a parametric method against a non-parametric one. The forecasting in AR is straight forward. And consensus data has lots of samples for each period so you can get robust parameter estimates at each time. And for the association x_n-1 to x_n function is simply a smoothed interpolation of any choice.
Changes in zones, well based on empirical data or prior belief?
State of the art in consenus? Those methods are arcane. They iterate over generations! Aeons. You could use Gaussian processes which would be quite advanced methodology for these problems. But most in the field stick to older methods given more 'tuning'.
Best.
|
Forecasting demographic census
|
I don't know about the first point. But for the second one, autoregressive (AR) functions could be simple. I would really chose a parametric method against a non-parametric one. The forecasting in AR
|
Forecasting demographic census
I don't know about the first point. But for the second one, autoregressive (AR) functions could be simple. I would really chose a parametric method against a non-parametric one. The forecasting in AR is straight forward. And consensus data has lots of samples for each period so you can get robust parameter estimates at each time. And for the association x_n-1 to x_n function is simply a smoothed interpolation of any choice.
Changes in zones, well based on empirical data or prior belief?
State of the art in consenus? Those methods are arcane. They iterate over generations! Aeons. You could use Gaussian processes which would be quite advanced methodology for these problems. But most in the field stick to older methods given more 'tuning'.
Best.
|
Forecasting demographic census
I don't know about the first point. But for the second one, autoregressive (AR) functions could be simple. I would really chose a parametric method against a non-parametric one. The forecasting in AR
|
50,802 |
Prediction of the 1st stage in 2SLS not important?
|
Do we care how accurate the prediction of x^ actually is?
Yes, we definitely do. The instruments must be valid for the model to be considered acceptable. Any unnecessary instruments will not predict the x^ accurately. To check if the instruments are valid (predicting well), you can apply the Sargan Test. This test will also indicate if any of the instruments belong in the second stage (actual equation to be estimated).
Do the predicted values in the first stage have any interpretation?
Can the predicted value x^ be evaluated against the actual values of the instrumented variable?
You could say that the first stage removes the bias from the model caused due to endogeneity. The first stage attempts to capture the exogenous effects and remove any endogenous effects from the instrumented variable. If the instruments are valid, you could consider it as the exogenous effects of 'x' on the model equation. So, the x^ used in the second stage is supposed to represent the exogenous effects.
I hope this helps give you some intuition into the 2SLS stages.
|
Prediction of the 1st stage in 2SLS not important?
|
Do we care how accurate the prediction of x^ actually is?
Yes, we definitely do. The instruments must be valid for the model to be considered acceptable. Any unnecessary instruments will not predict
|
Prediction of the 1st stage in 2SLS not important?
Do we care how accurate the prediction of x^ actually is?
Yes, we definitely do. The instruments must be valid for the model to be considered acceptable. Any unnecessary instruments will not predict the x^ accurately. To check if the instruments are valid (predicting well), you can apply the Sargan Test. This test will also indicate if any of the instruments belong in the second stage (actual equation to be estimated).
Do the predicted values in the first stage have any interpretation?
Can the predicted value x^ be evaluated against the actual values of the instrumented variable?
You could say that the first stage removes the bias from the model caused due to endogeneity. The first stage attempts to capture the exogenous effects and remove any endogenous effects from the instrumented variable. If the instruments are valid, you could consider it as the exogenous effects of 'x' on the model equation. So, the x^ used in the second stage is supposed to represent the exogenous effects.
I hope this helps give you some intuition into the 2SLS stages.
|
Prediction of the 1st stage in 2SLS not important?
Do we care how accurate the prediction of x^ actually is?
Yes, we definitely do. The instruments must be valid for the model to be considered acceptable. Any unnecessary instruments will not predict
|
50,803 |
Number of samples in scikit-Learn cost function for Ridge/Lasso regression
|
You are right that the standartization $\gamma = \frac{c}{n}$, where $n$ is the sample size, aims to make regularization term $\alpha$ invariant to different sample sizes. This makes sense for Lasso-like models that compute coefficients coordinate-wise via soft-thresholding:
$$
\mathbf{w}_j \leftarrow \mathcal{S}_{\alpha}\Big(\frac{1}{n} \langle \mathbf{x}_j, \mathbf{r}_j \rangle \Big) = \text{sign} \Big(\frac{1}{n} \langle \mathbf{x}_j, \mathbf{r}_j \rangle \Big) \Big(|\alpha| - \frac{1}{n} \langle \mathbf{x}_j, \mathbf{r}_j \rangle \Big)_+
$$
Same with Elastic Net.
But in case of Ridge, which has a closed-form solution, I believe multiplication by $\gamma$ will be redundant and uninformative. First, let us quickly derive the solution:
$$
\min_{\mathbf{w}} \big\{ \| \mathbf{y} - \mathbf{X}\mathbf{w} \|_2^2 + \alpha \| \mathbf{w} \|_2^2 \big\} \\
\frac{d}{d\mathbf{w}}\Big[ (\mathbf{y} - \mathbf{X}\mathbf{w})^T(\mathbf{y} - \mathbf{X}\mathbf{w}) + \alpha\mathbf{w}^T\mathbf{w} \Big] = \mathbf{0} \\
-2 \mathbf{X}^T(\mathbf{y} - \mathbf{X}\mathbf{w}) + 2\alpha\mathbf{w} = \mathbf{0} \\
\mathbf{X}^T(\mathbf{y} - \mathbf{X}\mathbf{w}) - \alpha\mathbf{w} = \mathbf{0} \\
\mathbf{w}^* = (\mathbf{X}^T\mathbf{X} + \alpha\mathbf{I})^{-1}\mathbf{X}^T\mathbf{y}
$$
Now, what happens if we multiply the loss by $\gamma$? We end up with something like this:
$$
\mathbf{w}_{\gamma}^* = (\gamma\mathbf{X}^T\mathbf{X} + \alpha\mathbf{I})^{-1}\gamma\mathbf{X}^T\mathbf{y}
$$
or using matrix factorization like SVD:
$$
\mathbf{w}_{\gamma}^{SVD} = \mathbf{V}(\gamma\mathbf{D}^2 + \alpha\mathbf{I})^{-1} \gamma\mathbf{D}\mathbf{U}^T\mathbf{y} \\
\mathbf{X} = \mathbf{U} \mathbf{D} \mathbf{V}^T
$$
So, what does this standartization involve? Сan we explicitly state that it produces invariant results? (maybe the dual formulation will shed some light on this)
|
Number of samples in scikit-Learn cost function for Ridge/Lasso regression
|
You are right that the standartization $\gamma = \frac{c}{n}$, where $n$ is the sample size, aims to make regularization term $\alpha$ invariant to different sample sizes. This makes sense for Lasso-l
|
Number of samples in scikit-Learn cost function for Ridge/Lasso regression
You are right that the standartization $\gamma = \frac{c}{n}$, where $n$ is the sample size, aims to make regularization term $\alpha$ invariant to different sample sizes. This makes sense for Lasso-like models that compute coefficients coordinate-wise via soft-thresholding:
$$
\mathbf{w}_j \leftarrow \mathcal{S}_{\alpha}\Big(\frac{1}{n} \langle \mathbf{x}_j, \mathbf{r}_j \rangle \Big) = \text{sign} \Big(\frac{1}{n} \langle \mathbf{x}_j, \mathbf{r}_j \rangle \Big) \Big(|\alpha| - \frac{1}{n} \langle \mathbf{x}_j, \mathbf{r}_j \rangle \Big)_+
$$
Same with Elastic Net.
But in case of Ridge, which has a closed-form solution, I believe multiplication by $\gamma$ will be redundant and uninformative. First, let us quickly derive the solution:
$$
\min_{\mathbf{w}} \big\{ \| \mathbf{y} - \mathbf{X}\mathbf{w} \|_2^2 + \alpha \| \mathbf{w} \|_2^2 \big\} \\
\frac{d}{d\mathbf{w}}\Big[ (\mathbf{y} - \mathbf{X}\mathbf{w})^T(\mathbf{y} - \mathbf{X}\mathbf{w}) + \alpha\mathbf{w}^T\mathbf{w} \Big] = \mathbf{0} \\
-2 \mathbf{X}^T(\mathbf{y} - \mathbf{X}\mathbf{w}) + 2\alpha\mathbf{w} = \mathbf{0} \\
\mathbf{X}^T(\mathbf{y} - \mathbf{X}\mathbf{w}) - \alpha\mathbf{w} = \mathbf{0} \\
\mathbf{w}^* = (\mathbf{X}^T\mathbf{X} + \alpha\mathbf{I})^{-1}\mathbf{X}^T\mathbf{y}
$$
Now, what happens if we multiply the loss by $\gamma$? We end up with something like this:
$$
\mathbf{w}_{\gamma}^* = (\gamma\mathbf{X}^T\mathbf{X} + \alpha\mathbf{I})^{-1}\gamma\mathbf{X}^T\mathbf{y}
$$
or using matrix factorization like SVD:
$$
\mathbf{w}_{\gamma}^{SVD} = \mathbf{V}(\gamma\mathbf{D}^2 + \alpha\mathbf{I})^{-1} \gamma\mathbf{D}\mathbf{U}^T\mathbf{y} \\
\mathbf{X} = \mathbf{U} \mathbf{D} \mathbf{V}^T
$$
So, what does this standartization involve? Сan we explicitly state that it produces invariant results? (maybe the dual formulation will shed some light on this)
|
Number of samples in scikit-Learn cost function for Ridge/Lasso regression
You are right that the standartization $\gamma = \frac{c}{n}$, where $n$ is the sample size, aims to make regularization term $\alpha$ invariant to different sample sizes. This makes sense for Lasso-l
|
50,804 |
Nuisance parameters and $o_p(n^{-1/4})$ convergence: citation
|
The paper I'm looking for appears to be
Newey, W. K. (1994). The Asymptotic Variance of Semiparametric Estimators. Econometrica, 62(6), 1349–1382. https://doi.org/10.2307/2951752
The fourth-root convergence assumption appears in the discussion following Assumption 5.1
|
Nuisance parameters and $o_p(n^{-1/4})$ convergence: citation
|
The paper I'm looking for appears to be
Newey, W. K. (1994). The Asymptotic Variance of Semiparametric Estimators. Econometrica, 62(6), 1349–1382. https://doi.org/10.2307/2951752
The fourth-root conve
|
Nuisance parameters and $o_p(n^{-1/4})$ convergence: citation
The paper I'm looking for appears to be
Newey, W. K. (1994). The Asymptotic Variance of Semiparametric Estimators. Econometrica, 62(6), 1349–1382. https://doi.org/10.2307/2951752
The fourth-root convergence assumption appears in the discussion following Assumption 5.1
|
Nuisance parameters and $o_p(n^{-1/4})$ convergence: citation
The paper I'm looking for appears to be
Newey, W. K. (1994). The Asymptotic Variance of Semiparametric Estimators. Econometrica, 62(6), 1349–1382. https://doi.org/10.2307/2951752
The fourth-root conve
|
50,805 |
Statistical significance or Hypothesis testing? [duplicate]
|
Two questions on Cross Validated that contain answers:
What is the difference between "testing of hypothesis" and "test of significance"?
Is the "hybrid" between Fisher and Neyman-Pearson approaches to statistical testing really an "incoherent mishmash"?
Papers that explain in depth with historical context:
Goodman, Toward evidence-based medical statistics. 1: The P value fallacy. https://pubmed.ncbi.nlm.nih.gov/10383371/
Hurlbert, S., & Lombardi, C. (2009). Final collapse of the Neyman-Pearson decision theoretic framework and rise of the neoFisherian. Annales Zoologici Fennici, 46(5), 311–349. (Link to paper)
Lew, M. J. (2012). Bad statistical practice in pharmacology (and other basic biomedical disciplines): you probably don't know P. British Journal of Pharmacology, 166(5), 1559–1567. doi:10.1111/j.1476-5381.2012.01931.x (Link to paper)
A paper that explains the difference and also puts it into the context of scientific inference:
Lew M.J. (2019) A Reckless Guide to P-values. In: Bespalov A., Michel M., Steckler T. (eds) Good Research Practice in Non-Clinical Pharmacology and Biomedicine. Handbook of Experimental Pharmacology, vol 257. Springer, Cham. https://doi.org/10.1007/164_2019_286
|
Statistical significance or Hypothesis testing? [duplicate]
|
Two questions on Cross Validated that contain answers:
What is the difference between "testing of hypothesis" and "test of significance"?
Is the "hybrid" between Fisher and Neyman-Pearson approaches t
|
Statistical significance or Hypothesis testing? [duplicate]
Two questions on Cross Validated that contain answers:
What is the difference between "testing of hypothesis" and "test of significance"?
Is the "hybrid" between Fisher and Neyman-Pearson approaches to statistical testing really an "incoherent mishmash"?
Papers that explain in depth with historical context:
Goodman, Toward evidence-based medical statistics. 1: The P value fallacy. https://pubmed.ncbi.nlm.nih.gov/10383371/
Hurlbert, S., & Lombardi, C. (2009). Final collapse of the Neyman-Pearson decision theoretic framework and rise of the neoFisherian. Annales Zoologici Fennici, 46(5), 311–349. (Link to paper)
Lew, M. J. (2012). Bad statistical practice in pharmacology (and other basic biomedical disciplines): you probably don't know P. British Journal of Pharmacology, 166(5), 1559–1567. doi:10.1111/j.1476-5381.2012.01931.x (Link to paper)
A paper that explains the difference and also puts it into the context of scientific inference:
Lew M.J. (2019) A Reckless Guide to P-values. In: Bespalov A., Michel M., Steckler T. (eds) Good Research Practice in Non-Clinical Pharmacology and Biomedicine. Handbook of Experimental Pharmacology, vol 257. Springer, Cham. https://doi.org/10.1007/164_2019_286
|
Statistical significance or Hypothesis testing? [duplicate]
Two questions on Cross Validated that contain answers:
What is the difference between "testing of hypothesis" and "test of significance"?
Is the "hybrid" between Fisher and Neyman-Pearson approaches t
|
50,806 |
Wilcoxon–Mann–Whitney test sample size
|
Very roughly, suppose $\sigma/\Delta = 5,$ (where $\sigma$ is population standard deviation, $\Delta$ is effect size; maybe $\sigma=10, \Delta=2.)$ and desired power is 95%, then for a pooled t test $n \approx 650$ is required in each group (version), according to an on-line calculator here for pooled 2-sample t tests on normal data.
One example: $n=650, \mu_0 = 80, \mu_a = 82, \sigma=10.$
set.seed(1234) # for reproducibility
x1 = rnorm(650, 80, 10)
x2 = rnorm(650, 82, 10)
A pooled t test finds a significant difference for these
fictitious data with P-value about $0.0002 < 0.05 = 5\%.$
t.test(x1, x2, var.eq=T)
Two Sample t-test
data: x1 and x2
t = -3.7516, df = 1298, p-value = 0.0001834
alternative hypothesis:
true difference in means is not equal to 0
95 percent confidence interval:
-3.1259132 -0.9792445
sample estimates:
mean of x mean of y
79.80134 81.85392
So this seems to be going in the right direction. But is this just a "lucky" sample? How often do we reject, if we do such a test $10^5$ times?
set.seed(2021)
pv = replicate(10^5, t.test(rnorm(650,80,10),
rnorm(650,82,10), var.eq=T)$p.val)
mean(pv <= 0.05)
[1] 0.9507
The power is very nearly the 95% 'promised' by the on-line calculator.
A two-sample Wilcoxon rank sum test gives about the same
result when used with normal data; the power is about 94%. [I used fewer iterations because the program runs slowly.]
set.seed(2021)
pv = replicate(10^4, wilcox.test(rnorm(650,80,10),
rnorm(650,82,10))$p.val)
mean(pv <= 0.05)
[1] 0.9411
One run with non-normal data gives about 87% power.
The exponential populations involved in this simulation
have roughly the same shift and standard deviations as the
normal distributions used in the on-line calculator, but they are highly right skewed. Results will
vary depending on the shapes of the distributions involved. (Often 80% power is considered good enough. Additional simulation runs show that $n=700$ gives power near 90%; $n=800,$ about 95%.)
set.seed(1011)
pv = replicate(10^4, wilcox.test(rexp(650,1/9),
rexp(650,1/11))$p.val)
mean(pv <= 0.05)
[1] 0.8735
[Note: If the data are known to be exponential,
then there is a better test for different means than
the nonparametric 2-sample Wilcoxon test.]
|
Wilcoxon–Mann–Whitney test sample size
|
Very roughly, suppose $\sigma/\Delta = 5,$ (where $\sigma$ is population standard deviation, $\Delta$ is effect size; maybe $\sigma=10, \Delta=2.)$ and desired power is 95%, then for a pooled t test $
|
Wilcoxon–Mann–Whitney test sample size
Very roughly, suppose $\sigma/\Delta = 5,$ (where $\sigma$ is population standard deviation, $\Delta$ is effect size; maybe $\sigma=10, \Delta=2.)$ and desired power is 95%, then for a pooled t test $n \approx 650$ is required in each group (version), according to an on-line calculator here for pooled 2-sample t tests on normal data.
One example: $n=650, \mu_0 = 80, \mu_a = 82, \sigma=10.$
set.seed(1234) # for reproducibility
x1 = rnorm(650, 80, 10)
x2 = rnorm(650, 82, 10)
A pooled t test finds a significant difference for these
fictitious data with P-value about $0.0002 < 0.05 = 5\%.$
t.test(x1, x2, var.eq=T)
Two Sample t-test
data: x1 and x2
t = -3.7516, df = 1298, p-value = 0.0001834
alternative hypothesis:
true difference in means is not equal to 0
95 percent confidence interval:
-3.1259132 -0.9792445
sample estimates:
mean of x mean of y
79.80134 81.85392
So this seems to be going in the right direction. But is this just a "lucky" sample? How often do we reject, if we do such a test $10^5$ times?
set.seed(2021)
pv = replicate(10^5, t.test(rnorm(650,80,10),
rnorm(650,82,10), var.eq=T)$p.val)
mean(pv <= 0.05)
[1] 0.9507
The power is very nearly the 95% 'promised' by the on-line calculator.
A two-sample Wilcoxon rank sum test gives about the same
result when used with normal data; the power is about 94%. [I used fewer iterations because the program runs slowly.]
set.seed(2021)
pv = replicate(10^4, wilcox.test(rnorm(650,80,10),
rnorm(650,82,10))$p.val)
mean(pv <= 0.05)
[1] 0.9411
One run with non-normal data gives about 87% power.
The exponential populations involved in this simulation
have roughly the same shift and standard deviations as the
normal distributions used in the on-line calculator, but they are highly right skewed. Results will
vary depending on the shapes of the distributions involved. (Often 80% power is considered good enough. Additional simulation runs show that $n=700$ gives power near 90%; $n=800,$ about 95%.)
set.seed(1011)
pv = replicate(10^4, wilcox.test(rexp(650,1/9),
rexp(650,1/11))$p.val)
mean(pv <= 0.05)
[1] 0.8735
[Note: If the data are known to be exponential,
then there is a better test for different means than
the nonparametric 2-sample Wilcoxon test.]
|
Wilcoxon–Mann–Whitney test sample size
Very roughly, suppose $\sigma/\Delta = 5,$ (where $\sigma$ is population standard deviation, $\Delta$ is effect size; maybe $\sigma=10, \Delta=2.)$ and desired power is 95%, then for a pooled t test $
|
50,807 |
Decision Theory: Why is it called a "least favorable prior"?
|
I'm not sure how the name originates but here is my opinion on it.
The Bayes risk is some average of the risk function of the Bayes estimator, weighted by the prior. The least favorable prior only places weight on the part of the risk function that achieves the supremum. One example of such could be a Dirac delta at the $\arg \sup_{\theta} \text{R} (\theta, \hat{\theta})$.
However, there is a slight problem with this example. Namely, we cannot choose the least favorable prior after fixing a risk function, since the risk function is determined by the prior. So in reality, the prior comes first and the risk function of the Bayes estimator can be determined. If then we realize the prior happens to place all the weights on the supremum of the risk, we have found the least favorable prior.
|
Decision Theory: Why is it called a "least favorable prior"?
|
I'm not sure how the name originates but here is my opinion on it.
The Bayes risk is some average of the risk function of the Bayes estimator, weighted by the prior. The least favorable prior only pla
|
Decision Theory: Why is it called a "least favorable prior"?
I'm not sure how the name originates but here is my opinion on it.
The Bayes risk is some average of the risk function of the Bayes estimator, weighted by the prior. The least favorable prior only places weight on the part of the risk function that achieves the supremum. One example of such could be a Dirac delta at the $\arg \sup_{\theta} \text{R} (\theta, \hat{\theta})$.
However, there is a slight problem with this example. Namely, we cannot choose the least favorable prior after fixing a risk function, since the risk function is determined by the prior. So in reality, the prior comes first and the risk function of the Bayes estimator can be determined. If then we realize the prior happens to place all the weights on the supremum of the risk, we have found the least favorable prior.
|
Decision Theory: Why is it called a "least favorable prior"?
I'm not sure how the name originates but here is my opinion on it.
The Bayes risk is some average of the risk function of the Bayes estimator, weighted by the prior. The least favorable prior only pla
|
50,808 |
When to care about FDR vs when to care about FWER
|
In the simplest possible terms, you control FWER when you care about the result of the specific hypotheses tested whereas you control FDR when you care about the number of significant results.
Here's my take on an example justifying FDR: suppose, for instance, you are exploring an in vitro or pharmacodynamic study of the efficacy of a certain novel anti-neoplastic therapy. Suppose further this cancer under study is broadly characterized in terms of a number of qualitative and quantitative markers - such as metabolic rate, number and size of measurable lesions, qualitative status of non-target lesions, cancer antigen markers, gene expressions identified at baseline biopsies, etc. etc. etc. You sincerely believe that if the drug really kills the cancer, you expect all of these to change toward normal values. Of course, the disease may mutate, the assays may be false positives at baseline or follow-up, etc. etc. So I may look at the false discovery rate when inspecting each possible efficacy measure, even though the specific mechanism is unknown and not yet specified. More "hits" than expected under a non-associative status would suggest the drug activity is "promising".
|
When to care about FDR vs when to care about FWER
|
In the simplest possible terms, you control FWER when you care about the result of the specific hypotheses tested whereas you control FDR when you care about the number of significant results.
Here's
|
When to care about FDR vs when to care about FWER
In the simplest possible terms, you control FWER when you care about the result of the specific hypotheses tested whereas you control FDR when you care about the number of significant results.
Here's my take on an example justifying FDR: suppose, for instance, you are exploring an in vitro or pharmacodynamic study of the efficacy of a certain novel anti-neoplastic therapy. Suppose further this cancer under study is broadly characterized in terms of a number of qualitative and quantitative markers - such as metabolic rate, number and size of measurable lesions, qualitative status of non-target lesions, cancer antigen markers, gene expressions identified at baseline biopsies, etc. etc. etc. You sincerely believe that if the drug really kills the cancer, you expect all of these to change toward normal values. Of course, the disease may mutate, the assays may be false positives at baseline or follow-up, etc. etc. So I may look at the false discovery rate when inspecting each possible efficacy measure, even though the specific mechanism is unknown and not yet specified. More "hits" than expected under a non-associative status would suggest the drug activity is "promising".
|
When to care about FDR vs when to care about FWER
In the simplest possible terms, you control FWER when you care about the result of the specific hypotheses tested whereas you control FDR when you care about the number of significant results.
Here's
|
50,809 |
When to care about FDR vs when to care about FWER
|
Great question @Tobl, I had the same therefore I'm sharing the insights that I've been able to find hoping that they are enough or they can lead us to a constructive discussion.
I'm now wondering, from a very practical standpoint, when is it acceptable to use Benjamini-Hochberg to control FDR, and when must I strictly keep FWER ≤5%
As far as I know, it all depends on which is your context and what you're looking for: if you cannot have any false positive, then you choose to control the FWER, otherwise you usually go for the FDR control.
As an example, suppose you have to perform a medical trial for a very dangerous disease that is composed of multiple tests, and for which you are considered healthy if and only if all tests are positive. Having a false positive may lead to misjudging an ill patient as healthy, which potentially leads to the death of the patient, therefore your desiderata is not to have any false positive and therefore you control for the FWER.
Side note: as far as I know, this is not how clinical tests are developed in real life, but I hope you got the intuition behind the example.
Let us now imagine a different scenario for which you are studying the behavior of a target variable $T$ in relation with other covariates $\mathbf{V}$ in a dataset (e.g. causal discovery scenarios). Suppose that you'd like to understand which are the most important variables on the dataset and you do that testing multiple hypotheses. You run your procedure correcting for the FWER but the tests are not powerful enough, therefore you don't get any meaningful result. Then, one way to proceed is to correct for the FDR.
|
When to care about FDR vs when to care about FWER
|
Great question @Tobl, I had the same therefore I'm sharing the insights that I've been able to find hoping that they are enough or they can lead us to a constructive discussion.
I'm now wondering, fr
|
When to care about FDR vs when to care about FWER
Great question @Tobl, I had the same therefore I'm sharing the insights that I've been able to find hoping that they are enough or they can lead us to a constructive discussion.
I'm now wondering, from a very practical standpoint, when is it acceptable to use Benjamini-Hochberg to control FDR, and when must I strictly keep FWER ≤5%
As far as I know, it all depends on which is your context and what you're looking for: if you cannot have any false positive, then you choose to control the FWER, otherwise you usually go for the FDR control.
As an example, suppose you have to perform a medical trial for a very dangerous disease that is composed of multiple tests, and for which you are considered healthy if and only if all tests are positive. Having a false positive may lead to misjudging an ill patient as healthy, which potentially leads to the death of the patient, therefore your desiderata is not to have any false positive and therefore you control for the FWER.
Side note: as far as I know, this is not how clinical tests are developed in real life, but I hope you got the intuition behind the example.
Let us now imagine a different scenario for which you are studying the behavior of a target variable $T$ in relation with other covariates $\mathbf{V}$ in a dataset (e.g. causal discovery scenarios). Suppose that you'd like to understand which are the most important variables on the dataset and you do that testing multiple hypotheses. You run your procedure correcting for the FWER but the tests are not powerful enough, therefore you don't get any meaningful result. Then, one way to proceed is to correct for the FDR.
|
When to care about FDR vs when to care about FWER
Great question @Tobl, I had the same therefore I'm sharing the insights that I've been able to find hoping that they are enough or they can lead us to a constructive discussion.
I'm now wondering, fr
|
50,810 |
Is there a formula for the determinant of the covariance matrix $\mathbf{X_n}^T \mathbf{X_n}$ in the case of multiple regression?
|
Just the 2) since I am not professor:
$\mathbf X^T \mathbf X$ is positive definite where $\mathsf {rk}(\mathbf X)=max(n,p+1)$ or maximum number of independent rows which leads the determinant you ask is positive since it is a product of $p+1$ eigenvalues of $\mathbf X^T \mathbf X$.
It's more fair to write $\mathbf X_{n \times {p+1}}$ because this is the shape of the matrix.
PS: Statisticians usually write transposed matrix using the $\mathbf X'$.
|
Is there a formula for the determinant of the covariance matrix $\mathbf{X_n}^T \mathbf{X_n}$ in the
|
Just the 2) since I am not professor:
$\mathbf X^T \mathbf X$ is positive definite where $\mathsf {rk}(\mathbf X)=max(n,p+1)$ or maximum number of independent rows which leads the determinant you ask
|
Is there a formula for the determinant of the covariance matrix $\mathbf{X_n}^T \mathbf{X_n}$ in the case of multiple regression?
Just the 2) since I am not professor:
$\mathbf X^T \mathbf X$ is positive definite where $\mathsf {rk}(\mathbf X)=max(n,p+1)$ or maximum number of independent rows which leads the determinant you ask is positive since it is a product of $p+1$ eigenvalues of $\mathbf X^T \mathbf X$.
It's more fair to write $\mathbf X_{n \times {p+1}}$ because this is the shape of the matrix.
PS: Statisticians usually write transposed matrix using the $\mathbf X'$.
|
Is there a formula for the determinant of the covariance matrix $\mathbf{X_n}^T \mathbf{X_n}$ in the
Just the 2) since I am not professor:
$\mathbf X^T \mathbf X$ is positive definite where $\mathsf {rk}(\mathbf X)=max(n,p+1)$ or maximum number of independent rows which leads the determinant you ask
|
50,811 |
$X\sim\frac{1}{b}\exp\{-\frac{1}{b}(x-a)\},x>a$. Find UMVUE of $\frac{a}{b}$
|
Since nobody answered, I'll try to answer my own question. Please let me know if anything is not correct.
Denote $S=\frac{1}{n-1}\sum_{i=1}^n[X_i-X_{(1)}]$. We have $$S\sim \frac{b}{n-1}\text{Gamma}(n-2,1),$$
and
$$\frac{1}{S}\sim \frac{n-1}{b}\text{inv-Gamma}(n-2,1)$$
These implies $$\mathbb{E}\frac{1}{S}=\frac{n-1}{b(n-3)}.$$
Also, $$\mathbb{E}\left(X_{(1)}-c_1S\right)=a,$$
thus we have $$\mathbb{E}\left[\left(X_{(1)}-c_1S\right)\frac{1}{S}\right]=\mathbb{E}\left[\frac{X_{(1)}}{S}-\frac{c_2}{n}\right].$$
Since $X_{(1)}$ is independent with $S$, we have $$\mathbb{E}X_{(1)}\frac{1}{S}=\mathbb{E}X_{(1)}\mathbb{E}\frac{1}{S}=c_3+\frac{a}{b}c_4$$
Since $X_{(1)}\text{ and }S$ complete and sufficient, with some additional work, we can get UMVUE of $\frac{a}{b}$. $c_1, c_2, c_3, c_4$ are some constant.
|
$X\sim\frac{1}{b}\exp\{-\frac{1}{b}(x-a)\},x>a$. Find UMVUE of $\frac{a}{b}$
|
Since nobody answered, I'll try to answer my own question. Please let me know if anything is not correct.
Denote $S=\frac{1}{n-1}\sum_{i=1}^n[X_i-X_{(1)}]$. We have $$S\sim \frac{b}{n-1}\text{Gamma}(n
|
$X\sim\frac{1}{b}\exp\{-\frac{1}{b}(x-a)\},x>a$. Find UMVUE of $\frac{a}{b}$
Since nobody answered, I'll try to answer my own question. Please let me know if anything is not correct.
Denote $S=\frac{1}{n-1}\sum_{i=1}^n[X_i-X_{(1)}]$. We have $$S\sim \frac{b}{n-1}\text{Gamma}(n-2,1),$$
and
$$\frac{1}{S}\sim \frac{n-1}{b}\text{inv-Gamma}(n-2,1)$$
These implies $$\mathbb{E}\frac{1}{S}=\frac{n-1}{b(n-3)}.$$
Also, $$\mathbb{E}\left(X_{(1)}-c_1S\right)=a,$$
thus we have $$\mathbb{E}\left[\left(X_{(1)}-c_1S\right)\frac{1}{S}\right]=\mathbb{E}\left[\frac{X_{(1)}}{S}-\frac{c_2}{n}\right].$$
Since $X_{(1)}$ is independent with $S$, we have $$\mathbb{E}X_{(1)}\frac{1}{S}=\mathbb{E}X_{(1)}\mathbb{E}\frac{1}{S}=c_3+\frac{a}{b}c_4$$
Since $X_{(1)}\text{ and }S$ complete and sufficient, with some additional work, we can get UMVUE of $\frac{a}{b}$. $c_1, c_2, c_3, c_4$ are some constant.
|
$X\sim\frac{1}{b}\exp\{-\frac{1}{b}(x-a)\},x>a$. Find UMVUE of $\frac{a}{b}$
Since nobody answered, I'll try to answer my own question. Please let me know if anything is not correct.
Denote $S=\frac{1}{n-1}\sum_{i=1}^n[X_i-X_{(1)}]$. We have $$S\sim \frac{b}{n-1}\text{Gamma}(n
|
50,812 |
In linear regression, we have 0 training error if data dimension is high, but are there similar results for other supervised learning problems?
|
Let me start with the linear regression case. Consider:
$$
Xb = y
$$
where $X$ is a $n\times p$ matrix, $y$ is a $n$-vector, and $b$ is a $p$-vector. If and only if there exists $b$ that satisfies this equation, we can achieve the zero training error for the linear regression. "If" part is trivial. "Only if" part can be proven by noting that there is a non-zero residual and thus squared sum is not zero.
Unfortunately $p \ge n$ is not sufficient due to the possibility that some equations are contradictory, as pointed out by @user21060 in the comment.
$p \ge n$ is not necessary either. To see this, imagine the case where $y$ is constant to zero; we can achieve zero training error by $b=0$.
Perhaps a general condition for $Xb=y$ to be possible is that
$$
\mathrm{rank}(X) = \mathrm{rank}([X, y])
$$
There can be better way to state this, but you can search for the linear algebra and the conditions regarding the solution existence for linear equations.
In the logistic regression context, consider:
$$
Xb = 2 y - 1
$$
Note that the right hand side converts $y$ from $\{0,1\}$ to $\{-1,1\}$.
Similar to the case of linear regression, we can achieve the zero training error if this equation has a solution.
But this is not necessary condition since all we need is that $Xb$ has the correct sign and we don't need them to be exactly equal to $1$ or $-1$.
It would be possible to refine the condition by considering the hyperplane separation. The hyperplane separation theorem states roughly that
If two sets are disjoint and convex, then there exists a hyperplane separating them.
The separating hyperplane is very close to what we need to achieve zero training error.
This is because, separating hyperplane would imply that
$$
x_i \cdot v \ge c \;\;\;\; \text{for all positive cases}
$$
$$
x_i \cdot v \le c \;\;\;\; \text{for all negative cases}
$$
If we have a separating hyperplane with the strict inequalities, then we can achieve zero training error. You can look into the conditions for achieving the strict hyperplane separation, but I cannot find one immediately.
|
In linear regression, we have 0 training error if data dimension is high, but are there similar resu
|
Let me start with the linear regression case. Consider:
$$
Xb = y
$$
where $X$ is a $n\times p$ matrix, $y$ is a $n$-vector, and $b$ is a $p$-vector. If and only if there exists $b$ that satisfies t
|
In linear regression, we have 0 training error if data dimension is high, but are there similar results for other supervised learning problems?
Let me start with the linear regression case. Consider:
$$
Xb = y
$$
where $X$ is a $n\times p$ matrix, $y$ is a $n$-vector, and $b$ is a $p$-vector. If and only if there exists $b$ that satisfies this equation, we can achieve the zero training error for the linear regression. "If" part is trivial. "Only if" part can be proven by noting that there is a non-zero residual and thus squared sum is not zero.
Unfortunately $p \ge n$ is not sufficient due to the possibility that some equations are contradictory, as pointed out by @user21060 in the comment.
$p \ge n$ is not necessary either. To see this, imagine the case where $y$ is constant to zero; we can achieve zero training error by $b=0$.
Perhaps a general condition for $Xb=y$ to be possible is that
$$
\mathrm{rank}(X) = \mathrm{rank}([X, y])
$$
There can be better way to state this, but you can search for the linear algebra and the conditions regarding the solution existence for linear equations.
In the logistic regression context, consider:
$$
Xb = 2 y - 1
$$
Note that the right hand side converts $y$ from $\{0,1\}$ to $\{-1,1\}$.
Similar to the case of linear regression, we can achieve the zero training error if this equation has a solution.
But this is not necessary condition since all we need is that $Xb$ has the correct sign and we don't need them to be exactly equal to $1$ or $-1$.
It would be possible to refine the condition by considering the hyperplane separation. The hyperplane separation theorem states roughly that
If two sets are disjoint and convex, then there exists a hyperplane separating them.
The separating hyperplane is very close to what we need to achieve zero training error.
This is because, separating hyperplane would imply that
$$
x_i \cdot v \ge c \;\;\;\; \text{for all positive cases}
$$
$$
x_i \cdot v \le c \;\;\;\; \text{for all negative cases}
$$
If we have a separating hyperplane with the strict inequalities, then we can achieve zero training error. You can look into the conditions for achieving the strict hyperplane separation, but I cannot find one immediately.
|
In linear regression, we have 0 training error if data dimension is high, but are there similar resu
Let me start with the linear regression case. Consider:
$$
Xb = y
$$
where $X$ is a $n\times p$ matrix, $y$ is a $n$-vector, and $b$ is a $p$-vector. If and only if there exists $b$ that satisfies t
|
50,813 |
one example of LDA and max number of features
|
About linear discriminant analysis
A classical example of least discriminant analysis is R.A. Fisher's 1936 article "The use of multiple measurements in taxonomic problems". This is based on the iris dataset and easily plotted.
### load library
### with Edgar Anderson's Iris data set
### and the lda function
library(MASS)
### Perform lda
lda <- lda(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width , data = iris)
### Compute the discriminant
predict(lda)
### Plot histogram with result from first discriminant
plot(lda, dimen=1, breaks = seq(-10,10,0.5))
### Plot histogram with only one variable
layout(matrix(1:3,3))
hist(iris$Sepal.Length[iris$Species == "setosa"], breaks = seq(3,9,0.25),
main = "", xlab = "group setosa", freq = 0)
hist(iris$Sepal.Length[iris$Species == "versicolor"], breaks = seq(3,9,0.25),
main = "", xlab = "group versicolor", freq = 0)
hist(iris$Sepal.Length[iris$Species == "virginica"], breaks = seq(3,9,0.25),
main = "", xlab = "group virginica", freq = 0)
Result from first linear discriminant
Result from a single variable (sepal length)
The idea from Fisher was to use a linear combination of the variables such that the distance between the classes is larger. This distance is considered relative to the variance of the groups. (To see more about this, consider this question: When is MANOVA most useful )
When parameters > samples
So, the intuition behind LDA is to find a linear combination of parameters for which the in-between distance/variance of the groups is larger than the within distance/variance of the groups.
When you have more parameters than the sample size, then you will be able to find a perfect linear combination. One for which the within distance is zero.
This linear combination can be found by finding the linear combination of parameters for which the linear combination in one class equals zero and in the other class equals one.
This relates to solving a linear regression problem
$$Y = \beta X$$
Where $Y$ is a column with ones and zeros depending on the class, $X$ is a matrix with the features, and $\beta$ are coeffients to be found.
This problem is overdetermined when the number of features is larger than the number of samples. This means that you will be able to find many linear functions of the features for which the one class equals zero and the other class equals one (as long as there are no different class members with the exact same features).
The number of features that you need is similar to the number of features that you need to fit exactly a regression problem. Which is $X-1$. For example, if you have two data points then a straight line, a function of only one feature (and a function of two parameters, because besides the slope the intercept is included as well), will fit perfectly through the points.
So $x-1$ features will be sufficient to find a perfect solution to the LDA problem
Regularization
So, when the number of features is larger than the sample, then the problem is similar to a regression problem.
For this over-determined case, you can say that $X-1$ features are sufficient, but it is not the only solution. The exact answer will be dependent on how you weigh the different solutions. You can do this in several ways. Regularization is one way to do it. In the case that the problem is solved with Lasso regression or stepwise regression (which add regressors/features in steps, building up a solution starting with zero regressors), then I can imagine that the limit is $x-1$ features. In the case that the problem is solved with ridge regression (which uses all regressors/features from the start) then this is not the case.
|
one example of LDA and max number of features
|
About linear discriminant analysis
A classical example of least discriminant analysis is R.A. Fisher's 1936 article "The use of multiple measurements in taxonomic problems". This is based on the iris
|
one example of LDA and max number of features
About linear discriminant analysis
A classical example of least discriminant analysis is R.A. Fisher's 1936 article "The use of multiple measurements in taxonomic problems". This is based on the iris dataset and easily plotted.
### load library
### with Edgar Anderson's Iris data set
### and the lda function
library(MASS)
### Perform lda
lda <- lda(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width , data = iris)
### Compute the discriminant
predict(lda)
### Plot histogram with result from first discriminant
plot(lda, dimen=1, breaks = seq(-10,10,0.5))
### Plot histogram with only one variable
layout(matrix(1:3,3))
hist(iris$Sepal.Length[iris$Species == "setosa"], breaks = seq(3,9,0.25),
main = "", xlab = "group setosa", freq = 0)
hist(iris$Sepal.Length[iris$Species == "versicolor"], breaks = seq(3,9,0.25),
main = "", xlab = "group versicolor", freq = 0)
hist(iris$Sepal.Length[iris$Species == "virginica"], breaks = seq(3,9,0.25),
main = "", xlab = "group virginica", freq = 0)
Result from first linear discriminant
Result from a single variable (sepal length)
The idea from Fisher was to use a linear combination of the variables such that the distance between the classes is larger. This distance is considered relative to the variance of the groups. (To see more about this, consider this question: When is MANOVA most useful )
When parameters > samples
So, the intuition behind LDA is to find a linear combination of parameters for which the in-between distance/variance of the groups is larger than the within distance/variance of the groups.
When you have more parameters than the sample size, then you will be able to find a perfect linear combination. One for which the within distance is zero.
This linear combination can be found by finding the linear combination of parameters for which the linear combination in one class equals zero and in the other class equals one.
This relates to solving a linear regression problem
$$Y = \beta X$$
Where $Y$ is a column with ones and zeros depending on the class, $X$ is a matrix with the features, and $\beta$ are coeffients to be found.
This problem is overdetermined when the number of features is larger than the number of samples. This means that you will be able to find many linear functions of the features for which the one class equals zero and the other class equals one (as long as there are no different class members with the exact same features).
The number of features that you need is similar to the number of features that you need to fit exactly a regression problem. Which is $X-1$. For example, if you have two data points then a straight line, a function of only one feature (and a function of two parameters, because besides the slope the intercept is included as well), will fit perfectly through the points.
So $x-1$ features will be sufficient to find a perfect solution to the LDA problem
Regularization
So, when the number of features is larger than the sample, then the problem is similar to a regression problem.
For this over-determined case, you can say that $X-1$ features are sufficient, but it is not the only solution. The exact answer will be dependent on how you weigh the different solutions. You can do this in several ways. Regularization is one way to do it. In the case that the problem is solved with Lasso regression or stepwise regression (which add regressors/features in steps, building up a solution starting with zero regressors), then I can imagine that the limit is $x-1$ features. In the case that the problem is solved with ridge regression (which uses all regressors/features from the start) then this is not the case.
|
one example of LDA and max number of features
About linear discriminant analysis
A classical example of least discriminant analysis is R.A. Fisher's 1936 article "The use of multiple measurements in taxonomic problems". This is based on the iris
|
50,814 |
Expected squared distance between order statistics?
|
The terms of this sum are known exactly for some distributions, since
$$E[(X_{(i)}-Y_{(i)})^2]=E[X_{(i)}^2]-2E[X_{(i)}]E[Y_{(i)}]+E[Y_{(i)}^2]=2\text{Var}[X_{(i)}].$$
For those distributions, we can get some nice expressions for the limiting behavior.
In what follows, $\psi_1(z)$ is the trigamma function $d^2\log \Gamma(z)/dz^2$, appearing in the calculation for the logistic distribution in N. Balakrishnan and A. Clifford Cohen, Order Statistics and Inference (1991), p. 40. The approximations given here with $\sim$ are exact in the highest-order terms.
For a uniform distribution bounded by $0,1$:
\begin{align}
\text{Var}[X_{(i:k)}]&=\frac{i(k+1-i)}{(k+1)^2(k+2)}\phantom{+123456}\\
\\
2\sum_i\text{Var}[X_{(i:k)}]&=\frac{k}{3(k+1)}\sim\frac13
\end{align}
For an exponential distribution with mean $1$:
\begin{align}
\text{Var}[X_{(i:k)}]&=\psi_1(k+1-i)-\psi_1(k+1)\\
\\
2\sum_i\text{Var}[X_{(i:k)}]&\sim 2\log k+1
\end{align}
For a logistic distribution with parameters 0,1:
\begin{align}
\text{Var}[X_{(i:k)}]&=\psi_1(k+1-i)+\psi_1(k)\phantom{+12}\\
\\
2\sum_i\text{Var}[X_{(i:k)}]&\sim 4\log k+8
\end{align}
For the unbounded distributions, these are growing functions: the answer linked in the question shows $\frac{1}{k}\|X-Y\|_1\to 0$, while this is showing $\|X-Y\|_2^2\to \infty$.
|
Expected squared distance between order statistics?
|
The terms of this sum are known exactly for some distributions, since
$$E[(X_{(i)}-Y_{(i)})^2]=E[X_{(i)}^2]-2E[X_{(i)}]E[Y_{(i)}]+E[Y_{(i)}^2]=2\text{Var}[X_{(i)}].$$
For those distributions, we can g
|
Expected squared distance between order statistics?
The terms of this sum are known exactly for some distributions, since
$$E[(X_{(i)}-Y_{(i)})^2]=E[X_{(i)}^2]-2E[X_{(i)}]E[Y_{(i)}]+E[Y_{(i)}^2]=2\text{Var}[X_{(i)}].$$
For those distributions, we can get some nice expressions for the limiting behavior.
In what follows, $\psi_1(z)$ is the trigamma function $d^2\log \Gamma(z)/dz^2$, appearing in the calculation for the logistic distribution in N. Balakrishnan and A. Clifford Cohen, Order Statistics and Inference (1991), p. 40. The approximations given here with $\sim$ are exact in the highest-order terms.
For a uniform distribution bounded by $0,1$:
\begin{align}
\text{Var}[X_{(i:k)}]&=\frac{i(k+1-i)}{(k+1)^2(k+2)}\phantom{+123456}\\
\\
2\sum_i\text{Var}[X_{(i:k)}]&=\frac{k}{3(k+1)}\sim\frac13
\end{align}
For an exponential distribution with mean $1$:
\begin{align}
\text{Var}[X_{(i:k)}]&=\psi_1(k+1-i)-\psi_1(k+1)\\
\\
2\sum_i\text{Var}[X_{(i:k)}]&\sim 2\log k+1
\end{align}
For a logistic distribution with parameters 0,1:
\begin{align}
\text{Var}[X_{(i:k)}]&=\psi_1(k+1-i)+\psi_1(k)\phantom{+12}\\
\\
2\sum_i\text{Var}[X_{(i:k)}]&\sim 4\log k+8
\end{align}
For the unbounded distributions, these are growing functions: the answer linked in the question shows $\frac{1}{k}\|X-Y\|_1\to 0$, while this is showing $\|X-Y\|_2^2\to \infty$.
|
Expected squared distance between order statistics?
The terms of this sum are known exactly for some distributions, since
$$E[(X_{(i)}-Y_{(i)})^2]=E[X_{(i)}^2]-2E[X_{(i)}]E[Y_{(i)}]+E[Y_{(i)}^2]=2\text{Var}[X_{(i)}].$$
For those distributions, we can g
|
50,815 |
Transfer Learning: data in the source domain and the target domain are required to be independent and identically distributed
|
I don't know what exactly was meant by the original statement, but it may include some or all of below statements
Source data generative process is i.i.d
Target data generative process is i.i.d
The processes are i.i.d with each other
All of these are very sensible standard assumptions, because if this is not the case, one can design adversarial generative processes for which the method will work very differently than for i.i.d datasets.
For points 1. and 2. a bad example is all data being the same. For 3., imagine if source and target are forced to explore very different parts of phase space. This requires them not being i.i.d, but will result in transfer learning being useless, as there will be no overlap
EDIT: Some clarifications based on comments
Q1) If you cannot assume i.i.d, it means that you have to, in principle, be ready to deal with any non-iid datasets. Adversarial means that a bad guy can come and, out of all possible generating processes that are allowed by your assumptions, select the one that screws you up the most.
Q2) Phase-space is the multidimensional space spanned by all variables of the system. For example, if you input a 10x10 pixel colored image, your phase-space will have 10x10x3 = 300 dimensions. Any knowledge can be represented as a partition of the phase space. For example, all possible 10x10 colored images of a cat will take a certain volume in phase space. While this volume need not be convex, it is typically concentrated in some part of the phase space, if your object (a cat, that is) is well-defined. I highly recommend taking introductory courses on dynamical systems and information theory before attempting to study advanced topics such as transfer learning. I think it is beneficial to think generally about what knowledge means, how it is represented and related to other knowledge before going into details of implementation of specific knowledge-processing devices
|
Transfer Learning: data in the source domain and the target domain are required to be independent an
|
I don't know what exactly was meant by the original statement, but it may include some or all of below statements
Source data generative process is i.i.d
Target data generative process is i.i.d
The p
|
Transfer Learning: data in the source domain and the target domain are required to be independent and identically distributed
I don't know what exactly was meant by the original statement, but it may include some or all of below statements
Source data generative process is i.i.d
Target data generative process is i.i.d
The processes are i.i.d with each other
All of these are very sensible standard assumptions, because if this is not the case, one can design adversarial generative processes for which the method will work very differently than for i.i.d datasets.
For points 1. and 2. a bad example is all data being the same. For 3., imagine if source and target are forced to explore very different parts of phase space. This requires them not being i.i.d, but will result in transfer learning being useless, as there will be no overlap
EDIT: Some clarifications based on comments
Q1) If you cannot assume i.i.d, it means that you have to, in principle, be ready to deal with any non-iid datasets. Adversarial means that a bad guy can come and, out of all possible generating processes that are allowed by your assumptions, select the one that screws you up the most.
Q2) Phase-space is the multidimensional space spanned by all variables of the system. For example, if you input a 10x10 pixel colored image, your phase-space will have 10x10x3 = 300 dimensions. Any knowledge can be represented as a partition of the phase space. For example, all possible 10x10 colored images of a cat will take a certain volume in phase space. While this volume need not be convex, it is typically concentrated in some part of the phase space, if your object (a cat, that is) is well-defined. I highly recommend taking introductory courses on dynamical systems and information theory before attempting to study advanced topics such as transfer learning. I think it is beneficial to think generally about what knowledge means, how it is represented and related to other knowledge before going into details of implementation of specific knowledge-processing devices
|
Transfer Learning: data in the source domain and the target domain are required to be independent an
I don't know what exactly was meant by the original statement, but it may include some or all of below statements
Source data generative process is i.i.d
Target data generative process is i.i.d
The p
|
50,816 |
Bias-Variance decomposition: Expectations over what?
|
The Bias-Variance Decomposition is done to the prediction error on a fixed observation in the test set.
We assume we resample our training set again and again and re-train the model with each of the resampled train sets.
For example, the estimation of the error goes in this way: After we get $N$ train sets by resampling, we fit $N$ models with each of $N$ train sets. With the each of fitted models, we make a prediction on the same observation(OOS) in the test set. With the predictions, we will have $N$ predicted values, and the expected value of errors is calculated by taking the average of all the prediction errors.
The bias-variance decomposition states that the estimated error consists of error from bias, error from variance, and reducible error.
|
Bias-Variance decomposition: Expectations over what?
|
The Bias-Variance Decomposition is done to the prediction error on a fixed observation in the test set.
We assume we resample our training set again and again and re-train the model with each of the
|
Bias-Variance decomposition: Expectations over what?
The Bias-Variance Decomposition is done to the prediction error on a fixed observation in the test set.
We assume we resample our training set again and again and re-train the model with each of the resampled train sets.
For example, the estimation of the error goes in this way: After we get $N$ train sets by resampling, we fit $N$ models with each of $N$ train sets. With the each of fitted models, we make a prediction on the same observation(OOS) in the test set. With the predictions, we will have $N$ predicted values, and the expected value of errors is calculated by taking the average of all the prediction errors.
The bias-variance decomposition states that the estimated error consists of error from bias, error from variance, and reducible error.
|
Bias-Variance decomposition: Expectations over what?
The Bias-Variance Decomposition is done to the prediction error on a fixed observation in the test set.
We assume we resample our training set again and again and re-train the model with each of the
|
50,817 |
Why aren't neural networks used with RBF activation functions (or other non-monotonic ones)?
|
Seems that some people are a bit confused by your question because of its title; indeed, RBF neural networks exist, but they are a different architecture than the traditional multi-layer NNs. The body of your question is complete and formulated well (apart from some ambiguity because of the use of MLP), so to get to the answer let me ask a slightly different question: why are some activation functions more popular than others? Why are there only some activation functions in use? There is an infinite number of functions that are not used as activation functions in multi-layer NNs. One could think about some activation function that is a slight modification of the popular one, for example by squaring the argument, and ask "Why this kind of a function is not widely used as an activation function?"
In multi-layer NNs, each layer transforms the space in some (usually non-linear) way. When we use a non-monotonic activation function, we can imagine how a single layer of neurons works. But what would happen if we used another layer with a non-monotonic activation function transforming the outputs of the first layer? What if we added yet another such layer?
As you can imagine, the transformation of the original space gets more sophisticated and twisted more quickly compared to if we used a monotonic activation function.
The training process may also be more difficult because the error landscape is more complicated.
Calculating the derivatives may be less efficient depending on the formula of the activation function.
So it is not like you cannot use a Gaussian as an activation function in a multi-layer NN. You can use it, and you can use other unpopular activation functions, and for a particular data and a particular NN topology they may even be more efficient and yield better predictions than those provided by the most popular activation functions. The question is: Why use this function and not the other? Why is this particular activation function beneficial? How is this function better from the other one that works well in a general case, hence it became so popular?
In a similar vein, you can use different activation functions (other than the most popular Gaussian) in the RBF NN architecture, and some of them will make more sense (and will perform better) than others.
This reminds me of another question that I want to bring up here just for illustration: how many layers in a NN you should use? We know that a single hidden layer is sufficient. So why people use more hidden layers? For efficiency, because of the lower total number of neurons needed when more layers are introduced? For better generalization? This demonstrates that your goal may be achieved in many ways, and it is good to first define some evaluation criteria to be able to measure the performance of different possible approaches and compare them.
Coming back to the original question "Why aren't [traditional] neural networks used with RBF activation functions (or other non-monotonic ones)?" – They are, but if one wants to use many such layers, given the potential problems I mentioned above, one should justify this decision by stating "This activation function is better than sigmoid or ReLU because..."
|
Why aren't neural networks used with RBF activation functions (or other non-monotonic ones)?
|
Seems that some people are a bit confused by your question because of its title; indeed, RBF neural networks exist, but they are a different architecture than the traditional multi-layer NNs. The body
|
Why aren't neural networks used with RBF activation functions (or other non-monotonic ones)?
Seems that some people are a bit confused by your question because of its title; indeed, RBF neural networks exist, but they are a different architecture than the traditional multi-layer NNs. The body of your question is complete and formulated well (apart from some ambiguity because of the use of MLP), so to get to the answer let me ask a slightly different question: why are some activation functions more popular than others? Why are there only some activation functions in use? There is an infinite number of functions that are not used as activation functions in multi-layer NNs. One could think about some activation function that is a slight modification of the popular one, for example by squaring the argument, and ask "Why this kind of a function is not widely used as an activation function?"
In multi-layer NNs, each layer transforms the space in some (usually non-linear) way. When we use a non-monotonic activation function, we can imagine how a single layer of neurons works. But what would happen if we used another layer with a non-monotonic activation function transforming the outputs of the first layer? What if we added yet another such layer?
As you can imagine, the transformation of the original space gets more sophisticated and twisted more quickly compared to if we used a monotonic activation function.
The training process may also be more difficult because the error landscape is more complicated.
Calculating the derivatives may be less efficient depending on the formula of the activation function.
So it is not like you cannot use a Gaussian as an activation function in a multi-layer NN. You can use it, and you can use other unpopular activation functions, and for a particular data and a particular NN topology they may even be more efficient and yield better predictions than those provided by the most popular activation functions. The question is: Why use this function and not the other? Why is this particular activation function beneficial? How is this function better from the other one that works well in a general case, hence it became so popular?
In a similar vein, you can use different activation functions (other than the most popular Gaussian) in the RBF NN architecture, and some of them will make more sense (and will perform better) than others.
This reminds me of another question that I want to bring up here just for illustration: how many layers in a NN you should use? We know that a single hidden layer is sufficient. So why people use more hidden layers? For efficiency, because of the lower total number of neurons needed when more layers are introduced? For better generalization? This demonstrates that your goal may be achieved in many ways, and it is good to first define some evaluation criteria to be able to measure the performance of different possible approaches and compare them.
Coming back to the original question "Why aren't [traditional] neural networks used with RBF activation functions (or other non-monotonic ones)?" – They are, but if one wants to use many such layers, given the potential problems I mentioned above, one should justify this decision by stating "This activation function is better than sigmoid or ReLU because..."
|
Why aren't neural networks used with RBF activation functions (or other non-monotonic ones)?
Seems that some people are a bit confused by your question because of its title; indeed, RBF neural networks exist, but they are a different architecture than the traditional multi-layer NNs. The body
|
50,818 |
CDF that combines properties of Pareto and Exponential
|
The only possible distribution on $[1,\infty)$ satisfying the key equation above of
\begin{align}
P[&Y>ay+b]=z(a,b)\,P[Y>y]\\
&\text{ whenever } a>0, b\le 0, y\ge 1
\end{align}
is the distribution with $P[Y=1]=1$, concentrated entirely at $y=1$.
If the distribution is not concentrated entirely at $Y=1$, then:
Let $s$ be such that $s>1$ and $P[Y>s]$ is positive.
Let $t$ be such that $t>s$ and $P[Y>t]<P[Y>s]$.
Let $r = \sqrt{s}$, so $1<r<s<t$, and $P[Y>r]$ is also positive.
Solve for $a$ and $b$ such that
\begin{align}
ar+b&=r\\
as+b&=t\\
\end{align}
Subtracting these two equations gives $a(s-r)=(t-r)$, so $a>1$, and that combined with the first of them gives $b<0$. Now:
The key equation for $y=r$ gives $P[Y>r]=z(a,b)P[Y>r]$, so $z(a,b)=1$.
The key equation for $y=s$ gives $P[Y>t]=z(a,b)P[Y>s]$, so $z(a,b)<1$.
This is a contradiction, so the distribution must have been entirely concentrated at $Y=1$.
|
CDF that combines properties of Pareto and Exponential
|
The only possible distribution on $[1,\infty)$ satisfying the key equation above of
\begin{align}
P[&Y>ay+b]=z(a,b)\,P[Y>y]\\
&\text{ whenever } a>0, b\le 0, y\ge 1
\end{align}
is the distribution wit
|
CDF that combines properties of Pareto and Exponential
The only possible distribution on $[1,\infty)$ satisfying the key equation above of
\begin{align}
P[&Y>ay+b]=z(a,b)\,P[Y>y]\\
&\text{ whenever } a>0, b\le 0, y\ge 1
\end{align}
is the distribution with $P[Y=1]=1$, concentrated entirely at $y=1$.
If the distribution is not concentrated entirely at $Y=1$, then:
Let $s$ be such that $s>1$ and $P[Y>s]$ is positive.
Let $t$ be such that $t>s$ and $P[Y>t]<P[Y>s]$.
Let $r = \sqrt{s}$, so $1<r<s<t$, and $P[Y>r]$ is also positive.
Solve for $a$ and $b$ such that
\begin{align}
ar+b&=r\\
as+b&=t\\
\end{align}
Subtracting these two equations gives $a(s-r)=(t-r)$, so $a>1$, and that combined with the first of them gives $b<0$. Now:
The key equation for $y=r$ gives $P[Y>r]=z(a,b)P[Y>r]$, so $z(a,b)=1$.
The key equation for $y=s$ gives $P[Y>t]=z(a,b)P[Y>s]$, so $z(a,b)<1$.
This is a contradiction, so the distribution must have been entirely concentrated at $Y=1$.
|
CDF that combines properties of Pareto and Exponential
The only possible distribution on $[1,\infty)$ satisfying the key equation above of
\begin{align}
P[&Y>ay+b]=z(a,b)\,P[Y>y]\\
&\text{ whenever } a>0, b\le 0, y\ge 1
\end{align}
is the distribution wit
|
50,819 |
Recover full covariance matrix from covariance diagonal and precision off-diagonals
|
This can be setup as a non-linear system of equations. Because of non-linearity, it is not obvious that the system has a unique solution, but I did for the $2\times 2$-case, where it is unique as far as I can see.
But the equations become unwieldy, so in practice it seems easier to formulate it as a minimization problem. Below I do this in the case $2\times 2$, as a proof of concept, and it seems to work well.
Let
$$
\Sigma =\begin{pmatrix} a & x \\ x & b \end{pmatrix}, \quad \Lambda = \begin{pmatrix} y & c \\ c & z \end{pmatrix}
$$
multiply them, subtract $I$, square each of the elements and sum them. At the solution this sum-of-squares criterion should be zero. An R implementation:
crit <- function(par) {
a <- par[1]; b<- par[2]; c <- par[3]
function(xx) {
x <- xx[1] ; y <- xx[2] ; z <- xx[3]
(a*y + c*x -1)^2 + (a*c + x*z)^2 +
(x*y + b*c)^2 + (x*c + b*z -1)^2
}
}
init <- function( aa) {
a <- aa[1] ; b <- aa[2] ; c <- aa[3]
x <- -c/2
c(x, b/(a*b-x*x), a/(a*b-x*x))
}
completeSigma <- function( dsigma, offd_lambda) {
obj <- optim( init( c(dsigma, offd_lambda)),
crit( c(dsigma, offd_lambda)), method="BFGS")
### Return completed sigma:
par <- obj$par
matrix( c( dsigma[1], par[1], par[1], dsigma[2]), 2, 2)
}
completeSigma( c(4, 1), -1/3)
[,1] [,2]
[1,] 4 1
[2,] 1 1
(For a more mathematical treatment, I asked at https://mathoverflow.net/questions/406753/finding-a-matrix-from-its-diagonal-and-the-off-diagonal-elements-of-its-inverse)
$$
|
Recover full covariance matrix from covariance diagonal and precision off-diagonals
|
This can be setup as a non-linear system of equations. Because of non-linearity, it is not obvious that the system has a unique solution, but I did for the $2\times 2$-case, where it is unique as far
|
Recover full covariance matrix from covariance diagonal and precision off-diagonals
This can be setup as a non-linear system of equations. Because of non-linearity, it is not obvious that the system has a unique solution, but I did for the $2\times 2$-case, where it is unique as far as I can see.
But the equations become unwieldy, so in practice it seems easier to formulate it as a minimization problem. Below I do this in the case $2\times 2$, as a proof of concept, and it seems to work well.
Let
$$
\Sigma =\begin{pmatrix} a & x \\ x & b \end{pmatrix}, \quad \Lambda = \begin{pmatrix} y & c \\ c & z \end{pmatrix}
$$
multiply them, subtract $I$, square each of the elements and sum them. At the solution this sum-of-squares criterion should be zero. An R implementation:
crit <- function(par) {
a <- par[1]; b<- par[2]; c <- par[3]
function(xx) {
x <- xx[1] ; y <- xx[2] ; z <- xx[3]
(a*y + c*x -1)^2 + (a*c + x*z)^2 +
(x*y + b*c)^2 + (x*c + b*z -1)^2
}
}
init <- function( aa) {
a <- aa[1] ; b <- aa[2] ; c <- aa[3]
x <- -c/2
c(x, b/(a*b-x*x), a/(a*b-x*x))
}
completeSigma <- function( dsigma, offd_lambda) {
obj <- optim( init( c(dsigma, offd_lambda)),
crit( c(dsigma, offd_lambda)), method="BFGS")
### Return completed sigma:
par <- obj$par
matrix( c( dsigma[1], par[1], par[1], dsigma[2]), 2, 2)
}
completeSigma( c(4, 1), -1/3)
[,1] [,2]
[1,] 4 1
[2,] 1 1
(For a more mathematical treatment, I asked at https://mathoverflow.net/questions/406753/finding-a-matrix-from-its-diagonal-and-the-off-diagonal-elements-of-its-inverse)
$$
|
Recover full covariance matrix from covariance diagonal and precision off-diagonals
This can be setup as a non-linear system of equations. Because of non-linearity, it is not obvious that the system has a unique solution, but I did for the $2\times 2$-case, where it is unique as far
|
50,820 |
In a paired test, what constitutes a valid pair?
|
Yes, the two measurement methods could constitute a "pair" in this example. More concerning (in my opinion) is that a t-test will only help you identify a constant bias between methods A and B. There could be a proportional (and/or constant) bias(es) between the methods which a t-test is not well suited to identify. Consider the data
$A = (10, 11, 12, 13, 14)$
$B = (11, 11.5, 12, 12.5, 13)$
A paired t-test on these data will not be significant:
$diff = 0[-0.982, 0.982]$
but both the proportional and constant biases are being missed.
CLSI EP09 describes various ways to perform method comparisons.
|
In a paired test, what constitutes a valid pair?
|
Yes, the two measurement methods could constitute a "pair" in this example. More concerning (in my opinion) is that a t-test will only help you identify a constant bias between methods A and B. There
|
In a paired test, what constitutes a valid pair?
Yes, the two measurement methods could constitute a "pair" in this example. More concerning (in my opinion) is that a t-test will only help you identify a constant bias between methods A and B. There could be a proportional (and/or constant) bias(es) between the methods which a t-test is not well suited to identify. Consider the data
$A = (10, 11, 12, 13, 14)$
$B = (11, 11.5, 12, 12.5, 13)$
A paired t-test on these data will not be significant:
$diff = 0[-0.982, 0.982]$
but both the proportional and constant biases are being missed.
CLSI EP09 describes various ways to perform method comparisons.
|
In a paired test, what constitutes a valid pair?
Yes, the two measurement methods could constitute a "pair" in this example. More concerning (in my opinion) is that a t-test will only help you identify a constant bias between methods A and B. There
|
50,821 |
Visualizing the Coronavirus COVID-19 epidemic?
|
Representing population data on a map is difficult and implies applying simplifications to understand the data « at a glance ». One of these is to use a scatter plot which is exactly what is shown in this data:
For the different data points, the size of the area is shown as a disk whose surface increases linearly with the number shown (here, infected people).
Indeed, this can lead to some confusion (it’s a data point on the map, it is not spread), and will difficulty apply to data which would be densely packed, leading to overlaps in the disks. For the latter, you may prefer heatmaps.
|
Visualizing the Coronavirus COVID-19 epidemic?
|
Representing population data on a map is difficult and implies applying simplifications to understand the data « at a glance ». One of these is to use a scatter plot which is exactly what is shown in
|
Visualizing the Coronavirus COVID-19 epidemic?
Representing population data on a map is difficult and implies applying simplifications to understand the data « at a glance ». One of these is to use a scatter plot which is exactly what is shown in this data:
For the different data points, the size of the area is shown as a disk whose surface increases linearly with the number shown (here, infected people).
Indeed, this can lead to some confusion (it’s a data point on the map, it is not spread), and will difficulty apply to data which would be densely packed, leading to overlaps in the disks. For the latter, you may prefer heatmaps.
|
Visualizing the Coronavirus COVID-19 epidemic?
Representing population data on a map is difficult and implies applying simplifications to understand the data « at a glance ». One of these is to use a scatter plot which is exactly what is shown in
|
50,822 |
Notation and meaning of a general probability distribution
|
A "probability distribution" can be uniquely described either by its CDF or the corresponding probability measure. Contrarily, a density function is often not a unique description of a probability distribution, and so it would not usually be used for statements of the equality of distributions.$^\dagger$ Unfortunately, there is no standard notation for these kinds of problems, and usage differs substantially over different fields, so you really just have to read the statements in their context, to ensure you are interpreting the author correctly. The problem is compounded by the fact that an assertion of equivalence of distributions is already so clearly specified that some authors will play a bit "fast and loose" with the notation, and may actually use notation that is not strictly correct, but you are expected to understand what they intend anyway. (For example, you might occasionally see authors use the same notation for the "distribution" and also the density function.)
When using upper case letters like $P$ and $Q$ this is often (but not always) a reference to the CDF, whereas the blackboard-bold letters $\mathbb{P}$ and $\mathbb{Q}$ are often (but not always) a reference to the probability measure. In the absence of some contextual cues to the contrary, I would usually interpret them this way, but since there is no standard notation for these kinds of statements, you really just have to read the full paper, and you may even have to take an educated guess as to exactly what the author is referring to in the notation. Good luck!
$^\dagger$ For continuous random variables (dominated by Lebesgue measure), the density function can be altered at any countable set of points without changing the distribution. For discrete random variables (dominated by counting measure), the mass function is a unique representation of the distribution.
|
Notation and meaning of a general probability distribution
|
A "probability distribution" can be uniquely described either by its CDF or the corresponding probability measure. Contrarily, a density function is often not a unique description of a probability di
|
Notation and meaning of a general probability distribution
A "probability distribution" can be uniquely described either by its CDF or the corresponding probability measure. Contrarily, a density function is often not a unique description of a probability distribution, and so it would not usually be used for statements of the equality of distributions.$^\dagger$ Unfortunately, there is no standard notation for these kinds of problems, and usage differs substantially over different fields, so you really just have to read the statements in their context, to ensure you are interpreting the author correctly. The problem is compounded by the fact that an assertion of equivalence of distributions is already so clearly specified that some authors will play a bit "fast and loose" with the notation, and may actually use notation that is not strictly correct, but you are expected to understand what they intend anyway. (For example, you might occasionally see authors use the same notation for the "distribution" and also the density function.)
When using upper case letters like $P$ and $Q$ this is often (but not always) a reference to the CDF, whereas the blackboard-bold letters $\mathbb{P}$ and $\mathbb{Q}$ are often (but not always) a reference to the probability measure. In the absence of some contextual cues to the contrary, I would usually interpret them this way, but since there is no standard notation for these kinds of statements, you really just have to read the full paper, and you may even have to take an educated guess as to exactly what the author is referring to in the notation. Good luck!
$^\dagger$ For continuous random variables (dominated by Lebesgue measure), the density function can be altered at any countable set of points without changing the distribution. For discrete random variables (dominated by counting measure), the mass function is a unique representation of the distribution.
|
Notation and meaning of a general probability distribution
A "probability distribution" can be uniquely described either by its CDF or the corresponding probability measure. Contrarily, a density function is often not a unique description of a probability di
|
50,823 |
Differentiable programming for general Bayesian decision theory
|
TensorFlow Probability is a standalone probabilistic programming module for TensorFlow, numpyro package uses JAX, while Pyro is a PyTorch framework. All those frameworks enable you to do Variational Inference and Markov Chain Monte Carlo sampling.
The simplest way of computing the expected posterior loss, is using Monte Carlo samples from the posterior distribution (either using MCMC, or first use VI estimate posterior distribution, then sample from it). To calculate expected posterior loss, you need to do is to take samples from the posterior predictive distribution, calculate loss function over those values, and average the losses.
Frameworks that you describe (TensorFlow, JAX, PyTorch) are designed for using automatic differentiation, not for taking integrals, what is needed for Bayesian problems. You can find some packages that are focused on taking integrals, e.g. using Bayesian quadrature, but they are far less mature then the mentioned packages, so the procedure described by me above for now remains state-of-art for Bayesian problems.
|
Differentiable programming for general Bayesian decision theory
|
TensorFlow Probability is a standalone probabilistic programming module for TensorFlow, numpyro package uses JAX, while Pyro is a PyTorch framework. All those frameworks enable you to do Variational I
|
Differentiable programming for general Bayesian decision theory
TensorFlow Probability is a standalone probabilistic programming module for TensorFlow, numpyro package uses JAX, while Pyro is a PyTorch framework. All those frameworks enable you to do Variational Inference and Markov Chain Monte Carlo sampling.
The simplest way of computing the expected posterior loss, is using Monte Carlo samples from the posterior distribution (either using MCMC, or first use VI estimate posterior distribution, then sample from it). To calculate expected posterior loss, you need to do is to take samples from the posterior predictive distribution, calculate loss function over those values, and average the losses.
Frameworks that you describe (TensorFlow, JAX, PyTorch) are designed for using automatic differentiation, not for taking integrals, what is needed for Bayesian problems. You can find some packages that are focused on taking integrals, e.g. using Bayesian quadrature, but they are far less mature then the mentioned packages, so the procedure described by me above for now remains state-of-art for Bayesian problems.
|
Differentiable programming for general Bayesian decision theory
TensorFlow Probability is a standalone probabilistic programming module for TensorFlow, numpyro package uses JAX, while Pyro is a PyTorch framework. All those frameworks enable you to do Variational I
|
50,824 |
What distribution should I fit to this data
|
I've plotted log(data) vs abscissa and dropped two last points, graph below
data going below x=500 would be good fitted with just a linear function - which means exponential distribution because we plotted log(data).
But from 0 to 500 things looks different, maybe power law? Thus, I don't know if data could be fitted with one distribution function.
UPDATE
I played with truncated power law, and indeed this might work
Code (Python3.7, Anaconda x64 Win 10)
import numpy as np
from scipy.special import gamma
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
xs = []
ys = []
with open('my_data.csv') as f:
for line in f:
x, y = line.split(',')
xs.append(float(x))
ys.append(float(y))
xs = np.asarray(xs)
ys = np.asarray(np.log(ys))
x0 = xs[0]
def F(x, a, b):
return np.power((x-x0)+1.0, -a) * np.exp(-b*(x-x0))
def logF(x, a, b):
return -a*np.log((x-x0)+1.0) + (-b*(x-x0))
popt, pcov = curve_fit(logF, xs, ys)
print(popt)
plt.plot(xs, ys, 'b*', label='data')
plt.plot(xs, logF(xs, *popt), 'g-', label='fit')
plt.show()
produced reasonable fit graph. And if you print sqrt of pcov diagonal, errors looks small
print(popt)
print(np.sqrt(np.diag(pcov)))
produced
[0.38962489 0.00140291]
[2.51804031e-03 2.10496530e-05]
|
What distribution should I fit to this data
|
I've plotted log(data) vs abscissa and dropped two last points, graph below
data going below x=500 would be good fitted with just a linear function - which means exponential distribution because we p
|
What distribution should I fit to this data
I've plotted log(data) vs abscissa and dropped two last points, graph below
data going below x=500 would be good fitted with just a linear function - which means exponential distribution because we plotted log(data).
But from 0 to 500 things looks different, maybe power law? Thus, I don't know if data could be fitted with one distribution function.
UPDATE
I played with truncated power law, and indeed this might work
Code (Python3.7, Anaconda x64 Win 10)
import numpy as np
from scipy.special import gamma
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
xs = []
ys = []
with open('my_data.csv') as f:
for line in f:
x, y = line.split(',')
xs.append(float(x))
ys.append(float(y))
xs = np.asarray(xs)
ys = np.asarray(np.log(ys))
x0 = xs[0]
def F(x, a, b):
return np.power((x-x0)+1.0, -a) * np.exp(-b*(x-x0))
def logF(x, a, b):
return -a*np.log((x-x0)+1.0) + (-b*(x-x0))
popt, pcov = curve_fit(logF, xs, ys)
print(popt)
plt.plot(xs, ys, 'b*', label='data')
plt.plot(xs, logF(xs, *popt), 'g-', label='fit')
plt.show()
produced reasonable fit graph. And if you print sqrt of pcov diagonal, errors looks small
print(popt)
print(np.sqrt(np.diag(pcov)))
produced
[0.38962489 0.00140291]
[2.51804031e-03 2.10496530e-05]
|
What distribution should I fit to this data
I've plotted log(data) vs abscissa and dropped two last points, graph below
data going below x=500 would be good fitted with just a linear function - which means exponential distribution because we p
|
50,825 |
Can you infer standard deviation/error from bootstrapped confidence intervals?
|
"is there any relationship between the size of confidence intervals calculated from bootstrapping and sd?"
Yes if the model residuals are perfectly normally distributed they would be identical ... non-normal residuals would lead to a mismatch.
I don't think that increasing the number of monte-carlo samples would reduce anything ,,,just get a better handle on the probability distribution.
|
Can you infer standard deviation/error from bootstrapped confidence intervals?
|
"is there any relationship between the size of confidence intervals calculated from bootstrapping and sd?"
Yes if the model residuals are perfectly normally distributed they would be identical ... no
|
Can you infer standard deviation/error from bootstrapped confidence intervals?
"is there any relationship between the size of confidence intervals calculated from bootstrapping and sd?"
Yes if the model residuals are perfectly normally distributed they would be identical ... non-normal residuals would lead to a mismatch.
I don't think that increasing the number of monte-carlo samples would reduce anything ,,,just get a better handle on the probability distribution.
|
Can you infer standard deviation/error from bootstrapped confidence intervals?
"is there any relationship between the size of confidence intervals calculated from bootstrapping and sd?"
Yes if the model residuals are perfectly normally distributed they would be identical ... no
|
50,826 |
Cross Validation and Multiple Imputation for Missing Data
|
I believe that your thinking is right.
The alternative is to perform multiple imputation on the entire dataset prior to splitting into train/test partitions. Doing so would mean that some information from the training sets is used to create/impute values in the test sets. In other words, there would be leakage from the training sets into the test sets, thereby biasing the results of cross-validation.
|
Cross Validation and Multiple Imputation for Missing Data
|
I believe that your thinking is right.
The alternative is to perform multiple imputation on the entire dataset prior to splitting into train/test partitions. Doing so would mean that some information
|
Cross Validation and Multiple Imputation for Missing Data
I believe that your thinking is right.
The alternative is to perform multiple imputation on the entire dataset prior to splitting into train/test partitions. Doing so would mean that some information from the training sets is used to create/impute values in the test sets. In other words, there would be leakage from the training sets into the test sets, thereby biasing the results of cross-validation.
|
Cross Validation and Multiple Imputation for Missing Data
I believe that your thinking is right.
The alternative is to perform multiple imputation on the entire dataset prior to splitting into train/test partitions. Doing so would mean that some information
|
50,827 |
Treatment interference (causal analysis)
|
I would say this is indeed valid.
What you likely measure by comparing the control group
those who only see their actual grades in a course (as a percentage)
with the treatment group
who see both their actual grades in a course (as a percentage) and their percentile rank
is essentially the effect of presenting a (relative) measure in which your relative gain means someone else's loss.
Statistically, you should be aware of two other problems with ranks (see also here):
The first is ranking changes with respect to sample size: In small classes, a minor change in the actual grade could lead to substantial percentile rank changes (e.g. from 60% to 70% if there are only 11 students in the class). If treatment and control group class sizes differ, this could in some sense bias your interpretation (depending on the mechanism you are expecting). Usually, you would more seldom use a ranking much in very small class (e.g. for data privacy reasons). Presenting a rank among a group of let's say five people could let students act differently for other reasons than you have in mind I think.
The second is the shape of the underlying distribution. A rank change of one percentile pont can be easier or more difficult depending on where you are. Think there is one extreme hard task in the exam while all others are easy. You can easily climb to the 80th percentile but another rank increases requires to have an idea how to solve that task.
|
Treatment interference (causal analysis)
|
I would say this is indeed valid.
What you likely measure by comparing the control group
those who only see their actual grades in a course (as a percentage)
with the treatment group
who see bot
|
Treatment interference (causal analysis)
I would say this is indeed valid.
What you likely measure by comparing the control group
those who only see their actual grades in a course (as a percentage)
with the treatment group
who see both their actual grades in a course (as a percentage) and their percentile rank
is essentially the effect of presenting a (relative) measure in which your relative gain means someone else's loss.
Statistically, you should be aware of two other problems with ranks (see also here):
The first is ranking changes with respect to sample size: In small classes, a minor change in the actual grade could lead to substantial percentile rank changes (e.g. from 60% to 70% if there are only 11 students in the class). If treatment and control group class sizes differ, this could in some sense bias your interpretation (depending on the mechanism you are expecting). Usually, you would more seldom use a ranking much in very small class (e.g. for data privacy reasons). Presenting a rank among a group of let's say five people could let students act differently for other reasons than you have in mind I think.
The second is the shape of the underlying distribution. A rank change of one percentile pont can be easier or more difficult depending on where you are. Think there is one extreme hard task in the exam while all others are easy. You can easily climb to the 80th percentile but another rank increases requires to have an idea how to solve that task.
|
Treatment interference (causal analysis)
I would say this is indeed valid.
What you likely measure by comparing the control group
those who only see their actual grades in a course (as a percentage)
with the treatment group
who see bot
|
50,828 |
Kolmogorov Smirnov p-values not uniform under the null in R?
|
It is not surprising that when dealing with a two sample test with a fairly small sample size (100), the test statistic (and thus the p-value) takes on discrete values. Increasing n (and decreasing K to reduce computational time) leads to a less discontinuous distribution.
As whuber pointed out in the comments, the fact that the p-value is obligately discrete leads to unusually high histogram bars. The apparent skew in the distribution is an artefact of the bins used to construct it and the discrete values possible for the test statistic in the low n setting.
K = 1000
n = 1000
p.val = sapply(1:K,FUN = function(x) ks.test(rnorm(n),rnorm(n),exact=TRUE)$p.value)
mean(p.val<0.05)
#> [1] 0.055
plot(p.val,main = 'Plot of p.val')
hist(p.val,freq=FALSE, breaks = "FD")
Created on 2019-10-15 by the reprex package (v0.3.0)
|
Kolmogorov Smirnov p-values not uniform under the null in R?
|
It is not surprising that when dealing with a two sample test with a fairly small sample size (100), the test statistic (and thus the p-value) takes on discrete values. Increasing n (and decreasing K
|
Kolmogorov Smirnov p-values not uniform under the null in R?
It is not surprising that when dealing with a two sample test with a fairly small sample size (100), the test statistic (and thus the p-value) takes on discrete values. Increasing n (and decreasing K to reduce computational time) leads to a less discontinuous distribution.
As whuber pointed out in the comments, the fact that the p-value is obligately discrete leads to unusually high histogram bars. The apparent skew in the distribution is an artefact of the bins used to construct it and the discrete values possible for the test statistic in the low n setting.
K = 1000
n = 1000
p.val = sapply(1:K,FUN = function(x) ks.test(rnorm(n),rnorm(n),exact=TRUE)$p.value)
mean(p.val<0.05)
#> [1] 0.055
plot(p.val,main = 'Plot of p.val')
hist(p.val,freq=FALSE, breaks = "FD")
Created on 2019-10-15 by the reprex package (v0.3.0)
|
Kolmogorov Smirnov p-values not uniform under the null in R?
It is not surprising that when dealing with a two sample test with a fairly small sample size (100), the test statistic (and thus the p-value) takes on discrete values. Increasing n (and decreasing K
|
50,829 |
Why construct statistics when you can never beat LRT?
|
Your question is very broad, so this is more of a comment. One possible problem is that the (generalized) likelihood ratio test might be suboptimal in some cases, this paper points to some such examples.
You say Indeed, many, if not all, of the above mentioned tests can be shown to be equivalent to a LRT, but I was referring to LRTs directly constructed by log-likelihood functions. The point is, a handcrafted test statistic can never do better than a no-brainer LRT, so why bother? Well, even then, we would need the null hypothesis distribution of the directly constructed LRT, and maybe it is easier to find that for some transformation?
In no-standard cases the non-asymptotic null distribution an be quite complicated ...
|
Why construct statistics when you can never beat LRT?
|
Your question is very broad, so this is more of a comment. One possible problem is that the (generalized) likelihood ratio test might be suboptimal in some cases, this paper points to some such examp
|
Why construct statistics when you can never beat LRT?
Your question is very broad, so this is more of a comment. One possible problem is that the (generalized) likelihood ratio test might be suboptimal in some cases, this paper points to some such examples.
You say Indeed, many, if not all, of the above mentioned tests can be shown to be equivalent to a LRT, but I was referring to LRTs directly constructed by log-likelihood functions. The point is, a handcrafted test statistic can never do better than a no-brainer LRT, so why bother? Well, even then, we would need the null hypothesis distribution of the directly constructed LRT, and maybe it is easier to find that for some transformation?
In no-standard cases the non-asymptotic null distribution an be quite complicated ...
|
Why construct statistics when you can never beat LRT?
Your question is very broad, so this is more of a comment. One possible problem is that the (generalized) likelihood ratio test might be suboptimal in some cases, this paper points to some such examp
|
50,830 |
L1 and L2 regularization showing increased MSE with added vars (that eventually decreases)
|
This can be explained by the trade of between bias and variance. We know that mse = bias^2 + var, a sum of a decreasing function of the number of predictors involved (bias) and an increasing function (var).
The thing, we dont have a specific role about the behavior of mse (training mse), but generally it decreased with more predictors involved, but its not always the case.
In this situation your mse movement is justified by the fact bias is slowly decreasing compared to how variance is going up (the first part of the graph ) . And when it reaches its max value of complexity(var), any predictor added will only decrease the biais so the mse will go down.
There may be other explanations that comes out of your data set. For example a large variance of the target. If so your model var will take more predictors until it reaches the max mse before starts decreasing
|
L1 and L2 regularization showing increased MSE with added vars (that eventually decreases)
|
This can be explained by the trade of between bias and variance. We know that mse = bias^2 + var, a sum of a decreasing function of the number of predictors involved (bias) and an increasing function
|
L1 and L2 regularization showing increased MSE with added vars (that eventually decreases)
This can be explained by the trade of between bias and variance. We know that mse = bias^2 + var, a sum of a decreasing function of the number of predictors involved (bias) and an increasing function (var).
The thing, we dont have a specific role about the behavior of mse (training mse), but generally it decreased with more predictors involved, but its not always the case.
In this situation your mse movement is justified by the fact bias is slowly decreasing compared to how variance is going up (the first part of the graph ) . And when it reaches its max value of complexity(var), any predictor added will only decrease the biais so the mse will go down.
There may be other explanations that comes out of your data set. For example a large variance of the target. If so your model var will take more predictors until it reaches the max mse before starts decreasing
|
L1 and L2 regularization showing increased MSE with added vars (that eventually decreases)
This can be explained by the trade of between bias and variance. We know that mse = bias^2 + var, a sum of a decreasing function of the number of predictors involved (bias) and an increasing function
|
50,831 |
Generalized Least Squares using Moore Penrose pseudo inverse
|
You can compute a solution using the Moore-Penrose inverse in place of the (non-existing) usual inverse. That is known to give a minimum-norm solution. That is, with the linear model in matrix form (assuming iid errors)
$$
Y = X\beta + \epsilon
$$ (you write generalized least square so presumably the covariance matrix of the error term $\epsilon$ is not of the form $\sigma^2 I$, but everything can be generalized to that case.) Then the least squares solution is $\hat{\beta}= (X^TX)^{-1} X^T Y$, but this only exists if $X^T X$ is invertible. Failing that, the equation system
$$ X^T X \beta = X^T Y
$$ has infinitely many solutions, and we could pick any of those. But it is argued that when the estimated model is used for prediction, it is advantageous that $\beta$ is "small", since $\beta$ will also amplify errors. So it is natural to choose the solution of minimal norm $ ||\beta||^2 = \sum_j \beta_j^2$. That solution is found by using the Moore-Penrose inverse. Details can be found here Solve $X^TX b = a$ for $b$ using $XX^T$ for a short and wide matrix $X$.
The you ask if it is safe to replace the inverse of the covariance matrix with a pseudo inverse of the correlation matrix when using a GLS? Well, it is safe. Denote the Moore-Penrose inverse of $X^TX$ with $(X^TX)^+$ and the minimum norm estimator by $\beta^*$. Then
\begin{align} \DeclareMathOperator{\C}{\mathbb{Cov}}
\C \beta^* &=& \C\left\{ (X^TX)^+ X^T Y\right\} \\
&=& (X^TX)^+ X^T \sigma^2 I X (X^T X)^+ \\
&=& \sigma^2 (X^TX)^+ X^TX (X^TX)^+ \\
&=& \sigma^2 (X^TX)^+
\end{align}
where we in the last line used a basic property of the Moore-Penrose inverse, that $A^+ A A^+ = A^+$.
|
Generalized Least Squares using Moore Penrose pseudo inverse
|
You can compute a solution using the Moore-Penrose inverse in place of the (non-existing) usual inverse. That is known to give a minimum-norm solution. That is, with the linear model in matrix form (a
|
Generalized Least Squares using Moore Penrose pseudo inverse
You can compute a solution using the Moore-Penrose inverse in place of the (non-existing) usual inverse. That is known to give a minimum-norm solution. That is, with the linear model in matrix form (assuming iid errors)
$$
Y = X\beta + \epsilon
$$ (you write generalized least square so presumably the covariance matrix of the error term $\epsilon$ is not of the form $\sigma^2 I$, but everything can be generalized to that case.) Then the least squares solution is $\hat{\beta}= (X^TX)^{-1} X^T Y$, but this only exists if $X^T X$ is invertible. Failing that, the equation system
$$ X^T X \beta = X^T Y
$$ has infinitely many solutions, and we could pick any of those. But it is argued that when the estimated model is used for prediction, it is advantageous that $\beta$ is "small", since $\beta$ will also amplify errors. So it is natural to choose the solution of minimal norm $ ||\beta||^2 = \sum_j \beta_j^2$. That solution is found by using the Moore-Penrose inverse. Details can be found here Solve $X^TX b = a$ for $b$ using $XX^T$ for a short and wide matrix $X$.
The you ask if it is safe to replace the inverse of the covariance matrix with a pseudo inverse of the correlation matrix when using a GLS? Well, it is safe. Denote the Moore-Penrose inverse of $X^TX$ with $(X^TX)^+$ and the minimum norm estimator by $\beta^*$. Then
\begin{align} \DeclareMathOperator{\C}{\mathbb{Cov}}
\C \beta^* &=& \C\left\{ (X^TX)^+ X^T Y\right\} \\
&=& (X^TX)^+ X^T \sigma^2 I X (X^T X)^+ \\
&=& \sigma^2 (X^TX)^+ X^TX (X^TX)^+ \\
&=& \sigma^2 (X^TX)^+
\end{align}
where we in the last line used a basic property of the Moore-Penrose inverse, that $A^+ A A^+ = A^+$.
|
Generalized Least Squares using Moore Penrose pseudo inverse
You can compute a solution using the Moore-Penrose inverse in place of the (non-existing) usual inverse. That is known to give a minimum-norm solution. That is, with the linear model in matrix form (a
|
50,832 |
When does the underfitted regression model have more precise coefficient estimates?
|
The sufficient condition mentioned in the book turns out to be necessary as well! I finally verified it using the two different formulas for the inverse of a block matrix.
Looking at the full model estimator
$$
\mathbf{X}^\intercal\mathbf{X} =
\begin{bmatrix}
\mathbf{X}_p^\intercal\mathbf{X}_p &\mathbf{X}_p^\intercal\mathbf{X}_r \\
\mathbf{X}_r^\intercal\mathbf{X}_p & \mathbf{X}_r^\intercal\mathbf{X}_r
\end{bmatrix}
$$
so $\text{MSE}[\hat{\boldsymbol{\beta}}^*_p]=\sigma^2[(\mathbf{X}^\intercal\mathbf{X})^{-1}]_p$ equals
$$
\sigma^2\left\{(\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} + (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1}\mathbf{X}^\intercal_p\mathbf{X}_r(\mathbf{X}_r^\intercal\mathbf{X}_r - \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} \mathbf{X}_p^\intercal \mathbf{X}_r)^{-1}\mathbf{X}_r^\intercal\mathbf{X}_p(\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1}\right\}. \tag{1}
$$
Looking at the smaller model's estimator, $\mathbf{A} = (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}\mathbf{X}_p^\intercal \mathbf{X}_r$ so
\begin{align*}
\text{MSE}[\hat{\boldsymbol{\beta}}_p] &= V[\hat{\boldsymbol{\beta}}_p] + \mathbf{A}\boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal \mathbf{A}^\intercal\\
&= \sigma^2(\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1} + (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}\mathbf{X}_p^\intercal \mathbf{X}_r \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1} \tag{2}\\
\end{align*}
Subtracting (2) from (1) yields
$$
(\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}\mathbf{X}_p^\intercal \mathbf{X}_r\left[ \sigma^2 (\mathbf{X}_r^\intercal\mathbf{X}_r - \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} \mathbf{X}_p^\intercal \mathbf{X}_r)^{-1} - \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal \right]\mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}
$$
which is positive semi-definite if this is as well:
$$
\sigma^2 (\mathbf{X}_r^\intercal\mathbf{X}_r - \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} \mathbf{X}_p^\intercal \mathbf{X}_r)^{-1} - \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal.
$$
This is the same as the expression $V[\hat{\boldsymbol{\beta}}^*_r] - \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal$.
|
When does the underfitted regression model have more precise coefficient estimates?
|
The sufficient condition mentioned in the book turns out to be necessary as well! I finally verified it using the two different formulas for the inverse of a block matrix.
Looking at the full model es
|
When does the underfitted regression model have more precise coefficient estimates?
The sufficient condition mentioned in the book turns out to be necessary as well! I finally verified it using the two different formulas for the inverse of a block matrix.
Looking at the full model estimator
$$
\mathbf{X}^\intercal\mathbf{X} =
\begin{bmatrix}
\mathbf{X}_p^\intercal\mathbf{X}_p &\mathbf{X}_p^\intercal\mathbf{X}_r \\
\mathbf{X}_r^\intercal\mathbf{X}_p & \mathbf{X}_r^\intercal\mathbf{X}_r
\end{bmatrix}
$$
so $\text{MSE}[\hat{\boldsymbol{\beta}}^*_p]=\sigma^2[(\mathbf{X}^\intercal\mathbf{X})^{-1}]_p$ equals
$$
\sigma^2\left\{(\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} + (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1}\mathbf{X}^\intercal_p\mathbf{X}_r(\mathbf{X}_r^\intercal\mathbf{X}_r - \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} \mathbf{X}_p^\intercal \mathbf{X}_r)^{-1}\mathbf{X}_r^\intercal\mathbf{X}_p(\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1}\right\}. \tag{1}
$$
Looking at the smaller model's estimator, $\mathbf{A} = (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}\mathbf{X}_p^\intercal \mathbf{X}_r$ so
\begin{align*}
\text{MSE}[\hat{\boldsymbol{\beta}}_p] &= V[\hat{\boldsymbol{\beta}}_p] + \mathbf{A}\boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal \mathbf{A}^\intercal\\
&= \sigma^2(\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1} + (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}\mathbf{X}_p^\intercal \mathbf{X}_r \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1} \tag{2}\\
\end{align*}
Subtracting (2) from (1) yields
$$
(\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}\mathbf{X}_p^\intercal \mathbf{X}_r\left[ \sigma^2 (\mathbf{X}_r^\intercal\mathbf{X}_r - \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} \mathbf{X}_p^\intercal \mathbf{X}_r)^{-1} - \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal \right]\mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal \mathbf{X}_p)^{-1}
$$
which is positive semi-definite if this is as well:
$$
\sigma^2 (\mathbf{X}_r^\intercal\mathbf{X}_r - \mathbf{X}_r^\intercal \mathbf{X}_p (\mathbf{X}_p^\intercal\mathbf{X}_p)^{-1} \mathbf{X}_p^\intercal \mathbf{X}_r)^{-1} - \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal.
$$
This is the same as the expression $V[\hat{\boldsymbol{\beta}}^*_r] - \boldsymbol{\beta}_r\boldsymbol{\beta}_r^\intercal$.
|
When does the underfitted regression model have more precise coefficient estimates?
The sufficient condition mentioned in the book turns out to be necessary as well! I finally verified it using the two different formulas for the inverse of a block matrix.
Looking at the full model es
|
50,833 |
Examples of "one to many" for RNN/LSTM
|
The most popular example is the decoder part of the seq2seq recurrent neural network (RNN). Such networks are one of the most basic examples of networks that can be used for machine translation. They consist of two sub-networks: encoder RNN network that takes as input sentence in one language and encodes using some vector representation for the whole sentence, and decoder network that uses the vector representation of a sentence to produce a sentence in target language.
You can find many examples and tutorials on such networks online, e.g. here (above image was taken from this blog), here, here, or here. Moreover, Keras code example can be found on StackOverflow.
|
Examples of "one to many" for RNN/LSTM
|
The most popular example is the decoder part of the seq2seq recurrent neural network (RNN). Such networks are one of the most basic examples of networks that can be used for machine translation. They
|
Examples of "one to many" for RNN/LSTM
The most popular example is the decoder part of the seq2seq recurrent neural network (RNN). Such networks are one of the most basic examples of networks that can be used for machine translation. They consist of two sub-networks: encoder RNN network that takes as input sentence in one language and encodes using some vector representation for the whole sentence, and decoder network that uses the vector representation of a sentence to produce a sentence in target language.
You can find many examples and tutorials on such networks online, e.g. here (above image was taken from this blog), here, here, or here. Moreover, Keras code example can be found on StackOverflow.
|
Examples of "one to many" for RNN/LSTM
The most popular example is the decoder part of the seq2seq recurrent neural network (RNN). Such networks are one of the most basic examples of networks that can be used for machine translation. They
|
50,834 |
Bounding residual variance with distance from mean
|
I was able to come up with a bound although it's not very tight.
Let $X = UDV^T$ be the SVD of $X$, so that $H = UU^T$. Let $u_1,\dots,u_n \in \mathbb R^p$ be the rows of $U$ (as column vectors) which means that $h_i = \|u_i\|^2$.
Let $s_i^2 = \|x_i - \frac 1n X^T\mathbf 1\|^2$. If $e_i$ is the $i$th standard basis vector then $x_i = X^Te_i$ so I can write
$$
s_i^2 = \|X^Te_i - \frac 1n X^T\mathbf 1\|^2 = \|X^T(e_i - \frac 1n\mathbf 1)\|^2 \\
= (e_i - \frac 1n\mathbf 1)^TXX^T(e_i - \frac 1n\mathbf 1) \\
= (e_i - \frac 1n\mathbf 1)^TUD^2U^T(e_i - \frac 1n\mathbf 1) .
$$
I don't like the $D^2$ since it seems like it'll be helpful to get a quadratic form with $H=UU^T$ instead of $XX^T$ so I'll use the fact that $d_1^2$ is the largest squared singular value so
$$
s_i^2 \leq d_1^2(e_i - \frac 1n\mathbf 1)^TUU^T(e_i - \frac 1n\mathbf 1) \\
= d_1^2 \left(e_i^TUU^Te_i - \frac 2n \mathbf 1^TUU^Te_i + \frac 1{n^2}\mathbf 1^TUU^T\mathbf 1\right) \\
= d_1^2 \left(h_i - \frac 2n \mathbf 1^TUU^Te_i + \frac 1{n^2}\mathbf 1^TUU^T\mathbf 1\right).
$$
Now I'll assume that $\mathbf 1$ is in the column space of $X$ (i.e. it has an intercept, which shouldn't be too controversial). This means that $H\mathbf 1 = UU^T\mathbf 1 = \mathbf 1$ so
$$
s_i^2 \leq d_1^2 \left(h_i - \frac 2n \mathbf 1^Te_i + \frac 1{n^2}\mathbf 1^T\mathbf 1\right) \\
= d_1^2 \left(h_i - \frac 1n \right)
$$
which implies that
$$
h_i \geq \frac{s_i^2}{d_1^2} + \frac 1n \\
\iff 1 - h_i \leq 1 - \frac 1n - \frac{s_i^2}{d_1^2}.
$$
Thus as $s_i^2$ increases this upper bound on the variance of a residual does go up, which is nice to see, but I'm not particularly happy with this as $d_1^2$ is often massive in the experiments I've done so this is close to just saying $1 - h_i \leq 1 - \frac 1n$.
Is there a better bound available?
|
Bounding residual variance with distance from mean
|
I was able to come up with a bound although it's not very tight.
Let $X = UDV^T$ be the SVD of $X$, so that $H = UU^T$. Let $u_1,\dots,u_n \in \mathbb R^p$ be the rows of $U$ (as column vectors) which
|
Bounding residual variance with distance from mean
I was able to come up with a bound although it's not very tight.
Let $X = UDV^T$ be the SVD of $X$, so that $H = UU^T$. Let $u_1,\dots,u_n \in \mathbb R^p$ be the rows of $U$ (as column vectors) which means that $h_i = \|u_i\|^2$.
Let $s_i^2 = \|x_i - \frac 1n X^T\mathbf 1\|^2$. If $e_i$ is the $i$th standard basis vector then $x_i = X^Te_i$ so I can write
$$
s_i^2 = \|X^Te_i - \frac 1n X^T\mathbf 1\|^2 = \|X^T(e_i - \frac 1n\mathbf 1)\|^2 \\
= (e_i - \frac 1n\mathbf 1)^TXX^T(e_i - \frac 1n\mathbf 1) \\
= (e_i - \frac 1n\mathbf 1)^TUD^2U^T(e_i - \frac 1n\mathbf 1) .
$$
I don't like the $D^2$ since it seems like it'll be helpful to get a quadratic form with $H=UU^T$ instead of $XX^T$ so I'll use the fact that $d_1^2$ is the largest squared singular value so
$$
s_i^2 \leq d_1^2(e_i - \frac 1n\mathbf 1)^TUU^T(e_i - \frac 1n\mathbf 1) \\
= d_1^2 \left(e_i^TUU^Te_i - \frac 2n \mathbf 1^TUU^Te_i + \frac 1{n^2}\mathbf 1^TUU^T\mathbf 1\right) \\
= d_1^2 \left(h_i - \frac 2n \mathbf 1^TUU^Te_i + \frac 1{n^2}\mathbf 1^TUU^T\mathbf 1\right).
$$
Now I'll assume that $\mathbf 1$ is in the column space of $X$ (i.e. it has an intercept, which shouldn't be too controversial). This means that $H\mathbf 1 = UU^T\mathbf 1 = \mathbf 1$ so
$$
s_i^2 \leq d_1^2 \left(h_i - \frac 2n \mathbf 1^Te_i + \frac 1{n^2}\mathbf 1^T\mathbf 1\right) \\
= d_1^2 \left(h_i - \frac 1n \right)
$$
which implies that
$$
h_i \geq \frac{s_i^2}{d_1^2} + \frac 1n \\
\iff 1 - h_i \leq 1 - \frac 1n - \frac{s_i^2}{d_1^2}.
$$
Thus as $s_i^2$ increases this upper bound on the variance of a residual does go up, which is nice to see, but I'm not particularly happy with this as $d_1^2$ is often massive in the experiments I've done so this is close to just saying $1 - h_i \leq 1 - \frac 1n$.
Is there a better bound available?
|
Bounding residual variance with distance from mean
I was able to come up with a bound although it's not very tight.
Let $X = UDV^T$ be the SVD of $X$, so that $H = UU^T$. Let $u_1,\dots,u_n \in \mathbb R^p$ be the rows of $U$ (as column vectors) which
|
50,835 |
Approximate density from moments and quantiles, then sample from it
|
To quickly simulate based on moments, try rpearson() from library(PearsonDS).
library(PearsonDS)
target.moms <- c(1262.39, 9567670, 10.59025, 157.7004)
y <- rpearson(n=1000000, moments=target.moms)
rpearson() works well for matching the moments. However, the splines approach that you're already using will be better at recovering the percentiles. See below for an example.
#Evaluating the results
library(moments)
eval <- function(data) {
result.list <- list(mean=mean(data),
var=var(data),
skew=skewness(data),
kurt=kurtosis(data),
quantile(data, c(.01,.05,.10,.25,.50,.75,.90,.95,.99) ) )
round(unlist(result.list), 2)
}
x <- splsample(percentiles, values, plot = TRUE)
eval(x) #splines
eval(y) #rpearson()
|
Approximate density from moments and quantiles, then sample from it
|
To quickly simulate based on moments, try rpearson() from library(PearsonDS).
library(PearsonDS)
target.moms <- c(1262.39, 9567670, 10.59025, 157.7004)
y <- rpearson(n=1000000, moments=target.moms)
r
|
Approximate density from moments and quantiles, then sample from it
To quickly simulate based on moments, try rpearson() from library(PearsonDS).
library(PearsonDS)
target.moms <- c(1262.39, 9567670, 10.59025, 157.7004)
y <- rpearson(n=1000000, moments=target.moms)
rpearson() works well for matching the moments. However, the splines approach that you're already using will be better at recovering the percentiles. See below for an example.
#Evaluating the results
library(moments)
eval <- function(data) {
result.list <- list(mean=mean(data),
var=var(data),
skew=skewness(data),
kurt=kurtosis(data),
quantile(data, c(.01,.05,.10,.25,.50,.75,.90,.95,.99) ) )
round(unlist(result.list), 2)
}
x <- splsample(percentiles, values, plot = TRUE)
eval(x) #splines
eval(y) #rpearson()
|
Approximate density from moments and quantiles, then sample from it
To quickly simulate based on moments, try rpearson() from library(PearsonDS).
library(PearsonDS)
target.moms <- c(1262.39, 9567670, 10.59025, 157.7004)
y <- rpearson(n=1000000, moments=target.moms)
r
|
50,836 |
Under what conditions does it make sense to fit random intercepts for an interaction, but not the main effects?
|
Using the notation dept:service you get the interaction and main effects. You can see this also in the output where the number of groups are specified as 28.
Loading required package: Matrix
Linear mixed model fit by maximum likelihood ['lmerMod']
Formula: y ~ 1 + (1 | s) + (1 | d) + (1 | dept:service)
Data: InstEval
AIC BIC logLik deviance df.resid
237663.3 237709.3 -118826.6 237653.3 73416
Scaled residuals:
Min 1Q Median 3Q Max
-2.9941 -0.7474 0.0400 0.7721 3.1124
Random effects:
Groups Name Variance Std.Dev.
s (Intercept) 0.10541 0.3247
d (Intercept) 0.26256 0.5124
dept:service (Intercept) 0.01213 0.1101
Residual 1.38495 1.1768
Number of obs: 73421, groups: s, 2972; d, 1128; dept:service, 28
Fixed effects:
Estimate Std. Error t value
(Intercept) 3.25521 0.02824 115.3
Using an interaction term without a main effect would make sense if the effect is only expected in the interaction.
For instance, let $x$ be number of kids in a family and $y$ number of schools in the area. Say there would be some effect that involves the number of schools that is only relevant when a family has kids, then it makes no sense to include number of schools as a main effect.
|
Under what conditions does it make sense to fit random intercepts for an interaction, but not the ma
|
Using the notation dept:service you get the interaction and main effects. You can see this also in the output where the number of groups are specified as 28.
Loading required package: Matrix
Linear mi
|
Under what conditions does it make sense to fit random intercepts for an interaction, but not the main effects?
Using the notation dept:service you get the interaction and main effects. You can see this also in the output where the number of groups are specified as 28.
Loading required package: Matrix
Linear mixed model fit by maximum likelihood ['lmerMod']
Formula: y ~ 1 + (1 | s) + (1 | d) + (1 | dept:service)
Data: InstEval
AIC BIC logLik deviance df.resid
237663.3 237709.3 -118826.6 237653.3 73416
Scaled residuals:
Min 1Q Median 3Q Max
-2.9941 -0.7474 0.0400 0.7721 3.1124
Random effects:
Groups Name Variance Std.Dev.
s (Intercept) 0.10541 0.3247
d (Intercept) 0.26256 0.5124
dept:service (Intercept) 0.01213 0.1101
Residual 1.38495 1.1768
Number of obs: 73421, groups: s, 2972; d, 1128; dept:service, 28
Fixed effects:
Estimate Std. Error t value
(Intercept) 3.25521 0.02824 115.3
Using an interaction term without a main effect would make sense if the effect is only expected in the interaction.
For instance, let $x$ be number of kids in a family and $y$ number of schools in the area. Say there would be some effect that involves the number of schools that is only relevant when a family has kids, then it makes no sense to include number of schools as a main effect.
|
Under what conditions does it make sense to fit random intercepts for an interaction, but not the ma
Using the notation dept:service you get the interaction and main effects. You can see this also in the output where the number of groups are specified as 28.
Loading required package: Matrix
Linear mi
|
50,837 |
Which gamma regression model to use for extrapolation?
|
The OP has done a great job exploring a variety of different techniques. As commented, given that the response variable is Gamma-distributed it makes sense to consider a GLM and/or a GAM for Gamma distributed variables. Particularly for the use of GAMs, if the computation burden appears too much we might want to consider restricted the basis functions used by the GAM (in the case of pyGAM used here that being achieved by setting s(..., n_splines=X) where X is something smaller than the default $20$.
The main point to rectify is the use of evaluating the error of each method. Simple random resampling by cross-validation is providing us an indication on "interpolation" rather than "extrapolation" performance. Here, given $x_e = \{1, \dots, 10\}$, we focus on predicting $x_e =0$; therefore it is more reasonable to use instances where $x_e = 1$ in our validation set and instances where $x_e =\{2, \dots, 10\}$ in our training set. Note that in-sample errors are rather misleading for a extrapolation task; there is no "overfitting" perse because the validation and training set do not refer to the same sample/population. On that matter, the fact we get simple models (Elastic Net regression and Bayesian Ridge regression) as our top-performing routines is not too surprising. When extrapolating most bets are off (e.g. see the CV thread: What is wrong with extrapolation?) and commonly simple methods outperform complex ones (e.g. see the CV thread Best method for short time-series).
As a final note, it is always prudent to get estimates of the variability of our performance metric. If possible we should set aside a number of observations, fit our candidate models to the remaining data, and evaluate the models in the data we set aside. This should be repeated multiple times.
In effect, what is described is nested cross-validation for model selection; only particular will be that the for each loop the hold-out set is such that $x_e = 1$. (Once again) CV has a great thread on the matter: Nested cross validation for model selection and Model selection and cross-validation: The right way. In short, the outer loop will be used to assess the performance of the particular model (e.g. Ridge regression), and the inner loop will be used to select the best model (the regularisation parameter $\lambda$ for the case of Ridge). A simplified and very succinct Python example of nested CV would be as follows:
myS = cross_val_score(GridSearchCV(linear_model.ElasticNet(), param_grid, cv=5),
myX, myY, cv=5)
print("CV scores: ", myS)
print("Mean CV scores & Std. Dev.: {:.3f} {:.3f}".format(myS.mean(), myS.std()))
|
Which gamma regression model to use for extrapolation?
|
The OP has done a great job exploring a variety of different techniques. As commented, given that the response variable is Gamma-distributed it makes sense to consider a GLM and/or a GAM for Gamma dis
|
Which gamma regression model to use for extrapolation?
The OP has done a great job exploring a variety of different techniques. As commented, given that the response variable is Gamma-distributed it makes sense to consider a GLM and/or a GAM for Gamma distributed variables. Particularly for the use of GAMs, if the computation burden appears too much we might want to consider restricted the basis functions used by the GAM (in the case of pyGAM used here that being achieved by setting s(..., n_splines=X) where X is something smaller than the default $20$.
The main point to rectify is the use of evaluating the error of each method. Simple random resampling by cross-validation is providing us an indication on "interpolation" rather than "extrapolation" performance. Here, given $x_e = \{1, \dots, 10\}$, we focus on predicting $x_e =0$; therefore it is more reasonable to use instances where $x_e = 1$ in our validation set and instances where $x_e =\{2, \dots, 10\}$ in our training set. Note that in-sample errors are rather misleading for a extrapolation task; there is no "overfitting" perse because the validation and training set do not refer to the same sample/population. On that matter, the fact we get simple models (Elastic Net regression and Bayesian Ridge regression) as our top-performing routines is not too surprising. When extrapolating most bets are off (e.g. see the CV thread: What is wrong with extrapolation?) and commonly simple methods outperform complex ones (e.g. see the CV thread Best method for short time-series).
As a final note, it is always prudent to get estimates of the variability of our performance metric. If possible we should set aside a number of observations, fit our candidate models to the remaining data, and evaluate the models in the data we set aside. This should be repeated multiple times.
In effect, what is described is nested cross-validation for model selection; only particular will be that the for each loop the hold-out set is such that $x_e = 1$. (Once again) CV has a great thread on the matter: Nested cross validation for model selection and Model selection and cross-validation: The right way. In short, the outer loop will be used to assess the performance of the particular model (e.g. Ridge regression), and the inner loop will be used to select the best model (the regularisation parameter $\lambda$ for the case of Ridge). A simplified and very succinct Python example of nested CV would be as follows:
myS = cross_val_score(GridSearchCV(linear_model.ElasticNet(), param_grid, cv=5),
myX, myY, cv=5)
print("CV scores: ", myS)
print("Mean CV scores & Std. Dev.: {:.3f} {:.3f}".format(myS.mean(), myS.std()))
|
Which gamma regression model to use for extrapolation?
The OP has done a great job exploring a variety of different techniques. As commented, given that the response variable is Gamma-distributed it makes sense to consider a GLM and/or a GAM for Gamma dis
|
50,838 |
Which gamma regression model to use for extrapolation?
|
Linear models are great for extrapolation, since they don't make too complex assumptions which might not generalize outside of the training set. Unfortunately that also means that they are not able to use the full potential of other features which are not changed when extrapolating.
Since extrapolation is done only in respect of input $x_e$ we can split all inputs $X$ into vector $x_e$ and matrix $X_{other}$.
One approach could be to add more features based on the values of $X_{other}$. These could be interactions between these features, squared values, logarithms etc. This could work well especially if you have a good idea on how each feature should contribute to the output.
One could also build a custom model, which fits only a linear relationship in respect of $x_e$ but uses more complex relations for $X_{other}$. Here is an example model built with keras which fits a neural network with 4 hidden layers for $X_{other}$, then concatenates the last hidden layer with $x_e$ and uses one final layer with softplus activation (to ensure that the predictions are positive). With keras
from keras.layers import Input, Dense, Lambda, concatenate
from keras.models import Model
import keras.backend as K
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
def loss(y_true, y_pred):
return -K.log(1/y_pred) + y_true/y_pred
all_inputs = Input(shape=(n_inputs,))
# Only the first feature will be used for extrapolation
x_e = Lambda(lambda x: x[:,:1], output_shape=(1,))(all_inputs)
x_other = Lambda(lambda x: x[:,1:], output_shape=(n_inputs-1,))(all_inputs)
hidden_1 = Dense(20, activation='relu')(x_other)
hidden_2 = Dense(20, activation='relu')(hidden_1)
hidden_3 = Dense(10, activation='relu')(hidden_2)
hidden_4 = Dense(20, activation='relu')(hidden_3)
merged = concatenate([hidden_3, x_e])
preds = Dense(1,activation='softplus')(merged)
model = Model(inputs=all_inputs, outputs=preds)
model.compile(optimizer='adam', loss=loss, metrics=['mse'])
model = Pipeline([
('scale', StandardScaler()),
('keras', model),
])
With a model similar to this (I added some customization to my specific problem) I was able to get a test loss of 0.653. This model also seems to be best so far for interpolation within the training set.
|
Which gamma regression model to use for extrapolation?
|
Linear models are great for extrapolation, since they don't make too complex assumptions which might not generalize outside of the training set. Unfortunately that also means that they are not able to
|
Which gamma regression model to use for extrapolation?
Linear models are great for extrapolation, since they don't make too complex assumptions which might not generalize outside of the training set. Unfortunately that also means that they are not able to use the full potential of other features which are not changed when extrapolating.
Since extrapolation is done only in respect of input $x_e$ we can split all inputs $X$ into vector $x_e$ and matrix $X_{other}$.
One approach could be to add more features based on the values of $X_{other}$. These could be interactions between these features, squared values, logarithms etc. This could work well especially if you have a good idea on how each feature should contribute to the output.
One could also build a custom model, which fits only a linear relationship in respect of $x_e$ but uses more complex relations for $X_{other}$. Here is an example model built with keras which fits a neural network with 4 hidden layers for $X_{other}$, then concatenates the last hidden layer with $x_e$ and uses one final layer with softplus activation (to ensure that the predictions are positive). With keras
from keras.layers import Input, Dense, Lambda, concatenate
from keras.models import Model
import keras.backend as K
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
def loss(y_true, y_pred):
return -K.log(1/y_pred) + y_true/y_pred
all_inputs = Input(shape=(n_inputs,))
# Only the first feature will be used for extrapolation
x_e = Lambda(lambda x: x[:,:1], output_shape=(1,))(all_inputs)
x_other = Lambda(lambda x: x[:,1:], output_shape=(n_inputs-1,))(all_inputs)
hidden_1 = Dense(20, activation='relu')(x_other)
hidden_2 = Dense(20, activation='relu')(hidden_1)
hidden_3 = Dense(10, activation='relu')(hidden_2)
hidden_4 = Dense(20, activation='relu')(hidden_3)
merged = concatenate([hidden_3, x_e])
preds = Dense(1,activation='softplus')(merged)
model = Model(inputs=all_inputs, outputs=preds)
model.compile(optimizer='adam', loss=loss, metrics=['mse'])
model = Pipeline([
('scale', StandardScaler()),
('keras', model),
])
With a model similar to this (I added some customization to my specific problem) I was able to get a test loss of 0.653. This model also seems to be best so far for interpolation within the training set.
|
Which gamma regression model to use for extrapolation?
Linear models are great for extrapolation, since they don't make too complex assumptions which might not generalize outside of the training set. Unfortunately that also means that they are not able to
|
50,839 |
Some questions about quarterly and monthly timeseries
|
I work with time series rather than being an expert in it and I have never seen this raised. I don't think, however, that you can go from data aggregated at the quarterly level to the monthly level. Why is it important to your company to answer the question at the monthly level if there are no patterns at the monthly level and thus no predictability?
We predict at the monthly level as well, but due to unpredictable changes over time (my organization has no knowledge and limited interest in our spending process since we have little capacity to refuse services) our results are rarely accurate at less than the yearly level which is what I tell the people I report the data to.
In response to the IP response.
We get asked for monthly data even though it is doubtful we can predict such accurately given the level of variation in our poorly documented process. When you have to do something you do, the key is to point out that what is being asked is not reasonable given the nature of the process. That way decision makers know the limits on what is being provided.
Have you considered using exponential smoothing to do predictions (Holt simple, damp trend etc)? Its not a perfect solution (its what we use) but its easy to do, has a good reputation, and can be accurate as long as the basic patterns don't change too much I think.
|
Some questions about quarterly and monthly timeseries
|
I work with time series rather than being an expert in it and I have never seen this raised. I don't think, however, that you can go from data aggregated at the quarterly level to the monthly level. W
|
Some questions about quarterly and monthly timeseries
I work with time series rather than being an expert in it and I have never seen this raised. I don't think, however, that you can go from data aggregated at the quarterly level to the monthly level. Why is it important to your company to answer the question at the monthly level if there are no patterns at the monthly level and thus no predictability?
We predict at the monthly level as well, but due to unpredictable changes over time (my organization has no knowledge and limited interest in our spending process since we have little capacity to refuse services) our results are rarely accurate at less than the yearly level which is what I tell the people I report the data to.
In response to the IP response.
We get asked for monthly data even though it is doubtful we can predict such accurately given the level of variation in our poorly documented process. When you have to do something you do, the key is to point out that what is being asked is not reasonable given the nature of the process. That way decision makers know the limits on what is being provided.
Have you considered using exponential smoothing to do predictions (Holt simple, damp trend etc)? Its not a perfect solution (its what we use) but its easy to do, has a good reputation, and can be accurate as long as the basic patterns don't change too much I think.
|
Some questions about quarterly and monthly timeseries
I work with time series rather than being an expert in it and I have never seen this raised. I don't think, however, that you can go from data aggregated at the quarterly level to the monthly level. W
|
50,840 |
Interrupted Time Series Analysis with multiple Intervention timepoints
|
A starting point for the concept of ITSA is Shadish, Cooke, & Campbell (2002) and a starting palce for the mathematical procedures for ITSA is Glass, Wilson, & Gottman (1975).
Some researchers may recommend a dummy code moderator in a multiple regression, where 0 represents no intervention and 1 represents intervention:
$$\hat{y}=b_0+b_1(time)+b_2(intervention)$$
This is a simple solution and may work if you do not care about autocorrelation.
However, the interrupted time series (ITSA) allows you to include autoregressive and moving average components:
$$y_t=z_t=AR+I+MA+a_t$$
where $z_t$ is the observed value of teh DV at time point $t$, $AR$ is the order of autoregression of the series, $I$ is the order of differencing required to create a stationary series, $MA$ is the order of moving average of the series, and $a_t$ is the error.
Alternatively, and more precisely, an ARIMA (p, d, q) process may be modeled by:
$$y_t=Δz_t=ϕz_tΔz_{t−1}θzt$$
where $ϕ$ is the autocorrelation coefficient, $θ$ is the moving average coefficient, and $Δzt=zt−zt−d$ when $d>0$. When $d=0$, $Δzt=zt−1$ or simply $Δzt$ is ignored, depending on the order of p and q.
You can identify $ϕ$, $θ$, and $Δ$ using software, such as Rob Hyndman's auto.arima in R. The models are all different given the order of the coefficients and I do not know of any comprehensive source for all possible ITSA or a generalization thereof. Generally, though, there is a level at baseline, $L$, and a change from that level in the treatment phase, $\delta$, where the level of the treatment phase is $L+\delta$. This is similar to the dummy coding solution, but now you are incorporating the ARIMA model. You may need to derive the model yourself, as I did for an ARIMA(1,1,0) in a submitted manuscript where most of this information comes from (Raadt, in-press).
Glass, G. V., Willson, V. L., Gottman, J. M. (1975). Design and analysis of time-series experiments. Boulder, CO: Colorado Associated University Press.
Shadish, W. R., Cook, T. D., & Campbell, D. T. (2002). Experimental and quasi-experimental designs for generalized causal inference. Boston, MA, US: Houghton, Mifflin and Company.
|
Interrupted Time Series Analysis with multiple Intervention timepoints
|
A starting point for the concept of ITSA is Shadish, Cooke, & Campbell (2002) and a starting palce for the mathematical procedures for ITSA is Glass, Wilson, & Gottman (1975).
Some researchers may rec
|
Interrupted Time Series Analysis with multiple Intervention timepoints
A starting point for the concept of ITSA is Shadish, Cooke, & Campbell (2002) and a starting palce for the mathematical procedures for ITSA is Glass, Wilson, & Gottman (1975).
Some researchers may recommend a dummy code moderator in a multiple regression, where 0 represents no intervention and 1 represents intervention:
$$\hat{y}=b_0+b_1(time)+b_2(intervention)$$
This is a simple solution and may work if you do not care about autocorrelation.
However, the interrupted time series (ITSA) allows you to include autoregressive and moving average components:
$$y_t=z_t=AR+I+MA+a_t$$
where $z_t$ is the observed value of teh DV at time point $t$, $AR$ is the order of autoregression of the series, $I$ is the order of differencing required to create a stationary series, $MA$ is the order of moving average of the series, and $a_t$ is the error.
Alternatively, and more precisely, an ARIMA (p, d, q) process may be modeled by:
$$y_t=Δz_t=ϕz_tΔz_{t−1}θzt$$
where $ϕ$ is the autocorrelation coefficient, $θ$ is the moving average coefficient, and $Δzt=zt−zt−d$ when $d>0$. When $d=0$, $Δzt=zt−1$ or simply $Δzt$ is ignored, depending on the order of p and q.
You can identify $ϕ$, $θ$, and $Δ$ using software, such as Rob Hyndman's auto.arima in R. The models are all different given the order of the coefficients and I do not know of any comprehensive source for all possible ITSA or a generalization thereof. Generally, though, there is a level at baseline, $L$, and a change from that level in the treatment phase, $\delta$, where the level of the treatment phase is $L+\delta$. This is similar to the dummy coding solution, but now you are incorporating the ARIMA model. You may need to derive the model yourself, as I did for an ARIMA(1,1,0) in a submitted manuscript where most of this information comes from (Raadt, in-press).
Glass, G. V., Willson, V. L., Gottman, J. M. (1975). Design and analysis of time-series experiments. Boulder, CO: Colorado Associated University Press.
Shadish, W. R., Cook, T. D., & Campbell, D. T. (2002). Experimental and quasi-experimental designs for generalized causal inference. Boston, MA, US: Houghton, Mifflin and Company.
|
Interrupted Time Series Analysis with multiple Intervention timepoints
A starting point for the concept of ITSA is Shadish, Cooke, & Campbell (2002) and a starting palce for the mathematical procedures for ITSA is Glass, Wilson, & Gottman (1975).
Some researchers may rec
|
50,841 |
Interrupted Time Series Analysis with multiple Intervention timepoints
|
I'd never heard of interrupted time series analysis before this question, and I can't really speak to how it's different from regular time series analysis that involves sophisticated-enough techniques to handle "outliers" and seasonality.
So I'd suggest looking more widely at time series literature in regards to seasonality effects -- which are sometimes confounding effects that researchers want to factor out, or are sometimes the focus of research -- and also "outliers".
Your problem sounds a lot like marketing time series problems, where marketers want to know if ad campaigns are having an impact on consumer behavior. In that case, ad campaigns are often aperiodic -- i.e. when HQ thinks sales need a boost -- but may be periodic and repeating like "Our Big Summer Sale!". And, of course, there are always seasonal effects like Christmas, summer vacations, etc, that affects marketing/sales.
You may run into issues where finance/marketing-related techniques are focused on monthly or quarterly time series and don't work very well on other timescales. State Space models are sophisticated but sometimes hard to use. ARIMA-based models might be useful. In the "outlier" literature you may see labels like AO (Additive Outlier, a one-time kind of thing), TC (Temporary Change, which sounds like your interventions), or LC (Level Change, a permanent shock).
What is your goal, actually? Do you want to evaluate the impact of interventions? Do you want to look at the time series, "factoring out" interventions? Right now it feels like your question is a bit theoretical and perhaps caught in a particular genre of time series analysis that may be too restrictive for what you want to do.
|
Interrupted Time Series Analysis with multiple Intervention timepoints
|
I'd never heard of interrupted time series analysis before this question, and I can't really speak to how it's different from regular time series analysis that involves sophisticated-enough techniques
|
Interrupted Time Series Analysis with multiple Intervention timepoints
I'd never heard of interrupted time series analysis before this question, and I can't really speak to how it's different from regular time series analysis that involves sophisticated-enough techniques to handle "outliers" and seasonality.
So I'd suggest looking more widely at time series literature in regards to seasonality effects -- which are sometimes confounding effects that researchers want to factor out, or are sometimes the focus of research -- and also "outliers".
Your problem sounds a lot like marketing time series problems, where marketers want to know if ad campaigns are having an impact on consumer behavior. In that case, ad campaigns are often aperiodic -- i.e. when HQ thinks sales need a boost -- but may be periodic and repeating like "Our Big Summer Sale!". And, of course, there are always seasonal effects like Christmas, summer vacations, etc, that affects marketing/sales.
You may run into issues where finance/marketing-related techniques are focused on monthly or quarterly time series and don't work very well on other timescales. State Space models are sophisticated but sometimes hard to use. ARIMA-based models might be useful. In the "outlier" literature you may see labels like AO (Additive Outlier, a one-time kind of thing), TC (Temporary Change, which sounds like your interventions), or LC (Level Change, a permanent shock).
What is your goal, actually? Do you want to evaluate the impact of interventions? Do you want to look at the time series, "factoring out" interventions? Right now it feels like your question is a bit theoretical and perhaps caught in a particular genre of time series analysis that may be too restrictive for what you want to do.
|
Interrupted Time Series Analysis with multiple Intervention timepoints
I'd never heard of interrupted time series analysis before this question, and I can't really speak to how it's different from regular time series analysis that involves sophisticated-enough techniques
|
50,842 |
Logistic Regression and Omitted Variable Bias
|
In practice this issue with omitted-variable bias in logistic regression might not be that much different from what is faced in ordinary least squares (OLS). The added problem in logistic regression is that, unlike OLS, omitting predictors associated with outcome but uncorrelated with the included predictors leads to bias in the coefficient estimates for the included predictors.
A major point of this question is how this principle should inform the inclusion of interaction terms in a logistic model. Although it can be possible to transform 2 variables to have their interaction or product uncorrelated with either of them, that isn't always done in practice and doesn't seem to have been done for the set of all interactions up to 3rd order in the example in this question.* So if interaction terms are correlated with included predictors there can still be an omitted-variable bias when interaction terms are omitted from OLS. To that extent, the issues with interaction terms and omitted-variable bias aren't necessarily different between OLS and logistic regression.
Furthermore, the bias in logistic regression tends to be in a conservative direction: omitting predictors associated with outcome but uncorrelated with the included predictors leads to bias of coefficient estimates toward 0. Depending on the purpose of the modeling, that might be an acceptable tradeoff.
Multicollinearity doesn't necessarily lead to an unreliable model. Yes, there can be large standard errors of individual coefficient estimates. But as this answer puts it:
Finally, consider the actual impact of multicollinearity. It doesn't change the predictive power of the model (at least, on the training data) but it does screw with our coefficient estimates. In most ML applications, we don't care about coefficients themselves, just the loss of our model predictions...
Predictions take into account both the coefficient estimates (including the interaction coefficients) and the coefficient covariance matrix, providing a precision in predictions superior to what one might expect from just looking at the standard error of an individual coefficient.
I have no experience with the Bayesian approach mentioned in this question, and can't say why it didn't converge. But with respect to including interaction terms in logistic regression, the principles to apply in practice aren't necessarily much different from those for OLS. Domain knowledge should be a primary guide. Then apply the standard arts of statistical analysis, choosing a model complexity appropriate to the available data.
*It's not clear to me whether predictors can always be transformed to make all their 3-way interactions uncorrelated with the individual predictors.
|
Logistic Regression and Omitted Variable Bias
|
In practice this issue with omitted-variable bias in logistic regression might not be that much different from what is faced in ordinary least squares (OLS). The added problem in logistic regression i
|
Logistic Regression and Omitted Variable Bias
In practice this issue with omitted-variable bias in logistic regression might not be that much different from what is faced in ordinary least squares (OLS). The added problem in logistic regression is that, unlike OLS, omitting predictors associated with outcome but uncorrelated with the included predictors leads to bias in the coefficient estimates for the included predictors.
A major point of this question is how this principle should inform the inclusion of interaction terms in a logistic model. Although it can be possible to transform 2 variables to have their interaction or product uncorrelated with either of them, that isn't always done in practice and doesn't seem to have been done for the set of all interactions up to 3rd order in the example in this question.* So if interaction terms are correlated with included predictors there can still be an omitted-variable bias when interaction terms are omitted from OLS. To that extent, the issues with interaction terms and omitted-variable bias aren't necessarily different between OLS and logistic regression.
Furthermore, the bias in logistic regression tends to be in a conservative direction: omitting predictors associated with outcome but uncorrelated with the included predictors leads to bias of coefficient estimates toward 0. Depending on the purpose of the modeling, that might be an acceptable tradeoff.
Multicollinearity doesn't necessarily lead to an unreliable model. Yes, there can be large standard errors of individual coefficient estimates. But as this answer puts it:
Finally, consider the actual impact of multicollinearity. It doesn't change the predictive power of the model (at least, on the training data) but it does screw with our coefficient estimates. In most ML applications, we don't care about coefficients themselves, just the loss of our model predictions...
Predictions take into account both the coefficient estimates (including the interaction coefficients) and the coefficient covariance matrix, providing a precision in predictions superior to what one might expect from just looking at the standard error of an individual coefficient.
I have no experience with the Bayesian approach mentioned in this question, and can't say why it didn't converge. But with respect to including interaction terms in logistic regression, the principles to apply in practice aren't necessarily much different from those for OLS. Domain knowledge should be a primary guide. Then apply the standard arts of statistical analysis, choosing a model complexity appropriate to the available data.
*It's not clear to me whether predictors can always be transformed to make all their 3-way interactions uncorrelated with the individual predictors.
|
Logistic Regression and Omitted Variable Bias
In practice this issue with omitted-variable bias in logistic regression might not be that much different from what is faced in ordinary least squares (OLS). The added problem in logistic regression i
|
50,843 |
Evaluating if time series need differencing
|
I'm a little confused about what your data is but, based on the above information, it does appear to be stationary. This is because there is relatively little persistence in the ACF, meaning that the autocorrelations do not consistently remain close to 1 (see here for a textbook example of a non-stationary ACF).
However there is really no substitute for performing a proper statistical test. ADF is a good start here. Broadly speaking, the theory behind it is that you re-write a time-series model in such a way that the first term on the right-hand-side contains all the (autoregressive) parameters of your time series model. As you probably know, non-stationarity occurs when the sum of the parameters in a model is 1, so you then perform a regression on this rewritten model to test whether that first parameter is equal to 1. Below I provide an example using an AR(2) model.
Let's assume the model you are trying to specify for your data is AR(2):
$$y_t = \psi_1y_{t-1} + \psi_2y_{t-2} + \epsilon_t $$
Now add and subtract $\psi_2y_{t-1}$ to the right-hand side to get:
$$y_t = (\psi_1 + \psi_2)y_{t-1} + \psi_2y_{t-2} - \psi_2y_{t-1} + \epsilon_t $$
Now note that the 2nd and third terms can be rewritten as a differenced term and that we can rewrite $\psi_1 + \psi_2$ as $\beta$. Then what we get is:
$$y_t = \beta y_{t-1} - \psi_2\Delta y_{t-1} + \epsilon_t $$
As explained above you then run an OLS regression that tests whether $\beta = 0$ or not.
A more generalised form of the ADF test can be found here, though hopefully the above has provided some intuition.
In terms of your results, I would recommend running the ADF test with multiple lags to see if there is a consistent pattern in your results. If you want to choose the k for the optimal number of lags, the typical approach is to calculate the AIC or BIC for different numbers of lags and choose the k that results in a model with the lowest AIC or BIC.
|
Evaluating if time series need differencing
|
I'm a little confused about what your data is but, based on the above information, it does appear to be stationary. This is because there is relatively little persistence in the ACF, meaning that the
|
Evaluating if time series need differencing
I'm a little confused about what your data is but, based on the above information, it does appear to be stationary. This is because there is relatively little persistence in the ACF, meaning that the autocorrelations do not consistently remain close to 1 (see here for a textbook example of a non-stationary ACF).
However there is really no substitute for performing a proper statistical test. ADF is a good start here. Broadly speaking, the theory behind it is that you re-write a time-series model in such a way that the first term on the right-hand-side contains all the (autoregressive) parameters of your time series model. As you probably know, non-stationarity occurs when the sum of the parameters in a model is 1, so you then perform a regression on this rewritten model to test whether that first parameter is equal to 1. Below I provide an example using an AR(2) model.
Let's assume the model you are trying to specify for your data is AR(2):
$$y_t = \psi_1y_{t-1} + \psi_2y_{t-2} + \epsilon_t $$
Now add and subtract $\psi_2y_{t-1}$ to the right-hand side to get:
$$y_t = (\psi_1 + \psi_2)y_{t-1} + \psi_2y_{t-2} - \psi_2y_{t-1} + \epsilon_t $$
Now note that the 2nd and third terms can be rewritten as a differenced term and that we can rewrite $\psi_1 + \psi_2$ as $\beta$. Then what we get is:
$$y_t = \beta y_{t-1} - \psi_2\Delta y_{t-1} + \epsilon_t $$
As explained above you then run an OLS regression that tests whether $\beta = 0$ or not.
A more generalised form of the ADF test can be found here, though hopefully the above has provided some intuition.
In terms of your results, I would recommend running the ADF test with multiple lags to see if there is a consistent pattern in your results. If you want to choose the k for the optimal number of lags, the typical approach is to calculate the AIC or BIC for different numbers of lags and choose the k that results in a model with the lowest AIC or BIC.
|
Evaluating if time series need differencing
I'm a little confused about what your data is but, based on the above information, it does appear to be stationary. This is because there is relatively little persistence in the ACF, meaning that the
|
50,844 |
Evaluating if time series need differencing
|
Unnecessary differencing or filtering can inject structure (see Slutsky Effect) . Sometimes a series can have a shift in the mean causing "non-statioanarity" ..the correct remedy is to neither difference or de-trend but to "de-mean" or use a Level Shift variable/filter to render the residual series stationary.
Sometimes there is more than 1 trend requiring a number of trend variables/filters .... none of which have to start at the beginning if the series. Analysis will tell you which of these three approaches
differencing
de-meaning
de-trending
are suitable for your data.
|
Evaluating if time series need differencing
|
Unnecessary differencing or filtering can inject structure (see Slutsky Effect) . Sometimes a series can have a shift in the mean causing "non-statioanarity" ..the correct remedy is to neither differe
|
Evaluating if time series need differencing
Unnecessary differencing or filtering can inject structure (see Slutsky Effect) . Sometimes a series can have a shift in the mean causing "non-statioanarity" ..the correct remedy is to neither difference or de-trend but to "de-mean" or use a Level Shift variable/filter to render the residual series stationary.
Sometimes there is more than 1 trend requiring a number of trend variables/filters .... none of which have to start at the beginning if the series. Analysis will tell you which of these three approaches
differencing
de-meaning
de-trending
are suitable for your data.
|
Evaluating if time series need differencing
Unnecessary differencing or filtering can inject structure (see Slutsky Effect) . Sometimes a series can have a shift in the mean causing "non-statioanarity" ..the correct remedy is to neither differe
|
50,845 |
What are some techniques to augment tabular data?
|
SMOTE has many variants. SMOTE should be treated as a conservative density estimation of the data, which makes the conservative assumption that the line segments between close neighbors of some class belong to the same class. Sampling from this rough, conservative density estimation absolutely makes sense, but does not work necessarily, depending on the distribution of the data.
There are more advanced variants of SMOTE carrying out more proper density estimation. Let me recommend my own package smote-variants implementing 85 variants of SMOTE for binary oversampling (out of which 61 can be used for multiclass oversampling, too), and further model selection functionalities: https://github.com/gykovacs/smote_variants
You can also access a recent comparative study from the GitHub page, which clearly shows the benefits of oversampling in classification scenarios (Table 3): https://www.researchgate.net/publication/334732374_An_empirical_comparison_and_evaluation_of_minority_oversampling_techniques_on_a_large_number_of_imbalanced_datasets
|
What are some techniques to augment tabular data?
|
SMOTE has many variants. SMOTE should be treated as a conservative density estimation of the data, which makes the conservative assumption that the line segments between close neighbors of some class
|
What are some techniques to augment tabular data?
SMOTE has many variants. SMOTE should be treated as a conservative density estimation of the data, which makes the conservative assumption that the line segments between close neighbors of some class belong to the same class. Sampling from this rough, conservative density estimation absolutely makes sense, but does not work necessarily, depending on the distribution of the data.
There are more advanced variants of SMOTE carrying out more proper density estimation. Let me recommend my own package smote-variants implementing 85 variants of SMOTE for binary oversampling (out of which 61 can be used for multiclass oversampling, too), and further model selection functionalities: https://github.com/gykovacs/smote_variants
You can also access a recent comparative study from the GitHub page, which clearly shows the benefits of oversampling in classification scenarios (Table 3): https://www.researchgate.net/publication/334732374_An_empirical_comparison_and_evaluation_of_minority_oversampling_techniques_on_a_large_number_of_imbalanced_datasets
|
What are some techniques to augment tabular data?
SMOTE has many variants. SMOTE should be treated as a conservative density estimation of the data, which makes the conservative assumption that the line segments between close neighbors of some class
|
50,846 |
Why there's never a good reason to use the Jarque-Bera test
|
I'm no expert on this subject, but there seems to be quite some blog posts and even publications on this subject.
I would suggest reading those, but in general it seems that the test might be biased and have low power when using small samples, and when the original distribution is short-tailed.
|
Why there's never a good reason to use the Jarque-Bera test
|
I'm no expert on this subject, but there seems to be quite some blog posts and even publications on this subject.
I would suggest reading those, but in general it seems that the test might be biased
|
Why there's never a good reason to use the Jarque-Bera test
I'm no expert on this subject, but there seems to be quite some blog posts and even publications on this subject.
I would suggest reading those, but in general it seems that the test might be biased and have low power when using small samples, and when the original distribution is short-tailed.
|
Why there's never a good reason to use the Jarque-Bera test
I'm no expert on this subject, but there seems to be quite some blog posts and even publications on this subject.
I would suggest reading those, but in general it seems that the test might be biased
|
50,847 |
Why there's never a good reason to use the Jarque-Bera test
|
I would argue the opposite... and that as far as tests for Normal distributions are concerned, Jarque-Bera is the most transparent and explicit since it captures a combination of Skewness and Kurtosis which are the two dimensions that capture divergence from a Normal distribution. And, to my knowledge it does that better than any other tests for Normal distribution.
One may argue that Jarque-Bera is too sensitive to sample size. The larger the sample the more a trivial divergence from the Normal Distribution will become statistically significant. However, this is true of all such Normal Distribution tests. Actually, this is true of the entire body of hypothesis testing that relies on p-value instead of Effect Size.
|
Why there's never a good reason to use the Jarque-Bera test
|
I would argue the opposite... and that as far as tests for Normal distributions are concerned, Jarque-Bera is the most transparent and explicit since it captures a combination of Skewness and Kurtosis
|
Why there's never a good reason to use the Jarque-Bera test
I would argue the opposite... and that as far as tests for Normal distributions are concerned, Jarque-Bera is the most transparent and explicit since it captures a combination of Skewness and Kurtosis which are the two dimensions that capture divergence from a Normal distribution. And, to my knowledge it does that better than any other tests for Normal distribution.
One may argue that Jarque-Bera is too sensitive to sample size. The larger the sample the more a trivial divergence from the Normal Distribution will become statistically significant. However, this is true of all such Normal Distribution tests. Actually, this is true of the entire body of hypothesis testing that relies on p-value instead of Effect Size.
|
Why there's never a good reason to use the Jarque-Bera test
I would argue the opposite... and that as far as tests for Normal distributions are concerned, Jarque-Bera is the most transparent and explicit since it captures a combination of Skewness and Kurtosis
|
50,848 |
Is the use of loglik or AIC to compare logit/probit/cloglog models valid?
|
I would say yes, I can't see any reason why they wouldn't. We're talking about evaluating the log-likelihood for the same conditional probability distribution, with the same probability density (i.e. we don't have to account for changes in the scale due to transformation). So we're comparing the likelihoods for
$$
y_i \sim \textrm{Distrib}(g_1^{-1}((\mathbf X \boldsymbol \beta)_i), \phi)
$$
with
$$
y_i \sim \textrm{Distrib}(g_2^{-1}((\mathbf X \boldsymbol \beta)_i), \phi)
$$
where $\textrm{Distrib}$ is the response distribution, $g_1$ and $g_2$ are the alternative link functions (the rest is as usual for GLMs: $\mathbf X$=model matrix, $\boldsymbol \beta$=coefficient vector, $\phi$=scale parameter). This is just comparing two different nonlinear specifications for the location of the distribution. As long as you're OK with using AIC to compare non-nested functions (which almost everyone is), this should be fine.
|
Is the use of loglik or AIC to compare logit/probit/cloglog models valid?
|
I would say yes, I can't see any reason why they wouldn't. We're talking about evaluating the log-likelihood for the same conditional probability distribution, with the same probability density (i.e.
|
Is the use of loglik or AIC to compare logit/probit/cloglog models valid?
I would say yes, I can't see any reason why they wouldn't. We're talking about evaluating the log-likelihood for the same conditional probability distribution, with the same probability density (i.e. we don't have to account for changes in the scale due to transformation). So we're comparing the likelihoods for
$$
y_i \sim \textrm{Distrib}(g_1^{-1}((\mathbf X \boldsymbol \beta)_i), \phi)
$$
with
$$
y_i \sim \textrm{Distrib}(g_2^{-1}((\mathbf X \boldsymbol \beta)_i), \phi)
$$
where $\textrm{Distrib}$ is the response distribution, $g_1$ and $g_2$ are the alternative link functions (the rest is as usual for GLMs: $\mathbf X$=model matrix, $\boldsymbol \beta$=coefficient vector, $\phi$=scale parameter). This is just comparing two different nonlinear specifications for the location of the distribution. As long as you're OK with using AIC to compare non-nested functions (which almost everyone is), this should be fine.
|
Is the use of loglik or AIC to compare logit/probit/cloglog models valid?
I would say yes, I can't see any reason why they wouldn't. We're talking about evaluating the log-likelihood for the same conditional probability distribution, with the same probability density (i.e.
|
50,849 |
Is the likelihood in Bayes theorem a probability? [duplicate]
|
The likelihood is a so-called conditional density. It is a probability density function on the data space (for $D$) given any parameter $\theta$ that we pass over to the function. When integrating over it with respect to $D$ we obtain the conditional distribution of the data given a certain parameter. This conditional distribution is a Markov Kernel.
Maybe this helps: The fundamental Problem that is to be solved in any kind of parametric statistics is: There is some underlying parameter $\theta^*$. We do not know this parameter. We obtain a sample $D \sim p(\cdot|\theta^*)$. Given this sample $D$, we now want to identify $\theta^*$. Frequentist statistics uses estimators, and hypothesis tests. Bayesian statistics uses posterior measures. Hence the likelihood is the density from which the data is sampled.
One more confusion to mention: Note that a density function in a particular point does in general not refer to a „probability“ - a probability being a value between 0 and 1. The probability is what we obtain, when integrating over a density function with respect to the correct measure.
|
Is the likelihood in Bayes theorem a probability? [duplicate]
|
The likelihood is a so-called conditional density. It is a probability density function on the data space (for $D$) given any parameter $\theta$ that we pass over to the function. When integrating ove
|
Is the likelihood in Bayes theorem a probability? [duplicate]
The likelihood is a so-called conditional density. It is a probability density function on the data space (for $D$) given any parameter $\theta$ that we pass over to the function. When integrating over it with respect to $D$ we obtain the conditional distribution of the data given a certain parameter. This conditional distribution is a Markov Kernel.
Maybe this helps: The fundamental Problem that is to be solved in any kind of parametric statistics is: There is some underlying parameter $\theta^*$. We do not know this parameter. We obtain a sample $D \sim p(\cdot|\theta^*)$. Given this sample $D$, we now want to identify $\theta^*$. Frequentist statistics uses estimators, and hypothesis tests. Bayesian statistics uses posterior measures. Hence the likelihood is the density from which the data is sampled.
One more confusion to mention: Note that a density function in a particular point does in general not refer to a „probability“ - a probability being a value between 0 and 1. The probability is what we obtain, when integrating over a density function with respect to the correct measure.
|
Is the likelihood in Bayes theorem a probability? [duplicate]
The likelihood is a so-called conditional density. It is a probability density function on the data space (for $D$) given any parameter $\theta$ that we pass over to the function. When integrating ove
|
50,850 |
Peanut butter jars full of river mud and bacteria?
|
You don't want a test, because you have no definite hypothesis to assess: you are exploring. This calls for graphical display of relationships among bacterial counts and the potential explanatory variables. It's likely you will need to re-express the grain size fractions, because basic science suggests many possible meaningful properties including surface area and mass. This will require some creativity and as much information as possible. Let's hope you have a lot of jars!
|
Peanut butter jars full of river mud and bacteria?
|
You don't want a test, because you have no definite hypothesis to assess: you are exploring. This calls for graphical display of relationships among bacterial counts and the potential explanatory vari
|
Peanut butter jars full of river mud and bacteria?
You don't want a test, because you have no definite hypothesis to assess: you are exploring. This calls for graphical display of relationships among bacterial counts and the potential explanatory variables. It's likely you will need to re-express the grain size fractions, because basic science suggests many possible meaningful properties including surface area and mass. This will require some creativity and as much information as possible. Let's hope you have a lot of jars!
|
Peanut butter jars full of river mud and bacteria?
You don't want a test, because you have no definite hypothesis to assess: you are exploring. This calls for graphical display of relationships among bacterial counts and the potential explanatory vari
|
50,851 |
Calculate binomial deviance (binomial log-likelihood) in the test dataset
|
I recommend against fudging these prediction values. The appropriate outcome here is that if the model predicts a thing with probability 1, and that thing doesn't happen, then its deviance is infinite. Similarly, if the model predicts a thing with probability 0, and that thing happens, then its deviance is infinite. That is the price you pay for making such strong predictions on an outcome and getting them wrong.
To achieve this as the outcome, you just have to deal with the ambiguity in terms of the form $0 \times -\infty$. Here you would adopt the convention that $\ln 0 = \infty$ and $0 \times -\infty = 0$, giving you:
$$\begin{align}
Y_i \ln \hat{p}_i
&= \begin{cases}
0 & & & & & \ \text{if } Y_i = 0, \\[6pt]
\ln \hat{p}_i & & & & & \ \text{if } Y_i = 1. \\[6pt]
\end{cases} \\[18pt]
(1-Y_i) \ln (1-\hat{p}_i)
&= \begin{cases}
\ln (1-\hat{p}_i) & & & \text{if } Y_i = 0, \\[6pt]
0 & & & \text{if } Y_i = 1. \\[6pt]
\end{cases}
\end{align}$$
|
Calculate binomial deviance (binomial log-likelihood) in the test dataset
|
I recommend against fudging these prediction values. The appropriate outcome here is that if the model predicts a thing with probability 1, and that thing doesn't happen, then its deviance is infinit
|
Calculate binomial deviance (binomial log-likelihood) in the test dataset
I recommend against fudging these prediction values. The appropriate outcome here is that if the model predicts a thing with probability 1, and that thing doesn't happen, then its deviance is infinite. Similarly, if the model predicts a thing with probability 0, and that thing happens, then its deviance is infinite. That is the price you pay for making such strong predictions on an outcome and getting them wrong.
To achieve this as the outcome, you just have to deal with the ambiguity in terms of the form $0 \times -\infty$. Here you would adopt the convention that $\ln 0 = \infty$ and $0 \times -\infty = 0$, giving you:
$$\begin{align}
Y_i \ln \hat{p}_i
&= \begin{cases}
0 & & & & & \ \text{if } Y_i = 0, \\[6pt]
\ln \hat{p}_i & & & & & \ \text{if } Y_i = 1. \\[6pt]
\end{cases} \\[18pt]
(1-Y_i) \ln (1-\hat{p}_i)
&= \begin{cases}
\ln (1-\hat{p}_i) & & & \text{if } Y_i = 0, \\[6pt]
0 & & & \text{if } Y_i = 1. \\[6pt]
\end{cases}
\end{align}$$
|
Calculate binomial deviance (binomial log-likelihood) in the test dataset
I recommend against fudging these prediction values. The appropriate outcome here is that if the model predicts a thing with probability 1, and that thing doesn't happen, then its deviance is infinit
|
50,852 |
Calculate binomial deviance (binomial log-likelihood) in the test dataset
|
You can clip the probabilities to guarantee that will they will never be 0 or 1. For example as per sklearn docs, set up a small value named eps and use max(eps, min(1 - eps, p) where p is the classifier's probability.
sklearn docs for logloss
|
Calculate binomial deviance (binomial log-likelihood) in the test dataset
|
You can clip the probabilities to guarantee that will they will never be 0 or 1. For example as per sklearn docs, set up a small value named eps and use max(eps, min(1 - eps, p) where p is the classif
|
Calculate binomial deviance (binomial log-likelihood) in the test dataset
You can clip the probabilities to guarantee that will they will never be 0 or 1. For example as per sklearn docs, set up a small value named eps and use max(eps, min(1 - eps, p) where p is the classifier's probability.
sklearn docs for logloss
|
Calculate binomial deviance (binomial log-likelihood) in the test dataset
You can clip the probabilities to guarantee that will they will never be 0 or 1. For example as per sklearn docs, set up a small value named eps and use max(eps, min(1 - eps, p) where p is the classif
|
50,853 |
Partial Effects Plots vs. Partial Dependence Plots for Random Forests
|
For linear models without categorical variables, if you are using the mean when computing the PE plot, then the PE plot is the same as the PDP. Intuitively, the PE plot is to take the average for other variables first and then plot a curve, where the slope is the beta. The PDP is to compute the values for every instance and then take an average, where the slope is also the beta (see https://cran.r-project.org/web/packages/datarobot/vignettes/PartialDependence.html).
However, for linear models with categorical variables, using the mode for categorical variables cannot generate a curve with a slope equal to beta (since using mode to approximate the "mean" of categorical variables is not accurate enough). But PDP still can. I think here is where the difference lies. Obviously, PDP seems better in this sense.
|
Partial Effects Plots vs. Partial Dependence Plots for Random Forests
|
For linear models without categorical variables, if you are using the mean when computing the PE plot, then the PE plot is the same as the PDP. Intuitively, the PE plot is to take the average for othe
|
Partial Effects Plots vs. Partial Dependence Plots for Random Forests
For linear models without categorical variables, if you are using the mean when computing the PE plot, then the PE plot is the same as the PDP. Intuitively, the PE plot is to take the average for other variables first and then plot a curve, where the slope is the beta. The PDP is to compute the values for every instance and then take an average, where the slope is also the beta (see https://cran.r-project.org/web/packages/datarobot/vignettes/PartialDependence.html).
However, for linear models with categorical variables, using the mode for categorical variables cannot generate a curve with a slope equal to beta (since using mode to approximate the "mean" of categorical variables is not accurate enough). But PDP still can. I think here is where the difference lies. Obviously, PDP seems better in this sense.
|
Partial Effects Plots vs. Partial Dependence Plots for Random Forests
For linear models without categorical variables, if you are using the mean when computing the PE plot, then the PE plot is the same as the PDP. Intuitively, the PE plot is to take the average for othe
|
50,854 |
Which method to use when calculating the confidence interval of GLMM Gamma Regression with the lme4 package in R
|
I found this blog to be helpful RE finding CI's for estimates of a GLM(M):
https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
|
Which method to use when calculating the confidence interval of GLMM Gamma Regression with the lme4
|
I found this blog to be helpful RE finding CI's for estimates of a GLM(M):
https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
|
Which method to use when calculating the confidence interval of GLMM Gamma Regression with the lme4 package in R
I found this blog to be helpful RE finding CI's for estimates of a GLM(M):
https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
|
Which method to use when calculating the confidence interval of GLMM Gamma Regression with the lme4
I found this blog to be helpful RE finding CI's for estimates of a GLM(M):
https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
|
50,855 |
Notation question based on 1950s typesetting
|
From @whuber's answer in the comments:
I looked at the paper on JSTOR. The typesetting looks clear to me:
what you haven't reproduced here is the spacing used there to clarify
the meaning. For instance, look closely at this:
$$D = 1 + 2e^{\gamma/\delta}\ \cos \sqrt{}2\ \pi/\delta h +
e^{2\gamma/\delta}.$$
|
Notation question based on 1950s typesetting
|
From @whuber's answer in the comments:
I looked at the paper on JSTOR. The typesetting looks clear to me:
what you haven't reproduced here is the spacing used there to clarify
the meaning. For in
|
Notation question based on 1950s typesetting
From @whuber's answer in the comments:
I looked at the paper on JSTOR. The typesetting looks clear to me:
what you haven't reproduced here is the spacing used there to clarify
the meaning. For instance, look closely at this:
$$D = 1 + 2e^{\gamma/\delta}\ \cos \sqrt{}2\ \pi/\delta h +
e^{2\gamma/\delta}.$$
|
Notation question based on 1950s typesetting
From @whuber's answer in the comments:
I looked at the paper on JSTOR. The typesetting looks clear to me:
what you haven't reproduced here is the spacing used there to clarify
the meaning. For in
|
50,856 |
What's the definition of "Dynamic Regression Models"?
|
No problem but I'd definitely try to get my hands on some kind of textbook or lecture notes. The following is not a formal definition but here goes my attempt: To me, a DRM is any model which is time dependent, in the sense that, the next value of an observation (on the right hand side of the model ), at the next point in time, changes the model forecast. So, suppose you are sitting at time $t$, and you have a model say
$y_{t+1} = \alpha y_{t} + \beta_{1} x_{t} + \beta_2 x_{t-1} + \epsilon_{t+1}$.
Now, depending on the convention, this model would probably be referred to as an ARDL(1,1) which is a specific case of a class of dynamic regression models called auto-regressive distributed lag models. Note that, when sitting at time $t$, this model ( after some algebraic manipulation and assumptions about $x_{t}$ and $\epsilon_{t+1}$ ) can provide a forecast for say $y_{t+h}$ where $h$ is the forecast horizon. My point here is that that $h$ does not necessarily need to be assumed to be one. Next , suppose one unit of time passes so that a new observation, $x_{t+1}$ arrives at time $t+1$. This means that the new model forecast of $y_{t+h+1}$ will get updated to reflect this new observation. Note also (and this can be crucial) , the error terms can play a big role also ( be say MA(1) or AR(1) rather than just IID-normal ) so, even if the new observation of $x$ at time $t+1$ was the same as the observations at time $t$ and time $t-1$, and there was no lagged dependent variable, $y_{t-1}$ like there is above, the forecast at time $t+h+1$ could still change !!!!!! This is a powerful concept and would not be the case in a more "static" type of regression model. Essentially, this is what is meant by the term dynamic, namely that, because of the lagged dependent variable on the RHS and or the error terms, the new $x_t$ observations that arrive in the future could stay constant for many periods and the model forecasts could still change.
I hope this helped a little. It isn't really an answer but I put it in the answer section because there's more space. I happen to have a lot of experience with dynamic regression models so I've collected many lecture notes and texts over the years. When I get a chance this weekend, I'll try to send some useful links but the dynamic concept is pretty much as simple as what I explained. There's nothing terribly complex regarding the term "dynamic" but it can sound intimidating. Estimation of parameters can be a problem sometimes because of multiple parameters, multi-collinearity etc. Stability of parameters over time is another possibly problematic issue. Remind me if I forget to post links.
Here are some links.
https://www.reed.edu/economics/parker/312/tschapters/S13_Ch_3.pdf
http://www-personal.umich.edu/~franzese/DeBoefKeele.2008.TakingTimeSeriously.pdf
https://www.nuff.ox.ac.uk/politics/papers/2005/Keele%20DeBoef%20ECM%20041213.pdf
https://pdfs.semanticscholar.org/presentation/fd49/2458fbe607f3bf19ff28aa872b4980ebd629.pdf
https://jdemeritt.weebly.com/uploads/2/2/7/7/22771764/timeseries.pdf
http://web.thu.edu.tw/wichuang/www/Financial%20Econometrics/Lectures/CHAPTER%2015.pdf
The literature is beyond huge so above is only touching it. The reason it is so vast because these models arise in statistical time series, econometric time series and DSP but all using different notation and sometimes different terminology.
Most of the links above, if not all, have an econometric-statistical time series connection. Also, keep in mind that, although some of the above links will touch on the koyck distributed lag (1954), that model has a whole literature unto itself. Definitely, DRM's are a deceptive area because there's a TON to know about a relatively straightforward time-series topic.I I think that my original statement above about them being straightforward could be misleading because their flexibility makes them quite powerful and provides a lot to discuss and learn about them. All the best.
Oh, one last thing: you may want to check out economics.stackexchange.com also. It's obviously more economics but econometric time series is discussed once in a while and there are some really good people over there just like there are here.
|
What's the definition of "Dynamic Regression Models"?
|
No problem but I'd definitely try to get my hands on some kind of textbook or lecture notes. The following is not a formal definition but here goes my attempt: To me, a DRM is any model which is tim
|
What's the definition of "Dynamic Regression Models"?
No problem but I'd definitely try to get my hands on some kind of textbook or lecture notes. The following is not a formal definition but here goes my attempt: To me, a DRM is any model which is time dependent, in the sense that, the next value of an observation (on the right hand side of the model ), at the next point in time, changes the model forecast. So, suppose you are sitting at time $t$, and you have a model say
$y_{t+1} = \alpha y_{t} + \beta_{1} x_{t} + \beta_2 x_{t-1} + \epsilon_{t+1}$.
Now, depending on the convention, this model would probably be referred to as an ARDL(1,1) which is a specific case of a class of dynamic regression models called auto-regressive distributed lag models. Note that, when sitting at time $t$, this model ( after some algebraic manipulation and assumptions about $x_{t}$ and $\epsilon_{t+1}$ ) can provide a forecast for say $y_{t+h}$ where $h$ is the forecast horizon. My point here is that that $h$ does not necessarily need to be assumed to be one. Next , suppose one unit of time passes so that a new observation, $x_{t+1}$ arrives at time $t+1$. This means that the new model forecast of $y_{t+h+1}$ will get updated to reflect this new observation. Note also (and this can be crucial) , the error terms can play a big role also ( be say MA(1) or AR(1) rather than just IID-normal ) so, even if the new observation of $x$ at time $t+1$ was the same as the observations at time $t$ and time $t-1$, and there was no lagged dependent variable, $y_{t-1}$ like there is above, the forecast at time $t+h+1$ could still change !!!!!! This is a powerful concept and would not be the case in a more "static" type of regression model. Essentially, this is what is meant by the term dynamic, namely that, because of the lagged dependent variable on the RHS and or the error terms, the new $x_t$ observations that arrive in the future could stay constant for many periods and the model forecasts could still change.
I hope this helped a little. It isn't really an answer but I put it in the answer section because there's more space. I happen to have a lot of experience with dynamic regression models so I've collected many lecture notes and texts over the years. When I get a chance this weekend, I'll try to send some useful links but the dynamic concept is pretty much as simple as what I explained. There's nothing terribly complex regarding the term "dynamic" but it can sound intimidating. Estimation of parameters can be a problem sometimes because of multiple parameters, multi-collinearity etc. Stability of parameters over time is another possibly problematic issue. Remind me if I forget to post links.
Here are some links.
https://www.reed.edu/economics/parker/312/tschapters/S13_Ch_3.pdf
http://www-personal.umich.edu/~franzese/DeBoefKeele.2008.TakingTimeSeriously.pdf
https://www.nuff.ox.ac.uk/politics/papers/2005/Keele%20DeBoef%20ECM%20041213.pdf
https://pdfs.semanticscholar.org/presentation/fd49/2458fbe607f3bf19ff28aa872b4980ebd629.pdf
https://jdemeritt.weebly.com/uploads/2/2/7/7/22771764/timeseries.pdf
http://web.thu.edu.tw/wichuang/www/Financial%20Econometrics/Lectures/CHAPTER%2015.pdf
The literature is beyond huge so above is only touching it. The reason it is so vast because these models arise in statistical time series, econometric time series and DSP but all using different notation and sometimes different terminology.
Most of the links above, if not all, have an econometric-statistical time series connection. Also, keep in mind that, although some of the above links will touch on the koyck distributed lag (1954), that model has a whole literature unto itself. Definitely, DRM's are a deceptive area because there's a TON to know about a relatively straightforward time-series topic.I I think that my original statement above about them being straightforward could be misleading because their flexibility makes them quite powerful and provides a lot to discuss and learn about them. All the best.
Oh, one last thing: you may want to check out economics.stackexchange.com also. It's obviously more economics but econometric time series is discussed once in a while and there are some really good people over there just like there are here.
|
What's the definition of "Dynamic Regression Models"?
No problem but I'd definitely try to get my hands on some kind of textbook or lecture notes. The following is not a formal definition but here goes my attempt: To me, a DRM is any model which is tim
|
50,857 |
Which approach based on the LASSO yields more biologically relevant results for gene data-sets?
|
Since you're only interested in the influence of the genes, you should "force keep" the non-gene variables in the model (for example in R with glmnet package and option penalty.factor equal to zero for the corresponding variables). Or you could first do a model with the confounding variables only and identify the ones that have a significant influence on the outcome and then force-keep these along with the genes in the second full model. Another approach would be to stratify your data such that you're doing different lasso models for subgroups (given that you have enough observations), e.g. which genes are chosen for females/age 18-49 compared to males/age 18-49 etc.
Confidence intervals aren't needed, as pointed out by rep_ho in the comment to the question.
You CAN use group lasso or sparse-group lasso if you have pathway/subnetwork information on the genes available. Be aware that vanilla lasso has an undesirable property: if some features are correlated, it tends to choose one of them and disregards the other ones in the remainder. This translates to group lasso but on the group level (out of some correlated groups it chooses only one group) and to sparse-group lasso as well (but here for correlations on between- and within-group levels). It depends on the original scientific question (respectively, what your outcome is) if you're more interested in specific genes or specific pathways. Additionally, stability selection is already a good idea to deal with correlated variables. Furthermore, you might want to take a look into elastic net regression, which is basically a mixture of lasso and ridge regression and has been shown to handle correlated variables better than lasso.
I'm not sure what you're referring to. I hope you're doing cross-validation, then you're actually assessing the residuals to find the best $\lambda$ value and as such the corresponding regression coefficients that best describe your outcome and avoid overfitting. You shouldn't do an additonal model with the chosen features, instead analyse the model chosen by cross-validation.
Lasso is fine. Elastic net might be worth a look. Some Support Vector Machine models (e.g. SVEN) are shown to be similar to lasso methods, and there's Bayesian alternatives to the different lasso methods as well which might be more precise than lasso ("spike-and-slab", for an overview and slow implementations based on Gibbs sampling see here, and more efficient implementations: simple spike-and-slab, grouped spike-and-slab, and sparse-group spike-and-slab). (Disclaimer: the last reference is a paper by me.)
|
Which approach based on the LASSO yields more biologically relevant results for gene data-sets?
|
Since you're only interested in the influence of the genes, you should "force keep" the non-gene variables in the model (for example in R with glmnet package and option penalty.factor equal to zero fo
|
Which approach based on the LASSO yields more biologically relevant results for gene data-sets?
Since you're only interested in the influence of the genes, you should "force keep" the non-gene variables in the model (for example in R with glmnet package and option penalty.factor equal to zero for the corresponding variables). Or you could first do a model with the confounding variables only and identify the ones that have a significant influence on the outcome and then force-keep these along with the genes in the second full model. Another approach would be to stratify your data such that you're doing different lasso models for subgroups (given that you have enough observations), e.g. which genes are chosen for females/age 18-49 compared to males/age 18-49 etc.
Confidence intervals aren't needed, as pointed out by rep_ho in the comment to the question.
You CAN use group lasso or sparse-group lasso if you have pathway/subnetwork information on the genes available. Be aware that vanilla lasso has an undesirable property: if some features are correlated, it tends to choose one of them and disregards the other ones in the remainder. This translates to group lasso but on the group level (out of some correlated groups it chooses only one group) and to sparse-group lasso as well (but here for correlations on between- and within-group levels). It depends on the original scientific question (respectively, what your outcome is) if you're more interested in specific genes or specific pathways. Additionally, stability selection is already a good idea to deal with correlated variables. Furthermore, you might want to take a look into elastic net regression, which is basically a mixture of lasso and ridge regression and has been shown to handle correlated variables better than lasso.
I'm not sure what you're referring to. I hope you're doing cross-validation, then you're actually assessing the residuals to find the best $\lambda$ value and as such the corresponding regression coefficients that best describe your outcome and avoid overfitting. You shouldn't do an additonal model with the chosen features, instead analyse the model chosen by cross-validation.
Lasso is fine. Elastic net might be worth a look. Some Support Vector Machine models (e.g. SVEN) are shown to be similar to lasso methods, and there's Bayesian alternatives to the different lasso methods as well which might be more precise than lasso ("spike-and-slab", for an overview and slow implementations based on Gibbs sampling see here, and more efficient implementations: simple spike-and-slab, grouped spike-and-slab, and sparse-group spike-and-slab). (Disclaimer: the last reference is a paper by me.)
|
Which approach based on the LASSO yields more biologically relevant results for gene data-sets?
Since you're only interested in the influence of the genes, you should "force keep" the non-gene variables in the model (for example in R with glmnet package and option penalty.factor equal to zero fo
|
50,858 |
How to improve forecast accuray of bsts model
|
Clean out the outlier instead of using a dummy variable (use tsclean()).
Try AddTrig instead of AddSeasonal for there seasonal component, since your data seems to have multiple seasonalities.
What other methods are you using that are giving better results than BSTS?
|
How to improve forecast accuray of bsts model
|
Clean out the outlier instead of using a dummy variable (use tsclean()).
Try AddTrig instead of AddSeasonal for there seasonal component, since your data seems to have multiple seasonalities.
What o
|
How to improve forecast accuray of bsts model
Clean out the outlier instead of using a dummy variable (use tsclean()).
Try AddTrig instead of AddSeasonal for there seasonal component, since your data seems to have multiple seasonalities.
What other methods are you using that are giving better results than BSTS?
|
How to improve forecast accuray of bsts model
Clean out the outlier instead of using a dummy variable (use tsclean()).
Try AddTrig instead of AddSeasonal for there seasonal component, since your data seems to have multiple seasonalities.
What o
|
50,859 |
How to improve forecast accuray of bsts model
|
Your approach is feasible but you need to accommodate many more columns (i.e. predictor series) than you have. I took your data into a comprehensive time series package that simultaneously deals with i.e. identifies 1) lead and lag effects around holidays 2) day-of-the-week effects and changes in day-of-the-week effects 3) time trends and level shifts 4) day-of-the-month effects % 5) week=of-the-month effects , 6) month-of-the-year effects 7) week-of-the-year effects 8) long-weekend effects
9) anomalies 10) changes in error variance over time and others including user-specified/suggested causals et al and of course any necessary arima structure to deal with omitted structure.
This is the Actual/Fit and Forecast that you should be getting from a useful model with model residuals here and forecasts here for the next 365 days .
Part of the equation is shown here and here
Hope this helps raise your expectations regarding daily modelling . solutions....
If you can find a way to identify these additional "columns" for your data you possibly might be able to something useful out of your current approach. Of course the trick is this do this automatically/programattically as I did.
Your "lack of confidence in your results" is echoed/mirrored by the "lack of confidence in your forecasts i.e. unrealistically very wide prediction limits "
In help to Alex , I have added more of the equation explicitely showing the indicator series for some of the Pulses ..
I was asked to provide a clear picture of the forecasts vis-a-vis the actuals
|
How to improve forecast accuray of bsts model
|
Your approach is feasible but you need to accommodate many more columns (i.e. predictor series) than you have. I took your data into a comprehensive time series package that simultaneously deals with
|
How to improve forecast accuray of bsts model
Your approach is feasible but you need to accommodate many more columns (i.e. predictor series) than you have. I took your data into a comprehensive time series package that simultaneously deals with i.e. identifies 1) lead and lag effects around holidays 2) day-of-the-week effects and changes in day-of-the-week effects 3) time trends and level shifts 4) day-of-the-month effects % 5) week=of-the-month effects , 6) month-of-the-year effects 7) week-of-the-year effects 8) long-weekend effects
9) anomalies 10) changes in error variance over time and others including user-specified/suggested causals et al and of course any necessary arima structure to deal with omitted structure.
This is the Actual/Fit and Forecast that you should be getting from a useful model with model residuals here and forecasts here for the next 365 days .
Part of the equation is shown here and here
Hope this helps raise your expectations regarding daily modelling . solutions....
If you can find a way to identify these additional "columns" for your data you possibly might be able to something useful out of your current approach. Of course the trick is this do this automatically/programattically as I did.
Your "lack of confidence in your results" is echoed/mirrored by the "lack of confidence in your forecasts i.e. unrealistically very wide prediction limits "
In help to Alex , I have added more of the equation explicitely showing the indicator series for some of the Pulses ..
I was asked to provide a clear picture of the forecasts vis-a-vis the actuals
|
How to improve forecast accuray of bsts model
Your approach is feasible but you need to accommodate many more columns (i.e. predictor series) than you have. I took your data into a comprehensive time series package that simultaneously deals with
|
50,860 |
Finding most similar training samples for a given ML model output
|
Found a recent paper that presents a similar approach to the one I described in the question: "Consistent Individualized Feature Attribution for Tree Ensembles", Lundberg et.al., KDD 2018.
They use Shapley values to explain the model prediction for each sample as a sum of contributions from each feature, and then compare the distances between the resulting vectors to find samples that are similar according to the model. The results seem to be fairly intuitive and interpretable:
So the approach in the question appears to be both sensible and used elsewhere.
|
Finding most similar training samples for a given ML model output
|
Found a recent paper that presents a similar approach to the one I described in the question: "Consistent Individualized Feature Attribution for Tree Ensembles", Lundberg et.al., KDD 2018.
They use Sh
|
Finding most similar training samples for a given ML model output
Found a recent paper that presents a similar approach to the one I described in the question: "Consistent Individualized Feature Attribution for Tree Ensembles", Lundberg et.al., KDD 2018.
They use Shapley values to explain the model prediction for each sample as a sum of contributions from each feature, and then compare the distances between the resulting vectors to find samples that are similar according to the model. The results seem to be fairly intuitive and interpretable:
So the approach in the question appears to be both sensible and used elsewhere.
|
Finding most similar training samples for a given ML model output
Found a recent paper that presents a similar approach to the one I described in the question: "Consistent Individualized Feature Attribution for Tree Ensembles", Lundberg et.al., KDD 2018.
They use Sh
|
50,861 |
Finding most similar training samples for a given ML model output
|
If you are looking to pick 'n' closest samples from the training data set that is similar to an out-of-sample observation, why not simply use the features you have to get a distance with each training observation - euclidean, manhattan or whatever (depends on the feature types)? The training sample with the smallest distance to the new observation would be the most similar.
|
Finding most similar training samples for a given ML model output
|
If you are looking to pick 'n' closest samples from the training data set that is similar to an out-of-sample observation, why not simply use the features you have to get a distance with each trainin
|
Finding most similar training samples for a given ML model output
If you are looking to pick 'n' closest samples from the training data set that is similar to an out-of-sample observation, why not simply use the features you have to get a distance with each training observation - euclidean, manhattan or whatever (depends on the feature types)? The training sample with the smallest distance to the new observation would be the most similar.
|
Finding most similar training samples for a given ML model output
If you are looking to pick 'n' closest samples from the training data set that is similar to an out-of-sample observation, why not simply use the features you have to get a distance with each trainin
|
50,862 |
When to stop training of neural network when validation loss is still decreasing but gap with training loss is increasing?
|
As long as your validation loss is continuing to decrease, your model is continuing to perform better in a generalized setting.
A growing gap between training and validation performance does mean that your model is treating more and more of the noise in your training set as real signal. However, the fact that your validation loss is decreasing means that the model is taking even more advantage of true signal. In some sense, it's gaining more generalizability than it's losing.
I would agree with your first instincts, and choose the model at the iteration indicated with the green line.
|
When to stop training of neural network when validation loss is still decreasing but gap with traini
|
As long as your validation loss is continuing to decrease, your model is continuing to perform better in a generalized setting.
A growing gap between training and validation performance does mean that
|
When to stop training of neural network when validation loss is still decreasing but gap with training loss is increasing?
As long as your validation loss is continuing to decrease, your model is continuing to perform better in a generalized setting.
A growing gap between training and validation performance does mean that your model is treating more and more of the noise in your training set as real signal. However, the fact that your validation loss is decreasing means that the model is taking even more advantage of true signal. In some sense, it's gaining more generalizability than it's losing.
I would agree with your first instincts, and choose the model at the iteration indicated with the green line.
|
When to stop training of neural network when validation loss is still decreasing but gap with traini
As long as your validation loss is continuing to decrease, your model is continuing to perform better in a generalized setting.
A growing gap between training and validation performance does mean that
|
50,863 |
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
|
You can think about the raters as points that occupy a 35 dimensional space (one dimension for each trait) for each person.
Then, you can measure their degree of agreement by measuring how far apart they are from each other in that space. The distance can be measured using the Euclidean distance (Pythagorean) formula.
Below are a few examples of four raters rating four people on a total of 10 traits (for brevity). If a rater chose a specific trait, the person gets a score of 1 for that trait, otherwise 0. In this example each rater chose two traits per person.
In the first case, all four raters have a very little agreement, and their total Euclidean distance comes out to be 14.63 for this person.
In the second case, there's a little more agreement, and as a result, the total distance reduces to 13.14. The lower the distance, the closer all raters are to each other in this 10 dimensional space.
In the last example, all raters agree with each other, so the total distance is zero. This is the best possible score.
In this example, since there are four raters, there would be a total of six pairs (comparisons) for which the Euclidean distances need to be calculated. In your example, six rater would yield 15 pairs.
For the aggregate measure of agreement, you can take the average distance across all people.
Since the distance measure doesn't really have a very intuitive interpretation (like how a percentage value that goes from 0 to 100 would) -- you might want to create a spectrum that shows the range from lowest to highest score for this dataset.
|
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
|
You can think about the raters as points that occupy a 35 dimensional space (one dimension for each trait) for each person.
Then, you can measure their degree of agreement by measuring how far apart
|
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
You can think about the raters as points that occupy a 35 dimensional space (one dimension for each trait) for each person.
Then, you can measure their degree of agreement by measuring how far apart they are from each other in that space. The distance can be measured using the Euclidean distance (Pythagorean) formula.
Below are a few examples of four raters rating four people on a total of 10 traits (for brevity). If a rater chose a specific trait, the person gets a score of 1 for that trait, otherwise 0. In this example each rater chose two traits per person.
In the first case, all four raters have a very little agreement, and their total Euclidean distance comes out to be 14.63 for this person.
In the second case, there's a little more agreement, and as a result, the total distance reduces to 13.14. The lower the distance, the closer all raters are to each other in this 10 dimensional space.
In the last example, all raters agree with each other, so the total distance is zero. This is the best possible score.
In this example, since there are four raters, there would be a total of six pairs (comparisons) for which the Euclidean distances need to be calculated. In your example, six rater would yield 15 pairs.
For the aggregate measure of agreement, you can take the average distance across all people.
Since the distance measure doesn't really have a very intuitive interpretation (like how a percentage value that goes from 0 to 100 would) -- you might want to create a spectrum that shows the range from lowest to highest score for this dataset.
|
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
You can think about the raters as points that occupy a 35 dimensional space (one dimension for each trait) for each person.
Then, you can measure their degree of agreement by measuring how far apart
|
50,864 |
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
|
I think you are on the right track. Below are some thoughts that may be of help.
ad A. The non-standardized Rater Agreement measure that you suggest is called Hamming distance.
The traits ($1 \le k \le 35$) assigned to individual $i$ by rater $j$ can be represented as a binary vector, $v_{ij}$, of length $35$.
Say traits $1, 3, 4$ were assigned to individual $7$ by rater $3$, then $v_{7,3}$ would look like:
$$ [1, \, 0, \, 1, \, 1, \, 0, \, 0, \, 0, \, 0, \, ..., \, 0]. $$
And say rater $4$ assigns traits $1, 3, 5$ to individual $7$, then $v_{7,4}$ is:
$$ [1, \, 0, \, 1, \, 0, \, 1, \, 0, \, 0, \, 0, \, ..., \, 0]. $$
The Hamming distances, $d_H(\cdot, \cdot)$, of these vectors to themselves are $0$; and $1$ to each other:
$$
d_H(v_{7,3}, \, v_{7,3}) = 0, \\
d_H(v_{7,4}, \, v_{7,4}) = 0, \\
d_H(v_{7,4}, \, v_{7,3}) = 1.
$$
The Hamming distance between binary vectors is maximal if their intersection$^1$ is minimal (in your case zero). Hamming distance is minimal (zero) if the intersection is maximal, i.e. if the vectors are identical.
ad B. A Monte-Carlo approach may indeed be warranted, though it may also help to know that the probability distribution of the intersection size of two "equal-weighted" binary vectors is Hypergometric.
Say, $w$ is the number of ones (or "weight") of the binary vectors $x, y \in [0, 1]^K$. Then for the weight $W_z$ of the intersection vector, $z$, it holds that:
$$ P(W_z = l) = \frac{\binom{w}{l}\binom{K-w}{w-l}}{\binom{K}{w}} \, , $$
for $\max(0, 2w - K) \le l \le w\,$ (the support of $W_z$).
$^1$ Strictly speaking intersection ($\cap$) is an operation on sets – not vectors. However, binary vectors can (straightforwardly) be interpreted as representing sets. In your case as a set of traits that an individual was assigned ($1$) or not ($0$).
|
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
|
I think you are on the right track. Below are some thoughts that may be of help.
ad A. The non-standardized Rater Agreement measure that you suggest is called Hamming distance.
The traits ($1 \le k \
|
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
I think you are on the right track. Below are some thoughts that may be of help.
ad A. The non-standardized Rater Agreement measure that you suggest is called Hamming distance.
The traits ($1 \le k \le 35$) assigned to individual $i$ by rater $j$ can be represented as a binary vector, $v_{ij}$, of length $35$.
Say traits $1, 3, 4$ were assigned to individual $7$ by rater $3$, then $v_{7,3}$ would look like:
$$ [1, \, 0, \, 1, \, 1, \, 0, \, 0, \, 0, \, 0, \, ..., \, 0]. $$
And say rater $4$ assigns traits $1, 3, 5$ to individual $7$, then $v_{7,4}$ is:
$$ [1, \, 0, \, 1, \, 0, \, 1, \, 0, \, 0, \, 0, \, ..., \, 0]. $$
The Hamming distances, $d_H(\cdot, \cdot)$, of these vectors to themselves are $0$; and $1$ to each other:
$$
d_H(v_{7,3}, \, v_{7,3}) = 0, \\
d_H(v_{7,4}, \, v_{7,4}) = 0, \\
d_H(v_{7,4}, \, v_{7,3}) = 1.
$$
The Hamming distance between binary vectors is maximal if their intersection$^1$ is minimal (in your case zero). Hamming distance is minimal (zero) if the intersection is maximal, i.e. if the vectors are identical.
ad B. A Monte-Carlo approach may indeed be warranted, though it may also help to know that the probability distribution of the intersection size of two "equal-weighted" binary vectors is Hypergometric.
Say, $w$ is the number of ones (or "weight") of the binary vectors $x, y \in [0, 1]^K$. Then for the weight $W_z$ of the intersection vector, $z$, it holds that:
$$ P(W_z = l) = \frac{\binom{w}{l}\binom{K-w}{w-l}}{\binom{K}{w}} \, , $$
for $\max(0, 2w - K) \le l \le w\,$ (the support of $W_z$).
$^1$ Strictly speaking intersection ($\cap$) is an operation on sets – not vectors. However, binary vectors can (straightforwardly) be interpreted as representing sets. In your case as a set of traits that an individual was assigned ($1$) or not ($0$).
|
How to index rater agreement: multiple raters identify strenghts/weaknesses from 30 traits?
I think you are on the right track. Below are some thoughts that may be of help.
ad A. The non-standardized Rater Agreement measure that you suggest is called Hamming distance.
The traits ($1 \le k \
|
50,865 |
Is 'poisson-izing' a feature a useful method?
|
Technically, it sounds like your method is trying to "unpoisson" the data.
You don't typically see changes-of-variable for a regressor along the lines of what you propose. That's for a couple reasons: 1) You don't need normally distributed regressors, you just want centered/scaled regressors so the L1-penalty is comparing apples-to-apples in terms of effect-size 2) $X/\bar{X}$ has no out of sample validity since the value of $\bar{X}$ is subjective. 3) The variance stabilizing transform $\sqrt{x}$ is known to make more "normally distributed" data out of Poisson values. 4) A log transform is like a square root but has more readily available interpretation.
That said, there's no reason you can't use $\bar{X}$ as a plug-in estimate of the variance. However, to "center-scale" a variable means dividing by the standard error, not the variance, so I would propose the following transformation instead:
$$ X^* = \frac{X-\bar{X}}{\sqrt{\bar{X}}} $$
Alternately, you can just map the quantiles of your Poisson sample onto a standard normal quantile.
As far as evaluating your ideas, it's always good to have an approach in mind. Here's a simulation showing the rate of rejection for Shapiro-Wilk tests of $X/ \bar{X}$ versus $\sqrt{X}$ in samples of Poisson values.
set.seed(123)
p <- replicate(1e5, {
x <- rpois(100, 10)
c(
'xbarx' = shapiro.test(x/mean(x))$p.value,
'sqrtx'= shapiro.test(sqrt(x))$p.value
)
})
rowMeans(p < 0.05)
> rowMeans(p < 0.05)
xbarx sqrtx
0.45866 0.34166
You can see $\sqrt{x}$ rejects the null 34% of the time whereas $x/\bar{x}$ rejects the null 46% of the time: i.e. in a sample of 100 there is more statistical evidence to say the $X/\bar{X}$ is non-normal than the $\sqrt{X}$, putting aside some known issues with the test.
In summary $X/\bar{X}$ doesn't make the regressor more normal as you say, and normality isn't necessary to begin with.
|
Is 'poisson-izing' a feature a useful method?
|
Technically, it sounds like your method is trying to "unpoisson" the data.
You don't typically see changes-of-variable for a regressor along the lines of what you propose. That's for a couple reasons:
|
Is 'poisson-izing' a feature a useful method?
Technically, it sounds like your method is trying to "unpoisson" the data.
You don't typically see changes-of-variable for a regressor along the lines of what you propose. That's for a couple reasons: 1) You don't need normally distributed regressors, you just want centered/scaled regressors so the L1-penalty is comparing apples-to-apples in terms of effect-size 2) $X/\bar{X}$ has no out of sample validity since the value of $\bar{X}$ is subjective. 3) The variance stabilizing transform $\sqrt{x}$ is known to make more "normally distributed" data out of Poisson values. 4) A log transform is like a square root but has more readily available interpretation.
That said, there's no reason you can't use $\bar{X}$ as a plug-in estimate of the variance. However, to "center-scale" a variable means dividing by the standard error, not the variance, so I would propose the following transformation instead:
$$ X^* = \frac{X-\bar{X}}{\sqrt{\bar{X}}} $$
Alternately, you can just map the quantiles of your Poisson sample onto a standard normal quantile.
As far as evaluating your ideas, it's always good to have an approach in mind. Here's a simulation showing the rate of rejection for Shapiro-Wilk tests of $X/ \bar{X}$ versus $\sqrt{X}$ in samples of Poisson values.
set.seed(123)
p <- replicate(1e5, {
x <- rpois(100, 10)
c(
'xbarx' = shapiro.test(x/mean(x))$p.value,
'sqrtx'= shapiro.test(sqrt(x))$p.value
)
})
rowMeans(p < 0.05)
> rowMeans(p < 0.05)
xbarx sqrtx
0.45866 0.34166
You can see $\sqrt{x}$ rejects the null 34% of the time whereas $x/\bar{x}$ rejects the null 46% of the time: i.e. in a sample of 100 there is more statistical evidence to say the $X/\bar{X}$ is non-normal than the $\sqrt{X}$, putting aside some known issues with the test.
In summary $X/\bar{X}$ doesn't make the regressor more normal as you say, and normality isn't necessary to begin with.
|
Is 'poisson-izing' a feature a useful method?
Technically, it sounds like your method is trying to "unpoisson" the data.
You don't typically see changes-of-variable for a regressor along the lines of what you propose. That's for a couple reasons:
|
50,866 |
Ridge regression: penalizing weights corresponding to larger-scale features
|
If the columns of $X$ have mean zero, then their variances are $\sigma^2 = \text{diag}(X^TX)$. Then if $X_s$ is the scaled version of $X$ so that $X = X_s \cdot \text{diag}(\sigma)$, the standard ridge loss can be written as
$$
\begin{align}
\|y - X_s\beta_s\|^2 + \lambda \|\beta_s\|^2
&= \|y - X_s \cdot \text{diag}(\sigma) \cdot \frac{1}{\text{diag}(\sigma)} \beta_s \|^2 + \lambda \|\text{diag}(\sigma) \cdot \frac{1}{\text{diag}(\sigma)} \beta_s\|^2 \\
&= \|y - X\beta\|^2 + \lambda\|\text{diag}(\sigma) \beta\|^2
\end{align}
$$
where $\beta = \frac{1}{\text{diag}(\sigma)} \beta_s$.
TL;DR The $\text{diag}(X^TX)$ are the coefficients you use to standardize the matrix, and you can shift them from dividing through the matrix to multiplying through the weights.
|
Ridge regression: penalizing weights corresponding to larger-scale features
|
If the columns of $X$ have mean zero, then their variances are $\sigma^2 = \text{diag}(X^TX)$. Then if $X_s$ is the scaled version of $X$ so that $X = X_s \cdot \text{diag}(\sigma)$, the standard ridg
|
Ridge regression: penalizing weights corresponding to larger-scale features
If the columns of $X$ have mean zero, then their variances are $\sigma^2 = \text{diag}(X^TX)$. Then if $X_s$ is the scaled version of $X$ so that $X = X_s \cdot \text{diag}(\sigma)$, the standard ridge loss can be written as
$$
\begin{align}
\|y - X_s\beta_s\|^2 + \lambda \|\beta_s\|^2
&= \|y - X_s \cdot \text{diag}(\sigma) \cdot \frac{1}{\text{diag}(\sigma)} \beta_s \|^2 + \lambda \|\text{diag}(\sigma) \cdot \frac{1}{\text{diag}(\sigma)} \beta_s\|^2 \\
&= \|y - X\beta\|^2 + \lambda\|\text{diag}(\sigma) \beta\|^2
\end{align}
$$
where $\beta = \frac{1}{\text{diag}(\sigma)} \beta_s$.
TL;DR The $\text{diag}(X^TX)$ are the coefficients you use to standardize the matrix, and you can shift them from dividing through the matrix to multiplying through the weights.
|
Ridge regression: penalizing weights corresponding to larger-scale features
If the columns of $X$ have mean zero, then their variances are $\sigma^2 = \text{diag}(X^TX)$. Then if $X_s$ is the scaled version of $X$ so that $X = X_s \cdot \text{diag}(\sigma)$, the standard ridg
|
50,867 |
Generate Beta distribution from Uniform random variables
|
I just had the same problem with the distribution creation, thanks for the latest reply to the original post.
Please find below a viable solution to create one RV in Python:
def beta(a,b):
rv1 = np.random.rand()**(1/a)
rv2 = np.random.rand()**(1/b)
while (rv1+rv2) > 1:
rv1 = np.random.rand()**(1/a)
rv2 = np.random.rand()**(1/b)
return = rv1 / (rv1+rv2)
|
Generate Beta distribution from Uniform random variables
|
I just had the same problem with the distribution creation, thanks for the latest reply to the original post.
Please find below a viable solution to create one RV in Python:
def beta(a,b):
rv1 = n
|
Generate Beta distribution from Uniform random variables
I just had the same problem with the distribution creation, thanks for the latest reply to the original post.
Please find below a viable solution to create one RV in Python:
def beta(a,b):
rv1 = np.random.rand()**(1/a)
rv2 = np.random.rand()**(1/b)
while (rv1+rv2) > 1:
rv1 = np.random.rand()**(1/a)
rv2 = np.random.rand()**(1/b)
return = rv1 / (rv1+rv2)
|
Generate Beta distribution from Uniform random variables
I just had the same problem with the distribution creation, thanks for the latest reply to the original post.
Please find below a viable solution to create one RV in Python:
def beta(a,b):
rv1 = n
|
50,868 |
effect of class 0,1 proportion on logistic regression estimated probability
|
As Tim wrote above the logistic regression gives you a prediction of the probability of each class. Concretely, you will get
$$P(C_a|D)$$ and $$P(C_n|D)$$
where $C_a$ and $C_n$ are the anomaly class and normal class and $D$ is your data.
According to Baye's Theorem:
$$P(C_a|D)= \frac{P(D|C_a) P(C_a)}{P(D)}$$
$$P(C_n|D)= \frac{P(D|C_n) P(C_n)}{P(D)}$$
Empirically,
$$P(C_a)=\frac{\text{Number of anomalies}}{\text{Total samples}}$$
So if the number total samples change dramatically while the number of anomalies stays the same then you have a factor that changes significantly (20/220 versus 20/20020). This could change the probabilities that you get from logistic regression.
We need to pay more attention where does the 200 and 20000 samples come from. If you are testing the same system with different experiments and in one experiment you have 20 anomalies out of 200 and in the other one 20 out of 20000 then these experiments wildly disagree.
Since you mention anomaly detection, I assume that you have exactly 20 anomalies and many samples (probably more than 20000) and you are wondering how many normal samples should I put into my classification.
With logistic regression since you are fitting the model such that the total cost is minimized the more of one class that you have the decisions are more favored to classify the data as a member of that class (the majority class). I argue that this is not what you generally want in anomaly detection. Think about finding a cancer patient or early detection of an airplane engine. In these cases, you don't want to miss even a single one. In the case of a large sample imbalance if you use logistic regression without further modification (e.g. applying weights or resampling) then your classifier would not be optimum for anomaly detection. In the following pictures, you see the impact of class imbalance on the decision boundary. As the number of normal class members increases then the decision boundary is shifted.
The following picture shows the evolution of the average probability of being an anomaly for both classes.
So going back to your original question: Yes the probability is affected by the sample size in a not very straight forward way.
I am including the python script used for the experiment. One key factor to change is the variance of each class.
from sklearn.linear_model import LogisticRegression
import numpy as np
from numpy.random import randn
import matplotlib.pyplot as plt
plt.close('all')
#%%
def genData(n0=20,m0=np.array([0,0]),s0=np.array([0.5, 0.5])/2, n1=200,m1=np.array ([1,1]),s1=np.array([0.5, 0.5])/2):
D0=np.concatenate ([randn(n0,1)*s0[0]+m0[0] , randn(n0,1)*s0[1]+m0[1]],1)
D1=np.concatenate ([randn(n1,1)*s1[0]+m1[0] , randn(n1,1)*s1[1]+m1[1]],1)
return D0,D1
#%%
n1v=[20,200,400,1000,2000,4000, 10000,20000]
nTrial=20
n0Pr=[]
n1Pr=[]
for n1 in n1v:
n0PrS=[]
n1PrS=[]
print(n1)
for iT in range(0,nTrial):
n0=20
D0,D1 = genData(n0=n0,n1=n1)
X=np.concatenate ( [D0,D1] , 0)
y=np.concatenate ( (np.zeros([n0,1]),np.ones([n1,1])),0)
class_weight =None
#class_weight = {0:1, 1:1./np.sqrt(n1)} # Use class weight to neutralize the impact of the class imbalance
clf = LogisticRegression(random_state=0, solver='lbfgs',multi_class='multinomial',class_weight=class_weight ).fit(X, y[:,0])
if iT==0:
plt.figure()
plt.plot(D0[:,0],D0[:,1],'.r',label='Anomaly')
plt.plot(D1[:,0],D1[:,1],'.b',label='Normal class')
plt.xlabel('Feature 1');plt.ylabel('Feature 2');
xx = np.linspace(-0.5,2)
plt.plot(xx,-xx*clf.coef_[0,0]/clf.coef_[0,1]-clf.intercept_/clf.coef_[0,1],label='Decision boundary')
plt.xlim(-0.5, 2);plt.ylim(-0.5, 2)
plt.legend()
plt.title('Number of anomaly samples: {0}, Number of normal samples: {1}'.format(n0,n1))
plt.show()
#%%
pr0=clf.predict_log_proba(D0)
pr1=clf.predict_log_proba(D1)
n0PrS.append(np.exp(np.mean(pr0,0)[0]))
n1PrS.append(np.exp(np.mean(pr1,0)[0]))
n0Pr.append(np.mean(n0PrS))
n1Pr.append(np.mean(n1PrS))
#%%
plt.figure()
plt.plot(n1v,n0Pr,label='Gemetric Mean Probablity for members of Minority class')
plt.plot(n1v,n1Pr,label='Gemetric Mean Probablity for members of Majority class')
plt.xlabel('Sample size of the majority class')
plt.ylabel('Probablity of being anomaly')
plt.legend()
|
effect of class 0,1 proportion on logistic regression estimated probability
|
As Tim wrote above the logistic regression gives you a prediction of the probability of each class. Concretely, you will get
$$P(C_a|D)$$ and $$P(C_n|D)$$
where $C_a$ and $C_n$ are the anomaly class a
|
effect of class 0,1 proportion on logistic regression estimated probability
As Tim wrote above the logistic regression gives you a prediction of the probability of each class. Concretely, you will get
$$P(C_a|D)$$ and $$P(C_n|D)$$
where $C_a$ and $C_n$ are the anomaly class and normal class and $D$ is your data.
According to Baye's Theorem:
$$P(C_a|D)= \frac{P(D|C_a) P(C_a)}{P(D)}$$
$$P(C_n|D)= \frac{P(D|C_n) P(C_n)}{P(D)}$$
Empirically,
$$P(C_a)=\frac{\text{Number of anomalies}}{\text{Total samples}}$$
So if the number total samples change dramatically while the number of anomalies stays the same then you have a factor that changes significantly (20/220 versus 20/20020). This could change the probabilities that you get from logistic regression.
We need to pay more attention where does the 200 and 20000 samples come from. If you are testing the same system with different experiments and in one experiment you have 20 anomalies out of 200 and in the other one 20 out of 20000 then these experiments wildly disagree.
Since you mention anomaly detection, I assume that you have exactly 20 anomalies and many samples (probably more than 20000) and you are wondering how many normal samples should I put into my classification.
With logistic regression since you are fitting the model such that the total cost is minimized the more of one class that you have the decisions are more favored to classify the data as a member of that class (the majority class). I argue that this is not what you generally want in anomaly detection. Think about finding a cancer patient or early detection of an airplane engine. In these cases, you don't want to miss even a single one. In the case of a large sample imbalance if you use logistic regression without further modification (e.g. applying weights or resampling) then your classifier would not be optimum for anomaly detection. In the following pictures, you see the impact of class imbalance on the decision boundary. As the number of normal class members increases then the decision boundary is shifted.
The following picture shows the evolution of the average probability of being an anomaly for both classes.
So going back to your original question: Yes the probability is affected by the sample size in a not very straight forward way.
I am including the python script used for the experiment. One key factor to change is the variance of each class.
from sklearn.linear_model import LogisticRegression
import numpy as np
from numpy.random import randn
import matplotlib.pyplot as plt
plt.close('all')
#%%
def genData(n0=20,m0=np.array([0,0]),s0=np.array([0.5, 0.5])/2, n1=200,m1=np.array ([1,1]),s1=np.array([0.5, 0.5])/2):
D0=np.concatenate ([randn(n0,1)*s0[0]+m0[0] , randn(n0,1)*s0[1]+m0[1]],1)
D1=np.concatenate ([randn(n1,1)*s1[0]+m1[0] , randn(n1,1)*s1[1]+m1[1]],1)
return D0,D1
#%%
n1v=[20,200,400,1000,2000,4000, 10000,20000]
nTrial=20
n0Pr=[]
n1Pr=[]
for n1 in n1v:
n0PrS=[]
n1PrS=[]
print(n1)
for iT in range(0,nTrial):
n0=20
D0,D1 = genData(n0=n0,n1=n1)
X=np.concatenate ( [D0,D1] , 0)
y=np.concatenate ( (np.zeros([n0,1]),np.ones([n1,1])),0)
class_weight =None
#class_weight = {0:1, 1:1./np.sqrt(n1)} # Use class weight to neutralize the impact of the class imbalance
clf = LogisticRegression(random_state=0, solver='lbfgs',multi_class='multinomial',class_weight=class_weight ).fit(X, y[:,0])
if iT==0:
plt.figure()
plt.plot(D0[:,0],D0[:,1],'.r',label='Anomaly')
plt.plot(D1[:,0],D1[:,1],'.b',label='Normal class')
plt.xlabel('Feature 1');plt.ylabel('Feature 2');
xx = np.linspace(-0.5,2)
plt.plot(xx,-xx*clf.coef_[0,0]/clf.coef_[0,1]-clf.intercept_/clf.coef_[0,1],label='Decision boundary')
plt.xlim(-0.5, 2);plt.ylim(-0.5, 2)
plt.legend()
plt.title('Number of anomaly samples: {0}, Number of normal samples: {1}'.format(n0,n1))
plt.show()
#%%
pr0=clf.predict_log_proba(D0)
pr1=clf.predict_log_proba(D1)
n0PrS.append(np.exp(np.mean(pr0,0)[0]))
n1PrS.append(np.exp(np.mean(pr1,0)[0]))
n0Pr.append(np.mean(n0PrS))
n1Pr.append(np.mean(n1PrS))
#%%
plt.figure()
plt.plot(n1v,n0Pr,label='Gemetric Mean Probablity for members of Minority class')
plt.plot(n1v,n1Pr,label='Gemetric Mean Probablity for members of Majority class')
plt.xlabel('Sample size of the majority class')
plt.ylabel('Probablity of being anomaly')
plt.legend()
|
effect of class 0,1 proportion on logistic regression estimated probability
As Tim wrote above the logistic regression gives you a prediction of the probability of each class. Concretely, you will get
$$P(C_a|D)$$ and $$P(C_n|D)$$
where $C_a$ and $C_n$ are the anomaly class a
|
50,869 |
effect of class 0,1 proportion on logistic regression estimated probability
|
Logistic regression is a model that estimates probabilities. For the first dataset, it will predict the probability of "success", on average, to be $\tfrac{200}{20+200}$, in the second $\tfrac{20\,000}{20+20\,000}$. The predicted conditional probabilities will differ depending on how exactly the datasets differ.
It is a feature, not a bug. Logistic regression is a well-calibrated, so what follows, the estimated probabilities would be consistent with empirical probabilities. If, given only this data, the model told you that the probability of "success" to be $50/50$ you would be considering that something is deeply wrong with the model, as it gives predictions that are inconsistent with the data.
TL;DR in both cases models would give predictions on the "scale" of probability. The values would differ depending on how the data differs, but not only in terms of total count, but also the proportions of two groups and other related characteristics.
|
effect of class 0,1 proportion on logistic regression estimated probability
|
Logistic regression is a model that estimates probabilities. For the first dataset, it will predict the probability of "success", on average, to be $\tfrac{200}{20+200}$, in the second $\tfrac{20\,000
|
effect of class 0,1 proportion on logistic regression estimated probability
Logistic regression is a model that estimates probabilities. For the first dataset, it will predict the probability of "success", on average, to be $\tfrac{200}{20+200}$, in the second $\tfrac{20\,000}{20+20\,000}$. The predicted conditional probabilities will differ depending on how exactly the datasets differ.
It is a feature, not a bug. Logistic regression is a well-calibrated, so what follows, the estimated probabilities would be consistent with empirical probabilities. If, given only this data, the model told you that the probability of "success" to be $50/50$ you would be considering that something is deeply wrong with the model, as it gives predictions that are inconsistent with the data.
TL;DR in both cases models would give predictions on the "scale" of probability. The values would differ depending on how the data differs, but not only in terms of total count, but also the proportions of two groups and other related characteristics.
|
effect of class 0,1 proportion on logistic regression estimated probability
Logistic regression is a model that estimates probabilities. For the first dataset, it will predict the probability of "success", on average, to be $\tfrac{200}{20+200}$, in the second $\tfrac{20\,000
|
50,870 |
Neural Networks - Strategies for problems with high Bayes error rate
|
You might find focal loss interesting. This is a reshaped standard cross entropy loss that down-weights the loss assigned to well-classified examples. It motivates a classifier to show more confidence where appropriate instead of only fearing a huge penalty for misclassification and hiding behind the base rate.
It is also possible that the high Bayes error prevents good learning of useful features. Coming up with a toy task as an intermediate step might help.
Curious to hear if you made further progress.
|
Neural Networks - Strategies for problems with high Bayes error rate
|
You might find focal loss interesting. This is a reshaped standard cross entropy loss that down-weights the loss assigned to well-classified examples. It motivates a classifier to show more confidence
|
Neural Networks - Strategies for problems with high Bayes error rate
You might find focal loss interesting. This is a reshaped standard cross entropy loss that down-weights the loss assigned to well-classified examples. It motivates a classifier to show more confidence where appropriate instead of only fearing a huge penalty for misclassification and hiding behind the base rate.
It is also possible that the high Bayes error prevents good learning of useful features. Coming up with a toy task as an intermediate step might help.
Curious to hear if you made further progress.
|
Neural Networks - Strategies for problems with high Bayes error rate
You might find focal loss interesting. This is a reshaped standard cross entropy loss that down-weights the loss assigned to well-classified examples. It motivates a classifier to show more confidence
|
50,871 |
Comparing two models with statistical testing
|
This sounds like a great application for the $k$-fold cross-validated paired $t$ test (Dietterich, 1998). However, you need the accuracies per fold of both your model and the model from the other paper. Having only the mean accuracies over all folds is not sufficient (see alternative below).
The $k$-fold cross-validated paired $t$ test
We have two classification machine learning models $A$ and $B$, that we wish to compare. Under the null hypothesis, both models should have the same test set accuracies $p_A = p_B$. Dietterich (1998) refers to error rates, which is simply $1-$accuracy. The accuracy $p$ is the probability that a randomly drawn sample from the test set will be classified correctly.
To compare both models, we are interested in the difference of the accuracies $p = p_A - p_B$. First, we perform $k$-fold cross-validation by splitting the dataset into $k$ disjoint sets of equal size. We then perform $ k $ experiments, where each set is used as test set and the remaining sets are used for training. Assuming that the $ k $ differences $ p^{(i)} = p_A^{(i)}-p_B^{(i)} $ are drawn independently from a normal distribution, we can perform Student's $ t $ test by computing the statistic
$$
t = \frac{\bar{p}\sqrt{k}}{\sqrt{\frac{\sum_{i=1}^{k} (p^{(i)}-\bar{p})^2}{k-1}}} ~ ,
$$
where $ \bar{p} = \frac{1}{k} \sum_{i=1}^{k} p^{(i)} $.
For $ k=10 $ experiments (10-fold cross-validation), the test statistic has a $t$ distribution with $ k-1=9 $ degrees of freedom. The null hypothesis can be rejected if $ |t| > t_{9,0.975} = 2.262 $ (for a two-sided test with the probability of incorrectly rejecting the null hypothesis of $0.05$).
But what if I only have the mean accuracy over all folds?
In this case, you can still perform the following test. Let $p_A$ and $p_B$ be the mean of the accuracies over $k$ folds, which are assumed to be normally distributed. If the two accuracies are independent, the difference $ p_A - p_B $ is also normally distributed.
Assuming that the null hypothesis is true, we can compute the following statistic
$$
z = \frac{p_A - p_B}{\sqrt{2p(1-p)/n}} ~ ,
$$
where $ p=(p_A + p_B)/2 $ and number of test samples $n$. This test statistic has approximately a standard normal distribution and we can reject the null hypothesis if $ |z| > Z_{0.975} = 1.96 $.
However, this test has several problems as outlined by Dietterich (1998), e.g., $p_A$ and $p_B$ are not independent. Ideally, one should perform the proposed 5x2cv paired $t$ test, if retraining and evaluation of both models being compared is possible.
Dietterich, T. G. (1998). Approximate statistical tests for comparing supervised classification learning algorithms. Neural computation, 10(7), 1895-1923. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.37.3325&rep=rep1&type=pdf
|
Comparing two models with statistical testing
|
This sounds like a great application for the $k$-fold cross-validated paired $t$ test (Dietterich, 1998). However, you need the accuracies per fold of both your model and the model from the other pape
|
Comparing two models with statistical testing
This sounds like a great application for the $k$-fold cross-validated paired $t$ test (Dietterich, 1998). However, you need the accuracies per fold of both your model and the model from the other paper. Having only the mean accuracies over all folds is not sufficient (see alternative below).
The $k$-fold cross-validated paired $t$ test
We have two classification machine learning models $A$ and $B$, that we wish to compare. Under the null hypothesis, both models should have the same test set accuracies $p_A = p_B$. Dietterich (1998) refers to error rates, which is simply $1-$accuracy. The accuracy $p$ is the probability that a randomly drawn sample from the test set will be classified correctly.
To compare both models, we are interested in the difference of the accuracies $p = p_A - p_B$. First, we perform $k$-fold cross-validation by splitting the dataset into $k$ disjoint sets of equal size. We then perform $ k $ experiments, where each set is used as test set and the remaining sets are used for training. Assuming that the $ k $ differences $ p^{(i)} = p_A^{(i)}-p_B^{(i)} $ are drawn independently from a normal distribution, we can perform Student's $ t $ test by computing the statistic
$$
t = \frac{\bar{p}\sqrt{k}}{\sqrt{\frac{\sum_{i=1}^{k} (p^{(i)}-\bar{p})^2}{k-1}}} ~ ,
$$
where $ \bar{p} = \frac{1}{k} \sum_{i=1}^{k} p^{(i)} $.
For $ k=10 $ experiments (10-fold cross-validation), the test statistic has a $t$ distribution with $ k-1=9 $ degrees of freedom. The null hypothesis can be rejected if $ |t| > t_{9,0.975} = 2.262 $ (for a two-sided test with the probability of incorrectly rejecting the null hypothesis of $0.05$).
But what if I only have the mean accuracy over all folds?
In this case, you can still perform the following test. Let $p_A$ and $p_B$ be the mean of the accuracies over $k$ folds, which are assumed to be normally distributed. If the two accuracies are independent, the difference $ p_A - p_B $ is also normally distributed.
Assuming that the null hypothesis is true, we can compute the following statistic
$$
z = \frac{p_A - p_B}{\sqrt{2p(1-p)/n}} ~ ,
$$
where $ p=(p_A + p_B)/2 $ and number of test samples $n$. This test statistic has approximately a standard normal distribution and we can reject the null hypothesis if $ |z| > Z_{0.975} = 1.96 $.
However, this test has several problems as outlined by Dietterich (1998), e.g., $p_A$ and $p_B$ are not independent. Ideally, one should perform the proposed 5x2cv paired $t$ test, if retraining and evaluation of both models being compared is possible.
Dietterich, T. G. (1998). Approximate statistical tests for comparing supervised classification learning algorithms. Neural computation, 10(7), 1895-1923. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.37.3325&rep=rep1&type=pdf
|
Comparing two models with statistical testing
This sounds like a great application for the $k$-fold cross-validated paired $t$ test (Dietterich, 1998). However, you need the accuracies per fold of both your model and the model from the other pape
|
50,872 |
About the variance of a weighted sum
|
It turns out that for large $n$, the above estimator can be written in the form $\mathbb E_X [(h(X) - b) g(X)]$ where $h(x) := f(x) / \int f(y) d\mu_X(y)$ , and by direct computation, has variance $\mathbb E_X [h(X)g(X)] - b\mathbb E_X[g(X)^2]$ which is of course minimized by taking
$$b = b^* := \frac{\operatorname{cov}[h(X),g(X)]}{\operatorname{var}[g(X)]}.
$$
This is a variance-reduction technique known as "control variates".
It remains to estimate $\operatorname{cov}[h(X),g(X)]$ and $\operatorname{var} [g(X)]$ from finite samples $x_1,\ldots,x_n$, and we're done.
|
About the variance of a weighted sum
|
It turns out that for large $n$, the above estimator can be written in the form $\mathbb E_X [(h(X) - b) g(X)]$ where $h(x) := f(x) / \int f(y) d\mu_X(y)$ , and by direct computation, has variance $\m
|
About the variance of a weighted sum
It turns out that for large $n$, the above estimator can be written in the form $\mathbb E_X [(h(X) - b) g(X)]$ where $h(x) := f(x) / \int f(y) d\mu_X(y)$ , and by direct computation, has variance $\mathbb E_X [h(X)g(X)] - b\mathbb E_X[g(X)^2]$ which is of course minimized by taking
$$b = b^* := \frac{\operatorname{cov}[h(X),g(X)]}{\operatorname{var}[g(X)]}.
$$
This is a variance-reduction technique known as "control variates".
It remains to estimate $\operatorname{cov}[h(X),g(X)]$ and $\operatorname{var} [g(X)]$ from finite samples $x_1,\ldots,x_n$, and we're done.
|
About the variance of a weighted sum
It turns out that for large $n$, the above estimator can be written in the form $\mathbb E_X [(h(X) - b) g(X)]$ where $h(x) := f(x) / \int f(y) d\mu_X(y)$ , and by direct computation, has variance $\m
|
50,873 |
Keras difference between GRU and GRUCell
|
In GRU/LSTM Cell, there is no option of return_sequences. That means it is just a cell of an unfolded GRU/LSTM unit.
The argument of GRU/LSTM i.e. return_sequences, if return_sequences=True, then returns all the output state of the GRU/LSTM.
GRU/LSTM Cell computes and returns only one timestamp.
But, GRU/LSTM can return sequences of all timestamps.
In Figure 1, the unit in loop is GRU/LSTM.
In Figure 2, the cells shown are GRU/LSTM Cell which is an unfolded GRU/LSTM unit.
|
Keras difference between GRU and GRUCell
|
In GRU/LSTM Cell, there is no option of return_sequences. That means it is just a cell of an unfolded GRU/LSTM unit.
The argument of GRU/LSTM i.e. return_sequences, if return_sequences=True, then retu
|
Keras difference between GRU and GRUCell
In GRU/LSTM Cell, there is no option of return_sequences. That means it is just a cell of an unfolded GRU/LSTM unit.
The argument of GRU/LSTM i.e. return_sequences, if return_sequences=True, then returns all the output state of the GRU/LSTM.
GRU/LSTM Cell computes and returns only one timestamp.
But, GRU/LSTM can return sequences of all timestamps.
In Figure 1, the unit in loop is GRU/LSTM.
In Figure 2, the cells shown are GRU/LSTM Cell which is an unfolded GRU/LSTM unit.
|
Keras difference between GRU and GRUCell
In GRU/LSTM Cell, there is no option of return_sequences. That means it is just a cell of an unfolded GRU/LSTM unit.
The argument of GRU/LSTM i.e. return_sequences, if return_sequences=True, then retu
|
50,874 |
How would I use the largest expected effect size to determine a prior?
|
A good way to set priors is using prior predictive checks - basically you simulate new datasets from your model. If the simulated datasets are unrealistic in any way, it means your priors have problems.
Prior predictive checks have the advantage that they take complete structure of the model into account. If you however have only one effect in the model or have other reasons to believe you can set the prior independently for each parameter, and you have minimal bound $c_-$ and maximal bound $c_+$ than a good way is to choose a family and then find such parameters for the family that $P(\beta < c_-) = P(\beta > c_+) = \alpha$ where $\alpha$ is small, but not extremely small ($0.05$ tends to work nice).
Stan wiki has some more considerations:
https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations
Note that it is IMHO wrong to a-priori exclude effects in the opposite direction than expected.
Also, Bayes factors tend to be very sensitive to the parts of priors that don't matter for normal inference (e.g. choosing $N(0,100)$ vs. $N(0,1000)$ when the ML estimate is 0.5).
|
How would I use the largest expected effect size to determine a prior?
|
A good way to set priors is using prior predictive checks - basically you simulate new datasets from your model. If the simulated datasets are unrealistic in any way, it means your priors have problem
|
How would I use the largest expected effect size to determine a prior?
A good way to set priors is using prior predictive checks - basically you simulate new datasets from your model. If the simulated datasets are unrealistic in any way, it means your priors have problems.
Prior predictive checks have the advantage that they take complete structure of the model into account. If you however have only one effect in the model or have other reasons to believe you can set the prior independently for each parameter, and you have minimal bound $c_-$ and maximal bound $c_+$ than a good way is to choose a family and then find such parameters for the family that $P(\beta < c_-) = P(\beta > c_+) = \alpha$ where $\alpha$ is small, but not extremely small ($0.05$ tends to work nice).
Stan wiki has some more considerations:
https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations
Note that it is IMHO wrong to a-priori exclude effects in the opposite direction than expected.
Also, Bayes factors tend to be very sensitive to the parts of priors that don't matter for normal inference (e.g. choosing $N(0,100)$ vs. $N(0,1000)$ when the ML estimate is 0.5).
|
How would I use the largest expected effect size to determine a prior?
A good way to set priors is using prior predictive checks - basically you simulate new datasets from your model. If the simulated datasets are unrealistic in any way, it means your priors have problem
|
50,875 |
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
|
From your comments, it seems like what you are really after is feature selection - you want a set of models that use variable numbers of features (1, 2, 3, ..., N), such that incrementally adding a new feature yields as great an increase in model performance as possible. Then the decision makers can assess whether they want to carry out a costly procedure to obtain the data for an additional feature to use a more complicated model with greater precision/recall. We assume here that it costs the same to obtain the data for each feature.
In that case, I would separate your data into a training and test set; I would use cross-validation on the training set to select the best incremental feature (strictly speaking, you need to use nested cross-validation here, but if that is computationally infeasible or you don't have enough data we can verify that we did not overfit by cross-referencing CV results with test set results at the end). That is, you would start by trying each feature on their own, and choose the feature that gives you the best CV performance. You would then repeat the process to iteratively add additional features.
Note whether different CV folds show up with different best incremental features - if the variability is too high, this approach may not be feasible.
|
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
|
From your comments, it seems like what you are really after is feature selection - you want a set of models that use variable numbers of features (1, 2, 3, ..., N), such that incrementally adding a ne
|
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
From your comments, it seems like what you are really after is feature selection - you want a set of models that use variable numbers of features (1, 2, 3, ..., N), such that incrementally adding a new feature yields as great an increase in model performance as possible. Then the decision makers can assess whether they want to carry out a costly procedure to obtain the data for an additional feature to use a more complicated model with greater precision/recall. We assume here that it costs the same to obtain the data for each feature.
In that case, I would separate your data into a training and test set; I would use cross-validation on the training set to select the best incremental feature (strictly speaking, you need to use nested cross-validation here, but if that is computationally infeasible or you don't have enough data we can verify that we did not overfit by cross-referencing CV results with test set results at the end). That is, you would start by trying each feature on their own, and choose the feature that gives you the best CV performance. You would then repeat the process to iteratively add additional features.
Note whether different CV folds show up with different best incremental features - if the variability is too high, this approach may not be feasible.
|
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
From your comments, it seems like what you are really after is feature selection - you want a set of models that use variable numbers of features (1, 2, 3, ..., N), such that incrementally adding a ne
|
50,876 |
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
|
The question is ill-posed. We cannot advise the doctor that, for example, inspecting feature $X_a$ is more worthwhile than inspecting feature $X_b$, since how "important" a feature is only makes sense in the context of a specific model being used, and not the real world.
Logistic Regression and Random Forests are two completely different methods that make use of the features (in conjunction) differently to maximise predictive power. This is why a different set of features offer the most predictive power for each model.
Such feature importance figures often show up, but the information they are thought to convey is generally mistaken to be relevant to the real world. Why one would be interested in such a feature importance is figure is unclear.
|
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
|
The question is ill-posed. We cannot advise the doctor that, for example, inspecting feature $X_a$ is more worthwhile than inspecting feature $X_b$, since how "important" a feature is only makes sense
|
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
The question is ill-posed. We cannot advise the doctor that, for example, inspecting feature $X_a$ is more worthwhile than inspecting feature $X_b$, since how "important" a feature is only makes sense in the context of a specific model being used, and not the real world.
Logistic Regression and Random Forests are two completely different methods that make use of the features (in conjunction) differently to maximise predictive power. This is why a different set of features offer the most predictive power for each model.
Such feature importance figures often show up, but the information they are thought to convey is generally mistaken to be relevant to the real world. Why one would be interested in such a feature importance is figure is unclear.
|
Feature Importance for Breast Cancer: Random Forests vs Logistic Regression
The question is ill-posed. We cannot advise the doctor that, for example, inspecting feature $X_a$ is more worthwhile than inspecting feature $X_b$, since how "important" a feature is only makes sense
|
50,877 |
Zero-mean RV $X$, probability of being positive using moments
|
We can find find in literature (F.D. Lesley and V. Rotar) that:
$$P (X \geq 0) \geq \frac{2 \sqrt {3}-3}{E (X^4)}$$
if X has variance equal to 1. What is left for you to do is find out how this inequality scales when that condition is not true, and maybe see whether the $X\geq0$ instead of $X>0$ is not troubling.
|
Zero-mean RV $X$, probability of being positive using moments
|
We can find find in literature (F.D. Lesley and V. Rotar) that:
$$P (X \geq 0) \geq \frac{2 \sqrt {3}-3}{E (X^4)}$$
if X has variance equal to 1. What is left for you to do is find out how this inequa
|
Zero-mean RV $X$, probability of being positive using moments
We can find find in literature (F.D. Lesley and V. Rotar) that:
$$P (X \geq 0) \geq \frac{2 \sqrt {3}-3}{E (X^4)}$$
if X has variance equal to 1. What is left for you to do is find out how this inequality scales when that condition is not true, and maybe see whether the $X\geq0$ instead of $X>0$ is not troubling.
|
Zero-mean RV $X$, probability of being positive using moments
We can find find in literature (F.D. Lesley and V. Rotar) that:
$$P (X \geq 0) \geq \frac{2 \sqrt {3}-3}{E (X^4)}$$
if X has variance equal to 1. What is left for you to do is find out how this inequa
|
50,878 |
Equivalent Gradients in Kernelized SVM
|
The second method is valid. It will converge because like you said, the problem is convex in terms of $\alpha$. However the two methods will not follow the same trajectory.
The two methods are related via preconditioning. Section 4 of the Pegasos paper has some commentary on this. I give an explicit description of this preconditioning below.
Since $G$ is positive semi-definite, let $\sqrt{G}$ be its principal square root.
Let $\beta = \sqrt{G}\alpha$ and define
$$
\begin{align}
\mathcal{L}_\alpha(\alpha)
&= \frac{\lambda}{2} \alpha^T G \alpha
+ \frac{1}{m} \sum_{i=1}^{m} \max\left\lbrace
0, 1 - y_i \alpha^T G e_i
\right\rbrace \\
= \mathcal{L}_\beta(\beta)
&= \frac{\lambda}{2} \beta^T \beta
+ \frac{1}{m} \sum_{i=1}^{m} \max\left\lbrace
0, 1 - y_i \beta^T \sqrt{G} e_i
\right\rbrace.
\end{align}
$$
This means
$$
\begin{align}
\nabla \mathcal{L}_\beta(\beta)
&= \lambda \beta
+ \frac{1}{m} \sum_{i=1}^{m}
- y_i \sqrt{G} e_i
\cdot 1_\left\lbrace y_i\left<w,\varphi\left(x_i\right)\right><1\right\rbrace
\\
&=
\sqrt{G} \left( \lambda \alpha
+ \frac{1}{m} \sum_{i=1}^{m}
- y_i e_i
\cdot 1_\left\lbrace y_i\left<w,\varphi\left(x_i\right)\right><1\right\rbrace
\right).
\end{align}
$$
Now moving a displacement $\sqrt{G} d$ in $\beta$-space is equivalent to moving a displacement $d$ in $\alpha$-space. Thus moving in $\beta$-space a displacement of $\eta \cdot \nabla \mathcal{L}_\beta(\beta)$ is equivalent to moving in $\alpha$-space a displacement of
$$
\eta \cdot \left(
\lambda \alpha
+ \frac{1}{m} \sum_{i=1}^{m}
- y_i e_i
\cdot 1_\left\lbrace y_i\left<w,\varphi\left(x_i\right)\right><1\right\rbrace
\right).
$$
This last update is equivalent to the update of $\alpha$ when optimizing on $w$.
|
Equivalent Gradients in Kernelized SVM
|
The second method is valid. It will converge because like you said, the problem is convex in terms of $\alpha$. However the two methods will not follow the same trajectory.
The two methods are relate
|
Equivalent Gradients in Kernelized SVM
The second method is valid. It will converge because like you said, the problem is convex in terms of $\alpha$. However the two methods will not follow the same trajectory.
The two methods are related via preconditioning. Section 4 of the Pegasos paper has some commentary on this. I give an explicit description of this preconditioning below.
Since $G$ is positive semi-definite, let $\sqrt{G}$ be its principal square root.
Let $\beta = \sqrt{G}\alpha$ and define
$$
\begin{align}
\mathcal{L}_\alpha(\alpha)
&= \frac{\lambda}{2} \alpha^T G \alpha
+ \frac{1}{m} \sum_{i=1}^{m} \max\left\lbrace
0, 1 - y_i \alpha^T G e_i
\right\rbrace \\
= \mathcal{L}_\beta(\beta)
&= \frac{\lambda}{2} \beta^T \beta
+ \frac{1}{m} \sum_{i=1}^{m} \max\left\lbrace
0, 1 - y_i \beta^T \sqrt{G} e_i
\right\rbrace.
\end{align}
$$
This means
$$
\begin{align}
\nabla \mathcal{L}_\beta(\beta)
&= \lambda \beta
+ \frac{1}{m} \sum_{i=1}^{m}
- y_i \sqrt{G} e_i
\cdot 1_\left\lbrace y_i\left<w,\varphi\left(x_i\right)\right><1\right\rbrace
\\
&=
\sqrt{G} \left( \lambda \alpha
+ \frac{1}{m} \sum_{i=1}^{m}
- y_i e_i
\cdot 1_\left\lbrace y_i\left<w,\varphi\left(x_i\right)\right><1\right\rbrace
\right).
\end{align}
$$
Now moving a displacement $\sqrt{G} d$ in $\beta$-space is equivalent to moving a displacement $d$ in $\alpha$-space. Thus moving in $\beta$-space a displacement of $\eta \cdot \nabla \mathcal{L}_\beta(\beta)$ is equivalent to moving in $\alpha$-space a displacement of
$$
\eta \cdot \left(
\lambda \alpha
+ \frac{1}{m} \sum_{i=1}^{m}
- y_i e_i
\cdot 1_\left\lbrace y_i\left<w,\varphi\left(x_i\right)\right><1\right\rbrace
\right).
$$
This last update is equivalent to the update of $\alpha$ when optimizing on $w$.
|
Equivalent Gradients in Kernelized SVM
The second method is valid. It will converge because like you said, the problem is convex in terms of $\alpha$. However the two methods will not follow the same trajectory.
The two methods are relate
|
50,879 |
Interpretation of Constraint in Maximum Entropy Derivation of Cauchy distribution
|
I would say the result has been found backward, namely that, using the general property that the maximum entropy distribution under the constraint
$\mathbb{E}[f(X)]=\alpha$ is given by the density
$$\pi(x)=C\,\exp\{\lambda f(x)\}$$
when $C$ and $\lambda$ are determined by the conditions
$$\int_\mathcal{X} \exp\{\lambda f(x)\} \text{d}x = C^{-1}\quad
\text{and}\quad \int_\mathcal{X} f(x) \exp\{\lambda f(x)\} \text{d}x = \alpha C^{-1}$$(where $\text{d}x$ is understood as the chosen dominating measure (e.g., the Lebesgue measure).
Hence, if one wants an arbitrary distribution with density proportional to $\exp\{\lambda f(x)\}$ to become a maximum entropy distribution, it is enough to choose the constraint as $\mathbb{E}[f(X)]=\alpha$, or conversely to define $$f(x)=\log(\pi(x)$$ and find the value of $$\mathbb{E}[\log\pi(X)]$$
|
Interpretation of Constraint in Maximum Entropy Derivation of Cauchy distribution
|
I would say the result has been found backward, namely that, using the general property that the maximum entropy distribution under the constraint
$\mathbb{E}[f(X)]=\alpha$ is given by the density
$$\
|
Interpretation of Constraint in Maximum Entropy Derivation of Cauchy distribution
I would say the result has been found backward, namely that, using the general property that the maximum entropy distribution under the constraint
$\mathbb{E}[f(X)]=\alpha$ is given by the density
$$\pi(x)=C\,\exp\{\lambda f(x)\}$$
when $C$ and $\lambda$ are determined by the conditions
$$\int_\mathcal{X} \exp\{\lambda f(x)\} \text{d}x = C^{-1}\quad
\text{and}\quad \int_\mathcal{X} f(x) \exp\{\lambda f(x)\} \text{d}x = \alpha C^{-1}$$(where $\text{d}x$ is understood as the chosen dominating measure (e.g., the Lebesgue measure).
Hence, if one wants an arbitrary distribution with density proportional to $\exp\{\lambda f(x)\}$ to become a maximum entropy distribution, it is enough to choose the constraint as $\mathbb{E}[f(X)]=\alpha$, or conversely to define $$f(x)=\log(\pi(x)$$ and find the value of $$\mathbb{E}[\log\pi(X)]$$
|
Interpretation of Constraint in Maximum Entropy Derivation of Cauchy distribution
I would say the result has been found backward, namely that, using the general property that the maximum entropy distribution under the constraint
$\mathbb{E}[f(X)]=\alpha$ is given by the density
$$\
|
50,880 |
Number of components for Gaussian mixture model?
|
An alternative strategy is to test for Normality. If your data comes from a single Gaussian, you should fail to reject the null hypothesis. Conversely, if you get a statistically significant p-value for rejecting the null hypothesis, then you know that k > 1. This strategy can be easily generalized to the multi-variate case by performing PCA and testing each principal component separately.
Since you're working with R, I recommend you take a look at the nortest package.
|
Number of components for Gaussian mixture model?
|
An alternative strategy is to test for Normality. If your data comes from a single Gaussian, you should fail to reject the null hypothesis. Conversely, if you get a statistically significant p-value f
|
Number of components for Gaussian mixture model?
An alternative strategy is to test for Normality. If your data comes from a single Gaussian, you should fail to reject the null hypothesis. Conversely, if you get a statistically significant p-value for rejecting the null hypothesis, then you know that k > 1. This strategy can be easily generalized to the multi-variate case by performing PCA and testing each principal component separately.
Since you're working with R, I recommend you take a look at the nortest package.
|
Number of components for Gaussian mixture model?
An alternative strategy is to test for Normality. If your data comes from a single Gaussian, you should fail to reject the null hypothesis. Conversely, if you get a statistically significant p-value f
|
50,881 |
Unbiased estimator of distribution function in two-stage randomization design
|
This question contains a lot of background material, but most of it is not relevant for answering the questions you pose.
This is a two stage trial. The initial treatment $A$ has two levels $A_1$ and $A_2$. However, as explained in the paper, patients randomized to $A_1$ and $A_2$ form two independent samples, so I'm going to restrict (as in the paper) to patients randomized to $A_1$. How are the data for such a patient modelled? Well, in the paper the data for such a patient are generated from an IID realisation of the set of variables $(R,Z,T_1,T_2,C)$, where $R$ is an indicator for successful continuation to the second stage, $Z$ is an indicator for which second stage treatment is applied, $T_1,T_2$ are the potential survival times under the two potential second stage treatments, and $C$ is a censoring time which is independent of the other variables. All the quantities in your equations are functions of the set of variables $(R,Z,T_1,T_2,C)$ (NB I'm omitting the $i$ subscripts here which link variables to specific patients.).
In $\mathbb E[\frac{\Delta_i Q_{1i}}{K(V_i)}I(V_i\le t)]$ no variable is singled out as one over which the expectation is being taken. This usually means that the expectation is over the joint distribution of the variables $(R,Z,T_1,T_2,C)$. See this answer for a good explanation of the precise meaning of this. The same applies to your other questions about expectations - they're all expectations over the joint distribution of all variables involved.
There are also some conditional expectations e.g. $\mathbb E\{ I(T_{11i}<C_i)|R_i,Z_i,T_{11i}\}=K(T_{11i})$. How does this work? Intuitively, we think of any variable we condition on as being constant. In this case $T_{11i}$ is regarded as constant, but $C_i$ is independent of the variables on which we are conditioning (so is unaffected by the conditioning), so the conditional expectation evaluates to $\mathbb E(I(t_{11i}<C_i))=\mathbb P(C_i>t_{11i})=K(t_{11i})$ where $t_{11i}$ is the value of $T_{11i}$ which we're thinking of as constant. (More rigorously: see this answer.)
Here's a simple example of what's going on with the conditional expectation. Suppose $X$ and $Y$ are continuous IID random variables with cdf $F$. By symmetry we know that $P(X>Y)=\frac{1}{2}$. However this can also be calculated by conditioning. In fact $P(X>Y)=\mathbb E(I(X>Y))=\mathbb E(\mathbb E(I(X>Y)|Y))$. In the conditional expectation we think of $Y$ as constant so we just integrate over $X$ to get $1-F(Y)$. Hence $\mathbb E(\mathbb E(I(X>Y)|Y))$ reduces to $\mathbb E(1-F(Y))$. Since $F(Y)$ is uniform on $[0,1]$ this evaluates to $\frac{1}{2}$.
As for the last question, linearity of expectation implies that $\mathbb E[n^{-1}\sum_{i=1}^{n}\frac{\Delta_i Q_{ki}}{ K(V_i)}I(V_i\le t)]=F_{1k}(t)$. However, I don't think you can easily replace $K$ by its estimator $\hat K$ in this - which is why they don't try to do this in the paper. Still, what they've shown suggests that $\hat F_{1k}(t)$ is a useful estimator.
|
Unbiased estimator of distribution function in two-stage randomization design
|
This question contains a lot of background material, but most of it is not relevant for answering the questions you pose.
This is a two stage trial. The initial treatment $A$ has two levels $A_1$ and
|
Unbiased estimator of distribution function in two-stage randomization design
This question contains a lot of background material, but most of it is not relevant for answering the questions you pose.
This is a two stage trial. The initial treatment $A$ has two levels $A_1$ and $A_2$. However, as explained in the paper, patients randomized to $A_1$ and $A_2$ form two independent samples, so I'm going to restrict (as in the paper) to patients randomized to $A_1$. How are the data for such a patient modelled? Well, in the paper the data for such a patient are generated from an IID realisation of the set of variables $(R,Z,T_1,T_2,C)$, where $R$ is an indicator for successful continuation to the second stage, $Z$ is an indicator for which second stage treatment is applied, $T_1,T_2$ are the potential survival times under the two potential second stage treatments, and $C$ is a censoring time which is independent of the other variables. All the quantities in your equations are functions of the set of variables $(R,Z,T_1,T_2,C)$ (NB I'm omitting the $i$ subscripts here which link variables to specific patients.).
In $\mathbb E[\frac{\Delta_i Q_{1i}}{K(V_i)}I(V_i\le t)]$ no variable is singled out as one over which the expectation is being taken. This usually means that the expectation is over the joint distribution of the variables $(R,Z,T_1,T_2,C)$. See this answer for a good explanation of the precise meaning of this. The same applies to your other questions about expectations - they're all expectations over the joint distribution of all variables involved.
There are also some conditional expectations e.g. $\mathbb E\{ I(T_{11i}<C_i)|R_i,Z_i,T_{11i}\}=K(T_{11i})$. How does this work? Intuitively, we think of any variable we condition on as being constant. In this case $T_{11i}$ is regarded as constant, but $C_i$ is independent of the variables on which we are conditioning (so is unaffected by the conditioning), so the conditional expectation evaluates to $\mathbb E(I(t_{11i}<C_i))=\mathbb P(C_i>t_{11i})=K(t_{11i})$ where $t_{11i}$ is the value of $T_{11i}$ which we're thinking of as constant. (More rigorously: see this answer.)
Here's a simple example of what's going on with the conditional expectation. Suppose $X$ and $Y$ are continuous IID random variables with cdf $F$. By symmetry we know that $P(X>Y)=\frac{1}{2}$. However this can also be calculated by conditioning. In fact $P(X>Y)=\mathbb E(I(X>Y))=\mathbb E(\mathbb E(I(X>Y)|Y))$. In the conditional expectation we think of $Y$ as constant so we just integrate over $X$ to get $1-F(Y)$. Hence $\mathbb E(\mathbb E(I(X>Y)|Y))$ reduces to $\mathbb E(1-F(Y))$. Since $F(Y)$ is uniform on $[0,1]$ this evaluates to $\frac{1}{2}$.
As for the last question, linearity of expectation implies that $\mathbb E[n^{-1}\sum_{i=1}^{n}\frac{\Delta_i Q_{ki}}{ K(V_i)}I(V_i\le t)]=F_{1k}(t)$. However, I don't think you can easily replace $K$ by its estimator $\hat K$ in this - which is why they don't try to do this in the paper. Still, what they've shown suggests that $\hat F_{1k}(t)$ is a useful estimator.
|
Unbiased estimator of distribution function in two-stage randomization design
This question contains a lot of background material, but most of it is not relevant for answering the questions you pose.
This is a two stage trial. The initial treatment $A$ has two levels $A_1$ and
|
50,882 |
Autocorrelation and heteroskedasticity in time series data
|
We have seen residual plots such as yours when untreated deterministic effects are present. These might include hourly or daily effects. Care should be taken to identify and incorporate any needed effects like Pulses,Level Shifts,Seasonal Pulses and/or Local Time Trends . Needed ARIMA Structure suggested by model diagnostics should also be included. At that point consider testing for constancy of parameters over time as parameters may have changed OR testing for constancy of error variance over time . Non-constant error variance over time can be remedied by the TSAY test as described here http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html or the classic Box-Cox test . The TSAY test should be implemented first as it is the least intrusive transformation.
The correct Transfer Function identification procedure using pre-whitened cross-correlations in conjunction with the above should lead to a useful model. The process I have described here is fundamentally what I incorporated into AUTOBOX, a piece of software that I have helped to develop. You could attempt to program this yourself but it might be time consuming.
EDITED AFTER COMMENT BY OP
The ACF of the residuals from a tentative model is suggestive of the need to augment your current model with arima structure. The ccf of residuals from a tentative model and a prewhitened X variable suggests possible improvements in the TF structure. Yes to "see the initial lags" you use the CCF https://web.archive.org/web/20160216193539/https://onlinecourses.science.psu.edu/stat510/node/75/ and Why is prewhitening important?. It is literally a minefield of possible ways to do it rong which is why I automated the process. The automation doesn't guarantee optimality but it does clear the path. Advice from non-time series experts in this area should be studiously avoided as your problem can be daunting.
http://autobox.com/cms/images/dllupdate/TFFLOW.png is a start ... where one would add before forecasting checks for 1) constancy of parameters and 2) constancy of the variance of the error process . Now that you have a work statement (flow diagram) the next part is to implement it either manually or with creative productivity aids.
This is (somewhat) repetitive but ....
1.stationarity conditions i.e. the order of differences for both X and Y
2.the form of the X component in terms of needed lags i.e. numerator and denominator structure
3.the required arma
4.the need for Intervention detected variables viz. Pulses, Level Shifts, Seasonal Pulses, Local Time Trends
5.the need to deal with evidented parameter changes over time
6.the need to deal with evidented deterministic variance changes requiring Weighted Least Squares
7.the need to deal with evidented variance changes that are level dependent requiring a Power Transform
|
Autocorrelation and heteroskedasticity in time series data
|
We have seen residual plots such as yours when untreated deterministic effects are present. These might include hourly or daily effects. Care should be taken to identify and incorporate any needed eff
|
Autocorrelation and heteroskedasticity in time series data
We have seen residual plots such as yours when untreated deterministic effects are present. These might include hourly or daily effects. Care should be taken to identify and incorporate any needed effects like Pulses,Level Shifts,Seasonal Pulses and/or Local Time Trends . Needed ARIMA Structure suggested by model diagnostics should also be included. At that point consider testing for constancy of parameters over time as parameters may have changed OR testing for constancy of error variance over time . Non-constant error variance over time can be remedied by the TSAY test as described here http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html or the classic Box-Cox test . The TSAY test should be implemented first as it is the least intrusive transformation.
The correct Transfer Function identification procedure using pre-whitened cross-correlations in conjunction with the above should lead to a useful model. The process I have described here is fundamentally what I incorporated into AUTOBOX, a piece of software that I have helped to develop. You could attempt to program this yourself but it might be time consuming.
EDITED AFTER COMMENT BY OP
The ACF of the residuals from a tentative model is suggestive of the need to augment your current model with arima structure. The ccf of residuals from a tentative model and a prewhitened X variable suggests possible improvements in the TF structure. Yes to "see the initial lags" you use the CCF https://web.archive.org/web/20160216193539/https://onlinecourses.science.psu.edu/stat510/node/75/ and Why is prewhitening important?. It is literally a minefield of possible ways to do it rong which is why I automated the process. The automation doesn't guarantee optimality but it does clear the path. Advice from non-time series experts in this area should be studiously avoided as your problem can be daunting.
http://autobox.com/cms/images/dllupdate/TFFLOW.png is a start ... where one would add before forecasting checks for 1) constancy of parameters and 2) constancy of the variance of the error process . Now that you have a work statement (flow diagram) the next part is to implement it either manually or with creative productivity aids.
This is (somewhat) repetitive but ....
1.stationarity conditions i.e. the order of differences for both X and Y
2.the form of the X component in terms of needed lags i.e. numerator and denominator structure
3.the required arma
4.the need for Intervention detected variables viz. Pulses, Level Shifts, Seasonal Pulses, Local Time Trends
5.the need to deal with evidented parameter changes over time
6.the need to deal with evidented deterministic variance changes requiring Weighted Least Squares
7.the need to deal with evidented variance changes that are level dependent requiring a Power Transform
|
Autocorrelation and heteroskedasticity in time series data
We have seen residual plots such as yours when untreated deterministic effects are present. These might include hourly or daily effects. Care should be taken to identify and incorporate any needed eff
|
50,883 |
Dependent count variable with negative values
|
While the number of managers before and after are count variables, your dependent variable no longer is: Counts can't be negative, after all. So you don't need to use either poisson or negative binomial.
|
Dependent count variable with negative values
|
While the number of managers before and after are count variables, your dependent variable no longer is: Counts can't be negative, after all. So you don't need to use either poisson or negative binomi
|
Dependent count variable with negative values
While the number of managers before and after are count variables, your dependent variable no longer is: Counts can't be negative, after all. So you don't need to use either poisson or negative binomial.
|
Dependent count variable with negative values
While the number of managers before and after are count variables, your dependent variable no longer is: Counts can't be negative, after all. So you don't need to use either poisson or negative binomi
|
50,884 |
Dependent count variable with negative values
|
For this kind of analysis I would suggest that you follow whuber's advice in his comment, and track the individual counts of the number of managers before and after each change. It should not be too hard to create a GLM that uses the non-negative count variable managers as the response variable and uses a binary indicator investment to indicate whether or not an investment round occurred. This kind of model would have a coefficient for the effect of the investment round on the count of managers, and this coefficient could be positive or negative.
Since your underlying count values for this kind of model would be non-negative integers, a good place to start would be a standard negative binomial GLM. You could program this in R as shown below. If you are able to add some of your data, and give some additional information on other covariates, we could have a look at what you get.
library(MASS)
MODEL <- glm.nb(managers ~ 1 + investment + covariates, data = DATA_FRAME);
|
Dependent count variable with negative values
|
For this kind of analysis I would suggest that you follow whuber's advice in his comment, and track the individual counts of the number of managers before and after each change. It should not be too
|
Dependent count variable with negative values
For this kind of analysis I would suggest that you follow whuber's advice in his comment, and track the individual counts of the number of managers before and after each change. It should not be too hard to create a GLM that uses the non-negative count variable managers as the response variable and uses a binary indicator investment to indicate whether or not an investment round occurred. This kind of model would have a coefficient for the effect of the investment round on the count of managers, and this coefficient could be positive or negative.
Since your underlying count values for this kind of model would be non-negative integers, a good place to start would be a standard negative binomial GLM. You could program this in R as shown below. If you are able to add some of your data, and give some additional information on other covariates, we could have a look at what you get.
library(MASS)
MODEL <- glm.nb(managers ~ 1 + investment + covariates, data = DATA_FRAME);
|
Dependent count variable with negative values
For this kind of analysis I would suggest that you follow whuber's advice in his comment, and track the individual counts of the number of managers before and after each change. It should not be too
|
50,885 |
Dependent count variable with negative values
|
Y is not actually a count - counts can only have positive values. It's a difference, which is, well, different.
One option would be to treat Y as a continuous variable and use ordinary least squares regression. Another would be to add 5 to Y and use a count regression model. You could try both and see if the results are similar.
|
Dependent count variable with negative values
|
Y is not actually a count - counts can only have positive values. It's a difference, which is, well, different.
One option would be to treat Y as a continuous variable and use ordinary least squares
|
Dependent count variable with negative values
Y is not actually a count - counts can only have positive values. It's a difference, which is, well, different.
One option would be to treat Y as a continuous variable and use ordinary least squares regression. Another would be to add 5 to Y and use a count regression model. You could try both and see if the results are similar.
|
Dependent count variable with negative values
Y is not actually a count - counts can only have positive values. It's a difference, which is, well, different.
One option would be to treat Y as a continuous variable and use ordinary least squares
|
50,886 |
Batch normalization: How to update gamma and beta during backpropagation training step?
|
Your intuition is correct. You can use gradient descent to update any parameter in your network. So as long as you can compute the gradient of the loss function with respect to that parameter (using backpropagation). Gamma and Beta of batch normalization layers are no exceptions.
|
Batch normalization: How to update gamma and beta during backpropagation training step?
|
Your intuition is correct. You can use gradient descent to update any parameter in your network. So as long as you can compute the gradient of the loss function with respect to that parameter (using b
|
Batch normalization: How to update gamma and beta during backpropagation training step?
Your intuition is correct. You can use gradient descent to update any parameter in your network. So as long as you can compute the gradient of the loss function with respect to that parameter (using backpropagation). Gamma and Beta of batch normalization layers are no exceptions.
|
Batch normalization: How to update gamma and beta during backpropagation training step?
Your intuition is correct. You can use gradient descent to update any parameter in your network. So as long as you can compute the gradient of the loss function with respect to that parameter (using b
|
50,887 |
Functions of continuous random variables
|
First of all,
$$ P[W \le w] = P[Y^3 \le w] = P[Y \le w^{1/3}] = 1- e^\frac{-w^{1/3} }{t}$$
ie. this is a function of W not Y.
Second, as said in the comments your logic is right but your integral is wrong.
We have the expression
$$ \int_0^{w^{1/3}} \frac{1}{t} e^{-y/t} dy $$
Let $$u = \frac{-y}{t} $$
and you get the expression
$$ - \int_0^{-\frac{w^{1/3}}{t}} e^u du$$
Finish this integration and you arrive at the answer.
|
Functions of continuous random variables
|
First of all,
$$ P[W \le w] = P[Y^3 \le w] = P[Y \le w^{1/3}] = 1- e^\frac{-w^{1/3} }{t}$$
ie. this is a function of W not Y.
Second, as said in the comments your logic is right but your integral is w
|
Functions of continuous random variables
First of all,
$$ P[W \le w] = P[Y^3 \le w] = P[Y \le w^{1/3}] = 1- e^\frac{-w^{1/3} }{t}$$
ie. this is a function of W not Y.
Second, as said in the comments your logic is right but your integral is wrong.
We have the expression
$$ \int_0^{w^{1/3}} \frac{1}{t} e^{-y/t} dy $$
Let $$u = \frac{-y}{t} $$
and you get the expression
$$ - \int_0^{-\frac{w^{1/3}}{t}} e^u du$$
Finish this integration and you arrive at the answer.
|
Functions of continuous random variables
First of all,
$$ P[W \le w] = P[Y^3 \le w] = P[Y \le w^{1/3}] = 1- e^\frac{-w^{1/3} }{t}$$
ie. this is a function of W not Y.
Second, as said in the comments your logic is right but your integral is w
|
50,888 |
HMM for multichannel - multivariate data
|
One option:
I worked on this exact same problem couple of years ago. The mixed data I was working with were multivariate with some of the dimensions being categorical and some other continuous.
The trick has been to modify the equations of the Baum-Welch approach so it can handle both types of data. For instance, the responsibilities (outputs of the forward-backward algorithm) are approximated from "local responsibilities" that are computed with respect to each type of input (then considering data of smaller dimension then = number of dimensions of a sample being of one type). Then these approximated responsibilities are used for updating the HMM parameters. The distributions parameters though, have to be updated with respect to data of each type. Then a "global" HMM likelihood can be computed for convergence checking.
This was part of my PhD work, and the entire approach is reported in this paper:
Hybrid hidden Markov model for mixed continuous/continuous and discrete/continuous data modeling. E. Epaillard, N. Bouguila, MMSP'15, pp. 1-6
You will find no library for this as no method existed at the time I did this work (at least to the best of my knowledge). I was planning to release all my codes in the next few weeks, as I am completing my degree. My implementation is in Matlab and my code quite not documented at this time. However, if this could be of some help for you, I could release the code earlier. Just ask me in the comments.
Another option:
Also, if your data is of mixed types due to the fact it comes from different sources of information. Then I would have a look at multi-stream HMMs. I am not sure whether these models work for discrete/continuous mixed data though, but in the end, I found my approach to be somehow related to the theory behind multi-stream HMMs.
Multi-stream HMMs seems to also be a type of model that is so far mostly used in research and not implemented in main libraries (let's remember that it is already hard to find HMM other than Gaussian-based in libraries...). I find the theory behind these models quite difficult to understand (a lot of optimization going on). Maybe you have a chance to find some implementation by going through the list of the authors of the main papers on the topic, go through their personal websites and see whether they shared their codes or not.
|
HMM for multichannel - multivariate data
|
One option:
I worked on this exact same problem couple of years ago. The mixed data I was working with were multivariate with some of the dimensions being categorical and some other continuous.
The tr
|
HMM for multichannel - multivariate data
One option:
I worked on this exact same problem couple of years ago. The mixed data I was working with were multivariate with some of the dimensions being categorical and some other continuous.
The trick has been to modify the equations of the Baum-Welch approach so it can handle both types of data. For instance, the responsibilities (outputs of the forward-backward algorithm) are approximated from "local responsibilities" that are computed with respect to each type of input (then considering data of smaller dimension then = number of dimensions of a sample being of one type). Then these approximated responsibilities are used for updating the HMM parameters. The distributions parameters though, have to be updated with respect to data of each type. Then a "global" HMM likelihood can be computed for convergence checking.
This was part of my PhD work, and the entire approach is reported in this paper:
Hybrid hidden Markov model for mixed continuous/continuous and discrete/continuous data modeling. E. Epaillard, N. Bouguila, MMSP'15, pp. 1-6
You will find no library for this as no method existed at the time I did this work (at least to the best of my knowledge). I was planning to release all my codes in the next few weeks, as I am completing my degree. My implementation is in Matlab and my code quite not documented at this time. However, if this could be of some help for you, I could release the code earlier. Just ask me in the comments.
Another option:
Also, if your data is of mixed types due to the fact it comes from different sources of information. Then I would have a look at multi-stream HMMs. I am not sure whether these models work for discrete/continuous mixed data though, but in the end, I found my approach to be somehow related to the theory behind multi-stream HMMs.
Multi-stream HMMs seems to also be a type of model that is so far mostly used in research and not implemented in main libraries (let's remember that it is already hard to find HMM other than Gaussian-based in libraries...). I find the theory behind these models quite difficult to understand (a lot of optimization going on). Maybe you have a chance to find some implementation by going through the list of the authors of the main papers on the topic, go through their personal websites and see whether they shared their codes or not.
|
HMM for multichannel - multivariate data
One option:
I worked on this exact same problem couple of years ago. The mixed data I was working with were multivariate with some of the dimensions being categorical and some other continuous.
The tr
|
50,889 |
What is the point of putting two lstm cells one after another? [duplicate]
|
One layer only has one cell. For more information read this. And the stacked multi-layer LSTM model is for extracting more abstract information. I think this question and this answer have explained this issue in detail.
|
What is the point of putting two lstm cells one after another? [duplicate]
|
One layer only has one cell. For more information read this. And the stacked multi-layer LSTM model is for extracting more abstract information. I think this question and this answer have explained th
|
What is the point of putting two lstm cells one after another? [duplicate]
One layer only has one cell. For more information read this. And the stacked multi-layer LSTM model is for extracting more abstract information. I think this question and this answer have explained this issue in detail.
|
What is the point of putting two lstm cells one after another? [duplicate]
One layer only has one cell. For more information read this. And the stacked multi-layer LSTM model is for extracting more abstract information. I think this question and this answer have explained th
|
50,890 |
mean and variance of norm of normal random variables
|
The distribution you are looking for relates to the convolution of two non-central chi-squared distributions each with one degree-of-freedom (which is a nasty one). Squaring the norm gives you:
$$\begin{align}
R^2
&= X^2 + Y^2 \\[6pt]
&= \sigma_x^2 \Big( \frac{X}{\sigma_x} \Big)^2 + \sigma_y^2 \Big( \frac{Y}{\sigma_y} \Big)^2 \\[6pt]
&\sim \sigma_x^2 \cdot \text{ChiSq}\Big(\frac{\mu_x}{\sigma_x}, 1\Big)^2 + \sigma_y^2 \cdot \text{ChiSq}\Big(\frac{\mu_y}{\sigma_y}, 1\Big)^2. \\[6pt]
\end{align}$$
There is no closed form expression for this distribution. However, it has the characteristic function:
$$\phi_{R^2}(t) = \frac{1}{1-2it} \cdot \exp \Big( \frac{it}{1-2it} \Big(\frac{\mu_x}{\sigma_x} + \frac{\mu_y}{\sigma_y} \Big) \Big).$$
|
mean and variance of norm of normal random variables
|
The distribution you are looking for relates to the convolution of two non-central chi-squared distributions each with one degree-of-freedom (which is a nasty one). Squaring the norm gives you:
$$\be
|
mean and variance of norm of normal random variables
The distribution you are looking for relates to the convolution of two non-central chi-squared distributions each with one degree-of-freedom (which is a nasty one). Squaring the norm gives you:
$$\begin{align}
R^2
&= X^2 + Y^2 \\[6pt]
&= \sigma_x^2 \Big( \frac{X}{\sigma_x} \Big)^2 + \sigma_y^2 \Big( \frac{Y}{\sigma_y} \Big)^2 \\[6pt]
&\sim \sigma_x^2 \cdot \text{ChiSq}\Big(\frac{\mu_x}{\sigma_x}, 1\Big)^2 + \sigma_y^2 \cdot \text{ChiSq}\Big(\frac{\mu_y}{\sigma_y}, 1\Big)^2. \\[6pt]
\end{align}$$
There is no closed form expression for this distribution. However, it has the characteristic function:
$$\phi_{R^2}(t) = \frac{1}{1-2it} \cdot \exp \Big( \frac{it}{1-2it} \Big(\frac{\mu_x}{\sigma_x} + \frac{\mu_y}{\sigma_y} \Big) \Big).$$
|
mean and variance of norm of normal random variables
The distribution you are looking for relates to the convolution of two non-central chi-squared distributions each with one degree-of-freedom (which is a nasty one). Squaring the norm gives you:
$$\be
|
50,891 |
mean and variance of norm of normal random variables
|
If $x$ and $y$ are independent, $\mu_x=\mu_y=0$ and $\sigma_x=\sigma_y=\sigma$, $r$ follows a Rayleigh distribution, thus:
$$ \begin{align}
& E[r] = \sigma \sqrt{\frac{\pi}{2}}
\\[6pt]
& V[r] = \frac{4-\pi}{2}\sigma^2
\end{align} $$
|
mean and variance of norm of normal random variables
|
If $x$ and $y$ are independent, $\mu_x=\mu_y=0$ and $\sigma_x=\sigma_y=\sigma$, $r$ follows a Rayleigh distribution, thus:
$$ \begin{align}
& E[r] = \sigma \sqrt{\frac{\pi}{2}}
\\[6pt]
& V[r] = \frac{
|
mean and variance of norm of normal random variables
If $x$ and $y$ are independent, $\mu_x=\mu_y=0$ and $\sigma_x=\sigma_y=\sigma$, $r$ follows a Rayleigh distribution, thus:
$$ \begin{align}
& E[r] = \sigma \sqrt{\frac{\pi}{2}}
\\[6pt]
& V[r] = \frac{4-\pi}{2}\sigma^2
\end{align} $$
|
mean and variance of norm of normal random variables
If $x$ and $y$ are independent, $\mu_x=\mu_y=0$ and $\sigma_x=\sigma_y=\sigma$, $r$ follows a Rayleigh distribution, thus:
$$ \begin{align}
& E[r] = \sigma \sqrt{\frac{\pi}{2}}
\\[6pt]
& V[r] = \frac{
|
50,892 |
mean and variance of norm of normal random variables
|
Use the polar coordinates transformation if you're good at integrating.
Define
$$
\left[\begin{array}{c}
R \\
\theta
\end{array} \right]
=
\left[\begin{array}{c}
\sqrt{X^2 + Y^2} \\
\text{arctan}(\theta)
\end{array} \right],
$$
which means
$$
\left[\begin{array}{c}
X \\
Y
\end{array} \right]
=
\left[\begin{array}{c}
R \cos(\theta) \\
R\sin(\theta)
\end{array} \right].
$$
Use the transformation theorem to get the joint density $g_{R,\theta}(r,t)$, then integrate out $t$. Using that, you can get whatever moment you want. At the moment I'm having a hard time integrating out $t$, though.
I get a joint densty of
$$
g_{R,\theta}(r,t) = \frac{r}{2\pi \sigma_x \sigma_y}\exp\left[-\frac{h(r,t)}{2} \right]
$$
with
$$
h(r,t) = \frac{r^2\cos^2(t) + \mu_x^2 - 2\mu_xr\cos(t)}{\sigma^2_x} + \frac{r^2\sin(t) + \mu_y^2 -2\mu_yr\sin(t)}{\sigma^2_y},
$$
and $0 < r$ and $0 < t < 2\pi$. You can see how that will simplify if the variances are the same, and if the means are zero. This was mentioned in the other answer. Those two fractions inside the exponential will add nicely and a lot of terms will cancel, and you can use a trigonometric property--the whole function will be free of $t$.
But you're interested in the general case. Not sure, maybe someone good at mathematica can step in here.
NB: a few differences in notation: I'm using capital letters, and $\sigma^2$s for the variance.
|
mean and variance of norm of normal random variables
|
Use the polar coordinates transformation if you're good at integrating.
Define
$$
\left[\begin{array}{c}
R \\
\theta
\end{array} \right]
=
\left[\begin{array}{c}
\sqrt{X^2 + Y^2} \\
\text{arctan}(\th
|
mean and variance of norm of normal random variables
Use the polar coordinates transformation if you're good at integrating.
Define
$$
\left[\begin{array}{c}
R \\
\theta
\end{array} \right]
=
\left[\begin{array}{c}
\sqrt{X^2 + Y^2} \\
\text{arctan}(\theta)
\end{array} \right],
$$
which means
$$
\left[\begin{array}{c}
X \\
Y
\end{array} \right]
=
\left[\begin{array}{c}
R \cos(\theta) \\
R\sin(\theta)
\end{array} \right].
$$
Use the transformation theorem to get the joint density $g_{R,\theta}(r,t)$, then integrate out $t$. Using that, you can get whatever moment you want. At the moment I'm having a hard time integrating out $t$, though.
I get a joint densty of
$$
g_{R,\theta}(r,t) = \frac{r}{2\pi \sigma_x \sigma_y}\exp\left[-\frac{h(r,t)}{2} \right]
$$
with
$$
h(r,t) = \frac{r^2\cos^2(t) + \mu_x^2 - 2\mu_xr\cos(t)}{\sigma^2_x} + \frac{r^2\sin(t) + \mu_y^2 -2\mu_yr\sin(t)}{\sigma^2_y},
$$
and $0 < r$ and $0 < t < 2\pi$. You can see how that will simplify if the variances are the same, and if the means are zero. This was mentioned in the other answer. Those two fractions inside the exponential will add nicely and a lot of terms will cancel, and you can use a trigonometric property--the whole function will be free of $t$.
But you're interested in the general case. Not sure, maybe someone good at mathematica can step in here.
NB: a few differences in notation: I'm using capital letters, and $\sigma^2$s for the variance.
|
mean and variance of norm of normal random variables
Use the polar coordinates transformation if you're good at integrating.
Define
$$
\left[\begin{array}{c}
R \\
\theta
\end{array} \right]
=
\left[\begin{array}{c}
\sqrt{X^2 + Y^2} \\
\text{arctan}(\th
|
50,893 |
t test p value vs randomization-inference p value: What can we learn from comparison?
|
I think your statement of the randomization inference null hypothesis is incorrect. Or at least, you're confusing two methods to test hypotheses versus two different hypotheses. The randomization test aka the permutation test considers the exact or approximation distribution of test statistics obtained when "labels" are randomly swapped between treatment/control subjects. This can be used to test the weak null hypothesis of no average treatment effect by calculating the t-test statistic for each permuted dataset and evaluating the proportion of these exceeding the one obtained in the unpermuted dataset.
In this working article they frame the hypothesis of treatment effect variation as one of homogeneity where the average treatment effect is considered a nuisance parameter: basically "I don't care whether this drug works, I just want to know if it works differently in some people than it does in others." The effect for the first hypothesis, tested using usually analysis of parallel design, is called average treatment effect (ATE) and the second hypothesis here has been called treatment effect variation (TEV). Testing for TEV smells of a test of effect modification, in the absence of a known effect modifier, and resembles subgroup analysis. Using randomization tests for TEV is a novel and interesting method to consider and is worth reading this article in depth to understand how exactly they formulated such a test.
To summarize how the two hypothesis might agree or disagree in a $2 \times 2$ table:
Case 1: ATE no TEV: the drug works and it has the same potential outcome in everybody regardless. Solution: do not recommend if harmful, consider effect size before recommending approval/use.
Case 2: no ATE no TEV: the drug does not work in anyone. Solution: conclude drug is futile relative to standard of care.
Case 3: no ATE, TEV: the drug works in individuals in such a contrived way that the harm in some and the benefit in others is completely balanced. Solution: identify indicators/contraindicators of harm/benefit subgroups and conduct follow-up study if predicted benefit is of clinical significance.
Case 4: ATE, TEV: the drug shows some average effect but this effect is not the same in everyone. Solution: identify harm groups if any and establish contraindications, predict benefit in remaining group and conduct follow-up study if it is of clinical significance.
|
t test p value vs randomization-inference p value: What can we learn from comparison?
|
I think your statement of the randomization inference null hypothesis is incorrect. Or at least, you're confusing two methods to test hypotheses versus two different hypotheses. The randomization test
|
t test p value vs randomization-inference p value: What can we learn from comparison?
I think your statement of the randomization inference null hypothesis is incorrect. Or at least, you're confusing two methods to test hypotheses versus two different hypotheses. The randomization test aka the permutation test considers the exact or approximation distribution of test statistics obtained when "labels" are randomly swapped between treatment/control subjects. This can be used to test the weak null hypothesis of no average treatment effect by calculating the t-test statistic for each permuted dataset and evaluating the proportion of these exceeding the one obtained in the unpermuted dataset.
In this working article they frame the hypothesis of treatment effect variation as one of homogeneity where the average treatment effect is considered a nuisance parameter: basically "I don't care whether this drug works, I just want to know if it works differently in some people than it does in others." The effect for the first hypothesis, tested using usually analysis of parallel design, is called average treatment effect (ATE) and the second hypothesis here has been called treatment effect variation (TEV). Testing for TEV smells of a test of effect modification, in the absence of a known effect modifier, and resembles subgroup analysis. Using randomization tests for TEV is a novel and interesting method to consider and is worth reading this article in depth to understand how exactly they formulated such a test.
To summarize how the two hypothesis might agree or disagree in a $2 \times 2$ table:
Case 1: ATE no TEV: the drug works and it has the same potential outcome in everybody regardless. Solution: do not recommend if harmful, consider effect size before recommending approval/use.
Case 2: no ATE no TEV: the drug does not work in anyone. Solution: conclude drug is futile relative to standard of care.
Case 3: no ATE, TEV: the drug works in individuals in such a contrived way that the harm in some and the benefit in others is completely balanced. Solution: identify indicators/contraindicators of harm/benefit subgroups and conduct follow-up study if predicted benefit is of clinical significance.
Case 4: ATE, TEV: the drug shows some average effect but this effect is not the same in everyone. Solution: identify harm groups if any and establish contraindications, predict benefit in remaining group and conduct follow-up study if it is of clinical significance.
|
t test p value vs randomization-inference p value: What can we learn from comparison?
I think your statement of the randomization inference null hypothesis is incorrect. Or at least, you're confusing two methods to test hypotheses versus two different hypotheses. The randomization test
|
50,894 |
t test p value vs randomization-inference p value: What can we learn from comparison?
|
I found this discussion of the difference between t-test p values and RI p values helpful, and it speaks to the question I ask above.
Author: Don Green
Source: https://egap.org/resource/10-things-to-know-about-randomization-inference/
Randomization inference may give different p-values from conventional tests when the number of observations is small and when the distribution of outcomes is non-normal
Conventional p-values typically rely on approximations that presuppose either that the outcomes are normally distributed or that the subject pool is large enough that the test statistics follow a posited sampling distribution. When outcomes are highly skewed, as in the case of donations (a few people donate large sums, but the overwhelming majority donate nothing), conventional methods may produce inaccurate p-values. Gerber and Green, Field Experiments, (2012, p.65) give the following example in which randomization inference and conventional test statistics produce different results:
|
t test p value vs randomization-inference p value: What can we learn from comparison?
|
I found this discussion of the difference between t-test p values and RI p values helpful, and it speaks to the question I ask above.
Author: Don Green
Source: https://egap.org/resource/10-things-to-k
|
t test p value vs randomization-inference p value: What can we learn from comparison?
I found this discussion of the difference between t-test p values and RI p values helpful, and it speaks to the question I ask above.
Author: Don Green
Source: https://egap.org/resource/10-things-to-know-about-randomization-inference/
Randomization inference may give different p-values from conventional tests when the number of observations is small and when the distribution of outcomes is non-normal
Conventional p-values typically rely on approximations that presuppose either that the outcomes are normally distributed or that the subject pool is large enough that the test statistics follow a posited sampling distribution. When outcomes are highly skewed, as in the case of donations (a few people donate large sums, but the overwhelming majority donate nothing), conventional methods may produce inaccurate p-values. Gerber and Green, Field Experiments, (2012, p.65) give the following example in which randomization inference and conventional test statistics produce different results:
|
t test p value vs randomization-inference p value: What can we learn from comparison?
I found this discussion of the difference between t-test p values and RI p values helpful, and it speaks to the question I ask above.
Author: Don Green
Source: https://egap.org/resource/10-things-to-k
|
50,895 |
Regression Trees' greedy algorithm in Hastie et al. (2009)
|
This simple example might illustrate why the 'greedy algorithm' is quicker than 'finding the best partition', but also why it can be less good.
Imagine a binary outcome with two features that follows the following rule: the outcome is A if feature 1 is non-negative and feature 2 is negative or feature 1 is negative and feature 2 is non-negative. The outcome is B in every other case.
The optimal partition is very obvious: if ((f1 >= 0) & (f2 < 0)): the outcome is A ifelse (f1 < 0) & (f2 >= 0: the outcome is A. else the outcome is B.
However, to get this outcome it is necessary to evaluate two subsequent rules jointly (both regarding the f1 feature and the f2 feature). In other words, two rules would be evaluated simultaneously. This can get increasingly complex as the number of features increases (in this stylised example it would not be such a problem). Therefore, the greedy algorithm only looks at the single best decision rule of the form feature > a that can be made next.
Now if the algorithm can only choose f1 or f2 and a single split point a, which is the greedy algorithm, it very much depends on the latent structure of the data which one would be picked first (just think of some possible data structures which include the four possibilities [(f1 <0 , f2 < 0), (f1 < 0, f2 >= 0, (f1 >= 0, f2 < 0, (f1 >= 0, f2 >= 0]. It will definitely be fast, because it 'only' has to evaluate two variables spaces and all possibly binary partitions.
The best partition would require evaluating all possible partitions of the first choice variable, and all possible subsequenty partition of the next etc. As you can imagine, this is much more complex than the greedy approach.
This difference in complexity is what the authors refer to.
|
Regression Trees' greedy algorithm in Hastie et al. (2009)
|
This simple example might illustrate why the 'greedy algorithm' is quicker than 'finding the best partition', but also why it can be less good.
Imagine a binary outcome with two features that follows
|
Regression Trees' greedy algorithm in Hastie et al. (2009)
This simple example might illustrate why the 'greedy algorithm' is quicker than 'finding the best partition', but also why it can be less good.
Imagine a binary outcome with two features that follows the following rule: the outcome is A if feature 1 is non-negative and feature 2 is negative or feature 1 is negative and feature 2 is non-negative. The outcome is B in every other case.
The optimal partition is very obvious: if ((f1 >= 0) & (f2 < 0)): the outcome is A ifelse (f1 < 0) & (f2 >= 0: the outcome is A. else the outcome is B.
However, to get this outcome it is necessary to evaluate two subsequent rules jointly (both regarding the f1 feature and the f2 feature). In other words, two rules would be evaluated simultaneously. This can get increasingly complex as the number of features increases (in this stylised example it would not be such a problem). Therefore, the greedy algorithm only looks at the single best decision rule of the form feature > a that can be made next.
Now if the algorithm can only choose f1 or f2 and a single split point a, which is the greedy algorithm, it very much depends on the latent structure of the data which one would be picked first (just think of some possible data structures which include the four possibilities [(f1 <0 , f2 < 0), (f1 < 0, f2 >= 0, (f1 >= 0, f2 < 0, (f1 >= 0, f2 >= 0]. It will definitely be fast, because it 'only' has to evaluate two variables spaces and all possibly binary partitions.
The best partition would require evaluating all possible partitions of the first choice variable, and all possible subsequenty partition of the next etc. As you can imagine, this is much more complex than the greedy approach.
This difference in complexity is what the authors refer to.
|
Regression Trees' greedy algorithm in Hastie et al. (2009)
This simple example might illustrate why the 'greedy algorithm' is quicker than 'finding the best partition', but also why it can be less good.
Imagine a binary outcome with two features that follows
|
50,896 |
Regression Trees' greedy algorithm in Hastie et al. (2009)
|
The difference between the squared error minimization that is done for each split in a decision tree and that is done for a typical $L_2$ loss optimization has 1 subtle distinction:
The decision tree splitting problem must search across possible partitions of the data into 2 groups and then find the optimal means within each of the 2 groups of split data. For all continuous data you have $\mathcal{O}(n)$ possible binary partitions of the feature and the response vector.
|
Regression Trees' greedy algorithm in Hastie et al. (2009)
|
The difference between the squared error minimization that is done for each split in a decision tree and that is done for a typical $L_2$ loss optimization has 1 subtle distinction:
The decision tree
|
Regression Trees' greedy algorithm in Hastie et al. (2009)
The difference between the squared error minimization that is done for each split in a decision tree and that is done for a typical $L_2$ loss optimization has 1 subtle distinction:
The decision tree splitting problem must search across possible partitions of the data into 2 groups and then find the optimal means within each of the 2 groups of split data. For all continuous data you have $\mathcal{O}(n)$ possible binary partitions of the feature and the response vector.
|
Regression Trees' greedy algorithm in Hastie et al. (2009)
The difference between the squared error minimization that is done for each split in a decision tree and that is done for a typical $L_2$ loss optimization has 1 subtle distinction:
The decision tree
|
50,897 |
Different estimates for over dispersion using Pearson or Deviance statistics in Poisson model
|
What about the descriptive statistics to confirm those results? Is the variance of your dependent variable higher than the mean? Here is the reference:
Ryan, W. H., Evers, E. R. K., & Moore, D. A. (2021). Poisson regressions: A little fishy. Collabra: Psychology, 7(1), 27242. https://doi.org/10.1525/collabra.27242
I haven't heard and can't find anything about Deviance, let alone a comparison of it to another. Here are resources I found that recommend the Pearson Chi Square χ2/df:
Coxe, S., West, S. G., & Aiken, L. S. (2009). The analysis of count data: A gentle introduction to Poisson regression and its alternatives. Journal of Personality Assessment, 91(2), 121–136. https://doi.org/10.1080/00223890802634175
Marin, M. (2020). Poisson regression: Overdispersion causes and solutions. https://www.youtube.com/watch?v=0W5QF_OnR7w
|
Different estimates for over dispersion using Pearson or Deviance statistics in Poisson model
|
What about the descriptive statistics to confirm those results? Is the variance of your dependent variable higher than the mean? Here is the reference:
Ryan, W. H., Evers, E. R. K., & Moore, D. A. (2
|
Different estimates for over dispersion using Pearson or Deviance statistics in Poisson model
What about the descriptive statistics to confirm those results? Is the variance of your dependent variable higher than the mean? Here is the reference:
Ryan, W. H., Evers, E. R. K., & Moore, D. A. (2021). Poisson regressions: A little fishy. Collabra: Psychology, 7(1), 27242. https://doi.org/10.1525/collabra.27242
I haven't heard and can't find anything about Deviance, let alone a comparison of it to another. Here are resources I found that recommend the Pearson Chi Square χ2/df:
Coxe, S., West, S. G., & Aiken, L. S. (2009). The analysis of count data: A gentle introduction to Poisson regression and its alternatives. Journal of Personality Assessment, 91(2), 121–136. https://doi.org/10.1080/00223890802634175
Marin, M. (2020). Poisson regression: Overdispersion causes and solutions. https://www.youtube.com/watch?v=0W5QF_OnR7w
|
Different estimates for over dispersion using Pearson or Deviance statistics in Poisson model
What about the descriptive statistics to confirm those results? Is the variance of your dependent variable higher than the mean? Here is the reference:
Ryan, W. H., Evers, E. R. K., & Moore, D. A. (2
|
50,898 |
XGBoost feature subsampling
|
You seem to fine-tune the wrong things.
On your feature selection:
I don't think that this is done properly:
You remove the good feature and all linearly correlated features. That's nice, but higher order correlated features are still there. On the other hand, strong correlation does not always mean that the feature is useless.
So you should keep the good feature in the set and remove all the features that are useless. The goal is to still have a high score in the end. This way you make sure you don't remove good features as you would notice it because the score decreases.
You should train a good model (at least once in a while) in order to know which features are helpful.
For the hyperparameter optimization:
you should fix some variables in the beginning (all except n_estimators), optimize (roughly) that parameter with a more fine grained grid (from 10 to 500 in steps of 20 for example).
My general suspicion: Way to many estimators, to low learning_rate (at this stage) and to shallow (set depth to 6). Try maybe the following:
eta = 0.2
n_estimators = [50...400]
subsample = [0.8]
depth = 6
and leave the rest as is. Of course, those depend strongly on the data.
A nice guide for XGBoost hyperparameter optimization can be found here.
So I'd propose you to redo the feature selection keeping the good features in the set and sometimes use a good XGBoost configuration by optimizing it. Do not forget to maybe create a small holdout set which you do not use in the feature selection. This can be used in the end to know the real performance.
|
XGBoost feature subsampling
|
You seem to fine-tune the wrong things.
On your feature selection:
I don't think that this is done properly:
You remove the good feature and all linearly correlated features. That's nice, but higher
|
XGBoost feature subsampling
You seem to fine-tune the wrong things.
On your feature selection:
I don't think that this is done properly:
You remove the good feature and all linearly correlated features. That's nice, but higher order correlated features are still there. On the other hand, strong correlation does not always mean that the feature is useless.
So you should keep the good feature in the set and remove all the features that are useless. The goal is to still have a high score in the end. This way you make sure you don't remove good features as you would notice it because the score decreases.
You should train a good model (at least once in a while) in order to know which features are helpful.
For the hyperparameter optimization:
you should fix some variables in the beginning (all except n_estimators), optimize (roughly) that parameter with a more fine grained grid (from 10 to 500 in steps of 20 for example).
My general suspicion: Way to many estimators, to low learning_rate (at this stage) and to shallow (set depth to 6). Try maybe the following:
eta = 0.2
n_estimators = [50...400]
subsample = [0.8]
depth = 6
and leave the rest as is. Of course, those depend strongly on the data.
A nice guide for XGBoost hyperparameter optimization can be found here.
So I'd propose you to redo the feature selection keeping the good features in the set and sometimes use a good XGBoost configuration by optimizing it. Do not forget to maybe create a small holdout set which you do not use in the feature selection. This can be used in the end to know the real performance.
|
XGBoost feature subsampling
You seem to fine-tune the wrong things.
On your feature selection:
I don't think that this is done properly:
You remove the good feature and all linearly correlated features. That's nice, but higher
|
50,899 |
How to understand "factor loadings" in PCA? [duplicate]
|
I believe your two plots are factor loadings given by PCA for the first two principal components.
The bar represents the magnitude for each variable "loaded" on the latent component
The bar also represent whether the loading is positive or negative
Based on the plots, I can see variable 4 and 6 are highly loaded on PC 1. Thus, we can say the variable 4 and 6 are similar on the PC 1. There must be something in the original data set that makes variable 4 and 6 similar. Note that all loadings on PC 1 are positive
We can also see variable 6 continues to dominate the PC 2. This is a variable you might find useful for modelling. A few variables are now negatively loaded on PC 2, but they are all less than 0.5.
Although variable 4 and 6 are highly loaded on the first PC, they are not exact copy of each other.
Variable 7, 8 and 9 might not be very important for your analysis because they have low factor loading on both plots.
When you do PCA, you should also get the variance explained by each PC.
|
How to understand "factor loadings" in PCA? [duplicate]
|
I believe your two plots are factor loadings given by PCA for the first two principal components.
The bar represents the magnitude for each variable "loaded" on the latent component
The bar also repr
|
How to understand "factor loadings" in PCA? [duplicate]
I believe your two plots are factor loadings given by PCA for the first two principal components.
The bar represents the magnitude for each variable "loaded" on the latent component
The bar also represent whether the loading is positive or negative
Based on the plots, I can see variable 4 and 6 are highly loaded on PC 1. Thus, we can say the variable 4 and 6 are similar on the PC 1. There must be something in the original data set that makes variable 4 and 6 similar. Note that all loadings on PC 1 are positive
We can also see variable 6 continues to dominate the PC 2. This is a variable you might find useful for modelling. A few variables are now negatively loaded on PC 2, but they are all less than 0.5.
Although variable 4 and 6 are highly loaded on the first PC, they are not exact copy of each other.
Variable 7, 8 and 9 might not be very important for your analysis because they have low factor loading on both plots.
When you do PCA, you should also get the variance explained by each PC.
|
How to understand "factor loadings" in PCA? [duplicate]
I believe your two plots are factor loadings given by PCA for the first two principal components.
The bar represents the magnitude for each variable "loaded" on the latent component
The bar also repr
|
50,900 |
Opinion polls during which voters are allowed to see accumulated intermediate result
|
There is some research in betting markets which are a form of opinion poll with money attached. See Soccermatics by David Sumpter, p229. The wisdom of crowds polling is based on each individual making an independent choice. If they see what others have done then the "wisdom" of the crowd is lost - they become a dumb herd (eg Brexit, Trump election). P226 of the book gives details of Andrew King's, Royal Veterinary College experiments (Biology Letters 8(2): 197-200) with guessing number of sweets in a jar but telling later entrants the mean of the guesses to date. There were 751 sweets, but earlier mean guesses were 1396 (the median value was spot on at 751). Later guessers thought 1396 too high but took note and only lowered their guesses to a mean of 1000.
|
Opinion polls during which voters are allowed to see accumulated intermediate result
|
There is some research in betting markets which are a form of opinion poll with money attached. See Soccermatics by David Sumpter, p229. The wisdom of crowds polling is based on each individual making
|
Opinion polls during which voters are allowed to see accumulated intermediate result
There is some research in betting markets which are a form of opinion poll with money attached. See Soccermatics by David Sumpter, p229. The wisdom of crowds polling is based on each individual making an independent choice. If they see what others have done then the "wisdom" of the crowd is lost - they become a dumb herd (eg Brexit, Trump election). P226 of the book gives details of Andrew King's, Royal Veterinary College experiments (Biology Letters 8(2): 197-200) with guessing number of sweets in a jar but telling later entrants the mean of the guesses to date. There were 751 sweets, but earlier mean guesses were 1396 (the median value was spot on at 751). Later guessers thought 1396 too high but took note and only lowered their guesses to a mean of 1000.
|
Opinion polls during which voters are allowed to see accumulated intermediate result
There is some research in betting markets which are a form of opinion poll with money attached. See Soccermatics by David Sumpter, p229. The wisdom of crowds polling is based on each individual making
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.