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
37,801
Confidence Intervals for the Parameters of a Logistic Growth Curve
The fitting function growthcurver::SummarizeGrowth is wrapped around Nonlinear Least Squares model minpack.lm::nlsLM, which provides statistics on parameter estimations similar to lm. The NLS model is returned in $mod and is consistent with the returned statistics for K, N0, r. So K, N0, r are in the sort of standard estimate +/- critical value*se form. The critical value is determined by the t distribution with the residual degree of freedom (sample size - # parameters). In the example below, the critical value is 2.010635. #example from the package library(growthcurver) set.seed(1) k_in <- 0.5 n0_in <- 1e-5 r_in <- 1.2 N <- 50 data_t <- 0:N * 24 / N data_n <- NAtT(k = k_in, n0 = n0_in, r = r_in, t = data_t) + rnorm(N+1, sd=k_in/10) #add noise # Model fit gc <- SummarizeGrowth(data_t, data_n) summary(gc$mod) # returned nlsLM model # Estimate Std. Error t value Pr(>|t|) #k 0.608629 0.013334 45.643 < 2e-16 *** #n0 0.005795 0.003208 1.806 0.0772 . #r 0.563808 0.068195 8.268 8.71e-11 *** #Residual standard error: 0.05935 on 48 degrees of freedom # Extracted p-value for n0 matches above gc$vals$n0_p > 0.07715446 # The p-value can be calculated by t-distribution pt(gc$vals$n0 / gc$vals$n0_se, df=gc$vals$df, lower.tail=FALSE) * 2 > 0.07715446 # 95% confidence interval by t-distribution qt(0.975, gc$vals$df) > 2.010635 gc$vals$n0 + qt(0.975, gc$vals$df) * gc$vals$n0_se > 0.01224516 gc$vals$n0 - qt(0.975, gc$vals$df) * gc$vals$n0_se > -0.0006557696
Confidence Intervals for the Parameters of a Logistic Growth Curve
The fitting function growthcurver::SummarizeGrowth is wrapped around Nonlinear Least Squares model minpack.lm::nlsLM, which provides statistics on parameter estimations similar to lm. The NLS model is
Confidence Intervals for the Parameters of a Logistic Growth Curve The fitting function growthcurver::SummarizeGrowth is wrapped around Nonlinear Least Squares model minpack.lm::nlsLM, which provides statistics on parameter estimations similar to lm. The NLS model is returned in $mod and is consistent with the returned statistics for K, N0, r. So K, N0, r are in the sort of standard estimate +/- critical value*se form. The critical value is determined by the t distribution with the residual degree of freedom (sample size - # parameters). In the example below, the critical value is 2.010635. #example from the package library(growthcurver) set.seed(1) k_in <- 0.5 n0_in <- 1e-5 r_in <- 1.2 N <- 50 data_t <- 0:N * 24 / N data_n <- NAtT(k = k_in, n0 = n0_in, r = r_in, t = data_t) + rnorm(N+1, sd=k_in/10) #add noise # Model fit gc <- SummarizeGrowth(data_t, data_n) summary(gc$mod) # returned nlsLM model # Estimate Std. Error t value Pr(>|t|) #k 0.608629 0.013334 45.643 < 2e-16 *** #n0 0.005795 0.003208 1.806 0.0772 . #r 0.563808 0.068195 8.268 8.71e-11 *** #Residual standard error: 0.05935 on 48 degrees of freedom # Extracted p-value for n0 matches above gc$vals$n0_p > 0.07715446 # The p-value can be calculated by t-distribution pt(gc$vals$n0 / gc$vals$n0_se, df=gc$vals$df, lower.tail=FALSE) * 2 > 0.07715446 # 95% confidence interval by t-distribution qt(0.975, gc$vals$df) > 2.010635 gc$vals$n0 + qt(0.975, gc$vals$df) * gc$vals$n0_se > 0.01224516 gc$vals$n0 - qt(0.975, gc$vals$df) * gc$vals$n0_se > -0.0006557696
Confidence Intervals for the Parameters of a Logistic Growth Curve The fitting function growthcurver::SummarizeGrowth is wrapped around Nonlinear Least Squares model minpack.lm::nlsLM, which provides statistics on parameter estimations similar to lm. The NLS model is
37,802
Confidence Intervals for the Parameters of a Logistic Growth Curve
If the unknown fixed true parameter such as $r$ is a real number, then the interval using the identity link as you have constructed will work well. If the unknown fixed true parameter such as $r$ must be a non-negative real number, then you might benefit from using a log link function. In your example your 95% CI for $r$ was $\hat{r}\pm 1.96\cdot\hat{\text{se}}=(1.09, 1.15)$. This approximates the sampling distribution of $\hat{r}$ using a normal distribution and inverts a Wald hypothesis test. A log link function would approximate the sampling distribution of $\text{log}\{\hat{r}\}$ using a normal distribution. The resulting 95% CI for $r$ would be $\text{exp}[\text{log}\{\hat{r}\}\pm 1.96\cdot\hat{\text{se}}/\hat{r}]=(1.09, 1.15)$. Because the standard error is so small these intervals agree quite nicely. If the sample size was smaller so that the standard error was bigger the interval based on the log link would be different and should have better coverage probability compared to the interval using the identity link. For instance, if the standard error was 40 times larger, i.e. 0.6, the Wald interval using an identity link would be (-0.06, 2.30) whereas the interval using a log link function would be (0.39, 3.20).
Confidence Intervals for the Parameters of a Logistic Growth Curve
If the unknown fixed true parameter such as $r$ is a real number, then the interval using the identity link as you have constructed will work well. If the unknown fixed true parameter such as $r$ must
Confidence Intervals for the Parameters of a Logistic Growth Curve If the unknown fixed true parameter such as $r$ is a real number, then the interval using the identity link as you have constructed will work well. If the unknown fixed true parameter such as $r$ must be a non-negative real number, then you might benefit from using a log link function. In your example your 95% CI for $r$ was $\hat{r}\pm 1.96\cdot\hat{\text{se}}=(1.09, 1.15)$. This approximates the sampling distribution of $\hat{r}$ using a normal distribution and inverts a Wald hypothesis test. A log link function would approximate the sampling distribution of $\text{log}\{\hat{r}\}$ using a normal distribution. The resulting 95% CI for $r$ would be $\text{exp}[\text{log}\{\hat{r}\}\pm 1.96\cdot\hat{\text{se}}/\hat{r}]=(1.09, 1.15)$. Because the standard error is so small these intervals agree quite nicely. If the sample size was smaller so that the standard error was bigger the interval based on the log link would be different and should have better coverage probability compared to the interval using the identity link. For instance, if the standard error was 40 times larger, i.e. 0.6, the Wald interval using an identity link would be (-0.06, 2.30) whereas the interval using a log link function would be (0.39, 3.20).
Confidence Intervals for the Parameters of a Logistic Growth Curve If the unknown fixed true parameter such as $r$ is a real number, then the interval using the identity link as you have constructed will work well. If the unknown fixed true parameter such as $r$ must
37,803
Feature Engineering : combine a categorical Feature and a continuous Feature
This is probably just a hack that does not solve this kind of problem in general, but may be well-suited for your problem: a person that does not smoke is equivalent to a person that starts smoking at the age of infinity. Hence if you transform your $X2$ into $X2' = 1/X2$, then a person that never smoked should have a value $0 = 1 / \infty$, while other people just have $1/X2$. If you are doing some kind of linear regression, this will destroy the original linearity, but should be fine for nonlinear regression techniques.
Feature Engineering : combine a categorical Feature and a continuous Feature
This is probably just a hack that does not solve this kind of problem in general, but may be well-suited for your problem: a person that does not smoke is equivalent to a person that starts smoking at
Feature Engineering : combine a categorical Feature and a continuous Feature This is probably just a hack that does not solve this kind of problem in general, but may be well-suited for your problem: a person that does not smoke is equivalent to a person that starts smoking at the age of infinity. Hence if you transform your $X2$ into $X2' = 1/X2$, then a person that never smoked should have a value $0 = 1 / \infty$, while other people just have $1/X2$. If you are doing some kind of linear regression, this will destroy the original linearity, but should be fine for nonlinear regression techniques.
Feature Engineering : combine a categorical Feature and a continuous Feature This is probably just a hack that does not solve this kind of problem in general, but may be well-suited for your problem: a person that does not smoke is equivalent to a person that starts smoking at
37,804
Feature Engineering : combine a categorical Feature and a continuous Feature
Attributes for the smoker class of humans are different than attributes for the non-smoker class of humans. That is okay. Age started smoking is an attribute of the smoker class. Age started smoking is not an attribute of the non-smoker class. To pretend otherwise, fabricating numeric-looking values, is ill advised and confusing to your audience.
Feature Engineering : combine a categorical Feature and a continuous Feature
Attributes for the smoker class of humans are different than attributes for the non-smoker class of humans. That is okay. Age started smoking is an attribute of the smoker class. Age started smoking
Feature Engineering : combine a categorical Feature and a continuous Feature Attributes for the smoker class of humans are different than attributes for the non-smoker class of humans. That is okay. Age started smoking is an attribute of the smoker class. Age started smoking is not an attribute of the non-smoker class. To pretend otherwise, fabricating numeric-looking values, is ill advised and confusing to your audience.
Feature Engineering : combine a categorical Feature and a continuous Feature Attributes for the smoker class of humans are different than attributes for the non-smoker class of humans. That is okay. Age started smoking is an attribute of the smoker class. Age started smoking
37,805
Queuing theory for elevators
Not sure I fully understand the problem, but I just think the so-called "soonest on" strategy obviously wins (or at least draws) every time. Let's say I am currently on the 3rd floor and want to go up to 7th floor. The elevator is on the way down to 1st. At the time when the elevator reaches the 3rd floor on the way down, if I choose to enter it immediately and stay there, I can secure a slot and avoid the possibility of the elevator getting full of capacity when picking up people lined up on the 1st/2nd floor. Whereas if I choose to wait, the elevator still goes the same way, and I may lost the opportunity to get in if the elevator becomes full.
Queuing theory for elevators
Not sure I fully understand the problem, but I just think the so-called "soonest on" strategy obviously wins (or at least draws) every time. Let's say I am currently on the 3rd floor and want to go up
Queuing theory for elevators Not sure I fully understand the problem, but I just think the so-called "soonest on" strategy obviously wins (or at least draws) every time. Let's say I am currently on the 3rd floor and want to go up to 7th floor. The elevator is on the way down to 1st. At the time when the elevator reaches the 3rd floor on the way down, if I choose to enter it immediately and stay there, I can secure a slot and avoid the possibility of the elevator getting full of capacity when picking up people lined up on the 1st/2nd floor. Whereas if I choose to wait, the elevator still goes the same way, and I may lost the opportunity to get in if the elevator becomes full.
Queuing theory for elevators Not sure I fully understand the problem, but I just think the so-called "soonest on" strategy obviously wins (or at least draws) every time. Let's say I am currently on the 3rd floor and want to go up
37,806
Why is the type I error (power?!) for shapiro.test on studentized residuals on lm is 10% and for regular residuals is just 5%?
Just for the future, as @glen_b wrote, the answer is that Studentized residuals are not iid.
Why is the type I error (power?!) for shapiro.test on studentized residuals on lm is 10% and for reg
Just for the future, as @glen_b wrote, the answer is that Studentized residuals are not iid.
Why is the type I error (power?!) for shapiro.test on studentized residuals on lm is 10% and for regular residuals is just 5%? Just for the future, as @glen_b wrote, the answer is that Studentized residuals are not iid.
Why is the type I error (power?!) for shapiro.test on studentized residuals on lm is 10% and for reg Just for the future, as @glen_b wrote, the answer is that Studentized residuals are not iid.
37,807
How can I know when not to answer questions and shut up?
In a little simpler set-up with FAQ answering system, I'm using simple approach with threshold - when alogithm returns probability / similarity below the threshold, I'm falling back into path "I'm not sure" (sligtly below threshold) or "I don't know" (significantly below threshold / below the second threshold).
How can I know when not to answer questions and shut up?
In a little simpler set-up with FAQ answering system, I'm using simple approach with threshold - when alogithm returns probability / similarity below the threshold, I'm falling back into path "I'm not
How can I know when not to answer questions and shut up? In a little simpler set-up with FAQ answering system, I'm using simple approach with threshold - when alogithm returns probability / similarity below the threshold, I'm falling back into path "I'm not sure" (sligtly below threshold) or "I don't know" (significantly below threshold / below the second threshold).
How can I know when not to answer questions and shut up? In a little simpler set-up with FAQ answering system, I'm using simple approach with threshold - when alogithm returns probability / similarity below the threshold, I'm falling back into path "I'm not
37,808
Statistical analysis of disappearing eagles
I found a way to get to my answer from this comment "look up the hypergeometric distribution" on math.stackexchange: From Wikipedia's entry on hypergeometric distribution In probability theory and statistics, the hypergeometric distribution is a discrete probability distribution that describes the probability of k successes (random draws for which the object drawn has a specified feature) in n draws, without replacement. Then, using an online Hypergeometric Calculator and the following figures: Population: 135 Number of successes in population: 42 Sample size: 17 Number of successes in sample: 8 I find that the probability of getting exactly 8 is 0.0703, and the probability of getting 8 or more is 0.1095 I think the "8 or more" figure is the relevant one in this case, and I have to say that this probability is lower than my intuition predicted. So the numbers suggest that there is an 89% probability that there is something different about the failure rate when segregated by tag type. That does not mean that the cause of the difference is the tag type.
Statistical analysis of disappearing eagles
I found a way to get to my answer from this comment "look up the hypergeometric distribution" on math.stackexchange: From Wikipedia's entry on hypergeometric distribution In probability theory and s
Statistical analysis of disappearing eagles I found a way to get to my answer from this comment "look up the hypergeometric distribution" on math.stackexchange: From Wikipedia's entry on hypergeometric distribution In probability theory and statistics, the hypergeometric distribution is a discrete probability distribution that describes the probability of k successes (random draws for which the object drawn has a specified feature) in n draws, without replacement. Then, using an online Hypergeometric Calculator and the following figures: Population: 135 Number of successes in population: 42 Sample size: 17 Number of successes in sample: 8 I find that the probability of getting exactly 8 is 0.0703, and the probability of getting 8 or more is 0.1095 I think the "8 or more" figure is the relevant one in this case, and I have to say that this probability is lower than my intuition predicted. So the numbers suggest that there is an 89% probability that there is something different about the failure rate when segregated by tag type. That does not mean that the cause of the difference is the tag type.
Statistical analysis of disappearing eagles I found a way to get to my answer from this comment "look up the hypergeometric distribution" on math.stackexchange: From Wikipedia's entry on hypergeometric distribution In probability theory and s
37,809
Does marginalization of some of the latent variables improve convergence in EM?
Let me clean up your question: First, the equation given by you seems incorrect, $ p(x|\theta,z_1) \neq \int_{z_1} p(x|\theta, z_1)dz_1, $ what holds is: $ p(x|\theta,z_1) = \int_{z_1} p(x, z_1|\theta)dz_1. $ Second, if you want to connect $p(x|\theta, z_1)$ to $p(x|\theta) $, use the Bayes' theorem: $ p(x,z_1|\theta) = p(x|\theta, z_1)p(z_1|\theta) $ then $ p(x|\theta) = \int_{z_1}p(x,z_1|\theta)dz_1 = \int_{z_1} p(x|\theta, z_1)p(z_1|\theta)dz_1, $ Third, go back to the log-liklihood: $ \log p(x|\theta) =\log \int_{z_1} p(x|\theta, z_1)p(z_1|\theta)dz_1 \geq \int_{z_1} p(z_1|\theta)\log p(x|\theta, z_1)dz_1, \,\,\,\,\,(1) $ if you further augment $z_1$ with $z_2$, then you have: $ \log p(x|\theta) \geq \int_{z_1, z_2} p(z_1, z_2|\theta)\log p(x|\theta, z_1, z_2)dz_1dz_2, \,\,\,\,\,(2) $ Finally, you are essentially asking why (1) is better than (2) ?
Does marginalization of some of the latent variables improve convergence in EM?
Let me clean up your question: First, the equation given by you seems incorrect, $ p(x|\theta,z_1) \neq \int_{z_1} p(x|\theta, z_1)dz_1, $ what holds is: $ p(x|\theta,z_1) = \int_{z_1} p(x, z_1|\th
Does marginalization of some of the latent variables improve convergence in EM? Let me clean up your question: First, the equation given by you seems incorrect, $ p(x|\theta,z_1) \neq \int_{z_1} p(x|\theta, z_1)dz_1, $ what holds is: $ p(x|\theta,z_1) = \int_{z_1} p(x, z_1|\theta)dz_1. $ Second, if you want to connect $p(x|\theta, z_1)$ to $p(x|\theta) $, use the Bayes' theorem: $ p(x,z_1|\theta) = p(x|\theta, z_1)p(z_1|\theta) $ then $ p(x|\theta) = \int_{z_1}p(x,z_1|\theta)dz_1 = \int_{z_1} p(x|\theta, z_1)p(z_1|\theta)dz_1, $ Third, go back to the log-liklihood: $ \log p(x|\theta) =\log \int_{z_1} p(x|\theta, z_1)p(z_1|\theta)dz_1 \geq \int_{z_1} p(z_1|\theta)\log p(x|\theta, z_1)dz_1, \,\,\,\,\,(1) $ if you further augment $z_1$ with $z_2$, then you have: $ \log p(x|\theta) \geq \int_{z_1, z_2} p(z_1, z_2|\theta)\log p(x|\theta, z_1, z_2)dz_1dz_2, \,\,\,\,\,(2) $ Finally, you are essentially asking why (1) is better than (2) ?
Does marginalization of some of the latent variables improve convergence in EM? Let me clean up your question: First, the equation given by you seems incorrect, $ p(x|\theta,z_1) \neq \int_{z_1} p(x|\theta, z_1)dz_1, $ what holds is: $ p(x|\theta,z_1) = \int_{z_1} p(x, z_1|\th
37,810
Detecting changes in large number of time-series that share seasonality
Transfer Function model identification can be used to develop useful equations that can then be classified or segmented. "Things" can be simplified for expedience , if that is the goal. Doing this with freely available web resources is a little bit more tricky.
Detecting changes in large number of time-series that share seasonality
Transfer Function model identification can be used to develop useful equations that can then be classified or segmented. "Things" can be simplified for expedience , if that is the goal. Doing this wi
Detecting changes in large number of time-series that share seasonality Transfer Function model identification can be used to develop useful equations that can then be classified or segmented. "Things" can be simplified for expedience , if that is the goal. Doing this with freely available web resources is a little bit more tricky.
Detecting changes in large number of time-series that share seasonality Transfer Function model identification can be used to develop useful equations that can then be classified or segmented. "Things" can be simplified for expedience , if that is the goal. Doing this wi
37,811
Appropriate tests on discrete and paired data
Just to expand on why the t-test is working: this is a result of the Central Limit Theorem, which tells us that the sample mean has a Normal distribution as $n$ grows. Your data is clearly non-normal, taking discrete values only, but the sample mean will be fairly Normally distributed on account of your large sample size. If your sample size was much smaller then the Wilcoxon signed-rank test would be more suitable, avoiding the Normal assumption.
Appropriate tests on discrete and paired data
Just to expand on why the t-test is working: this is a result of the Central Limit Theorem, which tells us that the sample mean has a Normal distribution as $n$ grows. Your data is clearly non-normal,
Appropriate tests on discrete and paired data Just to expand on why the t-test is working: this is a result of the Central Limit Theorem, which tells us that the sample mean has a Normal distribution as $n$ grows. Your data is clearly non-normal, taking discrete values only, but the sample mean will be fairly Normally distributed on account of your large sample size. If your sample size was much smaller then the Wilcoxon signed-rank test would be more suitable, avoiding the Normal assumption.
Appropriate tests on discrete and paired data Just to expand on why the t-test is working: this is a result of the Central Limit Theorem, which tells us that the sample mean has a Normal distribution as $n$ grows. Your data is clearly non-normal,
37,812
Bayesian inference on mean of statistic from population
From your description, it sounds like you had two kinds of random variables: time intervals $t_1,\dots,t_n$ and the counts of events $y_1,\dots,y_n$. The occurrence of events depends on length of time intervals given a known, constant rate $\lambda$ according to Poisson distribution $$ y_i \sim \mathcal{P}(\lambda t_i) $$ This means that obviously both variables are correlated. You are interested in estimating the global mean of the process. What you were considering to do, is to estimate the conditional distribution of $t_i \mid y_i$. However, if you think about it, why wouldn't you simply look the marginal distribution of $t_i$'s..? The casual relation in this case is that $y_i$'s are caused by $t_i$'s (they are limited by the length of intervals), but the intervals are not influenced anyhow by the counts. If you grouped the lengths of intervals by the counts, would it provide any meaningful information? I'd say, that for your purpose it is enough for you to look at the marginal distribution of $t_i$'s and model it using the most appropriate distribution, e.g. gamma (as you suggested), $$ t_i \sim \mathcal{G}(\alpha, \beta) $$ Then the global expected value is $$ E(\lambda T) = \lambda E(T) = \lambda \frac{\alpha}{\beta} $$
Bayesian inference on mean of statistic from population
From your description, it sounds like you had two kinds of random variables: time intervals $t_1,\dots,t_n$ and the counts of events $y_1,\dots,y_n$. The occurrence of events depends on length of time
Bayesian inference on mean of statistic from population From your description, it sounds like you had two kinds of random variables: time intervals $t_1,\dots,t_n$ and the counts of events $y_1,\dots,y_n$. The occurrence of events depends on length of time intervals given a known, constant rate $\lambda$ according to Poisson distribution $$ y_i \sim \mathcal{P}(\lambda t_i) $$ This means that obviously both variables are correlated. You are interested in estimating the global mean of the process. What you were considering to do, is to estimate the conditional distribution of $t_i \mid y_i$. However, if you think about it, why wouldn't you simply look the marginal distribution of $t_i$'s..? The casual relation in this case is that $y_i$'s are caused by $t_i$'s (they are limited by the length of intervals), but the intervals are not influenced anyhow by the counts. If you grouped the lengths of intervals by the counts, would it provide any meaningful information? I'd say, that for your purpose it is enough for you to look at the marginal distribution of $t_i$'s and model it using the most appropriate distribution, e.g. gamma (as you suggested), $$ t_i \sim \mathcal{G}(\alpha, \beta) $$ Then the global expected value is $$ E(\lambda T) = \lambda E(T) = \lambda \frac{\alpha}{\beta} $$
Bayesian inference on mean of statistic from population From your description, it sounds like you had two kinds of random variables: time intervals $t_1,\dots,t_n$ and the counts of events $y_1,\dots,y_n$. The occurrence of events depends on length of time
37,813
How to make Bayesian-style inference for a Poisson process?
If you assume that the rate itself is a Gamma variable, you can easily update its distribution by Bayesian updating (The conjugate prior for a Poisson distribution is a Gamma distribution). If you use this approach, you'll have to define the event Busy in terms of the Poisson parameter (e.g. $P(\text{Busy}) = P(\lambda > c)$, where $\lambda$ is the rate and $c$ is a cutoff value).
How to make Bayesian-style inference for a Poisson process?
If you assume that the rate itself is a Gamma variable, you can easily update its distribution by Bayesian updating (The conjugate prior for a Poisson distribution is a Gamma distribution). If you u
How to make Bayesian-style inference for a Poisson process? If you assume that the rate itself is a Gamma variable, you can easily update its distribution by Bayesian updating (The conjugate prior for a Poisson distribution is a Gamma distribution). If you use this approach, you'll have to define the event Busy in terms of the Poisson parameter (e.g. $P(\text{Busy}) = P(\lambda > c)$, where $\lambda$ is the rate and $c$ is a cutoff value).
How to make Bayesian-style inference for a Poisson process? If you assume that the rate itself is a Gamma variable, you can easily update its distribution by Bayesian updating (The conjugate prior for a Poisson distribution is a Gamma distribution). If you u
37,814
2-Sample Proportions z-test vs Fisher's Exact Test
Fisher's exact test offers a more exact p-value by running every possible scenario with the given data set and figures out the total number of possible successes and total number of possible failures at the given sample size, then it converts those totals into a p-value. Also note that the total possible outcomes goes up by a factorial. The normal approximation can be computed by a calculator and is much easier to compute as the sample size gets large. The normal approximation also becomes closer to fisher's exact test as the sample size gets large.
2-Sample Proportions z-test vs Fisher's Exact Test
Fisher's exact test offers a more exact p-value by running every possible scenario with the given data set and figures out the total number of possible successes and total number of possible failures
2-Sample Proportions z-test vs Fisher's Exact Test Fisher's exact test offers a more exact p-value by running every possible scenario with the given data set and figures out the total number of possible successes and total number of possible failures at the given sample size, then it converts those totals into a p-value. Also note that the total possible outcomes goes up by a factorial. The normal approximation can be computed by a calculator and is much easier to compute as the sample size gets large. The normal approximation also becomes closer to fisher's exact test as the sample size gets large.
2-Sample Proportions z-test vs Fisher's Exact Test Fisher's exact test offers a more exact p-value by running every possible scenario with the given data set and figures out the total number of possible successes and total number of possible failures
37,815
Do I still need to include variables used to generate weights in a regression model when applying inverse probability weighting in estimation?
This really depends on your research question. There's no "rule"; it's a theory question. Let's say that one of your variables in $\pi$ is the number of adults in the household ($adults$). This would be fairly common variable to include in an inverse probability weight, because the more adults there are in a household, if only one adult is chosen to complete the survey, the probability of any given adult in the household being selected is lower. Now, let's say that your outcome of interest is whether the household is above or below a poverty threshold. You would want to include $adults$ in your model, because (a) more adults could mean more working members contributing to greater household income and thus lesser probability of household poverty or (b) more adults could mean more mouths to feed with one household income, and thus a greater probability of household poverty. You would want to be sure to have $adults$ in your model, so you could test to see which of these hypotheses (or both) are supported by your data. However, if you had reason to think that more adults would be, for example, associated with both greater non-response and greater poverty, then you would also want to review the literature on endogenous selection, to see how best to specify your model. So like many econometric questions, your answer depends on your theory and not just your data.
Do I still need to include variables used to generate weights in a regression model when applying in
This really depends on your research question. There's no "rule"; it's a theory question. Let's say that one of your variables in $\pi$ is the number of adults in the household ($adults$). This would
Do I still need to include variables used to generate weights in a regression model when applying inverse probability weighting in estimation? This really depends on your research question. There's no "rule"; it's a theory question. Let's say that one of your variables in $\pi$ is the number of adults in the household ($adults$). This would be fairly common variable to include in an inverse probability weight, because the more adults there are in a household, if only one adult is chosen to complete the survey, the probability of any given adult in the household being selected is lower. Now, let's say that your outcome of interest is whether the household is above or below a poverty threshold. You would want to include $adults$ in your model, because (a) more adults could mean more working members contributing to greater household income and thus lesser probability of household poverty or (b) more adults could mean more mouths to feed with one household income, and thus a greater probability of household poverty. You would want to be sure to have $adults$ in your model, so you could test to see which of these hypotheses (or both) are supported by your data. However, if you had reason to think that more adults would be, for example, associated with both greater non-response and greater poverty, then you would also want to review the literature on endogenous selection, to see how best to specify your model. So like many econometric questions, your answer depends on your theory and not just your data.
Do I still need to include variables used to generate weights in a regression model when applying in This really depends on your research question. There's no "rule"; it's a theory question. Let's say that one of your variables in $\pi$ is the number of adults in the household ($adults$). This would
37,816
Is ANOVA always more powerful than a two-sample t-test when the data can be blocked?
Using terminology from design of experiments, you seem to have a randomized block experiment (assuming suitable randomization was done) where the blocks are defined by the operators, and you have two treatments (devices). If you ignore the blocks, then the one-way anova will be equivalent to a t-test. Your two questions: Anova seems to be the appropriate analysis, yes. If there are differences between the operators (as would often be expected), anova will be more powerful. If there are no differences between the operators, not ... but simply a t-test would be seen as a risky analysis, as the conclusions would be conditional on there not being differences between operators. See also Understanding the advantages of CRD experiments.
Is ANOVA always more powerful than a two-sample t-test when the data can be blocked?
Using terminology from design of experiments, you seem to have a randomized block experiment (assuming suitable randomization was done) where the blocks are defined by the operators, and you have two
Is ANOVA always more powerful than a two-sample t-test when the data can be blocked? Using terminology from design of experiments, you seem to have a randomized block experiment (assuming suitable randomization was done) where the blocks are defined by the operators, and you have two treatments (devices). If you ignore the blocks, then the one-way anova will be equivalent to a t-test. Your two questions: Anova seems to be the appropriate analysis, yes. If there are differences between the operators (as would often be expected), anova will be more powerful. If there are no differences between the operators, not ... but simply a t-test would be seen as a risky analysis, as the conclusions would be conditional on there not being differences between operators. See also Understanding the advantages of CRD experiments.
Is ANOVA always more powerful than a two-sample t-test when the data can be blocked? Using terminology from design of experiments, you seem to have a randomized block experiment (assuming suitable randomization was done) where the blocks are defined by the operators, and you have two
37,817
Confidence Interval for variance given one observation
Viewed through the lens of probability inequalities and connections to the multiple-observation case, this result might not seem so impossible, or, at least, it might seem more plausible. Let $\renewcommand{\Pr}{\mathbb P}\newcommand{\Ind}[1]{\mathbf 1_{(#1)}}X \sim \mathcal N(\mu,\sigma^2)$ with $\mu$ and $\sigma^2$ unknown. We can write $X = \sigma Z + \mu$ for $Z \sim \mathcal N(0,1)$. Main Claim: $[0,X^2/q_\alpha)$ is a $(1-\alpha)$ confidence interval for $\sigma^2$ where $q_\alpha$ is the $\alpha$-level quantile of a chi-squared distribution with one degree of freedom. Furthermore, since this interval has exactly $(1-\alpha)$ coverage when $\mu = 0$, it is the narrowest possible interval of the form $[0,b X^2)$ for some $b \in \mathbb R$. A reason for optimism Recall that in the $n \geq 2$ case, with $T = \sum_{i=1}^n (X_i - \bar X)^2$, the typical $(1-\alpha)$ confidence interval for $\sigma^2$ is $$ \Big(\frac{T}{q_{n-1,(1-\alpha)/2}}, \frac{T}{q_{n-1,\alpha/2}} \Big) \>, $$ where $q_{k,a}$ is the $a$-level quantile of a chi-squared with $k$ degrees of freedom. This, of course, holds for any $\mu$. While this is the most popular interval (called the equal-tailed interval for obvious reasons), it is neither the only one nor even the one of smallest width! As should be apparent, another valid selection is $$ \Big(0,\frac{T}{q_{n-1,\alpha}}\Big) \>. $$ Since, $T \leq \sum_{i=1}^n X_i^2$, then $$ \Big(0,\frac{\sum_{i=1}^n X_i^2}{q_{n-1,\alpha}}\Big) \>, $$ also has coverage of at least $(1-\alpha)$. Viewed in this light, we might then be optimistic that the interval in the main claim is true for $n = 1$. The main difference is that there is no zero-degree-of-freedom chi-squared distribution for the case of a single observation, so we must hope that using a one-degree-of-freedom quantile will work. A half step toward our destination (Exploiting the right tail) Before diving into a proof of the main claim, let's first look at a preliminary claim that is not nearly as strong or satisfying statistically, but perhaps gives some additional insight into what is going on. You can skip down to the proof of the main claim below, without much (if any) loss. In this section and the next, the proofs—while slightly subtle—are based on only elementary facts: monotonicity of probabilities, and symmetry and unimodality of the normal distribution. Auxiliary claim: $[0,X^2/z^2_\alpha)$ is a $(1-\alpha)$ confidence interval for $\sigma^2$ as long as $\alpha > 1/2$. Here $z_\alpha$ is the $\alpha$-level quantile of a standard normal. Proof. $|X| = |-X|$ and $|\sigma Z + \mu| \stackrel{d}{=} |-\sigma Z+\mu|$ by symmetry, so in what follows we can take $\mu \geq 0$ without loss of generality. Now, for $\theta \geq 0$ and $\mu \geq 0$, $$ \Pr(|X| > \theta) \geq \Pr( X > \theta) = \Pr( \sigma Z + \mu > \theta) \geq \Pr( Z > \theta/\sigma) \>, $$ and so with $\theta = z_{\alpha} \sigma$, we see that $$ \Pr(0 \leq \sigma^2 < X^2 / z^2_\alpha) \geq 1 - \alpha \>. $$ This works only for $\alpha > 1/2$, since that is what is needed for $z_\alpha > 0$. This proves the auxiliary claim. While illustrative, it is unsatifying from a statistical perspective since it requires an absurdly large $\alpha$ to work. Proving the main claim A refinement of the above argument leads to a result that will work for an arbitrary confidence level. First, note that $$ \Pr(|X| > \theta) = \Pr(|Z + \mu/\sigma| > \theta / \sigma ) \>. $$ Set $a = \mu/\sigma \geq 0$ and $b = \theta / \sigma \geq 0$. Then, $$ \Pr(|Z + a| > b) = \Phi(a-b) + \Phi(-a-b) \>. $$ If we can show that the right-hand side increases in $a$ for every fixed $b$, then we can employ a similar argument as in the previous argument. This is at least plausible, since we'd like to believe that if the mean increases, then it becomes more probable that we see a value with a modulus that exceeds $b$. (However, we have to watch out for how quickly the mass is decreasing in the left tail!) Set $f_b(a) = \Phi(a-b) + \Phi(-a-b)$. Then $$ f'_b(a) = \varphi(a-b) - \varphi(-a-b) = \varphi(a-b) - \varphi(a+b) \>. $$ Note that $f'_b(0) = 0$ and for positive $u$, $\varphi(u)$ is decreasing in $u$. Now, for $a \in (0,2b)$, it is easy to see that $\varphi(a-b) \geq \varphi(-b) = \varphi(b)$. These facts taken together easily imply that $$ f'_b(a) \geq 0 $$ for all $a \geq 0$ and any fixed $b \geq 0$. Hence, we have shown that for $a \geq 0$ and $b \geq 0$, $$ \Pr(|Z + a| > b) \geq \Pr(|Z| > b) = 2\Phi(-b) \>. $$ Unraveling all of this, if we take $\theta = \sqrt{q_\alpha} \sigma$, we get $$ \Pr(X^2 > q_\alpha \sigma^2) \geq \Pr(Z^2 > q_\alpha) = 1 - \alpha \>, $$ which establishes the main claim. Closing remark: A careful reading of the above argument shows that it uses only the symmetric and unimodal properties of the normal distribution. Hence, the approach works analogously for obtaining confidence intervals from a single observation from any symmetric unimodal location-scale family, e.g., Cauchy or Laplace distributions.
Confidence Interval for variance given one observation
Viewed through the lens of probability inequalities and connections to the multiple-observation case, this result might not seem so impossible, or, at least, it might seem more plausible. Let $\renewc
Confidence Interval for variance given one observation Viewed through the lens of probability inequalities and connections to the multiple-observation case, this result might not seem so impossible, or, at least, it might seem more plausible. Let $\renewcommand{\Pr}{\mathbb P}\newcommand{\Ind}[1]{\mathbf 1_{(#1)}}X \sim \mathcal N(\mu,\sigma^2)$ with $\mu$ and $\sigma^2$ unknown. We can write $X = \sigma Z + \mu$ for $Z \sim \mathcal N(0,1)$. Main Claim: $[0,X^2/q_\alpha)$ is a $(1-\alpha)$ confidence interval for $\sigma^2$ where $q_\alpha$ is the $\alpha$-level quantile of a chi-squared distribution with one degree of freedom. Furthermore, since this interval has exactly $(1-\alpha)$ coverage when $\mu = 0$, it is the narrowest possible interval of the form $[0,b X^2)$ for some $b \in \mathbb R$. A reason for optimism Recall that in the $n \geq 2$ case, with $T = \sum_{i=1}^n (X_i - \bar X)^2$, the typical $(1-\alpha)$ confidence interval for $\sigma^2$ is $$ \Big(\frac{T}{q_{n-1,(1-\alpha)/2}}, \frac{T}{q_{n-1,\alpha/2}} \Big) \>, $$ where $q_{k,a}$ is the $a$-level quantile of a chi-squared with $k$ degrees of freedom. This, of course, holds for any $\mu$. While this is the most popular interval (called the equal-tailed interval for obvious reasons), it is neither the only one nor even the one of smallest width! As should be apparent, another valid selection is $$ \Big(0,\frac{T}{q_{n-1,\alpha}}\Big) \>. $$ Since, $T \leq \sum_{i=1}^n X_i^2$, then $$ \Big(0,\frac{\sum_{i=1}^n X_i^2}{q_{n-1,\alpha}}\Big) \>, $$ also has coverage of at least $(1-\alpha)$. Viewed in this light, we might then be optimistic that the interval in the main claim is true for $n = 1$. The main difference is that there is no zero-degree-of-freedom chi-squared distribution for the case of a single observation, so we must hope that using a one-degree-of-freedom quantile will work. A half step toward our destination (Exploiting the right tail) Before diving into a proof of the main claim, let's first look at a preliminary claim that is not nearly as strong or satisfying statistically, but perhaps gives some additional insight into what is going on. You can skip down to the proof of the main claim below, without much (if any) loss. In this section and the next, the proofs—while slightly subtle—are based on only elementary facts: monotonicity of probabilities, and symmetry and unimodality of the normal distribution. Auxiliary claim: $[0,X^2/z^2_\alpha)$ is a $(1-\alpha)$ confidence interval for $\sigma^2$ as long as $\alpha > 1/2$. Here $z_\alpha$ is the $\alpha$-level quantile of a standard normal. Proof. $|X| = |-X|$ and $|\sigma Z + \mu| \stackrel{d}{=} |-\sigma Z+\mu|$ by symmetry, so in what follows we can take $\mu \geq 0$ without loss of generality. Now, for $\theta \geq 0$ and $\mu \geq 0$, $$ \Pr(|X| > \theta) \geq \Pr( X > \theta) = \Pr( \sigma Z + \mu > \theta) \geq \Pr( Z > \theta/\sigma) \>, $$ and so with $\theta = z_{\alpha} \sigma$, we see that $$ \Pr(0 \leq \sigma^2 < X^2 / z^2_\alpha) \geq 1 - \alpha \>. $$ This works only for $\alpha > 1/2$, since that is what is needed for $z_\alpha > 0$. This proves the auxiliary claim. While illustrative, it is unsatifying from a statistical perspective since it requires an absurdly large $\alpha$ to work. Proving the main claim A refinement of the above argument leads to a result that will work for an arbitrary confidence level. First, note that $$ \Pr(|X| > \theta) = \Pr(|Z + \mu/\sigma| > \theta / \sigma ) \>. $$ Set $a = \mu/\sigma \geq 0$ and $b = \theta / \sigma \geq 0$. Then, $$ \Pr(|Z + a| > b) = \Phi(a-b) + \Phi(-a-b) \>. $$ If we can show that the right-hand side increases in $a$ for every fixed $b$, then we can employ a similar argument as in the previous argument. This is at least plausible, since we'd like to believe that if the mean increases, then it becomes more probable that we see a value with a modulus that exceeds $b$. (However, we have to watch out for how quickly the mass is decreasing in the left tail!) Set $f_b(a) = \Phi(a-b) + \Phi(-a-b)$. Then $$ f'_b(a) = \varphi(a-b) - \varphi(-a-b) = \varphi(a-b) - \varphi(a+b) \>. $$ Note that $f'_b(0) = 0$ and for positive $u$, $\varphi(u)$ is decreasing in $u$. Now, for $a \in (0,2b)$, it is easy to see that $\varphi(a-b) \geq \varphi(-b) = \varphi(b)$. These facts taken together easily imply that $$ f'_b(a) \geq 0 $$ for all $a \geq 0$ and any fixed $b \geq 0$. Hence, we have shown that for $a \geq 0$ and $b \geq 0$, $$ \Pr(|Z + a| > b) \geq \Pr(|Z| > b) = 2\Phi(-b) \>. $$ Unraveling all of this, if we take $\theta = \sqrt{q_\alpha} \sigma$, we get $$ \Pr(X^2 > q_\alpha \sigma^2) \geq \Pr(Z^2 > q_\alpha) = 1 - \alpha \>, $$ which establishes the main claim. Closing remark: A careful reading of the above argument shows that it uses only the symmetric and unimodal properties of the normal distribution. Hence, the approach works analogously for obtaining confidence intervals from a single observation from any symmetric unimodal location-scale family, e.g., Cauchy or Laplace distributions.
Confidence Interval for variance given one observation Viewed through the lens of probability inequalities and connections to the multiple-observation case, this result might not seem so impossible, or, at least, it might seem more plausible. Let $\renewc
37,818
Confidence Interval for variance given one observation
Time to follow up! Here's the solution I was given: We will construct a confidence interval of the form $[0,T(X))$, where $T(\cdot)$ is some statistic. By definition this will be a confidence interval with confidence level at least 99% if $$(\forall \mu \in \mathbb R )(\forall \sigma > 0)\; \mathbb P_{\mu,\sigma_2}(\sigma^2 > T(X)) < 0.01.$$ We note that the density of the $\mathcal{N}(\mu,\sigma^2)$ distribution does not exceed $1/\sigma\sqrt{2\pi}$. Therefore, $\mathbb{P}(|X| \leq a) \leq a/\sigma$ for every $a \geq 0$. It follows that $$t \geq \mathbb P (|X|/\sigma \leq t) = \mathbb P (X^2 \leq t^2\sigma^2) = \mathbb P (\sigma^2 \geq X^2/t^2).$$ Plugging in $t = 0.01$ we obtain that the appropriate statistic is $T(X) = 10000X^2.$ The confidence interval (which is very wide) is slightly conservative in simulation, with no empirical coverage (in 100,000 simulations) lower than 99.15% as I varied the CV over many orders of magnitude. For comparison, I also simulated cardinal's confidence interval. I should note that cardinal's interval is quite a bit narrower--in the 99% case, his ends up being up to about $6300X^2$, as opposed to the $10000X^2$ in the provided solution. Empirical coverage is right at the nominal level, again over many orders of magnitude for the CV. So his interval definitely wins. I haven't had time to look carefully at the paper Max posted, but I do plan to look at that and may add some comments regarding it later (i.e., no sooner than a week). That paper claims a 99% confidence interval of $(0,4900X^2)$, which has empirical coverage slightly lower (about 98.85%) than the nominal coverage for large CVs in my brief simulations.
Confidence Interval for variance given one observation
Time to follow up! Here's the solution I was given: We will construct a confidence interval of the form $[0,T(X))$, where $T(\cdot)$ is some statistic. By definition this will be a confidence interva
Confidence Interval for variance given one observation Time to follow up! Here's the solution I was given: We will construct a confidence interval of the form $[0,T(X))$, where $T(\cdot)$ is some statistic. By definition this will be a confidence interval with confidence level at least 99% if $$(\forall \mu \in \mathbb R )(\forall \sigma > 0)\; \mathbb P_{\mu,\sigma_2}(\sigma^2 > T(X)) < 0.01.$$ We note that the density of the $\mathcal{N}(\mu,\sigma^2)$ distribution does not exceed $1/\sigma\sqrt{2\pi}$. Therefore, $\mathbb{P}(|X| \leq a) \leq a/\sigma$ for every $a \geq 0$. It follows that $$t \geq \mathbb P (|X|/\sigma \leq t) = \mathbb P (X^2 \leq t^2\sigma^2) = \mathbb P (\sigma^2 \geq X^2/t^2).$$ Plugging in $t = 0.01$ we obtain that the appropriate statistic is $T(X) = 10000X^2.$ The confidence interval (which is very wide) is slightly conservative in simulation, with no empirical coverage (in 100,000 simulations) lower than 99.15% as I varied the CV over many orders of magnitude. For comparison, I also simulated cardinal's confidence interval. I should note that cardinal's interval is quite a bit narrower--in the 99% case, his ends up being up to about $6300X^2$, as opposed to the $10000X^2$ in the provided solution. Empirical coverage is right at the nominal level, again over many orders of magnitude for the CV. So his interval definitely wins. I haven't had time to look carefully at the paper Max posted, but I do plan to look at that and may add some comments regarding it later (i.e., no sooner than a week). That paper claims a 99% confidence interval of $(0,4900X^2)$, which has empirical coverage slightly lower (about 98.85%) than the nominal coverage for large CVs in my brief simulations.
Confidence Interval for variance given one observation Time to follow up! Here's the solution I was given: We will construct a confidence interval of the form $[0,T(X))$, where $T(\cdot)$ is some statistic. By definition this will be a confidence interva
37,819
Confidence Interval for variance given one observation
The CI's $(0,\infty)$ presumably.
Confidence Interval for variance given one observation
The CI's $(0,\infty)$ presumably.
Confidence Interval for variance given one observation The CI's $(0,\infty)$ presumably.
Confidence Interval for variance given one observation The CI's $(0,\infty)$ presumably.
37,820
How to fit a Pareto distribution to an observed CDF?
First, you technically have a survival function, which is the complement of the CDF. Second, you must be dealing with some form of censoring from above (insurance policy limits?) as you have plateaus in the CDF and a hard cap at 45,860,334.00. As such, no "pure" Pareto family will fit nicely as these densities are strictly increasing functions. That being said, the simplest approach is to ignore these complexities and fit a minimum distance (e.g squared error) error term between a specific Pareto and your empirical CDF. In US actuarial terms, the unvarnished term "Pareto" means the Pareto II or Lomax distribution where we use $\theta$ instead of $\lambda$ and is defined for $x > 0$: $$ \begin{aligned} f(x) &= \frac{\alpha\theta^\alpha}{\left(x + \theta\right)^{\alpha + 1}}\\ F(X) &= 1 - \left(\frac{\theta}{x + \theta}\right)^\alpha \end{aligned} $$ This gets around the issues of what we actuaries call the "single-parameter Pareto" where only $\alpha$ is a true parameter and $\theta$ is merely the minimal possible observation. The following R code will fit parameters to the Lomax based on the R code you presented above: # Turn survival into CDF D2 <- data.frame(data$X, 1 - data$P) # Names names(D2) <- c('x', 'p') # Make CDF function separate for later use plomax <- function(x, a, q) {1 - (q / (q + x)) ^ a} # Error Function lomErr <- function(par, data) { a <- par[[1L]] q <- par[[2L]] sum((plomax(data[, 1L], a, q) - data[, 2L]) ^ 2) } # Fit, although I prefer nloptr PFit <- optim(c(2.1, 1e5), ParErr, data = D2, method = 'Nelder-Mead') Results: Pfit $par [1] 9.264474e+00 3.926014e+06 $value [1] 0.008430267 $counts function gradient 149 NA $convergence [1] 0 $message NULL I'm not certain how you intend to proceed from here, but to show the fit is reasonable, here is a plot of the empirical CDF against the fitted: # Add to data table D3 <- data.frame(x = D2$x, p = D2$p, pp = plomax(D2$x, PFit$par[[1L]], PFit$par[[2L]])) # Compare with empirical plot(D3$p, D3$pp) abline(0, 1)
How to fit a Pareto distribution to an observed CDF?
First, you technically have a survival function, which is the complement of the CDF. Second, you must be dealing with some form of censoring from above (insurance policy limits?) as you have plateaus
How to fit a Pareto distribution to an observed CDF? First, you technically have a survival function, which is the complement of the CDF. Second, you must be dealing with some form of censoring from above (insurance policy limits?) as you have plateaus in the CDF and a hard cap at 45,860,334.00. As such, no "pure" Pareto family will fit nicely as these densities are strictly increasing functions. That being said, the simplest approach is to ignore these complexities and fit a minimum distance (e.g squared error) error term between a specific Pareto and your empirical CDF. In US actuarial terms, the unvarnished term "Pareto" means the Pareto II or Lomax distribution where we use $\theta$ instead of $\lambda$ and is defined for $x > 0$: $$ \begin{aligned} f(x) &= \frac{\alpha\theta^\alpha}{\left(x + \theta\right)^{\alpha + 1}}\\ F(X) &= 1 - \left(\frac{\theta}{x + \theta}\right)^\alpha \end{aligned} $$ This gets around the issues of what we actuaries call the "single-parameter Pareto" where only $\alpha$ is a true parameter and $\theta$ is merely the minimal possible observation. The following R code will fit parameters to the Lomax based on the R code you presented above: # Turn survival into CDF D2 <- data.frame(data$X, 1 - data$P) # Names names(D2) <- c('x', 'p') # Make CDF function separate for later use plomax <- function(x, a, q) {1 - (q / (q + x)) ^ a} # Error Function lomErr <- function(par, data) { a <- par[[1L]] q <- par[[2L]] sum((plomax(data[, 1L], a, q) - data[, 2L]) ^ 2) } # Fit, although I prefer nloptr PFit <- optim(c(2.1, 1e5), ParErr, data = D2, method = 'Nelder-Mead') Results: Pfit $par [1] 9.264474e+00 3.926014e+06 $value [1] 0.008430267 $counts function gradient 149 NA $convergence [1] 0 $message NULL I'm not certain how you intend to proceed from here, but to show the fit is reasonable, here is a plot of the empirical CDF against the fitted: # Add to data table D3 <- data.frame(x = D2$x, p = D2$p, pp = plomax(D2$x, PFit$par[[1L]], PFit$par[[2L]])) # Compare with empirical plot(D3$p, D3$pp) abline(0, 1)
How to fit a Pareto distribution to an observed CDF? First, you technically have a survival function, which is the complement of the CDF. Second, you must be dealing with some form of censoring from above (insurance policy limits?) as you have plateaus
37,821
How to fit a Pareto distribution to an observed CDF?
This Wikipedia page indicates the maximum likelihood estimates have a closed form solution. You can plug these estimates in for the parameter values and plot the resulting parametric CDF to see how well the model fits your data. You can construct tolerance limits (confidence limits for population percentiles) using the delta method and inverting a Wald test with a log link function to create a confidence band around the CDF.
How to fit a Pareto distribution to an observed CDF?
This Wikipedia page indicates the maximum likelihood estimates have a closed form solution. You can plug these estimates in for the parameter values and plot the resulting parametric CDF to see how w
How to fit a Pareto distribution to an observed CDF? This Wikipedia page indicates the maximum likelihood estimates have a closed form solution. You can plug these estimates in for the parameter values and plot the resulting parametric CDF to see how well the model fits your data. You can construct tolerance limits (confidence limits for population percentiles) using the delta method and inverting a Wald test with a log link function to create a confidence band around the CDF.
How to fit a Pareto distribution to an observed CDF? This Wikipedia page indicates the maximum likelihood estimates have a closed form solution. You can plug these estimates in for the parameter values and plot the resulting parametric CDF to see how w
37,822
Relative advantages of nnet, neuralnet, caret and RSNNS packages [closed]
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Section 7.1 from Bergmeir & Benítez Sánchez (2012) is the reference for RSNNS and provides a short overview on neuralnet and nnet. Package nnet is the simplest one and restricted to a single layer; RSNNS and neuralnet have more options. Bergmeir, C. N., & Benítez Sánchez, J. M. (2012). Neural networks in R using the Stuttgart neural network simulator: RSNNS. American Statistical Association. https://www.jstatsoft.org/article/view/v046i07/v46i07.pdf
Relative advantages of nnet, neuralnet, caret and RSNNS packages [closed]
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Relative advantages of nnet, neuralnet, caret and RSNNS packages [closed] Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Section 7.1 from Bergmeir & Benítez Sánchez (2012) is the reference for RSNNS and provides a short overview on neuralnet and nnet. Package nnet is the simplest one and restricted to a single layer; RSNNS and neuralnet have more options. Bergmeir, C. N., & Benítez Sánchez, J. M. (2012). Neural networks in R using the Stuttgart neural network simulator: RSNNS. American Statistical Association. https://www.jstatsoft.org/article/view/v046i07/v46i07.pdf
Relative advantages of nnet, neuralnet, caret and RSNNS packages [closed] Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
37,823
Difference between pointwise and uniform confidence sets
You can see many similar examples in real analysis. Let's say the $F$ can be indexed as $F_i$(The $\mathfrak{F}$ is countable). The confidence set $C_n$ have those property: $$ \begin{aligned} P_{F_i}(\theta \in C_n) & \ge 1-\alpha \quad if \quad i \le n\\ & < 1-\alpha \quad otherwise \end{aligned} $$ So $C_n$ is pointwise asymptotic $1-\alpha$ confidence set, but not uniform asymptotic $1-\alpha$ confidence set.
Difference between pointwise and uniform confidence sets
You can see many similar examples in real analysis. Let's say the $F$ can be indexed as $F_i$(The $\mathfrak{F}$ is countable). The confidence set $C_n$ have those property: $$ \begin{aligned} P_{F_i}
Difference between pointwise and uniform confidence sets You can see many similar examples in real analysis. Let's say the $F$ can be indexed as $F_i$(The $\mathfrak{F}$ is countable). The confidence set $C_n$ have those property: $$ \begin{aligned} P_{F_i}(\theta \in C_n) & \ge 1-\alpha \quad if \quad i \le n\\ & < 1-\alpha \quad otherwise \end{aligned} $$ So $C_n$ is pointwise asymptotic $1-\alpha$ confidence set, but not uniform asymptotic $1-\alpha$ confidence set.
Difference between pointwise and uniform confidence sets You can see many similar examples in real analysis. Let's say the $F$ can be indexed as $F_i$(The $\mathfrak{F}$ is countable). The confidence set $C_n$ have those property: $$ \begin{aligned} P_{F_i}
37,824
Dealing with hierarchical (panel, multi-level) data and fixed effects in LASSO?
First thing to do is to rearrange your data into a standard form. If you've got $n$ samples and $d$ features, that means you want An $n \times d$ input matrix $X$, in which each column has a mean of $0$ and variance of $1$. This ensures that LASSO's regularization effect treats each dimension "fairly" when deciding whether to shrink it to zero. A length-$n$ vector $y$ of outputs, which has a mean of $0$. This ensures the LASSO model doesn't need to use a constant term. You'll probably want to encode time and location as dimensions (ie as extra columns in $X$), though without knowing the details of the problem I can't say for sure. Anyway, if you feed $X$ and $y$ into a LASSO solver, you'll then get back a length-$d$ weights vector $w$, that you can then interpret in terms of time, location, and whatever other explanatory variables you have.
Dealing with hierarchical (panel, multi-level) data and fixed effects in LASSO?
First thing to do is to rearrange your data into a standard form. If you've got $n$ samples and $d$ features, that means you want An $n \times d$ input matrix $X$, in which each column has a mean of
Dealing with hierarchical (panel, multi-level) data and fixed effects in LASSO? First thing to do is to rearrange your data into a standard form. If you've got $n$ samples and $d$ features, that means you want An $n \times d$ input matrix $X$, in which each column has a mean of $0$ and variance of $1$. This ensures that LASSO's regularization effect treats each dimension "fairly" when deciding whether to shrink it to zero. A length-$n$ vector $y$ of outputs, which has a mean of $0$. This ensures the LASSO model doesn't need to use a constant term. You'll probably want to encode time and location as dimensions (ie as extra columns in $X$), though without knowing the details of the problem I can't say for sure. Anyway, if you feed $X$ and $y$ into a LASSO solver, you'll then get back a length-$d$ weights vector $w$, that you can then interpret in terms of time, location, and whatever other explanatory variables you have.
Dealing with hierarchical (panel, multi-level) data and fixed effects in LASSO? First thing to do is to rearrange your data into a standard form. If you've got $n$ samples and $d$ features, that means you want An $n \times d$ input matrix $X$, in which each column has a mean of
37,825
Using an RMSE with derived confidence interval, to generate a prediction interval for an estimate
The CART, as I understand it, does not have homoscedasticity assumptions. If anything it presumes that the variance of each component is independent from the variance of all other components. It doesn't account for correlations in variables either. The normality assumption is problematic. It is convenient but not necessarily true. There is often hand-waving about "law of large numbers" but the real world, impo, likes to frustrate such things. Have you considered using quantile regression forests for your estimate, or is that part of the problem?
Using an RMSE with derived confidence interval, to generate a prediction interval for an estimate
The CART, as I understand it, does not have homoscedasticity assumptions. If anything it presumes that the variance of each component is independent from the variance of all other components. It doe
Using an RMSE with derived confidence interval, to generate a prediction interval for an estimate The CART, as I understand it, does not have homoscedasticity assumptions. If anything it presumes that the variance of each component is independent from the variance of all other components. It doesn't account for correlations in variables either. The normality assumption is problematic. It is convenient but not necessarily true. There is often hand-waving about "law of large numbers" but the real world, impo, likes to frustrate such things. Have you considered using quantile regression forests for your estimate, or is that part of the problem?
Using an RMSE with derived confidence interval, to generate a prediction interval for an estimate The CART, as I understand it, does not have homoscedasticity assumptions. If anything it presumes that the variance of each component is independent from the variance of all other components. It doe
37,826
Fit a VAR model with R [closed]
After you fit your model using: fit <- VAR(data1,p=6) You can refine it with refVAR: fit2 <- refVAR(fit,thres=1.65)
Fit a VAR model with R [closed]
After you fit your model using: fit <- VAR(data1,p=6) You can refine it with refVAR: fit2 <- refVAR(fit,thres=1.65)
Fit a VAR model with R [closed] After you fit your model using: fit <- VAR(data1,p=6) You can refine it with refVAR: fit2 <- refVAR(fit,thres=1.65)
Fit a VAR model with R [closed] After you fit your model using: fit <- VAR(data1,p=6) You can refine it with refVAR: fit2 <- refVAR(fit,thres=1.65)
37,827
Having a conjugate prior: Deep property or mathematical accident?
It is not by accident. Here you shall find a brief a very nice review on conjugate priors. Concretely, it mentions that if there exist a set of sufficient statistics of fixed dimension for the given likelihood function, then you can construct a conjugate prior to it. Having a set of sufficient statistics means that you can factorize the likelihood in a form that lets you estimate the parameters in a computationally efficient way. Besides that, having conjugate priors is not only computationally convenient. It also provides smoothing and allows to work with very little samples or no previous samples, which is necessary for problems like decision making, in cases where you have very little evidence.
Having a conjugate prior: Deep property or mathematical accident?
It is not by accident. Here you shall find a brief a very nice review on conjugate priors. Concretely, it mentions that if there exist a set of sufficient statistics of fixed dimension for the given l
Having a conjugate prior: Deep property or mathematical accident? It is not by accident. Here you shall find a brief a very nice review on conjugate priors. Concretely, it mentions that if there exist a set of sufficient statistics of fixed dimension for the given likelihood function, then you can construct a conjugate prior to it. Having a set of sufficient statistics means that you can factorize the likelihood in a form that lets you estimate the parameters in a computationally efficient way. Besides that, having conjugate priors is not only computationally convenient. It also provides smoothing and allows to work with very little samples or no previous samples, which is necessary for problems like decision making, in cases where you have very little evidence.
Having a conjugate prior: Deep property or mathematical accident? It is not by accident. Here you shall find a brief a very nice review on conjugate priors. Concretely, it mentions that if there exist a set of sufficient statistics of fixed dimension for the given l
37,828
Having a conjugate prior: Deep property or mathematical accident?
I am very new to Bayesian statistics, but it seems to me that all of these distributions (and if not all of them then at least those that are useful) share the property that they are described by some limited metric about the observations that define them. I.e., for a normal distribution, you don't need to know every detail about every observation, just their total count and sum. To put it another way, assuming you already know the class/family of distribution, then the distribution has strictly lower information entropy than the observations that resulted in it. Does this seem trivial, or is it kind of what you're looking for?
Having a conjugate prior: Deep property or mathematical accident?
I am very new to Bayesian statistics, but it seems to me that all of these distributions (and if not all of them then at least those that are useful) share the property that they are described by some
Having a conjugate prior: Deep property or mathematical accident? I am very new to Bayesian statistics, but it seems to me that all of these distributions (and if not all of them then at least those that are useful) share the property that they are described by some limited metric about the observations that define them. I.e., for a normal distribution, you don't need to know every detail about every observation, just their total count and sum. To put it another way, assuming you already know the class/family of distribution, then the distribution has strictly lower information entropy than the observations that resulted in it. Does this seem trivial, or is it kind of what you're looking for?
Having a conjugate prior: Deep property or mathematical accident? I am very new to Bayesian statistics, but it seems to me that all of these distributions (and if not all of them then at least those that are useful) share the property that they are described by some
37,829
Having a conjugate prior: Deep property or mathematical accident?
What properties are "deep" is a very subjective issue! so the answer depends on your concept of "deep". But, if having conjugate priors is a "deep" property, in some sense, then that sense is mathematical and not statistical. The only reason that (some) statisticians are interested in conjugate priors is that they simplify some computations. But that is less important for each day that passes! EDIT Trying to answer @whuber comment below. First, an answer needs to ask more precisely what is a conjugate family of priors? It means a family that is closed under sampling, so, (for the given sampling model), the prior and posterior distributions belong to the same family. That is clearly true for the family of all distributions, but that interpretation leaves the question without content, so we need a more limited interpretation. Further, as pointed out by Diaconis & Ylvisaker, for the binomial model, if we let $h$ be a bounded positive function on $[0,1]$ and $f(p;\alpha,\beta)$ be the beta density then $h(p)f(p;\alpha,\beta)$ is a conjugate prior. It lacks some of the properties of the usual beta conjugate prior, but the family it generates is closed under sampling, so a conjugate prior. We don't get nice closed formulas, but we only need one numerical integration to get the normalizing constant. Now, the usual beta prior density has one further important property: The posterior expectation is a linear function: $$ \DeclareMathOperator{\E}{\mathbb{E}} \E \left\{ \E (\theta \mid X=x)\right\} = ax+b $$ (for some $a,b$). The corresponding property holds for the "usual" conjugate priors in exponential families, see Diaconis & Ylvisaker. So in these sense the usual conjugate families plays a role in Bayesian statistics similar to the Gauss-Markov theorem in classical statistics (see Role of Gauss-Markov Theorem in Linear Regression): it is a justification for linear methods. There is also another viewpoint leading to the usual conjugate families. If we think of the prior information as representing information from some prior data (from the same sampling distribution family), then we could incorporate this information as a prior likelihood function. Then we could get a combined likelihood function by multiplying the prior likelihood with the data likelihood. We could instead choose to represent the prior data information via a prior distribution, the "usual" conjugate prior is the choice that gives a $\text{prior}\times\text{likelihood}$ proportional to the combined likelihood above. See https://en.wikipedia.org/wiki/Conjugate_prior where this interpretation is used to give prior data interpretations to the parameters in the (usual) conjugate families listed. So, summarizing, the usual conjugate families in exponential families can be justified as priors leading to linear methods, or as priors coming from representing prior data. Hope this extended answer helps!
Having a conjugate prior: Deep property or mathematical accident?
What properties are "deep" is a very subjective issue! so the answer depends on your concept of "deep". But, if having conjugate priors is a "deep" property, in some sense, then that sense is mathemat
Having a conjugate prior: Deep property or mathematical accident? What properties are "deep" is a very subjective issue! so the answer depends on your concept of "deep". But, if having conjugate priors is a "deep" property, in some sense, then that sense is mathematical and not statistical. The only reason that (some) statisticians are interested in conjugate priors is that they simplify some computations. But that is less important for each day that passes! EDIT Trying to answer @whuber comment below. First, an answer needs to ask more precisely what is a conjugate family of priors? It means a family that is closed under sampling, so, (for the given sampling model), the prior and posterior distributions belong to the same family. That is clearly true for the family of all distributions, but that interpretation leaves the question without content, so we need a more limited interpretation. Further, as pointed out by Diaconis & Ylvisaker, for the binomial model, if we let $h$ be a bounded positive function on $[0,1]$ and $f(p;\alpha,\beta)$ be the beta density then $h(p)f(p;\alpha,\beta)$ is a conjugate prior. It lacks some of the properties of the usual beta conjugate prior, but the family it generates is closed under sampling, so a conjugate prior. We don't get nice closed formulas, but we only need one numerical integration to get the normalizing constant. Now, the usual beta prior density has one further important property: The posterior expectation is a linear function: $$ \DeclareMathOperator{\E}{\mathbb{E}} \E \left\{ \E (\theta \mid X=x)\right\} = ax+b $$ (for some $a,b$). The corresponding property holds for the "usual" conjugate priors in exponential families, see Diaconis & Ylvisaker. So in these sense the usual conjugate families plays a role in Bayesian statistics similar to the Gauss-Markov theorem in classical statistics (see Role of Gauss-Markov Theorem in Linear Regression): it is a justification for linear methods. There is also another viewpoint leading to the usual conjugate families. If we think of the prior information as representing information from some prior data (from the same sampling distribution family), then we could incorporate this information as a prior likelihood function. Then we could get a combined likelihood function by multiplying the prior likelihood with the data likelihood. We could instead choose to represent the prior data information via a prior distribution, the "usual" conjugate prior is the choice that gives a $\text{prior}\times\text{likelihood}$ proportional to the combined likelihood above. See https://en.wikipedia.org/wiki/Conjugate_prior where this interpretation is used to give prior data interpretations to the parameters in the (usual) conjugate families listed. So, summarizing, the usual conjugate families in exponential families can be justified as priors leading to linear methods, or as priors coming from representing prior data. Hope this extended answer helps!
Having a conjugate prior: Deep property or mathematical accident? What properties are "deep" is a very subjective issue! so the answer depends on your concept of "deep". But, if having conjugate priors is a "deep" property, in some sense, then that sense is mathemat
37,830
Does Greenhouse-Geisser correction influence the effect size estimation, the statistical significance treshold, or both of them?
Bellow I show part of a code I have written to estimate eta. In the first output I use the normal df, in the second the greenhouse geisser df and in the third the hyndt df. You can get the adjusted df by df*ε. According to what I have written, assuming that everything is correct, eta and partial eta as far as I can see, do not change. es<-function(condition,ss_effects,ss_error,df_ef,df_er,n) { ss_total<-ss_effects+ss_error ms_effects<-ss_effects/df_ef ms_error<-ss_error/df_er ms_total<-ms_effects+ms_error eta_squared<-ss_effects/ss_total partial_eta<-ss_effects/(ss_effects+ss_error) omega_squared<-(df_ef*(ms_effects-ms_error))/(ss_total+ms_error) partial_omega<-(df_ef*(ms_effects-ms_error))/(df_ef*ms_effects+(n-df_ef)*ms_error) cohens_f<-sqrt(eta_squared/(1-eta_squared)) result<-data.frame(condition,ss_total,ms_effects,ms_error,ms_total,eta_squared,partial_eta,omega_squared,partial_omega,cohens_f) return(result) } > es(condition=result_repeated$condition,ss_effects=ss_effects,ss_error=ss_error,df_ef=df_ef,df_er=df_er,n=n) condition ss_total ms_effects ms_error ms_total eta_squared partial_eta omega_squared partial_omega cohens_f 1 (Intercept) 56477.6604 55994.788226 2.4264934 55997.214719 0.99145021 0.99145021 0.9913646526 0.7807508983 10.76856192 2 IV1 31611.1552 15667.955258 0.6915697 15668.646827 0.99129280 0.99129280 0.9912273571 0.8748775914 10.66993196 3 IV2 29447.1128 14584.040310 0.7010859 14584.741396 0.99052429 0.99052429 0.9904530958 0.8652306377 10.22413944 4 IV3 298.3998 2.315401 0.7381130 3.053514 0.01551879 0.01551879 0.0105455609 0.0006591085 0.12555245 5 IV1:IV2 796.1730 3.083176 0.9847241 4.067900 0.01548998 0.01548998 0.0105296693 0.0013137071 0.12543402 6 IV1:IV3 698.4388 2.233520 0.8662120 3.099732 0.01279150 0.01279150 0.0078209534 0.0009734288 0.11382988 7 IV2:IV3 761.3055 1.129699 0.9507371 2.080436 0.00593559 0.00593559 0.0009391186 0.0001161811 0.07727245 8 IV1:IV2:IV3 1369.0296 3.530436 0.8422024 4.372638 0.02063029 0.02063029 0.0156991811 0.0039251608 0.14513741 > es(condition=result_repeated$condition,ss_effects=ss_effects,ss_error=ss_error,df_ef=result_repeated$GG_df_ef,df_er=result_repeated$GG_df_er,n=n) condition ss_total ms_effects ms_error ms_total eta_squared partial_eta omega_squared partial_omega cohens_f 1 (Intercept) 56477.6604 NA NA NA 0.99145021 0.99145021 NA NA 10.76856192 2 IV1 31611.1552 15736.719217 0.6946049 15737.413822 0.99129280 0.99129280 0.9912272620 0.8743974241 10.66993196 3 IV2 29447.1128 14819.338300 0.7123972 14820.050698 0.99052429 0.99052429 0.9904527154 0.8633533962 10.22413944 4 IV3 298.3998 2.344612 0.7474250 3.092037 0.01551879 0.01551879 0.0105452327 0.0006509022 0.12555245 5 IV1:IV2 796.1730 3.204442 1.0234546 4.227896 0.01548998 0.01548998 0.0105291577 0.0012640554 0.12543402 6 IV1:IV3 698.4388 2.348475 0.9107944 3.259270 0.01279150 0.01279150 0.0078204548 0.0009258246 0.11382988 7 IV2:IV3 761.3055 1.276727 1.0744736 2.351201 0.00593559 0.00593559 0.0009389662 0.0001028031 0.07727245 8 IV1:IV2:IV3 1369.0296 3.978377 0.9490609 4.927438 0.02063029 0.02063029 0.0156979565 0.0034847513 0.14513741 > es(condition=result_repeated$condition,ss_effects=ss_effects,ss_error=ss_error,df_ef=result_repeated$HF_df_ef,df_er=result_repeated$HF_df_er,n=n) condition ss_total ms_effects ms_error ms_total eta_squared partial_eta omega_squared partial_omega cohens_f 1 (Intercept) 56477.6604 NA NA NA 0.99145021 0.99145021 NA NA 10.76856192 2 IV1 31611.1552 15579.595929 0.6876696 15580.283599 0.99129280 0.99129280 0.9912274794 0.8754953645 10.66993196 3 IV2 29447.1128 14673.954723 0.7054083 14674.660131 0.99052429 0.99052429 0.9904529504 0.8645123245 10.22413944 4 IV3 298.3998 2.321489 0.7400537 3.061543 0.01551879 0.01551879 0.0105454925 0.0006573812 0.12555245 5 IV1:IV2 796.1730 3.134901 1.0012444 4.136146 0.01548998 0.01548998 0.0105294511 0.0012920592 0.12543402 6 IV1:IV3 698.4388 2.298103 0.8912590 3.189362 0.01279150 0.01279150 0.0078206733 0.0009460984 0.11382988 7 IV2:IV3 761.3055 1.251285 1.0530618 2.304347 0.00593559 0.00593559 0.0009389926 0.0001048931 0.07727245 8 IV1:IV2:IV3 1369.0296 3.822652 0.9119120 4.734564 0.02063029 0.02063029 0.0156983822 0.0036261961 0.14513741
Does Greenhouse-Geisser correction influence the effect size estimation, the statistical significanc
Bellow I show part of a code I have written to estimate eta. In the first output I use the normal df, in the second the greenhouse geisser df and in the third the hyndt df. You can get the adjusted df
Does Greenhouse-Geisser correction influence the effect size estimation, the statistical significance treshold, or both of them? Bellow I show part of a code I have written to estimate eta. In the first output I use the normal df, in the second the greenhouse geisser df and in the third the hyndt df. You can get the adjusted df by df*ε. According to what I have written, assuming that everything is correct, eta and partial eta as far as I can see, do not change. es<-function(condition,ss_effects,ss_error,df_ef,df_er,n) { ss_total<-ss_effects+ss_error ms_effects<-ss_effects/df_ef ms_error<-ss_error/df_er ms_total<-ms_effects+ms_error eta_squared<-ss_effects/ss_total partial_eta<-ss_effects/(ss_effects+ss_error) omega_squared<-(df_ef*(ms_effects-ms_error))/(ss_total+ms_error) partial_omega<-(df_ef*(ms_effects-ms_error))/(df_ef*ms_effects+(n-df_ef)*ms_error) cohens_f<-sqrt(eta_squared/(1-eta_squared)) result<-data.frame(condition,ss_total,ms_effects,ms_error,ms_total,eta_squared,partial_eta,omega_squared,partial_omega,cohens_f) return(result) } > es(condition=result_repeated$condition,ss_effects=ss_effects,ss_error=ss_error,df_ef=df_ef,df_er=df_er,n=n) condition ss_total ms_effects ms_error ms_total eta_squared partial_eta omega_squared partial_omega cohens_f 1 (Intercept) 56477.6604 55994.788226 2.4264934 55997.214719 0.99145021 0.99145021 0.9913646526 0.7807508983 10.76856192 2 IV1 31611.1552 15667.955258 0.6915697 15668.646827 0.99129280 0.99129280 0.9912273571 0.8748775914 10.66993196 3 IV2 29447.1128 14584.040310 0.7010859 14584.741396 0.99052429 0.99052429 0.9904530958 0.8652306377 10.22413944 4 IV3 298.3998 2.315401 0.7381130 3.053514 0.01551879 0.01551879 0.0105455609 0.0006591085 0.12555245 5 IV1:IV2 796.1730 3.083176 0.9847241 4.067900 0.01548998 0.01548998 0.0105296693 0.0013137071 0.12543402 6 IV1:IV3 698.4388 2.233520 0.8662120 3.099732 0.01279150 0.01279150 0.0078209534 0.0009734288 0.11382988 7 IV2:IV3 761.3055 1.129699 0.9507371 2.080436 0.00593559 0.00593559 0.0009391186 0.0001161811 0.07727245 8 IV1:IV2:IV3 1369.0296 3.530436 0.8422024 4.372638 0.02063029 0.02063029 0.0156991811 0.0039251608 0.14513741 > es(condition=result_repeated$condition,ss_effects=ss_effects,ss_error=ss_error,df_ef=result_repeated$GG_df_ef,df_er=result_repeated$GG_df_er,n=n) condition ss_total ms_effects ms_error ms_total eta_squared partial_eta omega_squared partial_omega cohens_f 1 (Intercept) 56477.6604 NA NA NA 0.99145021 0.99145021 NA NA 10.76856192 2 IV1 31611.1552 15736.719217 0.6946049 15737.413822 0.99129280 0.99129280 0.9912272620 0.8743974241 10.66993196 3 IV2 29447.1128 14819.338300 0.7123972 14820.050698 0.99052429 0.99052429 0.9904527154 0.8633533962 10.22413944 4 IV3 298.3998 2.344612 0.7474250 3.092037 0.01551879 0.01551879 0.0105452327 0.0006509022 0.12555245 5 IV1:IV2 796.1730 3.204442 1.0234546 4.227896 0.01548998 0.01548998 0.0105291577 0.0012640554 0.12543402 6 IV1:IV3 698.4388 2.348475 0.9107944 3.259270 0.01279150 0.01279150 0.0078204548 0.0009258246 0.11382988 7 IV2:IV3 761.3055 1.276727 1.0744736 2.351201 0.00593559 0.00593559 0.0009389662 0.0001028031 0.07727245 8 IV1:IV2:IV3 1369.0296 3.978377 0.9490609 4.927438 0.02063029 0.02063029 0.0156979565 0.0034847513 0.14513741 > es(condition=result_repeated$condition,ss_effects=ss_effects,ss_error=ss_error,df_ef=result_repeated$HF_df_ef,df_er=result_repeated$HF_df_er,n=n) condition ss_total ms_effects ms_error ms_total eta_squared partial_eta omega_squared partial_omega cohens_f 1 (Intercept) 56477.6604 NA NA NA 0.99145021 0.99145021 NA NA 10.76856192 2 IV1 31611.1552 15579.595929 0.6876696 15580.283599 0.99129280 0.99129280 0.9912274794 0.8754953645 10.66993196 3 IV2 29447.1128 14673.954723 0.7054083 14674.660131 0.99052429 0.99052429 0.9904529504 0.8645123245 10.22413944 4 IV3 298.3998 2.321489 0.7400537 3.061543 0.01551879 0.01551879 0.0105454925 0.0006573812 0.12555245 5 IV1:IV2 796.1730 3.134901 1.0012444 4.136146 0.01548998 0.01548998 0.0105294511 0.0012920592 0.12543402 6 IV1:IV3 698.4388 2.298103 0.8912590 3.189362 0.01279150 0.01279150 0.0078206733 0.0009460984 0.11382988 7 IV2:IV3 761.3055 1.251285 1.0530618 2.304347 0.00593559 0.00593559 0.0009389926 0.0001048931 0.07727245 8 IV1:IV2:IV3 1369.0296 3.822652 0.9119120 4.734564 0.02063029 0.02063029 0.0156983822 0.0036261961 0.14513741
Does Greenhouse-Geisser correction influence the effect size estimation, the statistical significanc Bellow I show part of a code I have written to estimate eta. In the first output I use the normal df, in the second the greenhouse geisser df and in the third the hyndt df. You can get the adjusted df
37,831
Why do Bayesian Networks use acyclicity assumption?
Just to add a little more clarity. this approach is sometimes called Temporal Bayesian Models. I have seen it being used in atleast one other situation of marketing mix models where today's marketing spend influences today's brand & revenue. Today's brand also influences tomorrow's brand & revenue and so on.
Why do Bayesian Networks use acyclicity assumption?
Just to add a little more clarity. this approach is sometimes called Temporal Bayesian Models. I have seen it being used in atleast one other situation of marketing mix models where today's marketing
Why do Bayesian Networks use acyclicity assumption? Just to add a little more clarity. this approach is sometimes called Temporal Bayesian Models. I have seen it being used in atleast one other situation of marketing mix models where today's marketing spend influences today's brand & revenue. Today's brand also influences tomorrow's brand & revenue and so on.
Why do Bayesian Networks use acyclicity assumption? Just to add a little more clarity. this approach is sometimes called Temporal Bayesian Models. I have seen it being used in atleast one other situation of marketing mix models where today's marketing
37,832
How to analyze and interpret A/B test results via Bootstrap method?
Bootstrapping for a mean does not usually make sense for due to the CLT. Just use the mean and standard error on the mean. This will either give the same result as your bootstrap or your bootstrap would have given a poor result. If you truly know you want to compare the mean (and it is not clear that you do Better estimator of expected sum than mean) then you want to test if the two samples are likely to have come from the same population. This would be a Welch t-test with the mean, $\mu$, and standard error on the mean, $\sigma_\mu$. The problem becomes more complicated if there is a different associated risk with each choice coming from other factors (eg implementation cost). If the t-test says there is no significant difference then you clearly want to take the variant with lower risk. However, if the variant with higher risk has a statistically significant impact on mean revenue then it is a judgment call.
How to analyze and interpret A/B test results via Bootstrap method?
Bootstrapping for a mean does not usually make sense for due to the CLT. Just use the mean and standard error on the mean. This will either give the same result as your bootstrap or your bootstrap wou
How to analyze and interpret A/B test results via Bootstrap method? Bootstrapping for a mean does not usually make sense for due to the CLT. Just use the mean and standard error on the mean. This will either give the same result as your bootstrap or your bootstrap would have given a poor result. If you truly know you want to compare the mean (and it is not clear that you do Better estimator of expected sum than mean) then you want to test if the two samples are likely to have come from the same population. This would be a Welch t-test with the mean, $\mu$, and standard error on the mean, $\sigma_\mu$. The problem becomes more complicated if there is a different associated risk with each choice coming from other factors (eg implementation cost). If the t-test says there is no significant difference then you clearly want to take the variant with lower risk. However, if the variant with higher risk has a statistically significant impact on mean revenue then it is a judgment call.
How to analyze and interpret A/B test results via Bootstrap method? Bootstrapping for a mean does not usually make sense for due to the CLT. Just use the mean and standard error on the mean. This will either give the same result as your bootstrap or your bootstrap wou
37,833
Difference-in-difference in panel data
You would expect equivalence when T = 2. If you have more than 2 years, use the latter approach (the one that relies on fixed effects). Please see http://econ.lse.ac.uk/staff/spischke/ec533/did.pdf for more. Note: xi: is redundant in the newer versions of Stata.
Difference-in-difference in panel data
You would expect equivalence when T = 2. If you have more than 2 years, use the latter approach (the one that relies on fixed effects). Please see http://econ.lse.ac.uk/staff/spischke/ec533/did.pdf fo
Difference-in-difference in panel data You would expect equivalence when T = 2. If you have more than 2 years, use the latter approach (the one that relies on fixed effects). Please see http://econ.lse.ac.uk/staff/spischke/ec533/did.pdf for more. Note: xi: is redundant in the newer versions of Stata.
Difference-in-difference in panel data You would expect equivalence when T = 2. If you have more than 2 years, use the latter approach (the one that relies on fixed effects). Please see http://econ.lse.ac.uk/staff/spischke/ec533/did.pdf fo
37,834
Difference-in-difference in panel data
As long as the treatment occurs at the same time for all units, the estimator of DiD is equivalent to the one from panel data (usually called Two-way fixed effects), as shown by Jeffrey Wooldridge in this paper, section 5. To show it, we can generate some random data, apply an effect and estimate with both methods. np.random.seed(1) n=10 #number of units ID=np.arange(n) #list of IDs t= 10 #periods of time #Create dataset data=pd.DataFrame({'ID':np.tile(ID,t),'year':np.repeat(np.arange(t),n), 'after_treatment':(np.repeat([0,1],n*t/2)),'treatment':np.zeros(n*t)}) data.loc[data['ID']<3, 'treatment']=1 #Mark these units as treated in the dataset data['interaction']=data['after_treatment']*data['treatment'] #Create interaction variable ui= np.random.normal (0,2,n*t) #Error term centered in zero with constant variance data['out']=2*data['after_treatment']+2*data['treatment']+3*data['interaction']+ui #generate outcome First, let's estimate with the classic diff-in-diff equation: $$Y_{it} = \beta_0 + \beta_1 \textrm{Post}_t + \beta_2 \textrm{Treated}_i + \beta_3 \textrm{Treated}_i \textrm{Post}_t + e_{it}$$ print(smf.ols('out~after_treatment*treatment', data=data).fit().params[3]) The result is 2.8685. If we estimate as a panel data including time and unit-fixes effects, we are doing: $$y_{it}=\alpha_{i}+ \gamma_{t} +\tau_{it}TreatedxPost +\epsilon_{it}$$ df_panel=data.set_index(['ID', 'year']) Y=df_panel["out"] #Dependent variable X=df_panel[[ "interaction"]] #Independent variables X=sm.add_constant(X) #adding constant model=PanelOLS(Y,X, entity_effects=True, time_effects=True).fit() print(model.params[1]) The result is the same, 2.8685
Difference-in-difference in panel data
As long as the treatment occurs at the same time for all units, the estimator of DiD is equivalent to the one from panel data (usually called Two-way fixed effects), as shown by Jeffrey Wooldridge in
Difference-in-difference in panel data As long as the treatment occurs at the same time for all units, the estimator of DiD is equivalent to the one from panel data (usually called Two-way fixed effects), as shown by Jeffrey Wooldridge in this paper, section 5. To show it, we can generate some random data, apply an effect and estimate with both methods. np.random.seed(1) n=10 #number of units ID=np.arange(n) #list of IDs t= 10 #periods of time #Create dataset data=pd.DataFrame({'ID':np.tile(ID,t),'year':np.repeat(np.arange(t),n), 'after_treatment':(np.repeat([0,1],n*t/2)),'treatment':np.zeros(n*t)}) data.loc[data['ID']<3, 'treatment']=1 #Mark these units as treated in the dataset data['interaction']=data['after_treatment']*data['treatment'] #Create interaction variable ui= np.random.normal (0,2,n*t) #Error term centered in zero with constant variance data['out']=2*data['after_treatment']+2*data['treatment']+3*data['interaction']+ui #generate outcome First, let's estimate with the classic diff-in-diff equation: $$Y_{it} = \beta_0 + \beta_1 \textrm{Post}_t + \beta_2 \textrm{Treated}_i + \beta_3 \textrm{Treated}_i \textrm{Post}_t + e_{it}$$ print(smf.ols('out~after_treatment*treatment', data=data).fit().params[3]) The result is 2.8685. If we estimate as a panel data including time and unit-fixes effects, we are doing: $$y_{it}=\alpha_{i}+ \gamma_{t} +\tau_{it}TreatedxPost +\epsilon_{it}$$ df_panel=data.set_index(['ID', 'year']) Y=df_panel["out"] #Dependent variable X=df_panel[[ "interaction"]] #Independent variables X=sm.add_constant(X) #adding constant model=PanelOLS(Y,X, entity_effects=True, time_effects=True).fit() print(model.params[1]) The result is the same, 2.8685
Difference-in-difference in panel data As long as the treatment occurs at the same time for all units, the estimator of DiD is equivalent to the one from panel data (usually called Two-way fixed effects), as shown by Jeffrey Wooldridge in
37,835
Unscented Kalman filter-negative covariance matrix
I also have this problem. However, I realised that depending on the covariance that you fix, it does not happen. If I set an unrealistic covariance matrix, then the error happens. Which makes me think that is perhaps a matter of numerical errors making the covariance matrix non-positive definite. However, as you say, in the SRUKF in its normal behaviour, this should not happen at all, the covariance matrix is ensured to be symmetric and semi-positive definite. I would suggest a test. Try to measure the covariance of the data, and then set those values. I hope it helps!
Unscented Kalman filter-negative covariance matrix
I also have this problem. However, I realised that depending on the covariance that you fix, it does not happen. If I set an unrealistic covariance matrix, then the error happens. Which makes me think
Unscented Kalman filter-negative covariance matrix I also have this problem. However, I realised that depending on the covariance that you fix, it does not happen. If I set an unrealistic covariance matrix, then the error happens. Which makes me think that is perhaps a matter of numerical errors making the covariance matrix non-positive definite. However, as you say, in the SRUKF in its normal behaviour, this should not happen at all, the covariance matrix is ensured to be symmetric and semi-positive definite. I would suggest a test. Try to measure the covariance of the data, and then set those values. I hope it helps!
Unscented Kalman filter-negative covariance matrix I also have this problem. However, I realised that depending on the covariance that you fix, it does not happen. If I set an unrealistic covariance matrix, then the error happens. Which makes me think
37,836
Modelling a mixed model in JAGS/BUGS [closed]
Sometimes ifelse doesn't work. Instead is0X[i] <- ifelse(goalsScored[i, 1]==0, 1, 0) you should try is0X[i] <- goalsScored[i, 1]==0 goalsScored[i, 1]==0 returns 1 if True and 0 if False
Modelling a mixed model in JAGS/BUGS [closed]
Sometimes ifelse doesn't work. Instead is0X[i] <- ifelse(goalsScored[i, 1]==0, 1, 0) you should try is0X[i] <- goalsScored[i, 1]==0 goalsScored[i, 1]==0 returns 1 if True and 0 if False
Modelling a mixed model in JAGS/BUGS [closed] Sometimes ifelse doesn't work. Instead is0X[i] <- ifelse(goalsScored[i, 1]==0, 1, 0) you should try is0X[i] <- goalsScored[i, 1]==0 goalsScored[i, 1]==0 returns 1 if True and 0 if False
Modelling a mixed model in JAGS/BUGS [closed] Sometimes ifelse doesn't work. Instead is0X[i] <- ifelse(goalsScored[i, 1]==0, 1, 0) you should try is0X[i] <- goalsScored[i, 1]==0 goalsScored[i, 1]==0 returns 1 if True and 0 if False
37,837
Modelling a mixed model in JAGS/BUGS [closed]
I do not think you can define zeros[i] ~ dpois(-log(kappa[i]) + C) inside of the model construction. Try to revise the code to be zeros ~ dpois(-log(kappa[i]) + C) (take out of '[i]'). After defining the model, you re-define the data at zeors: data$zero=0 Try if this works. Refer to The zero-crossings trick for JAGS: Finding roots stochastically for more information.
Modelling a mixed model in JAGS/BUGS [closed]
I do not think you can define zeros[i] ~ dpois(-log(kappa[i]) + C) inside of the model construction. Try to revise the code to be zeros ~ dpois(-log(kappa[i]) + C) (take out of '[i]'). After defining
Modelling a mixed model in JAGS/BUGS [closed] I do not think you can define zeros[i] ~ dpois(-log(kappa[i]) + C) inside of the model construction. Try to revise the code to be zeros ~ dpois(-log(kappa[i]) + C) (take out of '[i]'). After defining the model, you re-define the data at zeors: data$zero=0 Try if this works. Refer to The zero-crossings trick for JAGS: Finding roots stochastically for more information.
Modelling a mixed model in JAGS/BUGS [closed] I do not think you can define zeros[i] ~ dpois(-log(kappa[i]) + C) inside of the model construction. Try to revise the code to be zeros ~ dpois(-log(kappa[i]) + C) (take out of '[i]'). After defining
37,838
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian?
The bivariate normal distribution is the exception, not the rule! It is important to recognize that "almost all" joint distributions with normal marginals are not the bivariate normal distribution. That is, the common viewpoint that joint distributions with normal marginals that are not the bivariate normal are somehow "pathological", is a bit misguided. Certainly, the multivariate normal is extremely important due to its stability under linear transformations, and so receives the bulk of attention in applications. Examples It is useful to start with some examples. The figure below contains heatmaps of six bivariate distributions, all of which have standard normal marginals. The left and middle ones in the top row are bivariate normals, the remaining ones are not (as should be apparent). They're described further below. The bare bones of copulas Properties of dependence are often efficiently analyzed using copulas. A bivariate copula is just a fancy name for a probability distribution on the unit square $[0,1]^2$ with uniform marginals. Suppose $C(u,v)$ is a bivariate copula. Then, immediately from the above, we know that $C(u,v) \geq 0$, $C(u,1) = u$ and $C(1,v) = v$, for example. We can construct bivariate random variables on the Euclidean plane with prespecified marginals by a simple transformation of a bivariate copula. Let $F_1$ and $F_2$ be prescribed marginal distributions for a pair of random variables $(X,Y)$. Then, if $C(u,v)$ is a bivariate copula, $$ F(x,y) = C(F_1(x), F_2(y)) $$ is a bivariate distribution function with marginals $F_1$ and $F_2$. To see this last fact, just note that $$ \renewcommand{\Pr}{\mathbb P} \Pr(X \leq x) = \Pr(X \leq x, Y < \infty) = C(F_1(x), F_2(\infty)) = C(F_1(x),1) = F_1(x) \>. $$ The same argument works for $F_2$. For continuous $F_1$ and $F_2$, Sklar's theorem asserts a converse implying uniqueness. That is, given a bivariate distribution $F(x,y)$ with continuous marginals $F_1$, $F_2$, the corresponding copula is unique (on the appropriate range space). The bivariate normal is exceptional Sklar's theorem tells us (essentially) that there is only one copula that produces the bivariate normal distribution. This is, aptly named, the Gaussian copula which has density on $[0,1]^2$ $$ c_\rho(u,v) := \frac{\partial^2}{\partial u \, \partial v} C_\rho(u,v) = \frac{\varphi_{2,\rho}(\Phi^{-1}(u),\Phi^{-1}(v))}{\varphi(\Phi^{-1}(u)) \varphi(\Phi^{-1}(v))} \>, $$ where the numerator is the bivariate normal distribution with correlation $\rho$ evaluated at $\Phi^{-1}(u)$ and $\Phi^{-1}(v)$. But, there are lots of other copulas and all of them will give a bivariate distribution with normal marginals which is not the bivariate normal by using the transformation described in the previous section. Some details on the examples Note that if $C(u,v)$ is am arbitrary copula with density $c(u,v)$, the corresponding bivariate density with standard normal marginals under the transformation $F(x,y) = C(\Phi(x),\Phi(y))$ is $$ f(x,y) = \varphi(x) \varphi(y) c(\Phi(x), \Phi(y)) \> . $$ Note that by applying the Gaussian copula in the above equation, we recover the bivariate normal density. But, for any other choice of $c(u,v)$, we will not. The examples in the figure were constructed as follows (going across each row, one column at a time): Bivariate normal with independent components. Bivariate normal with $\rho = -0.4$. The example given in this answer of Dilip Sarwate. It can easily be seen to be induced by the copula $C(u,v)$ with density $c(u,v) = 2 (\mathbf 1_{(0 \leq u \leq 1/2, 0 \leq v \leq 1/2)} + \mathbf 1_{(1/2 < u \leq 1, 1/2 < v \leq 1)})$. Generated from the Frank copula with parameter $\theta = 2$. Generated from the Clayton copula with parameter $\theta = 1$. Generated from an asymmetric modification of the Clayton copula with parameter $\theta = 3$.
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G
The bivariate normal distribution is the exception, not the rule! It is important to recognize that "almost all" joint distributions with normal marginals are not the bivariate normal distribution. Th
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian? The bivariate normal distribution is the exception, not the rule! It is important to recognize that "almost all" joint distributions with normal marginals are not the bivariate normal distribution. That is, the common viewpoint that joint distributions with normal marginals that are not the bivariate normal are somehow "pathological", is a bit misguided. Certainly, the multivariate normal is extremely important due to its stability under linear transformations, and so receives the bulk of attention in applications. Examples It is useful to start with some examples. The figure below contains heatmaps of six bivariate distributions, all of which have standard normal marginals. The left and middle ones in the top row are bivariate normals, the remaining ones are not (as should be apparent). They're described further below. The bare bones of copulas Properties of dependence are often efficiently analyzed using copulas. A bivariate copula is just a fancy name for a probability distribution on the unit square $[0,1]^2$ with uniform marginals. Suppose $C(u,v)$ is a bivariate copula. Then, immediately from the above, we know that $C(u,v) \geq 0$, $C(u,1) = u$ and $C(1,v) = v$, for example. We can construct bivariate random variables on the Euclidean plane with prespecified marginals by a simple transformation of a bivariate copula. Let $F_1$ and $F_2$ be prescribed marginal distributions for a pair of random variables $(X,Y)$. Then, if $C(u,v)$ is a bivariate copula, $$ F(x,y) = C(F_1(x), F_2(y)) $$ is a bivariate distribution function with marginals $F_1$ and $F_2$. To see this last fact, just note that $$ \renewcommand{\Pr}{\mathbb P} \Pr(X \leq x) = \Pr(X \leq x, Y < \infty) = C(F_1(x), F_2(\infty)) = C(F_1(x),1) = F_1(x) \>. $$ The same argument works for $F_2$. For continuous $F_1$ and $F_2$, Sklar's theorem asserts a converse implying uniqueness. That is, given a bivariate distribution $F(x,y)$ with continuous marginals $F_1$, $F_2$, the corresponding copula is unique (on the appropriate range space). The bivariate normal is exceptional Sklar's theorem tells us (essentially) that there is only one copula that produces the bivariate normal distribution. This is, aptly named, the Gaussian copula which has density on $[0,1]^2$ $$ c_\rho(u,v) := \frac{\partial^2}{\partial u \, \partial v} C_\rho(u,v) = \frac{\varphi_{2,\rho}(\Phi^{-1}(u),\Phi^{-1}(v))}{\varphi(\Phi^{-1}(u)) \varphi(\Phi^{-1}(v))} \>, $$ where the numerator is the bivariate normal distribution with correlation $\rho$ evaluated at $\Phi^{-1}(u)$ and $\Phi^{-1}(v)$. But, there are lots of other copulas and all of them will give a bivariate distribution with normal marginals which is not the bivariate normal by using the transformation described in the previous section. Some details on the examples Note that if $C(u,v)$ is am arbitrary copula with density $c(u,v)$, the corresponding bivariate density with standard normal marginals under the transformation $F(x,y) = C(\Phi(x),\Phi(y))$ is $$ f(x,y) = \varphi(x) \varphi(y) c(\Phi(x), \Phi(y)) \> . $$ Note that by applying the Gaussian copula in the above equation, we recover the bivariate normal density. But, for any other choice of $c(u,v)$, we will not. The examples in the figure were constructed as follows (going across each row, one column at a time): Bivariate normal with independent components. Bivariate normal with $\rho = -0.4$. The example given in this answer of Dilip Sarwate. It can easily be seen to be induced by the copula $C(u,v)$ with density $c(u,v) = 2 (\mathbf 1_{(0 \leq u \leq 1/2, 0 \leq v \leq 1/2)} + \mathbf 1_{(1/2 < u \leq 1, 1/2 < v \leq 1)})$. Generated from the Frank copula with parameter $\theta = 2$. Generated from the Clayton copula with parameter $\theta = 1$. Generated from an asymmetric modification of the Clayton copula with parameter $\theta = 3$.
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G The bivariate normal distribution is the exception, not the rule! It is important to recognize that "almost all" joint distributions with normal marginals are not the bivariate normal distribution. Th
37,839
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian?
It is true that each element of a multivariate normal vector is itself normally distributed, and you can deduce their means and variances. However, it is not true that any two Guassian random variables are jointly normally distributed. Here is an example: Edit: In response to the consensus that a random variable that is a point mass can be thought of as a normally distributed variable with $\sigma^2=0$, I'm changing my example. Let $X \sim N(0,1)$ and let $Y = X \cdot (2B-1)$ where $B$ is a ${\rm Bernoulli}(1/2)$ random variable. That is, $Y = \pm X$ each with probability $1/2$. We first show that $Y$ has a standard normal distribution. By the law of total probability, $$ P(Y \leq y) = \frac{1}{2} \Big( P(Y \leq y | B = 1) + P(Y \leq y | B = 0) \Big) $$ Next, $$ P(Y \leq y | B = 0) = P(-X \leq y) = 1-P(X \leq -y) = 1-\Phi(-y) = \Phi(y) $$ where $\Phi$ is the standard normal CDF. Similarly, $$ P(Y \leq y | B = 1) = P(X \leq y) = \Phi(y) $$ Therefore, $$ P(Y \leq y) = \frac{1}{2} \Big( \Phi(y) + \Phi(y) \Big) = \Phi(y) $$ so, the CDF of $Y$ is $\Phi(\cdot)$, thus $Y \sim N(0,1)$. Now we show that $X,Y$ are not jointly normally distributed. As @cardinal points out, one characterization of the multivariate normal is that every linear combination of its elements is normally distributed. $X,Y$ do not have this property, since $$ Y+X = \begin{cases} 2X &\mbox{if } B = 1 \\ 0 & \mbox{if } B = 0. \end{cases} $$ Therefore $Y+X$ is a $50/50$ mixture of a $N(0,4)$ random variable and a point mass at 0, therefore it cannot be normally distributed.
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G
It is true that each element of a multivariate normal vector is itself normally distributed, and you can deduce their means and variances. However, it is not true that any two Guassian random variable
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian? It is true that each element of a multivariate normal vector is itself normally distributed, and you can deduce their means and variances. However, it is not true that any two Guassian random variables are jointly normally distributed. Here is an example: Edit: In response to the consensus that a random variable that is a point mass can be thought of as a normally distributed variable with $\sigma^2=0$, I'm changing my example. Let $X \sim N(0,1)$ and let $Y = X \cdot (2B-1)$ where $B$ is a ${\rm Bernoulli}(1/2)$ random variable. That is, $Y = \pm X$ each with probability $1/2$. We first show that $Y$ has a standard normal distribution. By the law of total probability, $$ P(Y \leq y) = \frac{1}{2} \Big( P(Y \leq y | B = 1) + P(Y \leq y | B = 0) \Big) $$ Next, $$ P(Y \leq y | B = 0) = P(-X \leq y) = 1-P(X \leq -y) = 1-\Phi(-y) = \Phi(y) $$ where $\Phi$ is the standard normal CDF. Similarly, $$ P(Y \leq y | B = 1) = P(X \leq y) = \Phi(y) $$ Therefore, $$ P(Y \leq y) = \frac{1}{2} \Big( \Phi(y) + \Phi(y) \Big) = \Phi(y) $$ so, the CDF of $Y$ is $\Phi(\cdot)$, thus $Y \sim N(0,1)$. Now we show that $X,Y$ are not jointly normally distributed. As @cardinal points out, one characterization of the multivariate normal is that every linear combination of its elements is normally distributed. $X,Y$ do not have this property, since $$ Y+X = \begin{cases} 2X &\mbox{if } B = 1 \\ 0 & \mbox{if } B = 0. \end{cases} $$ Therefore $Y+X$ is a $50/50$ mixture of a $N(0,4)$ random variable and a point mass at 0, therefore it cannot be normally distributed.
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G It is true that each element of a multivariate normal vector is itself normally distributed, and you can deduce their means and variances. However, it is not true that any two Guassian random variable
37,840
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian?
The following post contains an outline of a proof, just to give the main ideas and get you started. Let $z = (Z_1, Z_2)$ be two independent Gaussian random variables and let $x = (X_1, X_2)$ be $$ x = \begin{pmatrix} X_1 \\ X_2 \end{pmatrix} = \begin{pmatrix} \alpha_{11} Z_1 + \alpha_{12} Z_2\\ \alpha_{21} Z_1 + \alpha_{22} Z_2 \end{pmatrix} = \begin{pmatrix} \alpha_{11} & \alpha_{12}\\ \alpha_{21} & \alpha_{22} \end{pmatrix} \begin{pmatrix} Z_1 \\ Z_2 \end{pmatrix} = A z. $$ Each $X_i \sim N(\mu_i, \sigma_i^2)$, but as they are both linear combinations of the same independent r.vs, they are jointly dependent. Definition A pair of r.vs $x = (X_1, X_2)$ are said to be bivariate normally distributed iff it can be written as a linear combination $x = Az$ of independent normal r.vs $z = (Z_1, Z_2)$. Lemma If $ x = (X_1, X_2)$ is a bivariate Gaussian, then any other linear combination of them is again a normal random variable. Proof. Trivial, skipped to not offend anyone. Property If $X_1, X_2$ are uncorrelated, then they are independent and vice-versa. Distribution of $X_1 | X_2$ Assume $X_1, X_2$ are the same Gaussian r.vs as before but let's suppose they have positive variance and zero mean for simplicity. If $\mathbf S$ is the subspace spanned by $X_2$, let $ X_1^{\mathbf S} = \frac{\rho \sigma_{X_1}}{\sigma_{X_2}} X_2 $ and $ X_1^{\mathbf S^\perp} = X_1 - X_1^{\mathbf S} $. $X_1$ and $X_2$ are linear combinations of $z$, so $ X_2, X_1^{\mathbf S^\perp}$ are too. They are jointly Gaussian, uncorrelated (prove it) and independent. The decomposition $$ X_1 = X_1^{\mathbf S} + X_1^{\mathbf S^\perp} $$ holds with $\mathbf{E}[X_1 | X_2] = \frac{\rho \sigma_{X_1}}{\sigma_{X_2}} X_2 = X_1^{\mathbf S}$ $$ \begin{split} \mathbf{V}[X_1 | X_2] &= \mathbf{V}[X_1^{\mathbf S^\perp}] \\ &= \mathbf{E} \left[ X_1 - \frac{\rho \sigma_{X_1}}{\sigma_{X_2}} X_2 \right]^2 \\ &= (1 - \rho)^2 \sigma^2_{X_1}. \end{split} $$ Then $$ X_1 | X_2 \sim N\left( X_1^{\mathbf S}, (1 - \rho)^2 \sigma^2_{X_1} \right).$$ Two univariate Gaussian random variables $X, Y$ are jointly Gaussian if the conditionals $X | Y$ and $Y|X$ are Gaussian too.
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G
The following post contains an outline of a proof, just to give the main ideas and get you started. Let $z = (Z_1, Z_2)$ be two independent Gaussian random variables and let $x = (X_1, X_2)$ be $$ x =
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian? The following post contains an outline of a proof, just to give the main ideas and get you started. Let $z = (Z_1, Z_2)$ be two independent Gaussian random variables and let $x = (X_1, X_2)$ be $$ x = \begin{pmatrix} X_1 \\ X_2 \end{pmatrix} = \begin{pmatrix} \alpha_{11} Z_1 + \alpha_{12} Z_2\\ \alpha_{21} Z_1 + \alpha_{22} Z_2 \end{pmatrix} = \begin{pmatrix} \alpha_{11} & \alpha_{12}\\ \alpha_{21} & \alpha_{22} \end{pmatrix} \begin{pmatrix} Z_1 \\ Z_2 \end{pmatrix} = A z. $$ Each $X_i \sim N(\mu_i, \sigma_i^2)$, but as they are both linear combinations of the same independent r.vs, they are jointly dependent. Definition A pair of r.vs $x = (X_1, X_2)$ are said to be bivariate normally distributed iff it can be written as a linear combination $x = Az$ of independent normal r.vs $z = (Z_1, Z_2)$. Lemma If $ x = (X_1, X_2)$ is a bivariate Gaussian, then any other linear combination of them is again a normal random variable. Proof. Trivial, skipped to not offend anyone. Property If $X_1, X_2$ are uncorrelated, then they are independent and vice-versa. Distribution of $X_1 | X_2$ Assume $X_1, X_2$ are the same Gaussian r.vs as before but let's suppose they have positive variance and zero mean for simplicity. If $\mathbf S$ is the subspace spanned by $X_2$, let $ X_1^{\mathbf S} = \frac{\rho \sigma_{X_1}}{\sigma_{X_2}} X_2 $ and $ X_1^{\mathbf S^\perp} = X_1 - X_1^{\mathbf S} $. $X_1$ and $X_2$ are linear combinations of $z$, so $ X_2, X_1^{\mathbf S^\perp}$ are too. They are jointly Gaussian, uncorrelated (prove it) and independent. The decomposition $$ X_1 = X_1^{\mathbf S} + X_1^{\mathbf S^\perp} $$ holds with $\mathbf{E}[X_1 | X_2] = \frac{\rho \sigma_{X_1}}{\sigma_{X_2}} X_2 = X_1^{\mathbf S}$ $$ \begin{split} \mathbf{V}[X_1 | X_2] &= \mathbf{V}[X_1^{\mathbf S^\perp}] \\ &= \mathbf{E} \left[ X_1 - \frac{\rho \sigma_{X_1}}{\sigma_{X_2}} X_2 \right]^2 \\ &= (1 - \rho)^2 \sigma^2_{X_1}. \end{split} $$ Then $$ X_1 | X_2 \sim N\left( X_1^{\mathbf S}, (1 - \rho)^2 \sigma^2_{X_1} \right).$$ Two univariate Gaussian random variables $X, Y$ are jointly Gaussian if the conditionals $X | Y$ and $Y|X$ are Gaussian too.
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G The following post contains an outline of a proof, just to give the main ideas and get you started. Let $z = (Z_1, Z_2)$ be two independent Gaussian random variables and let $x = (X_1, X_2)$ be $$ x =
37,841
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian?
I thought it might be worth pointing out a couple of nice examples; one I've mentioned in a couple of older answers here on Cross Validated (e.g. this one) and one rather pretty one which occurred to me the other day. Here we have two variables, $Y$ and $Z$, that have (uncorrelated) normal distributions, where $Y$ is functionally (though nonlinearly) related to $Z$. There are any number of possible examples of this type: Start with $Z\sim N(0,1)$ Let $U = F(Z^{2})$ where $F$ is the cdf of a chi-squared variate with $1$ d.f. Note that $U$ is then standard uniform. Let $Y = \Phi^{-1}(U)$ Then $(Y,Z)$ are marginally normal (and in this case uncorrelated) but are not jointly normal You can generate samples from the joint distribution of Y and Z as follows (in R): y <- qnorm(pchisq((z=rnorm(100000L))^2,1)) # if plots are too slow, try 10000L #let's take a look at it: par(mfrow=c(2,2)) hist(z,n=50) hist(y,n=50) qqnorm(y,pch=16,cex=.2,col=rgb(.2,.2,.2,.2)) plot(z,y,pch=16,cex=.2,col=rgb(.2,.2,.2,.2)) par(mfrow=c(1,1)) In particular, the joint distribution lies on a continuous curve with a cusp in it. Here's another. This gives a rather nice bivariate density with heart-shaped contours: It relies on the fact that if $Z_1$, $Z_2$, $Z_3$, and $Z_4$ are iid standard normal, then $L=Z_1Z_2+Z_3Z_4$ is Laplace (double exponential). There's a variety of ways to convert $L$ to a normal, but one is to take $Y=\Phi^{-1}(1-\exp(-|L|))$. Then $Y$ is standard normal but (by symmetry) the relationship between $Z_i$ and $Y$ (for any $i$ in $\{1,2,3,4\}$) is the same; $Y$ and $Z_i$ are not jointly normal but are marginally normal). See the display below (the R code for this may be a little slow, but I think it's worth the wait. If you want a faster version, cut the sample size down. n=100000L z1=rnorm(n); z2=rnorm(n); z3=rnorm(n); z4=rnorm(n) L=z1*z2+z3*z4 y = qnorm(pexp(abs(L))) par(mfrow=c(2,2)) hist(z1,n=100) hist(y,n=100) qqnorm(y) plot(z1,y,cex=.6,col=rgb(.1,.2,.3,.2)) points(z1,y,cex=.5,col=rgb(.35,.3,.0,.1)) # this helps visualize points(z1,y,cex=.4,col=rgb(.4,.1,.1,.05)) # the contours par(mfrow=c(1,1))
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G
I thought it might be worth pointing out a couple of nice examples; one I've mentioned in a couple of older answers here on Cross Validated (e.g. this one) and one rather pretty one which occurred to
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not Gaussian? I thought it might be worth pointing out a couple of nice examples; one I've mentioned in a couple of older answers here on Cross Validated (e.g. this one) and one rather pretty one which occurred to me the other day. Here we have two variables, $Y$ and $Z$, that have (uncorrelated) normal distributions, where $Y$ is functionally (though nonlinearly) related to $Z$. There are any number of possible examples of this type: Start with $Z\sim N(0,1)$ Let $U = F(Z^{2})$ where $F$ is the cdf of a chi-squared variate with $1$ d.f. Note that $U$ is then standard uniform. Let $Y = \Phi^{-1}(U)$ Then $(Y,Z)$ are marginally normal (and in this case uncorrelated) but are not jointly normal You can generate samples from the joint distribution of Y and Z as follows (in R): y <- qnorm(pchisq((z=rnorm(100000L))^2,1)) # if plots are too slow, try 10000L #let's take a look at it: par(mfrow=c(2,2)) hist(z,n=50) hist(y,n=50) qqnorm(y,pch=16,cex=.2,col=rgb(.2,.2,.2,.2)) plot(z,y,pch=16,cex=.2,col=rgb(.2,.2,.2,.2)) par(mfrow=c(1,1)) In particular, the joint distribution lies on a continuous curve with a cusp in it. Here's another. This gives a rather nice bivariate density with heart-shaped contours: It relies on the fact that if $Z_1$, $Z_2$, $Z_3$, and $Z_4$ are iid standard normal, then $L=Z_1Z_2+Z_3Z_4$ is Laplace (double exponential). There's a variety of ways to convert $L$ to a normal, but one is to take $Y=\Phi^{-1}(1-\exp(-|L|))$. Then $Y$ is standard normal but (by symmetry) the relationship between $Z_i$ and $Y$ (for any $i$ in $\{1,2,3,4\}$) is the same; $Y$ and $Z_i$ are not jointly normal but are marginally normal). See the display below (the R code for this may be a little slow, but I think it's worth the wait. If you want a faster version, cut the sample size down. n=100000L z1=rnorm(n); z2=rnorm(n); z3=rnorm(n); z4=rnorm(n) L=z1*z2+z3*z4 y = qnorm(pexp(abs(L))) par(mfrow=c(2,2)) hist(z1,n=100) hist(y,n=100) qqnorm(y) plot(z1,y,cex=.6,col=rgb(.1,.2,.3,.2)) points(z1,y,cex=.5,col=rgb(.35,.3,.0,.1)) # this helps visualize points(z1,y,cex=.4,col=rgb(.4,.1,.1,.05)) # the contours par(mfrow=c(1,1))
Is it possible to have a pair of Gaussian random variables for which the joint distribution is not G I thought it might be worth pointing out a couple of nice examples; one I've mentioned in a couple of older answers here on Cross Validated (e.g. this one) and one rather pretty one which occurred to
37,842
Help with Bayesian derivation of normal model with conjugate prior
[Here is the full text from our book] The case of a normal distribution with a known variance being quite unrealistic, we now consider the general case of an iid sample $$\mathscr{D}_n=(x_1,\ldots,x_n)$$ from the normal distribution $\mathscr{N}(\mu,\sigma^2)$ and $\theta=(\mu,\sigma^2)$. Keeping the same prior distribution $$\mathscr{N}\left(0,\sigma^{2}\right)$$ on $\mu$, which then appears as a conditional distribution of $\mu$ given $\sigma^2$, {\em i.e.}, relies on the generic decomposition $$ \pi(\mu,\sigma^2) = \pi(\mu|\sigma^2) \pi(\sigma^2)\,, $$ we have to introduce a further prior distribution on $\sigma^2$. To make computations simple at this early stage, we choose an exponential $\mathscr{E}(1)$ distribution on $\sigma^{-2}$. This means that the random variable $\omega=\sigma^{-2}$ is distributed from an exponential $\mathscr{E}(1)$ distribution, the distribution on $\sigma^2$ being derived by the usual change of variable technique, $$ \pi(\sigma^2) = \exp(-\sigma^{-2})\,\left|\dfrac{\text{d}\sigma^{-2}}{\text{d}\sigma^2}\right| = \exp(-\sigma^{-2})\,(\sigma^2)^{-2}\,. $$ (This distribution is a special case of an inverse gamma distribution, namely $\mathcal{IG}(1,1)$.) The corresponding posterior density on $\theta$ is then given by \begin{eqnarray*}\label{eq:conjunor} \pi((\mu,\sigma^2)|\mathscr{D}_n) &\propto& \pi(\sigma^2)\times\pi(\mu|\sigma^2)\times f(\mathscr{D}_n| \mu,\sigma^2)\nonumber\\ & \propto & (\sigma^{-2})^{1/2+2}\, \exp\left\{-(\mu^2 + 2)/2\sigma^2\right\}\nonumber\\ && \times (\sigma^{-2})^{n/2}\,\exp \left\{-\left(n(\mu-\overline{x})^2 + s^2 \right)/2\sigma^2\right\} \\ &\propto& (\sigma^2)^{-(n+5)/2}\exp\left\{-\left[(n+1) (\mu-n\bar x/(n+1))^2+(2+s^2)\right]/2\sigma^2\right\}\nonumber\\ &\propto& (\sigma^2)^{-1/2}\exp\left\{-(n+1)[\mu-n\bar x/(n+1)]^2/2\sigma^2\right\}\,.\nonumber\\ &&\times (\sigma^2)^{-(n+2)/2-1}\exp\left\{-(2+s^2)/2\sigma^2\right\}\,.\nonumber \end{eqnarray*} Therefore, the posterior on $\theta$ can be decomposed as the product of an inverse gamma distribution on $\sigma^2$, $$\mathscr{IG}((n+2)/2,[2+s^2]/2)$$, which is the distribution of the inverse of a gamma $$\mathscr{G}((n+2)/2,[2+s^2]/2)$$ random variable, and, conditionally on $\sigma^2$, a normal distribution on $\mu$, $$\mathscr{N} (n\bar x/(n+1),\sigma^2/(n+1)).$$ The interpretation of this posterior is quite similar to the case when $\sigma$ is known, with the difference that the variability in $\sigma$ induces more variability in $\mu$, the marginal posterior in $\mu$ being then a Student's $t$ distribution $$ \mu|\mathscr{D}_n \sim \mathscr{T}\left(n+2,n\bar x/(n+1),(2+s^2)/(n+1)(n+2)\right)\,, $$ with $n+2$ degrees of freedom, a location parameter proportional to $\bar x$ and a scale parameter (almost) proportional to $s$. But then, indeed, there is a mistake in the derivation of the marginal on $\sigma^2$ which, as you point out, should include a discrepancy between the prior mean ($0$) and the sample mean. The main derivation should thus be \begin{eqnarray*}\label{eq:conjucor} \pi((\mu,\sigma^2)|\mathscr{D}_n) &\propto& \pi(\sigma^2)\times\pi(\mu|\sigma^2)\times f(\mathscr{D}_n| \mu,\sigma^2)\nonumber\\ & \propto & (\sigma^{-2})^{1/2+2}\, \exp\left\{-(\mu^2 + 2)/2\sigma^2\right\}\nonumber\\ && \times (\sigma^{-2})^{n/2}\,\exp \left\{-\left(n(\mu-\overline{x})^2 + s^2 \right)/2\sigma^2\right\} \\ &\propto& (\sigma^2)^{-(n+5)/2}\exp\left\{-\left[(n+1) (\mu-n\bar x/(n+1))^2+(2+s^2)\right]/2\sigma^2\right\}\nonumber\\ &\propto& (\sigma^2)^{-1/2}\exp\left\{-(n+1)[\mu-n\bar x/(n+1)]^2/2\sigma^2\right\}\,.\nonumber\\ &&\times (\sigma^2)^{-(n+2)/2-1}\exp\left\{-\left(2+s^2+\frac{n}{n+1}{\bar x}^2\right)/2\sigma^2\right\}\,.\nonumber \end{eqnarray*} This means that the posterior on $\sigma^2$ is an inverse gamma distribution $$\mathscr{IG}\left((n+2)/2,\left[2+s^2+\frac{n}{n+1}{\bar x}^2\right]/2\right)$$ Mea culpa! And apologies...
Help with Bayesian derivation of normal model with conjugate prior
[Here is the full text from our book] The case of a normal distribution with a known variance being quite unrealistic, we now consider the general case of an iid sample $$\mathscr{D}_n=(x_1,\ldot
Help with Bayesian derivation of normal model with conjugate prior [Here is the full text from our book] The case of a normal distribution with a known variance being quite unrealistic, we now consider the general case of an iid sample $$\mathscr{D}_n=(x_1,\ldots,x_n)$$ from the normal distribution $\mathscr{N}(\mu,\sigma^2)$ and $\theta=(\mu,\sigma^2)$. Keeping the same prior distribution $$\mathscr{N}\left(0,\sigma^{2}\right)$$ on $\mu$, which then appears as a conditional distribution of $\mu$ given $\sigma^2$, {\em i.e.}, relies on the generic decomposition $$ \pi(\mu,\sigma^2) = \pi(\mu|\sigma^2) \pi(\sigma^2)\,, $$ we have to introduce a further prior distribution on $\sigma^2$. To make computations simple at this early stage, we choose an exponential $\mathscr{E}(1)$ distribution on $\sigma^{-2}$. This means that the random variable $\omega=\sigma^{-2}$ is distributed from an exponential $\mathscr{E}(1)$ distribution, the distribution on $\sigma^2$ being derived by the usual change of variable technique, $$ \pi(\sigma^2) = \exp(-\sigma^{-2})\,\left|\dfrac{\text{d}\sigma^{-2}}{\text{d}\sigma^2}\right| = \exp(-\sigma^{-2})\,(\sigma^2)^{-2}\,. $$ (This distribution is a special case of an inverse gamma distribution, namely $\mathcal{IG}(1,1)$.) The corresponding posterior density on $\theta$ is then given by \begin{eqnarray*}\label{eq:conjunor} \pi((\mu,\sigma^2)|\mathscr{D}_n) &\propto& \pi(\sigma^2)\times\pi(\mu|\sigma^2)\times f(\mathscr{D}_n| \mu,\sigma^2)\nonumber\\ & \propto & (\sigma^{-2})^{1/2+2}\, \exp\left\{-(\mu^2 + 2)/2\sigma^2\right\}\nonumber\\ && \times (\sigma^{-2})^{n/2}\,\exp \left\{-\left(n(\mu-\overline{x})^2 + s^2 \right)/2\sigma^2\right\} \\ &\propto& (\sigma^2)^{-(n+5)/2}\exp\left\{-\left[(n+1) (\mu-n\bar x/(n+1))^2+(2+s^2)\right]/2\sigma^2\right\}\nonumber\\ &\propto& (\sigma^2)^{-1/2}\exp\left\{-(n+1)[\mu-n\bar x/(n+1)]^2/2\sigma^2\right\}\,.\nonumber\\ &&\times (\sigma^2)^{-(n+2)/2-1}\exp\left\{-(2+s^2)/2\sigma^2\right\}\,.\nonumber \end{eqnarray*} Therefore, the posterior on $\theta$ can be decomposed as the product of an inverse gamma distribution on $\sigma^2$, $$\mathscr{IG}((n+2)/2,[2+s^2]/2)$$, which is the distribution of the inverse of a gamma $$\mathscr{G}((n+2)/2,[2+s^2]/2)$$ random variable, and, conditionally on $\sigma^2$, a normal distribution on $\mu$, $$\mathscr{N} (n\bar x/(n+1),\sigma^2/(n+1)).$$ The interpretation of this posterior is quite similar to the case when $\sigma$ is known, with the difference that the variability in $\sigma$ induces more variability in $\mu$, the marginal posterior in $\mu$ being then a Student's $t$ distribution $$ \mu|\mathscr{D}_n \sim \mathscr{T}\left(n+2,n\bar x/(n+1),(2+s^2)/(n+1)(n+2)\right)\,, $$ with $n+2$ degrees of freedom, a location parameter proportional to $\bar x$ and a scale parameter (almost) proportional to $s$. But then, indeed, there is a mistake in the derivation of the marginal on $\sigma^2$ which, as you point out, should include a discrepancy between the prior mean ($0$) and the sample mean. The main derivation should thus be \begin{eqnarray*}\label{eq:conjucor} \pi((\mu,\sigma^2)|\mathscr{D}_n) &\propto& \pi(\sigma^2)\times\pi(\mu|\sigma^2)\times f(\mathscr{D}_n| \mu,\sigma^2)\nonumber\\ & \propto & (\sigma^{-2})^{1/2+2}\, \exp\left\{-(\mu^2 + 2)/2\sigma^2\right\}\nonumber\\ && \times (\sigma^{-2})^{n/2}\,\exp \left\{-\left(n(\mu-\overline{x})^2 + s^2 \right)/2\sigma^2\right\} \\ &\propto& (\sigma^2)^{-(n+5)/2}\exp\left\{-\left[(n+1) (\mu-n\bar x/(n+1))^2+(2+s^2)\right]/2\sigma^2\right\}\nonumber\\ &\propto& (\sigma^2)^{-1/2}\exp\left\{-(n+1)[\mu-n\bar x/(n+1)]^2/2\sigma^2\right\}\,.\nonumber\\ &&\times (\sigma^2)^{-(n+2)/2-1}\exp\left\{-\left(2+s^2+\frac{n}{n+1}{\bar x}^2\right)/2\sigma^2\right\}\,.\nonumber \end{eqnarray*} This means that the posterior on $\sigma^2$ is an inverse gamma distribution $$\mathscr{IG}\left((n+2)/2,\left[2+s^2+\frac{n}{n+1}{\bar x}^2\right]/2\right)$$ Mea culpa! And apologies...
Help with Bayesian derivation of normal model with conjugate prior [Here is the full text from our book] The case of a normal distribution with a known variance being quite unrealistic, we now consider the general case of an iid sample $$\mathscr{D}_n=(x_1,\ldot
37,843
What are some use of dense matrices in statistics?
You might find the Java Matrix Benchmark useful. The Matrix Market does not seem to have what you want, although it has many examples.
What are some use of dense matrices in statistics?
You might find the Java Matrix Benchmark useful. The Matrix Market does not seem to have what you want, although it has many examples.
What are some use of dense matrices in statistics? You might find the Java Matrix Benchmark useful. The Matrix Market does not seem to have what you want, although it has many examples.
What are some use of dense matrices in statistics? You might find the Java Matrix Benchmark useful. The Matrix Market does not seem to have what you want, although it has many examples.
37,844
What are some use of dense matrices in statistics?
Here is large, although I'm not sure if it's dense enough for you. From http://www.grouplens.org/node/73 MovieLens 100k - Consists of 100,000 ratings from 1000 users on 1700 movies. MovieLens 1M - Consists of 1 million ratings from 6000 users on 4000 movies. MovieLens 10M - Consists of 10 million ratings and 100,000 tag applications applied to 10,000 movies by 72,000 users.
What are some use of dense matrices in statistics?
Here is large, although I'm not sure if it's dense enough for you. From http://www.grouplens.org/node/73 MovieLens 100k - Consists of 100,000 ratings from 1000 users on 1700 movies. MovieLens 1M - Co
What are some use of dense matrices in statistics? Here is large, although I'm not sure if it's dense enough for you. From http://www.grouplens.org/node/73 MovieLens 100k - Consists of 100,000 ratings from 1000 users on 1700 movies. MovieLens 1M - Consists of 1 million ratings from 6000 users on 4000 movies. MovieLens 10M - Consists of 10 million ratings and 100,000 tag applications applied to 10,000 movies by 72,000 users.
What are some use of dense matrices in statistics? Here is large, although I'm not sure if it's dense enough for you. From http://www.grouplens.org/node/73 MovieLens 100k - Consists of 100,000 ratings from 1000 users on 1700 movies. MovieLens 1M - Co
37,845
What are some use of dense matrices in statistics?
I'm not sure the application you are seeking would make sense in a statistical context. What you're interested in is a linear regression analysis. $A\in R^{m\times n}$ is a matrix of $m$ measurements in which each row is a single measurement of $n$ variables. Two potential applications with possibly $n>5000$ come to my mind. 1) DNA microarray analysis and 2) analysis of functional MRI data. In any case it will be hard to find data sets with $m>5000$ people (measurements) in it. However, your requirement of $m=n$ restricts the sense of such an analysis in a principle way. After all statistics is about inferring some underlying, let's say, truth from noisy data, i.e., the statistical model implicit to your question is $$b=a^Tx + \epsilon$$ where $a$ is a single measurement, $x$ are the assumed parameters that you try to find with your analysis and $\epsilon$ is some form of noise. Now you say that $A$ needs to be invertible, i.e., has to be full rank, i.e., measurements $a$ must not repeat, i.e., you only have a single, noise corrupted observation $b$ per $a$ and that is a very bad situation to try to estimate parameters $x$, especially, in the case where the number of parameters exceeds (or is equal to) the number of measurements. Then your model simply fits the noise in the data which is called overfitting.
What are some use of dense matrices in statistics?
I'm not sure the application you are seeking would make sense in a statistical context. What you're interested in is a linear regression analysis. $A\in R^{m\times n}$ is a matrix of $m$ measurements
What are some use of dense matrices in statistics? I'm not sure the application you are seeking would make sense in a statistical context. What you're interested in is a linear regression analysis. $A\in R^{m\times n}$ is a matrix of $m$ measurements in which each row is a single measurement of $n$ variables. Two potential applications with possibly $n>5000$ come to my mind. 1) DNA microarray analysis and 2) analysis of functional MRI data. In any case it will be hard to find data sets with $m>5000$ people (measurements) in it. However, your requirement of $m=n$ restricts the sense of such an analysis in a principle way. After all statistics is about inferring some underlying, let's say, truth from noisy data, i.e., the statistical model implicit to your question is $$b=a^Tx + \epsilon$$ where $a$ is a single measurement, $x$ are the assumed parameters that you try to find with your analysis and $\epsilon$ is some form of noise. Now you say that $A$ needs to be invertible, i.e., has to be full rank, i.e., measurements $a$ must not repeat, i.e., you only have a single, noise corrupted observation $b$ per $a$ and that is a very bad situation to try to estimate parameters $x$, especially, in the case where the number of parameters exceeds (or is equal to) the number of measurements. Then your model simply fits the noise in the data which is called overfitting.
What are some use of dense matrices in statistics? I'm not sure the application you are seeking would make sense in a statistical context. What you're interested in is a linear regression analysis. $A\in R^{m\times n}$ is a matrix of $m$ measurements
37,846
Assessing the representativeness of population sampling
In survey sampling for commercial and government studies the orthodox approach is as compare the characteristics of the sample with those of the population. For example, comparing the % female, % under 24, etc. The closer the correspondence between the sample and known data for the entire population, the more confidence one can have in the sample. Similarly, the greater the difference between the sample statistics and known population parameters, the greater the uncertainty. Typically, when performing this approach researchers weight the data to remove any obvious biases. This approach has been used to justify the moving of most commercial research from phone samples to online samples over the past 15 years. Of course, while this approach is the orthodoxy it has no real support in the academic literature as the theoretical rigor of the approach can best be characterized as: "looks like a duck, walks like a duck, I'm going to call it a duck". Nevertheless, the approach is the orthodox approach due to the absence of any other alternatives.
Assessing the representativeness of population sampling
In survey sampling for commercial and government studies the orthodox approach is as compare the characteristics of the sample with those of the population. For example, comparing the % female, % und
Assessing the representativeness of population sampling In survey sampling for commercial and government studies the orthodox approach is as compare the characteristics of the sample with those of the population. For example, comparing the % female, % under 24, etc. The closer the correspondence between the sample and known data for the entire population, the more confidence one can have in the sample. Similarly, the greater the difference between the sample statistics and known population parameters, the greater the uncertainty. Typically, when performing this approach researchers weight the data to remove any obvious biases. This approach has been used to justify the moving of most commercial research from phone samples to online samples over the past 15 years. Of course, while this approach is the orthodoxy it has no real support in the academic literature as the theoretical rigor of the approach can best be characterized as: "looks like a duck, walks like a duck, I'm going to call it a duck". Nevertheless, the approach is the orthodox approach due to the absence of any other alternatives.
Assessing the representativeness of population sampling In survey sampling for commercial and government studies the orthodox approach is as compare the characteristics of the sample with those of the population. For example, comparing the % female, % und
37,847
Feature engineering for sheet music
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Maybe useful in this context, also a little bit too late: A novel way to measure similarities between notes Taken from here: The use of the twelfth root of two in music is very well known in Western music. It is known in music theory that two successive pitches $a,b$ which sound “consonant” or “nice” if some ratio $B/A$ is “simple”. The notion of simplicity has not been defined precisely, and we will give a possible notion here: Let $\alpha = 2^{\frac{1}{12}}$, $p_1 = \alpha^{k_1},p_2=\alpha^{k_2}$ where $0 \le k_1,k_2 \le 127$ are the midi pitches. We define the similarity between $p_1$ and $p_2$ to be: $$K_p(k_1,k_2) = \frac{\gcd(a,b)^2}{ab}$$ where $a = $ numerator of a rational approximation of $\alpha^{k_1-k_2}$ and $b = $ denominator of a rational approximation of $\alpha^{k_1-k_2}$. We argue that this similarity could capture when two pitches have a "simple" ratio and hence will sound "nice" together or when played in successive order. Since a pitch alone does not describe a note, we have also defined similarity measures for duration, volume and if it is a rest or not: Herefore we make use of the Jaccard-similarity of two intervals: $$J(A,B) = \frac{\mu(A \cap B)}{\mu(A \cup B)} = \frac{\min(a,b)}{\max(a,b)}$$ where $A = [0,a],B = [0,b]$ are closed intervals and $a,b>0$ and $\mu([x,y]) = y-x$. Using $J$ we define the duration similarity: $$K_d(d_1,d_2) = J([0,d_1],[0,d_2]) = \frac{\min(d_1,d_2)}{\max(d_1,d_2)}$$ for two durations $d_1,d_2$ given as multiple of quarter notes. And similarily we define the volume similarity as : $$K_v(v_1,v_2) = J([0,v_1],[0,v_2])=\frac{\min(v_1,v_2)}{\max(v_1,v_2)}$$ for $0 \le v_1,v_2 \le 127$ giving the volumes in midi notation. For rests we take the similarty $=0$ if one is not a rest and the other is, or $=1$ if both are no rests or both are rests. Having two notes $n_1 = (p_1,d_1,v_1,r_1),n_2 = (p_2,d_2,v_2,r_2)$ we define a similarity between them as: $$K(n_1,n_2) = \alpha_p K_P(p_1,p_2) +\alpha_d K_d(d_1,d_2) + \alpha_v K_v(v_1,v_2) + \alpha_r K_r(r_1,r_2)$$ where $\alpha_p+\alpha_d+\alpha_v+\alpha_r=1$ and $0<\alpha_x<1$ are weights, which can be chosen by the composer. The mathematical properties of this similarity measure are also nice and can be proven. We can use this similarity measure to define a distance between two notes: $$d(n_1,n_2) = \sqrt{2(1-K(n_1,n_2))}$$ This has the advantage of using the nearest neighbors algorithm in generating music. To capture similarities between fixed length sequences of notes, one could define the mean of the similarites: $$K_S((n_1,\cdots,n_s),(N_1,\cdots,N_s)) = \frac{1}{s}\sum_{i=1}^s K(n_i,N_i)$$ This could be useful for measuring consonance of two melodies or so. After having a kernel defined on notes, you could do Cholesky decomposition on the Gram matrix to get the feature vectors. Related question: A new method for processing music scores?
Feature engineering for sheet music
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Feature engineering for sheet music Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Maybe useful in this context, also a little bit too late: A novel way to measure similarities between notes Taken from here: The use of the twelfth root of two in music is very well known in Western music. It is known in music theory that two successive pitches $a,b$ which sound “consonant” or “nice” if some ratio $B/A$ is “simple”. The notion of simplicity has not been defined precisely, and we will give a possible notion here: Let $\alpha = 2^{\frac{1}{12}}$, $p_1 = \alpha^{k_1},p_2=\alpha^{k_2}$ where $0 \le k_1,k_2 \le 127$ are the midi pitches. We define the similarity between $p_1$ and $p_2$ to be: $$K_p(k_1,k_2) = \frac{\gcd(a,b)^2}{ab}$$ where $a = $ numerator of a rational approximation of $\alpha^{k_1-k_2}$ and $b = $ denominator of a rational approximation of $\alpha^{k_1-k_2}$. We argue that this similarity could capture when two pitches have a "simple" ratio and hence will sound "nice" together or when played in successive order. Since a pitch alone does not describe a note, we have also defined similarity measures for duration, volume and if it is a rest or not: Herefore we make use of the Jaccard-similarity of two intervals: $$J(A,B) = \frac{\mu(A \cap B)}{\mu(A \cup B)} = \frac{\min(a,b)}{\max(a,b)}$$ where $A = [0,a],B = [0,b]$ are closed intervals and $a,b>0$ and $\mu([x,y]) = y-x$. Using $J$ we define the duration similarity: $$K_d(d_1,d_2) = J([0,d_1],[0,d_2]) = \frac{\min(d_1,d_2)}{\max(d_1,d_2)}$$ for two durations $d_1,d_2$ given as multiple of quarter notes. And similarily we define the volume similarity as : $$K_v(v_1,v_2) = J([0,v_1],[0,v_2])=\frac{\min(v_1,v_2)}{\max(v_1,v_2)}$$ for $0 \le v_1,v_2 \le 127$ giving the volumes in midi notation. For rests we take the similarty $=0$ if one is not a rest and the other is, or $=1$ if both are no rests or both are rests. Having two notes $n_1 = (p_1,d_1,v_1,r_1),n_2 = (p_2,d_2,v_2,r_2)$ we define a similarity between them as: $$K(n_1,n_2) = \alpha_p K_P(p_1,p_2) +\alpha_d K_d(d_1,d_2) + \alpha_v K_v(v_1,v_2) + \alpha_r K_r(r_1,r_2)$$ where $\alpha_p+\alpha_d+\alpha_v+\alpha_r=1$ and $0<\alpha_x<1$ are weights, which can be chosen by the composer. The mathematical properties of this similarity measure are also nice and can be proven. We can use this similarity measure to define a distance between two notes: $$d(n_1,n_2) = \sqrt{2(1-K(n_1,n_2))}$$ This has the advantage of using the nearest neighbors algorithm in generating music. To capture similarities between fixed length sequences of notes, one could define the mean of the similarites: $$K_S((n_1,\cdots,n_s),(N_1,\cdots,N_s)) = \frac{1}{s}\sum_{i=1}^s K(n_i,N_i)$$ This could be useful for measuring consonance of two melodies or so. After having a kernel defined on notes, you could do Cholesky decomposition on the Gram matrix to get the feature vectors. Related question: A new method for processing music scores?
Feature engineering for sheet music Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
37,848
Train accuracy < Test accuracy with regularization
First, As I know, the training sample size is usually not less than the test sample size. However, it is not the case in your similation. Second, as comment as @gung - Reinstate Monica, how did you train the dataset, the cross-validaiton or other methods? Third, which kind of regularization you used, the LASSO, ridge or elastic net? The regularization is able to make a compromise between estmation variance and bias, thus usually obtain high testing accuracy.
Train accuracy < Test accuracy with regularization
First, As I know, the training sample size is usually not less than the test sample size. However, it is not the case in your similation. Second, as comment as @gung - Reinstate Monica, how did you tr
Train accuracy < Test accuracy with regularization First, As I know, the training sample size is usually not less than the test sample size. However, it is not the case in your similation. Second, as comment as @gung - Reinstate Monica, how did you train the dataset, the cross-validaiton or other methods? Third, which kind of regularization you used, the LASSO, ridge or elastic net? The regularization is able to make a compromise between estmation variance and bias, thus usually obtain high testing accuracy.
Train accuracy < Test accuracy with regularization First, As I know, the training sample size is usually not less than the test sample size. However, it is not the case in your similation. Second, as comment as @gung - Reinstate Monica, how did you tr
37,849
Train accuracy < Test accuracy with regularization
This is only a guess, but I suspect the regularization is interacting with the logistic regression optimizer. In principle, if you can find optimal loss-minimizing parameters, regularization won't increase performance, and instead is likely to lower it (on the training set). However, for large data sets, there are typically stochastic or iterative solvers used to learn the regression parameters, and these will not generally find an optimal solution. For example, the sklearn default in python is LBFGS, a low-memory variant of a quasi-Newtonian iterative solver. Intuitively, when you add regression, you may be restricting the optimization path to a smaller, "better behaved" region of the parameter space, making the optimizer work better in practice.
Train accuracy < Test accuracy with regularization
This is only a guess, but I suspect the regularization is interacting with the logistic regression optimizer. In principle, if you can find optimal loss-minimizing parameters, regularization won't inc
Train accuracy < Test accuracy with regularization This is only a guess, but I suspect the regularization is interacting with the logistic regression optimizer. In principle, if you can find optimal loss-minimizing parameters, regularization won't increase performance, and instead is likely to lower it (on the training set). However, for large data sets, there are typically stochastic or iterative solvers used to learn the regression parameters, and these will not generally find an optimal solution. For example, the sklearn default in python is LBFGS, a low-memory variant of a quasi-Newtonian iterative solver. Intuitively, when you add regression, you may be restricting the optimization path to a smaller, "better behaved" region of the parameter space, making the optimizer work better in practice.
Train accuracy < Test accuracy with regularization This is only a guess, but I suspect the regularization is interacting with the logistic regression optimizer. In principle, if you can find optimal loss-minimizing parameters, regularization won't inc
37,850
Train accuracy < Test accuracy with regularization
Did you look at the distribution of the classes... It may most likely be due imbalanced class distibutions. For example, if you sample contain two class labels 'A', 'B' and if 'A' occurs 80% of the times in your dataset. Assume that your classifier almost always classifies any test data as beloning to class 'A'. Then your training accuracy score is most likely to be around 0.8., However, since, you are chosing your test samples in random, if by some means, the number of samples belonging to Class 'A' is more than than the number of samples belonging to Class 'B', assuming a 90/10 ratio, then your test accuracy would be 0.9 i.e test accuracy > training accuracy. Typically, you'd have a low cross validation score and if you are using python scikit-learn and use StratifiedKFold, for some values of K you would receive warning messages.
Train accuracy < Test accuracy with regularization
Did you look at the distribution of the classes... It may most likely be due imbalanced class distibutions. For example, if you sample contain two class labels 'A', 'B' and if 'A' occurs 80% of the ti
Train accuracy < Test accuracy with regularization Did you look at the distribution of the classes... It may most likely be due imbalanced class distibutions. For example, if you sample contain two class labels 'A', 'B' and if 'A' occurs 80% of the times in your dataset. Assume that your classifier almost always classifies any test data as beloning to class 'A'. Then your training accuracy score is most likely to be around 0.8., However, since, you are chosing your test samples in random, if by some means, the number of samples belonging to Class 'A' is more than than the number of samples belonging to Class 'B', assuming a 90/10 ratio, then your test accuracy would be 0.9 i.e test accuracy > training accuracy. Typically, you'd have a low cross validation score and if you are using python scikit-learn and use StratifiedKFold, for some values of K you would receive warning messages.
Train accuracy < Test accuracy with regularization Did you look at the distribution of the classes... It may most likely be due imbalanced class distibutions. For example, if you sample contain two class labels 'A', 'B' and if 'A' occurs 80% of the ti
37,851
Using Google Causal Impact package to assess the significance of a planned intervention
About seasonality. From the reference: . For example, if the data represent daily observations, use 7 for a day-of-week component. This interface currently only supports up to one seasonal component. and use model.args = list(nseasons = 7, season.duration = 24) to add a day-of-week component to data with hourly granularity So I take it that in your case I think nseasons=13, season.duration=24 as well. What is meant by stable: I take it to mean that the relationship of the covariates, to the series you are tracking is would have been maintained (but for the intervention). So if I was doing a study on some measure affecting house prices (y), and was using as covariates average pay, then if the UK leaving the EU would happen during the intervention period, that might change the relationship between house prices and pay. So the assumption that the relationship between the covariates and y was stable, would be broken. The prior.level.sd, I don't think is something you can infer from your data. It's a parameter used by the algorithm, isn't it?
Using Google Causal Impact package to assess the significance of a planned intervention
About seasonality. From the reference: . For example, if the data represent daily observations, use 7 for a day-of-week component. This interface currently only supports up to one seasonal compo
Using Google Causal Impact package to assess the significance of a planned intervention About seasonality. From the reference: . For example, if the data represent daily observations, use 7 for a day-of-week component. This interface currently only supports up to one seasonal component. and use model.args = list(nseasons = 7, season.duration = 24) to add a day-of-week component to data with hourly granularity So I take it that in your case I think nseasons=13, season.duration=24 as well. What is meant by stable: I take it to mean that the relationship of the covariates, to the series you are tracking is would have been maintained (but for the intervention). So if I was doing a study on some measure affecting house prices (y), and was using as covariates average pay, then if the UK leaving the EU would happen during the intervention period, that might change the relationship between house prices and pay. So the assumption that the relationship between the covariates and y was stable, would be broken. The prior.level.sd, I don't think is something you can infer from your data. It's a parameter used by the algorithm, isn't it?
Using Google Causal Impact package to assess the significance of a planned intervention About seasonality. From the reference: . For example, if the data represent daily observations, use 7 for a day-of-week component. This interface currently only supports up to one seasonal compo
37,852
Sum of normal truncated random variables
You could use approximation by saddlepoint methods, for the sum of truncated normals. I will not give the details now, you can look at my answer to General sum of Gamma distributions for hints. What we need is to find the moment-generating function for a truncated normal, which is easy. I will do it here for a standard normal truncated at $\pm 2$, which has density $$ f(x) =\begin{cases} \frac1{C} \phi(x), & |x| \le 2 \\ 0, & |x| > 2 \end{cases} $$ where $C=\Phi(2) - \Phi(-2)$ here $\phi(x), \Phi(x)$ are density and cdf for a standard normal, respectively. The moment generating function can be calculated as $$ \DeclareMathOperator{\E}{\mathbb{E}} M(t) = \E e^{tX}=\frac1{C}\int_{-2}^2 e^{tx} \phi(x)\; dx=\frac1{C}e^{\frac12 t^2} [\Phi(2-t)-\Phi(-2-t) ] $$ and then we can use saddlepoint approximations.
Sum of normal truncated random variables
You could use approximation by saddlepoint methods, for the sum of truncated normals. I will not give the details now, you can look at my answer to General sum of Gamma distributions for hints. Wha
Sum of normal truncated random variables You could use approximation by saddlepoint methods, for the sum of truncated normals. I will not give the details now, you can look at my answer to General sum of Gamma distributions for hints. What we need is to find the moment-generating function for a truncated normal, which is easy. I will do it here for a standard normal truncated at $\pm 2$, which has density $$ f(x) =\begin{cases} \frac1{C} \phi(x), & |x| \le 2 \\ 0, & |x| > 2 \end{cases} $$ where $C=\Phi(2) - \Phi(-2)$ here $\phi(x), \Phi(x)$ are density and cdf for a standard normal, respectively. The moment generating function can be calculated as $$ \DeclareMathOperator{\E}{\mathbb{E}} M(t) = \E e^{tX}=\frac1{C}\int_{-2}^2 e^{tx} \phi(x)\; dx=\frac1{C}e^{\frac12 t^2} [\Phi(2-t)-\Phi(-2-t) ] $$ and then we can use saddlepoint approximations.
Sum of normal truncated random variables You could use approximation by saddlepoint methods, for the sum of truncated normals. I will not give the details now, you can look at my answer to General sum of Gamma distributions for hints. Wha
37,853
Sum of normal truncated random variables
I'm curious why, but yes, there is a simple way to generate the pdf of this sum of distributions: ## install.packages("truncnorm") ## install.packages("caTools") library(truncnorm) x.mu <- c(12, 18, 7) x.sd <- c(1.5, 2, 0.8) x.a <- x.mu - 2*x.sd x.b <- x.mu + 2*x.sd dmulti <- function(x, a, b, mu, sd) rowSums( sapply(1:length(mu), function(idx) dtruncnorm(x, a=a[idx], b=b[idx], mean=mu[idx], sd=sd[idx])))/length(mu) pmulti <- function(q, a, b, mu, sd) rowSums( sapply(1:length(mu), function(idx) ptruncnorm(q, a=a[idx], b=b[idx], mean=mu[idx], sd=sd[idx])))/length(mu) pointrange <- range(c(x.a, x.b)) pointseq <- seq(pointrange[1], pointrange[2], length.out=100) ## Plot the probability density function plot(pointseq, dmulti(pointseq, x.a, x.b, x.mu, x.sd), type="l") ## Plot the cumulative distribution function plot(pointseq, pmulti(pointseq, x.a, x.b, x.mu, x.sd), type="l")
Sum of normal truncated random variables
I'm curious why, but yes, there is a simple way to generate the pdf of this sum of distributions: ## install.packages("truncnorm") ## install.packages("caTools") library(truncnorm) x.mu <- c(12, 18,
Sum of normal truncated random variables I'm curious why, but yes, there is a simple way to generate the pdf of this sum of distributions: ## install.packages("truncnorm") ## install.packages("caTools") library(truncnorm) x.mu <- c(12, 18, 7) x.sd <- c(1.5, 2, 0.8) x.a <- x.mu - 2*x.sd x.b <- x.mu + 2*x.sd dmulti <- function(x, a, b, mu, sd) rowSums( sapply(1:length(mu), function(idx) dtruncnorm(x, a=a[idx], b=b[idx], mean=mu[idx], sd=sd[idx])))/length(mu) pmulti <- function(q, a, b, mu, sd) rowSums( sapply(1:length(mu), function(idx) ptruncnorm(q, a=a[idx], b=b[idx], mean=mu[idx], sd=sd[idx])))/length(mu) pointrange <- range(c(x.a, x.b)) pointseq <- seq(pointrange[1], pointrange[2], length.out=100) ## Plot the probability density function plot(pointseq, dmulti(pointseq, x.a, x.b, x.mu, x.sd), type="l") ## Plot the cumulative distribution function plot(pointseq, pmulti(pointseq, x.a, x.b, x.mu, x.sd), type="l")
Sum of normal truncated random variables I'm curious why, but yes, there is a simple way to generate the pdf of this sum of distributions: ## install.packages("truncnorm") ## install.packages("caTools") library(truncnorm) x.mu <- c(12, 18,
37,854
How to subset alternatives in nested multinomial logistic regression?
The general term for the type of model you want is a choice model. Assuming your description of the problem is correct, the choices that you are trying to model are not Fish vs Don't fish, but instead the days of the week. The second level of your hierarchy is not, I think, really a level of a hierarchy in terms of the choice. Rather, it is a characteristics of the fishing captain's environment, and so can be dealt with either via interactions, alternative specific effects, or, by estimating a separate model for each fish type. (A challenge with your question is that you are going to have to get across a whole field of research in order to model it; there are specialist books on this topic, and Hensher et al. is probably the simplest to get started with). The issue of certain nodes not being available at the same time is not dealt with by dummy variables. Rather, it is dealt with by having different alternatives in the choice sets. For example, in transportation research, if modeling choice of transport options, only people with a car have the option of traveling by a car. I can't see how you can model this in lmer. There are quite a few specialist choice modeling packages in R. People who estimate a lot of choice models for real-world problem solving (as opposed to academic publication) tend to choose between a latent class logit and a mixed logit (aka random parameters logit). Nested logit is a technique that had its day, 30 years ago. And, just to add to your challenge, this is one of those areas where R is not great, and you will find that some of the models will run for a very long time. Most practitioners will use specialized software that is a lot faster than R for this type of data, such as Stata, SAS, or more specialized packages, such as LIMDEP and Latent Gold.
How to subset alternatives in nested multinomial logistic regression?
The general term for the type of model you want is a choice model. Assuming your description of the problem is correct, the choices that you are trying to model are not Fish vs Don't fish, but instead
How to subset alternatives in nested multinomial logistic regression? The general term for the type of model you want is a choice model. Assuming your description of the problem is correct, the choices that you are trying to model are not Fish vs Don't fish, but instead the days of the week. The second level of your hierarchy is not, I think, really a level of a hierarchy in terms of the choice. Rather, it is a characteristics of the fishing captain's environment, and so can be dealt with either via interactions, alternative specific effects, or, by estimating a separate model for each fish type. (A challenge with your question is that you are going to have to get across a whole field of research in order to model it; there are specialist books on this topic, and Hensher et al. is probably the simplest to get started with). The issue of certain nodes not being available at the same time is not dealt with by dummy variables. Rather, it is dealt with by having different alternatives in the choice sets. For example, in transportation research, if modeling choice of transport options, only people with a car have the option of traveling by a car. I can't see how you can model this in lmer. There are quite a few specialist choice modeling packages in R. People who estimate a lot of choice models for real-world problem solving (as opposed to academic publication) tend to choose between a latent class logit and a mixed logit (aka random parameters logit). Nested logit is a technique that had its day, 30 years ago. And, just to add to your challenge, this is one of those areas where R is not great, and you will find that some of the models will run for a very long time. Most practitioners will use specialized software that is a lot faster than R for this type of data, such as Stata, SAS, or more specialized packages, such as LIMDEP and Latent Gold.
How to subset alternatives in nested multinomial logistic regression? The general term for the type of model you want is a choice model. Assuming your description of the problem is correct, the choices that you are trying to model are not Fish vs Don't fish, but instead
37,855
Interpreting odds ratios less than 1 with 3-category outcome
Given the coeffcient is significant, it means that the cummulative odds for being in a higher food category are .62 times as high for people with less time than for people with no time. Put differently, having more time than no time decreases the odds (and also the probability) for consuming more food (across all categories of your dependent variable). I do not know whether this makes any sense theoretically. Given that the coeffcient for category 1 is positive (OR>1), this suggests a nonlinear relationship across the categories of the iV. That is, the interpretation for catgory 1 is opposite of that for category 2, given the coefficient is significant.
Interpreting odds ratios less than 1 with 3-category outcome
Given the coeffcient is significant, it means that the cummulative odds for being in a higher food category are .62 times as high for people with less time than for people with no time. Put differentl
Interpreting odds ratios less than 1 with 3-category outcome Given the coeffcient is significant, it means that the cummulative odds for being in a higher food category are .62 times as high for people with less time than for people with no time. Put differently, having more time than no time decreases the odds (and also the probability) for consuming more food (across all categories of your dependent variable). I do not know whether this makes any sense theoretically. Given that the coeffcient for category 1 is positive (OR>1), this suggests a nonlinear relationship across the categories of the iV. That is, the interpretation for catgory 1 is opposite of that for category 2, given the coefficient is significant.
Interpreting odds ratios less than 1 with 3-category outcome Given the coeffcient is significant, it means that the cummulative odds for being in a higher food category are .62 times as high for people with less time than for people with no time. Put differentl
37,856
SVM with quadratic loss
They are different specially in the case of regression. The effect of the quadratic loss is to average errors (so it is more sensitive to outliers). To see this, if you minimize, $$ L_{2}(y) = \sum_{i}(y-x_{i})^{2} $$ you get the mean value. The effect of the L1 loss function is to , so that it leads to sparse solutions robust against outliers. Again, consider, $$ L_{1}(y) = \sum_{i}|y-x_{i}| $$ The derivative gives you $\sum_{i}\operatorname{sign}(y-x_{i}) = 0$, which is true for the median. And the median is robust against outliers. Now, how does this translate for SVMs? The loss function affects how the kernel function is regularized (i.e. how you compare samples). This is specially critical in the case of regression, since when using the $L_{2}$ the solution is no longer sparse! (which is one of the aspects of SVMs which makes them interesting in practice). The optimization problem in that case reads, $$ \min_{w} \sum_{i=1}^{l} \xi_{i}^{2} \\ \text{subject to } y_{i}-<w,\phi(x_{i})> = \xi_{i} \\ ||w|| \leq B \text{ and } i = 1,...,l $$ After deriving with respect to the primal variables and substituting, you get, $$ \min_{\alpha} -\lambda \sum_{i=1}^{l}\alpha_{i}^{2}-\sum_{i,j}\alpha_{i}\alpha_{j}\kappa(x_{i},x_{j}) + 2\sum_{i}\alpha_{i}y_{i} $$ for a detailed derivation see for example here. Notice that the first two terms can be grouped in we define as, $$ \min_{\alpha} -\sum_{i,j}\alpha_{i}\alpha_{j}\hat{\kappa}(x_{i},x_{j}) + 2\sum_{i}\alpha_{i}y_{i} $$ where $\hat{\kappa} = (\kappa + \lambda I)$. Notice that this forces the $\alpha$'s not to be sparse anymore.
SVM with quadratic loss
They are different specially in the case of regression. The effect of the quadratic loss is to average errors (so it is more sensitive to outliers). To see this, if you minimize, $$ L_{2}(y) = \sum_{i
SVM with quadratic loss They are different specially in the case of regression. The effect of the quadratic loss is to average errors (so it is more sensitive to outliers). To see this, if you minimize, $$ L_{2}(y) = \sum_{i}(y-x_{i})^{2} $$ you get the mean value. The effect of the L1 loss function is to , so that it leads to sparse solutions robust against outliers. Again, consider, $$ L_{1}(y) = \sum_{i}|y-x_{i}| $$ The derivative gives you $\sum_{i}\operatorname{sign}(y-x_{i}) = 0$, which is true for the median. And the median is robust against outliers. Now, how does this translate for SVMs? The loss function affects how the kernel function is regularized (i.e. how you compare samples). This is specially critical in the case of regression, since when using the $L_{2}$ the solution is no longer sparse! (which is one of the aspects of SVMs which makes them interesting in practice). The optimization problem in that case reads, $$ \min_{w} \sum_{i=1}^{l} \xi_{i}^{2} \\ \text{subject to } y_{i}-<w,\phi(x_{i})> = \xi_{i} \\ ||w|| \leq B \text{ and } i = 1,...,l $$ After deriving with respect to the primal variables and substituting, you get, $$ \min_{\alpha} -\lambda \sum_{i=1}^{l}\alpha_{i}^{2}-\sum_{i,j}\alpha_{i}\alpha_{j}\kappa(x_{i},x_{j}) + 2\sum_{i}\alpha_{i}y_{i} $$ for a detailed derivation see for example here. Notice that the first two terms can be grouped in we define as, $$ \min_{\alpha} -\sum_{i,j}\alpha_{i}\alpha_{j}\hat{\kappa}(x_{i},x_{j}) + 2\sum_{i}\alpha_{i}y_{i} $$ where $\hat{\kappa} = (\kappa + \lambda I)$. Notice that this forces the $\alpha$'s not to be sparse anymore.
SVM with quadratic loss They are different specially in the case of regression. The effect of the quadratic loss is to average errors (so it is more sensitive to outliers). To see this, if you minimize, $$ L_{2}(y) = \sum_{i
37,857
SVM with quadratic loss
"In the dual problem the L2 loss constant can be merged into the kernel." It can be done in the hinge loss too. You only need to rephrase the formulation. It is done here, for instance: A nested heuristic for parameter tuning in Support Vector Machines E Carrizosa, B Martín-Barragán, D Romero Morales Computers & Operations Research 43, 328-334
SVM with quadratic loss
"In the dual problem the L2 loss constant can be merged into the kernel." It can be done in the hinge loss too. You only need to rephrase the formulation. It is done here, for instance: A nested heur
SVM with quadratic loss "In the dual problem the L2 loss constant can be merged into the kernel." It can be done in the hinge loss too. You only need to rephrase the formulation. It is done here, for instance: A nested heuristic for parameter tuning in Support Vector Machines E Carrizosa, B Martín-Barragán, D Romero Morales Computers & Operations Research 43, 328-334
SVM with quadratic loss "In the dual problem the L2 loss constant can be merged into the kernel." It can be done in the hinge loss too. You only need to rephrase the formulation. It is done here, for instance: A nested heur
37,858
Fitting a curve OVER OR UNDER a set of points
As Mark L. Stone comments, your more general problem is indeed known as expectile regression. A nice overview can be found in Waltrup et al. (2015). We need to map your weights of $1$ and $\alpha$ to expectiles that sum to $1$; a little algebra shows that you need $\frac{1}{1+\alpha}$-expectiles. Again per Mark's comment, the expectreg package for R will do the fitting for you (and even include penalization if you want). Here are some random data with a correlation and the expectile regression fits for $\alpha\in\{0.1, 1, 10\}$: R code: n_points <- 25 set.seed(1) xx <- rnorm(n_points) yy <- xx+rnorm(n_points) dataset <- data.frame(x=xx,y=yy) x_predict <- range(xx) alpha <- c(0.1,1,10) expectiles <- 1/(1+alpha) library(expectreg) opar <- par(mai=c(.8,.8,.1,.1)) plot(dataset,las=1,pch=19) for ( ii in seq_along(alpha) ) { model <- expectreg.ls(y~x,dataset,lambda=0,expectiles=expectiles[ii]) lines(x_predict,predict(model,newdata=data.frame(x=x_predict))$fitted,col=ii,lwd=2) } legend("bottomright",lwd=2,col=seq_along(alpha),legend=paste("alpha =",alpha)) par(opar) Now, for your more specific problem of finding a line that passes under all points with minimal sum of squared errors. There are multiple ways to go about this: In the setting of expectile regression, you can simply work with the $0$-expectile (which is simply the limit, $\lim_{\alpha\to\infty}\frac{1}{1+\alpha}=0$). Just use the parameter expectiles=0 in the call to expectreg.ls() above, and you get your line. Symmetrically, expectiles=1 will give you a line above your points (and a ton of warnings, which don't look very serious to me). Alternatively, finding a line below (or above) all points with minimal costs is a straightforward quadratic programming exercise. Your objective function is the sum of squared residuals, which you want to minimize. Your constraints are that $ax_i+b\leq y_i$ for all $i$, and these are obviously linear. You can just feed this into the quadratic programming solver of your choice. Finally, a geometric approach would be to compute the convex hull of your point cloud. A line that is completely below your point cloud is determined by one of the finitely many segments of this hull below the cloud. So you can simply look at each such segment, extend it to a line in both directions, and compute the sum of squared residuals - and finally use the line with the smallest such sum. Again, the same works to find a minimal squared residual line above your point cloud.
Fitting a curve OVER OR UNDER a set of points
As Mark L. Stone comments, your more general problem is indeed known as expectile regression. A nice overview can be found in Waltrup et al. (2015). We need to map your weights of $1$ and $\alpha$ to
Fitting a curve OVER OR UNDER a set of points As Mark L. Stone comments, your more general problem is indeed known as expectile regression. A nice overview can be found in Waltrup et al. (2015). We need to map your weights of $1$ and $\alpha$ to expectiles that sum to $1$; a little algebra shows that you need $\frac{1}{1+\alpha}$-expectiles. Again per Mark's comment, the expectreg package for R will do the fitting for you (and even include penalization if you want). Here are some random data with a correlation and the expectile regression fits for $\alpha\in\{0.1, 1, 10\}$: R code: n_points <- 25 set.seed(1) xx <- rnorm(n_points) yy <- xx+rnorm(n_points) dataset <- data.frame(x=xx,y=yy) x_predict <- range(xx) alpha <- c(0.1,1,10) expectiles <- 1/(1+alpha) library(expectreg) opar <- par(mai=c(.8,.8,.1,.1)) plot(dataset,las=1,pch=19) for ( ii in seq_along(alpha) ) { model <- expectreg.ls(y~x,dataset,lambda=0,expectiles=expectiles[ii]) lines(x_predict,predict(model,newdata=data.frame(x=x_predict))$fitted,col=ii,lwd=2) } legend("bottomright",lwd=2,col=seq_along(alpha),legend=paste("alpha =",alpha)) par(opar) Now, for your more specific problem of finding a line that passes under all points with minimal sum of squared errors. There are multiple ways to go about this: In the setting of expectile regression, you can simply work with the $0$-expectile (which is simply the limit, $\lim_{\alpha\to\infty}\frac{1}{1+\alpha}=0$). Just use the parameter expectiles=0 in the call to expectreg.ls() above, and you get your line. Symmetrically, expectiles=1 will give you a line above your points (and a ton of warnings, which don't look very serious to me). Alternatively, finding a line below (or above) all points with minimal costs is a straightforward quadratic programming exercise. Your objective function is the sum of squared residuals, which you want to minimize. Your constraints are that $ax_i+b\leq y_i$ for all $i$, and these are obviously linear. You can just feed this into the quadratic programming solver of your choice. Finally, a geometric approach would be to compute the convex hull of your point cloud. A line that is completely below your point cloud is determined by one of the finitely many segments of this hull below the cloud. So you can simply look at each such segment, extend it to a line in both directions, and compute the sum of squared residuals - and finally use the line with the smallest such sum. Again, the same works to find a minimal squared residual line above your point cloud.
Fitting a curve OVER OR UNDER a set of points As Mark L. Stone comments, your more general problem is indeed known as expectile regression. A nice overview can be found in Waltrup et al. (2015). We need to map your weights of $1$ and $\alpha$ to
37,859
Fitting a curve OVER OR UNDER a set of points
Here is example code using the Python scipy.optimize.differential_evolution genetic algorithm module implementing a "brick wall" that gives a very large error if the genetic algorithm finds parameters that yield any predicted value above or below that of any data point per a code switch. It works in my tests when I flip the "upper/lower" switch in the code. import numpy as np import matplotlib import matplotlib.pyplot as plt from scipy.optimize import curve_fit import warnings from scipy.optimize import differential_evolution xData = np.array([5.0, 6.1, 7.2, 8.3, 9.4]) yData = np.array([ 10.0, 18.4, 20.8, 23.2, 35.0]) def func(data, a, b): return a * data + b # function for genetic algorithm to minimize (sum of squared error) # this contains the "brick wall" switch for upper/lower def sumOfSquaredError(parameterTuple): warnings.filterwarnings("ignore") # do not print warnings by genetic algorithm val = func(xData, *parameterTuple) for i in range(len(val)): if val[i] < yData[i]: # ****** upper/lower switch ****** val[i] = 1.0E10 return np.sum((yData - val) ** 2.0) def generate_Initial_Parameters(): # min and max used for bounds maxX = max(xData) minX = min(xData) maxY = max(yData) minY = min(yData) parameterBounds = [] maxSlope = (maxY - minY) / (maxX / minX) parameterBounds.append([-maxSlope, maxSlope]) # parameter bounds for a parameterBounds.append([-maxY, maxY]) # parameter bounds for b # "seed" the numpy random number generator for repeatable results result = differential_evolution(sumOfSquaredError, parameterBounds, seed=3) return result.x # generate initial parameter values geneticParameters = generate_Initial_Parameters() # create values for display of fitted peak function a, b = geneticParameters y_fit = func(xData, a, b) plt.plot(xData, yData, 'D') # plot the raw data plt.plot(xData, y_fit) # plot the equation using the fitted parameters plt.show() print('parameters:', geneticParameters)
Fitting a curve OVER OR UNDER a set of points
Here is example code using the Python scipy.optimize.differential_evolution genetic algorithm module implementing a "brick wall" that gives a very large error if the genetic algorithm finds parameters
Fitting a curve OVER OR UNDER a set of points Here is example code using the Python scipy.optimize.differential_evolution genetic algorithm module implementing a "brick wall" that gives a very large error if the genetic algorithm finds parameters that yield any predicted value above or below that of any data point per a code switch. It works in my tests when I flip the "upper/lower" switch in the code. import numpy as np import matplotlib import matplotlib.pyplot as plt from scipy.optimize import curve_fit import warnings from scipy.optimize import differential_evolution xData = np.array([5.0, 6.1, 7.2, 8.3, 9.4]) yData = np.array([ 10.0, 18.4, 20.8, 23.2, 35.0]) def func(data, a, b): return a * data + b # function for genetic algorithm to minimize (sum of squared error) # this contains the "brick wall" switch for upper/lower def sumOfSquaredError(parameterTuple): warnings.filterwarnings("ignore") # do not print warnings by genetic algorithm val = func(xData, *parameterTuple) for i in range(len(val)): if val[i] < yData[i]: # ****** upper/lower switch ****** val[i] = 1.0E10 return np.sum((yData - val) ** 2.0) def generate_Initial_Parameters(): # min and max used for bounds maxX = max(xData) minX = min(xData) maxY = max(yData) minY = min(yData) parameterBounds = [] maxSlope = (maxY - minY) / (maxX / minX) parameterBounds.append([-maxSlope, maxSlope]) # parameter bounds for a parameterBounds.append([-maxY, maxY]) # parameter bounds for b # "seed" the numpy random number generator for repeatable results result = differential_evolution(sumOfSquaredError, parameterBounds, seed=3) return result.x # generate initial parameter values geneticParameters = generate_Initial_Parameters() # create values for display of fitted peak function a, b = geneticParameters y_fit = func(xData, a, b) plt.plot(xData, yData, 'D') # plot the raw data plt.plot(xData, y_fit) # plot the equation using the fitted parameters plt.show() print('parameters:', geneticParameters)
Fitting a curve OVER OR UNDER a set of points Here is example code using the Python scipy.optimize.differential_evolution genetic algorithm module implementing a "brick wall" that gives a very large error if the genetic algorithm finds parameters
37,860
Asymptotics of the survival function for Anderson Darling distribution?
An asymptotic form for the AD distribution in C.D. Sinclair and B.D. Spurr, Journal of the American statistical association, 83, p. 1190-1191, (1988)
Asymptotics of the survival function for Anderson Darling distribution?
An asymptotic form for the AD distribution in C.D. Sinclair and B.D. Spurr, Journal of the American statistical association, 83, p. 1190-1191, (1988)
Asymptotics of the survival function for Anderson Darling distribution? An asymptotic form for the AD distribution in C.D. Sinclair and B.D. Spurr, Journal of the American statistical association, 83, p. 1190-1191, (1988)
Asymptotics of the survival function for Anderson Darling distribution? An asymptotic form for the AD distribution in C.D. Sinclair and B.D. Spurr, Journal of the American statistical association, 83, p. 1190-1191, (1988)
37,861
Ranking of categorical variables in logistic regression
Since you are interested in ranking the categories, you may want to re-code the categorical variables into a number of separate binary variables. Example: Create a binary variable for express delivery- which would take the value 1 for express delivery cases and 0 otherwise. Similarly, a binary variable for standard delivery. For each of these recoded binary variables you can calculate the marginal effects as indicated below: Let me explain a bit on the above equation: lets say d is the re-coded binary variable for express delivery is the probability of event evaluated at mean when d=1 is the probability of event evaluated at mean when d=0 Once you calculate the marginal effects for all the categories (re-coded binary variables) you can rank them.
Ranking of categorical variables in logistic regression
Since you are interested in ranking the categories, you may want to re-code the categorical variables into a number of separate binary variables. Example: Create a binary variable for express deliver
Ranking of categorical variables in logistic regression Since you are interested in ranking the categories, you may want to re-code the categorical variables into a number of separate binary variables. Example: Create a binary variable for express delivery- which would take the value 1 for express delivery cases and 0 otherwise. Similarly, a binary variable for standard delivery. For each of these recoded binary variables you can calculate the marginal effects as indicated below: Let me explain a bit on the above equation: lets say d is the re-coded binary variable for express delivery is the probability of event evaluated at mean when d=1 is the probability of event evaluated at mean when d=0 Once you calculate the marginal effects for all the categories (re-coded binary variables) you can rank them.
Ranking of categorical variables in logistic regression Since you are interested in ranking the categories, you may want to re-code the categorical variables into a number of separate binary variables. Example: Create a binary variable for express deliver
37,862
Ranking of categorical variables in logistic regression
You could fit the logistic regression model using only 1 variable at the time and examine the adjusted R2. The one explaining most of the variance should have more impact on the model... I am just guessing, not sure that it is a rigorous solution...
Ranking of categorical variables in logistic regression
You could fit the logistic regression model using only 1 variable at the time and examine the adjusted R2. The one explaining most of the variance should have more impact on the model... I am just gu
Ranking of categorical variables in logistic regression You could fit the logistic regression model using only 1 variable at the time and examine the adjusted R2. The one explaining most of the variance should have more impact on the model... I am just guessing, not sure that it is a rigorous solution...
Ranking of categorical variables in logistic regression You could fit the logistic regression model using only 1 variable at the time and examine the adjusted R2. The one explaining most of the variance should have more impact on the model... I am just gu
37,863
Ranking of categorical variables in logistic regression
This is a common question with a multitude of answers. The simplest is to use standardized features; the absolute value of coefficients that come back can then loosely be interpreted as 'higher' = 'more influence' on the log(odds). For the most part, using standard scores should not affect your overall results (ROC curve should be the same; confusion matrix should be the same assuming you choose a comparable decision threshold). I usually compute the regression both ways; once using raw scores (to get the prediction equation I will use) and a second time using standardized scores to see which are largest. As for categorical predictors, I assume (but have not checked) that the same holds true when using normalized predictors. If you haven't already, you should also consider using regularization: Lasso/ridge/elastic net. This will help weak, irrelevant or redundant features to drop out, leaving you with a more parsimonious model.
Ranking of categorical variables in logistic regression
This is a common question with a multitude of answers. The simplest is to use standardized features; the absolute value of coefficients that come back can then loosely be interpreted as 'higher' = 'mo
Ranking of categorical variables in logistic regression This is a common question with a multitude of answers. The simplest is to use standardized features; the absolute value of coefficients that come back can then loosely be interpreted as 'higher' = 'more influence' on the log(odds). For the most part, using standard scores should not affect your overall results (ROC curve should be the same; confusion matrix should be the same assuming you choose a comparable decision threshold). I usually compute the regression both ways; once using raw scores (to get the prediction equation I will use) and a second time using standardized scores to see which are largest. As for categorical predictors, I assume (but have not checked) that the same holds true when using normalized predictors. If you haven't already, you should also consider using regularization: Lasso/ridge/elastic net. This will help weak, irrelevant or redundant features to drop out, leaving you with a more parsimonious model.
Ranking of categorical variables in logistic regression This is a common question with a multitude of answers. The simplest is to use standardized features; the absolute value of coefficients that come back can then loosely be interpreted as 'higher' = 'mo
37,864
Finding the distribution of sample range for a Beta population
edit: please stop down voting this comment, it was a comment and should not have been accepted as the answer by the OP. Please read the comments and read the literature if you are unfamiliar with this technique. It seems that the relationship between the uniform distribution and beta distribution of it's ordered statistics is not taught/well understood. I'm guessing you've realized the range is distributed as a form of the beta density? Convert to Uniform if you don't like working with Beta. My advice is don't integrate it out, just think about what form this resembles, it may not have a closed form if involves the incomplete beta function but is not really necessary to find the distribution.
Finding the distribution of sample range for a Beta population
edit: please stop down voting this comment, it was a comment and should not have been accepted as the answer by the OP. Please read the comments and read the literature if you are unfamiliar with this
Finding the distribution of sample range for a Beta population edit: please stop down voting this comment, it was a comment and should not have been accepted as the answer by the OP. Please read the comments and read the literature if you are unfamiliar with this technique. It seems that the relationship between the uniform distribution and beta distribution of it's ordered statistics is not taught/well understood. I'm guessing you've realized the range is distributed as a form of the beta density? Convert to Uniform if you don't like working with Beta. My advice is don't integrate it out, just think about what form this resembles, it may not have a closed form if involves the incomplete beta function but is not really necessary to find the distribution.
Finding the distribution of sample range for a Beta population edit: please stop down voting this comment, it was a comment and should not have been accepted as the answer by the OP. Please read the comments and read the literature if you are unfamiliar with this
37,865
Anomaly detection on time series
I found this article to be very helpful in my case: https://mapr.com/blog/deep-learning-tensorflow/ Using this basic RNN structure, I was able to predict the outcome of the next timestep. By centering all events to the nearest minute, the network was able to recognize the pattern that correlates within the timeline.
Anomaly detection on time series
I found this article to be very helpful in my case: https://mapr.com/blog/deep-learning-tensorflow/ Using this basic RNN structure, I was able to predict the outcome of the next timestep. By centeri
Anomaly detection on time series I found this article to be very helpful in my case: https://mapr.com/blog/deep-learning-tensorflow/ Using this basic RNN structure, I was able to predict the outcome of the next timestep. By centering all events to the nearest minute, the network was able to recognize the pattern that correlates within the timeline.
Anomaly detection on time series I found this article to be very helpful in my case: https://mapr.com/blog/deep-learning-tensorflow/ Using this basic RNN structure, I was able to predict the outcome of the next timestep. By centeri
37,866
Anomaly detection on time series
A simple approach would be to treat each event type as independent, and then to build one model per event type. If you expect events to happen on a regular schedule, then an informative feature could be time-since-last-event. To evaluate the viability of such a model one should do some Exploratory Data Analysis and plot the histograms of such features and analyze whether outliers are present and visible. If it looks reasonable then one could fit a model to the features. If the features are continuous and normally distributed, the distance from the normalized distribution might be a decent anomaly score. That is easy to compute for a single feature (univariate). For multiple features one would use something like EllipticEnvelope or GaussianMixtureModel. One could build a multi-event anomaly scoring model using the anomaly scores fro the per-event models. I see that there are also failure/complete status for events. One might summarize those over a time-period and compute the (time-averaged) failure-rate. Either per-event-type or across all. This one could also build an anomaly detection model on. Perhaps just simple thresholding.
Anomaly detection on time series
A simple approach would be to treat each event type as independent, and then to build one model per event type. If you expect events to happen on a regular schedule, then an informative feature could
Anomaly detection on time series A simple approach would be to treat each event type as independent, and then to build one model per event type. If you expect events to happen on a regular schedule, then an informative feature could be time-since-last-event. To evaluate the viability of such a model one should do some Exploratory Data Analysis and plot the histograms of such features and analyze whether outliers are present and visible. If it looks reasonable then one could fit a model to the features. If the features are continuous and normally distributed, the distance from the normalized distribution might be a decent anomaly score. That is easy to compute for a single feature (univariate). For multiple features one would use something like EllipticEnvelope or GaussianMixtureModel. One could build a multi-event anomaly scoring model using the anomaly scores fro the per-event models. I see that there are also failure/complete status for events. One might summarize those over a time-period and compute the (time-averaged) failure-rate. Either per-event-type or across all. This one could also build an anomaly detection model on. Perhaps just simple thresholding.
Anomaly detection on time series A simple approach would be to treat each event type as independent, and then to build one model per event type. If you expect events to happen on a regular schedule, then an informative feature could
37,867
Anomaly detection on time series
There are several ways with which you can tackle this. Before jumping into designing any models standardize your data. Your data seems unlabeled, so initially, what you can do is perform a t-SNE visualization on it which will give you a lot insights to your data. Based on its result you can develop more sensible models which can group the samples into normal ones and anomalies. More on t-SNE here
Anomaly detection on time series
There are several ways with which you can tackle this. Before jumping into designing any models standardize your data. Your data seems unlabeled, so initially, what you can do is perform a t-SNE visua
Anomaly detection on time series There are several ways with which you can tackle this. Before jumping into designing any models standardize your data. Your data seems unlabeled, so initially, what you can do is perform a t-SNE visualization on it which will give you a lot insights to your data. Based on its result you can develop more sensible models which can group the samples into normal ones and anomalies. More on t-SNE here
Anomaly detection on time series There are several ways with which you can tackle this. Before jumping into designing any models standardize your data. Your data seems unlabeled, so initially, what you can do is perform a t-SNE visua
37,868
Average time ant needs to get out to the woods
$$T=7/3+(8+T)/3+(12+T)/3=9+2T/3$$ $$T/3=9$$ $$T=27$$ From start point, each of 3 paths are equally possible. Two paths lead you back to start point.
Average time ant needs to get out to the woods
$$T=7/3+(8+T)/3+(12+T)/3=9+2T/3$$ $$T/3=9$$ $$T=27$$ From start point, each of 3 paths are equally possible. Two paths lead you back to start point.
Average time ant needs to get out to the woods $$T=7/3+(8+T)/3+(12+T)/3=9+2T/3$$ $$T/3=9$$ $$T=27$$ From start point, each of 3 paths are equally possible. Two paths lead you back to start point.
Average time ant needs to get out to the woods $$T=7/3+(8+T)/3+(12+T)/3=9+2T/3$$ $$T/3=9$$ $$T=27$$ From start point, each of 3 paths are equally possible. Two paths lead you back to start point.
37,869
Average time ant needs to get out to the woods
To answer this question, you have to sum over all possible paths the ant can take, and get the duration of that path, multiplied by the probability of taking that path. That is, $$ E[T] = \sum_{\text{path} \in \text{possible paths}} p(\text{path}) T(\text{path}) $$ Every possible path takes Passage $A$ only once, but can take passages $B$ and $C$ any number of times, in any permutation. So possible paths can be $A$, $BA$, $BBCCA$, $BCCBA$, etc. Suppose the probabilities of choosing passages $A,$ $B,$ and $C,$ are $p_a$, $p_b$, and $p_c$ respectively. Then, for example, the probability of taking path $CBBCCA$ is $p_a p_b^2 p_c^3.$ And, because there are ${5 \choose 2} = 10$ ways of taking $B$ twice and $C$ three times, the contribution of the expected path time given by the possibility of 3 $C$s and 2 $B$s is $10 p_a p_b^2 p_c^3 (T_a + 2 T_b + 3 T_c)$, where $T_a$, $T_b$, and $T_c$ are the path times of each passage respectively. The above gives the contribution to the expected time for taking two $B$s and three $C$s before $A$. But in general, you have to sum over the expected time contribution of all possible combinations of paths $B$ and $C$ before $A$ I'll do that below, but I suggest you stop here and try it yourself first. SPOILER In general, the ant can take a non-$A$ passage any number of times between zero and infinity before taking passage $A$, and for that number of times, it can be any combination of passages $B$ and $C$. So, to get the expected path time, we sum up the contribution of all passage possibilities, multiplied by their time, which looks like, $$ E[T] = T_a + p_a \sum_{n=0}^\infty \sum_{i=0}^n {n \choose i} p_b^i p_c^{n-i} [i T_b + (n-i) T_c]. $$ These sums can be evaluated. Using the Binomial theorem and taking the derivative, you can show that, $$ \sum_{i=0}^n i {n \choose i} x^i y^{n-i} = n x (x+y)^{n-1} $$ and $$ \sum_{i=0}^n (n-i) {n \choose i} x^i y^{n-i} = n y (x+y)^{n-1}. $$ Using these identities, we get $$ E[T] = T_a + p_a (p_b T_b + p_c T_c) \sum_{n=0}^\infty n (p_b + p_c)^{n-1}. $$ Taking the derivative of the sum of the famous geometric series, you can show that, for $|x| < 1$, $$ \sum_{n=0}^\infty n x^{n-1} = \frac{1}{(1 - x)^2}. $$ Noting that $1 - (p_b + p_c) = p_a$, we get, $$ E[T] = T_a + \frac{1}{p_a} (T_b p_b + T_c p_c). $$ If we take $p_a = p_b = p_c = 1/3$ and your values for the times, we get $E[T] = T_a + T_b + T_c$ which is 27 minutes.
Average time ant needs to get out to the woods
To answer this question, you have to sum over all possible paths the ant can take, and get the duration of that path, multiplied by the probability of taking that path. That is, $$ E[T] = \sum_{\text{
Average time ant needs to get out to the woods To answer this question, you have to sum over all possible paths the ant can take, and get the duration of that path, multiplied by the probability of taking that path. That is, $$ E[T] = \sum_{\text{path} \in \text{possible paths}} p(\text{path}) T(\text{path}) $$ Every possible path takes Passage $A$ only once, but can take passages $B$ and $C$ any number of times, in any permutation. So possible paths can be $A$, $BA$, $BBCCA$, $BCCBA$, etc. Suppose the probabilities of choosing passages $A,$ $B,$ and $C,$ are $p_a$, $p_b$, and $p_c$ respectively. Then, for example, the probability of taking path $CBBCCA$ is $p_a p_b^2 p_c^3.$ And, because there are ${5 \choose 2} = 10$ ways of taking $B$ twice and $C$ three times, the contribution of the expected path time given by the possibility of 3 $C$s and 2 $B$s is $10 p_a p_b^2 p_c^3 (T_a + 2 T_b + 3 T_c)$, where $T_a$, $T_b$, and $T_c$ are the path times of each passage respectively. The above gives the contribution to the expected time for taking two $B$s and three $C$s before $A$. But in general, you have to sum over the expected time contribution of all possible combinations of paths $B$ and $C$ before $A$ I'll do that below, but I suggest you stop here and try it yourself first. SPOILER In general, the ant can take a non-$A$ passage any number of times between zero and infinity before taking passage $A$, and for that number of times, it can be any combination of passages $B$ and $C$. So, to get the expected path time, we sum up the contribution of all passage possibilities, multiplied by their time, which looks like, $$ E[T] = T_a + p_a \sum_{n=0}^\infty \sum_{i=0}^n {n \choose i} p_b^i p_c^{n-i} [i T_b + (n-i) T_c]. $$ These sums can be evaluated. Using the Binomial theorem and taking the derivative, you can show that, $$ \sum_{i=0}^n i {n \choose i} x^i y^{n-i} = n x (x+y)^{n-1} $$ and $$ \sum_{i=0}^n (n-i) {n \choose i} x^i y^{n-i} = n y (x+y)^{n-1}. $$ Using these identities, we get $$ E[T] = T_a + p_a (p_b T_b + p_c T_c) \sum_{n=0}^\infty n (p_b + p_c)^{n-1}. $$ Taking the derivative of the sum of the famous geometric series, you can show that, for $|x| < 1$, $$ \sum_{n=0}^\infty n x^{n-1} = \frac{1}{(1 - x)^2}. $$ Noting that $1 - (p_b + p_c) = p_a$, we get, $$ E[T] = T_a + \frac{1}{p_a} (T_b p_b + T_c p_c). $$ If we take $p_a = p_b = p_c = 1/3$ and your values for the times, we get $E[T] = T_a + T_b + T_c$ which is 27 minutes.
Average time ant needs to get out to the woods To answer this question, you have to sum over all possible paths the ant can take, and get the duration of that path, multiplied by the probability of taking that path. That is, $$ E[T] = \sum_{\text{
37,870
Average time ant needs to get out to the woods
Hello donkordr and welcome to CV. No, the mean does not answer the question unfortunately. You can read your problem as a Markov Chain with two states: woods, and ant house. Now, your transition probabilities are: From the woods: (does not really matter as it's the goal) $p=1$ to stay in the woods From the ant house: $p_1=\frac{2}{3}$ to stay at the ant house and $p_2=\frac{1}{3}$ to go to the woods We want to know how many movements it takes on average to reach the woods - and you can do so as explained here This results in an average of 3 movements. Of these 3 movements, one and only one will be the one leading to the woods, while the rest will be any of the others. The average time of a movement that does not go to the woods is $(8+12)/2 = 10$ minutes. As a result, the average time before you reach the woods is $27$ minutes: $7$ from the last step, and $2\cdot10$ from the previous ones. PS - there are other ways to make this computation with intermediate states that might be cleaner, but this seemed easy enough.
Average time ant needs to get out to the woods
Hello donkordr and welcome to CV. No, the mean does not answer the question unfortunately. You can read your problem as a Markov Chain with two states: woods, and ant house. Now, your transition pro
Average time ant needs to get out to the woods Hello donkordr and welcome to CV. No, the mean does not answer the question unfortunately. You can read your problem as a Markov Chain with two states: woods, and ant house. Now, your transition probabilities are: From the woods: (does not really matter as it's the goal) $p=1$ to stay in the woods From the ant house: $p_1=\frac{2}{3}$ to stay at the ant house and $p_2=\frac{1}{3}$ to go to the woods We want to know how many movements it takes on average to reach the woods - and you can do so as explained here This results in an average of 3 movements. Of these 3 movements, one and only one will be the one leading to the woods, while the rest will be any of the others. The average time of a movement that does not go to the woods is $(8+12)/2 = 10$ minutes. As a result, the average time before you reach the woods is $27$ minutes: $7$ from the last step, and $2\cdot10$ from the previous ones. PS - there are other ways to make this computation with intermediate states that might be cleaner, but this seemed easy enough.
Average time ant needs to get out to the woods Hello donkordr and welcome to CV. No, the mean does not answer the question unfortunately. You can read your problem as a Markov Chain with two states: woods, and ant house. Now, your transition pro
37,871
Average time ant needs to get out to the woods
Let me join with an explanation which, to me at least, seems even easier: First, observe that the paths $B$ and $C$ can be joined into a single path $X$, with the passage time equal to the mean times of $B$ and $C$, i.e. $10$ minutes. This is due to the fact that these paths have the same probability. If they didn't, we'd need to take a weighted average. The probability of taking the path $X$ is the sum of probabilities of taking either the path $B$ or $C$: $P(X) = P(B) + P(C) = 2/3$. Now, there are the following ways of getting to the woods: $$\begin{array}{lrr} i & \text{path}_i & P(i) & T(i)\\ \hline 0 & A & 1/3 & 7\\ 1 & XA & 2/3 \cdot 1/3 & 10 + 7 \\ 2 & XXA & (2/3)^2 \cdot 1/3 & 20 + 7 \\ 3 & XXXA & (2/3)^3 \cdot 1/3 & 30 + 7 \\ & ... & \\ i & (i \cdot X)A & (2/3)^i \cdot 1/3 & 10\cdot i + 7 \end{array}$$ and the expected time is: $$\begin{array}{lcl} E(T) & = & \sum_{i=0}^\infty P(i)T(i) \\ & = & 1/3 \cdot \sum_{i=0}^\infty \left( 10 \cdot i + 7 \right) \cdot(2/3)^i \\ & = & 10/3 \cdot \sum_{i=0}^\infty i \cdot(2/3)^i + 7/3 \cdot \sum_{i=0}^\infty (2/3)^i\\ & = & 10/3 \cdot 6 + 7/3 \cdot 3 \\ & = & 27 \\ \end{array}$$
Average time ant needs to get out to the woods
Let me join with an explanation which, to me at least, seems even easier: First, observe that the paths $B$ and $C$ can be joined into a single path $X$, with the passage time equal to the mean times
Average time ant needs to get out to the woods Let me join with an explanation which, to me at least, seems even easier: First, observe that the paths $B$ and $C$ can be joined into a single path $X$, with the passage time equal to the mean times of $B$ and $C$, i.e. $10$ minutes. This is due to the fact that these paths have the same probability. If they didn't, we'd need to take a weighted average. The probability of taking the path $X$ is the sum of probabilities of taking either the path $B$ or $C$: $P(X) = P(B) + P(C) = 2/3$. Now, there are the following ways of getting to the woods: $$\begin{array}{lrr} i & \text{path}_i & P(i) & T(i)\\ \hline 0 & A & 1/3 & 7\\ 1 & XA & 2/3 \cdot 1/3 & 10 + 7 \\ 2 & XXA & (2/3)^2 \cdot 1/3 & 20 + 7 \\ 3 & XXXA & (2/3)^3 \cdot 1/3 & 30 + 7 \\ & ... & \\ i & (i \cdot X)A & (2/3)^i \cdot 1/3 & 10\cdot i + 7 \end{array}$$ and the expected time is: $$\begin{array}{lcl} E(T) & = & \sum_{i=0}^\infty P(i)T(i) \\ & = & 1/3 \cdot \sum_{i=0}^\infty \left( 10 \cdot i + 7 \right) \cdot(2/3)^i \\ & = & 10/3 \cdot \sum_{i=0}^\infty i \cdot(2/3)^i + 7/3 \cdot \sum_{i=0}^\infty (2/3)^i\\ & = & 10/3 \cdot 6 + 7/3 \cdot 3 \\ & = & 27 \\ \end{array}$$
Average time ant needs to get out to the woods Let me join with an explanation which, to me at least, seems even easier: First, observe that the paths $B$ and $C$ can be joined into a single path $X$, with the passage time equal to the mean times
37,872
Average time ant needs to get out to the woods
Typical way to solve this: The ant will either take path a and finish or take path b or c and be back in it's starting position. Let $k$ be the number of times that the ant already has taken path b or c. Let $T_k$ be the expectation value for the time to finish for an ant that took already $k$ times the path. Then the expectation value for an ant with $k$ steps can be expressed in terms of an ant with $k+1$ steps. $$T_k = \underbrace{\frac{1}{3} 7}_{\substack{\frac{1}{3}th\text{ chance to finish with path} \\ \text{ a in 7 minutes }}} + \underbrace{\frac{1}{3} (T_{k+1} + 8)}_{\substack{\frac{1}{3}th\text{ chance to finish with path b} \\ \text{ in 8 minutes} \\ \text{plus what ant $k+1$ needs on average }}} + \underbrace{\frac{1}{3} (T_{k+1} +12)}_{\substack{\frac{1}{3}th\text{ chance to finish with path c} \\ \text{ in 12 minutes}\\ \text{ plus what ant $k+1$ needs on average }}}$$ Since the ants are in the same starting position independent from the history (number of steps $k$) the average time is (you have $T_k = T_{k+1}$ which you can use to solve the above equation) : $$T_k = \frac{1}{3}7+\frac{1}{3}(8+T_k)+\frac{1}{3}(12+T_k)$$ and after some rearrangments $$T_k = 7+8+12 = 27 $$ Using an average You can solve this with a mean, sort of. The ant finishes at least with path a which at least takes at least 7 minutes In addition, the ant has 2/3 probability to take paths b or c (each time) which take on average $\frac{8+12}{1+1} = 10$ minutes. The mean times that the ant takes paths b or c is: $$1 \cdot \frac{1}{3}\left(\frac{2}{3}\right) + 2 \cdot \frac{1}{3}\left(\frac{2}{3}\right)^2 + 3 \cdot \frac{1}{3}\left(\frac{2}{3}\right)^3 + 4 \cdot \frac{1}{3}\left(\frac{2}{3}\right)^4 + .... = \sum_{k=1}^\infty k \cdot \frac{1}{3}\left(\frac{2}{3}\right)^k = 2$$ note that this is related to a geometric distribution and the average number of extra steps that the ant needs is 2 (and each step takes on average 10 minutes). So the ant will take (on average): $$ \text{ $7$ minutes $+$ 2 times $\times$ $10$ minutes $= 27$ minutes}$$ Interestingly: you could also say the mean time for a single step is $9$ minutes (what you computed), and the mean number of steps is $3$, so the ant takes $3 \times 9 = 27$ minutes (you were not very far from the solution).
Average time ant needs to get out to the woods
Typical way to solve this: The ant will either take path a and finish or take path b or c and be back in it's starting position. Let $k$ be the number of times that the ant already has taken path b or
Average time ant needs to get out to the woods Typical way to solve this: The ant will either take path a and finish or take path b or c and be back in it's starting position. Let $k$ be the number of times that the ant already has taken path b or c. Let $T_k$ be the expectation value for the time to finish for an ant that took already $k$ times the path. Then the expectation value for an ant with $k$ steps can be expressed in terms of an ant with $k+1$ steps. $$T_k = \underbrace{\frac{1}{3} 7}_{\substack{\frac{1}{3}th\text{ chance to finish with path} \\ \text{ a in 7 minutes }}} + \underbrace{\frac{1}{3} (T_{k+1} + 8)}_{\substack{\frac{1}{3}th\text{ chance to finish with path b} \\ \text{ in 8 minutes} \\ \text{plus what ant $k+1$ needs on average }}} + \underbrace{\frac{1}{3} (T_{k+1} +12)}_{\substack{\frac{1}{3}th\text{ chance to finish with path c} \\ \text{ in 12 minutes}\\ \text{ plus what ant $k+1$ needs on average }}}$$ Since the ants are in the same starting position independent from the history (number of steps $k$) the average time is (you have $T_k = T_{k+1}$ which you can use to solve the above equation) : $$T_k = \frac{1}{3}7+\frac{1}{3}(8+T_k)+\frac{1}{3}(12+T_k)$$ and after some rearrangments $$T_k = 7+8+12 = 27 $$ Using an average You can solve this with a mean, sort of. The ant finishes at least with path a which at least takes at least 7 minutes In addition, the ant has 2/3 probability to take paths b or c (each time) which take on average $\frac{8+12}{1+1} = 10$ minutes. The mean times that the ant takes paths b or c is: $$1 \cdot \frac{1}{3}\left(\frac{2}{3}\right) + 2 \cdot \frac{1}{3}\left(\frac{2}{3}\right)^2 + 3 \cdot \frac{1}{3}\left(\frac{2}{3}\right)^3 + 4 \cdot \frac{1}{3}\left(\frac{2}{3}\right)^4 + .... = \sum_{k=1}^\infty k \cdot \frac{1}{3}\left(\frac{2}{3}\right)^k = 2$$ note that this is related to a geometric distribution and the average number of extra steps that the ant needs is 2 (and each step takes on average 10 minutes). So the ant will take (on average): $$ \text{ $7$ minutes $+$ 2 times $\times$ $10$ minutes $= 27$ minutes}$$ Interestingly: you could also say the mean time for a single step is $9$ minutes (what you computed), and the mean number of steps is $3$, so the ant takes $3 \times 9 = 27$ minutes (you were not very far from the solution).
Average time ant needs to get out to the woods Typical way to solve this: The ant will either take path a and finish or take path b or c and be back in it's starting position. Let $k$ be the number of times that the ant already has taken path b or
37,873
Average time ant needs to get out to the woods
Commenting on @Igor F.'s post (not enough reputation in this subforum to simply comment): Both terms are geometric series: $\sum_{i=0}^\infty i\cdot (\frac{2}{3})^i \overset{q=2/3}{=}\sum_{i=0}^\infty i\cdot q^i=q \frac{d}{dq}\sum_{i=0}^\infty q^i=\frac{q}{(1-q)^2}, \text{ for } |q|<1$, so for $q=\frac{2}{3}$ this equals $6$. $\sum_{i=0}^\infty (\frac{2}{3})^i$ is just a basic infinite geometric series and we have $\sum_{i=0}^\infty c\cdot q^i=\frac{c}{1-q}, \text{ with constant }c \text{ and } |q|<1$, which is $3$ for $q=\frac{2}{3}$ and $c=1$.
Average time ant needs to get out to the woods
Commenting on @Igor F.'s post (not enough reputation in this subforum to simply comment): Both terms are geometric series: $\sum_{i=0}^\infty i\cdot (\frac{2}{3})^i \overset{q=2/3}{=}\sum_{i=0}^\infty
Average time ant needs to get out to the woods Commenting on @Igor F.'s post (not enough reputation in this subforum to simply comment): Both terms are geometric series: $\sum_{i=0}^\infty i\cdot (\frac{2}{3})^i \overset{q=2/3}{=}\sum_{i=0}^\infty i\cdot q^i=q \frac{d}{dq}\sum_{i=0}^\infty q^i=\frac{q}{(1-q)^2}, \text{ for } |q|<1$, so for $q=\frac{2}{3}$ this equals $6$. $\sum_{i=0}^\infty (\frac{2}{3})^i$ is just a basic infinite geometric series and we have $\sum_{i=0}^\infty c\cdot q^i=\frac{c}{1-q}, \text{ with constant }c \text{ and } |q|<1$, which is $3$ for $q=\frac{2}{3}$ and $c=1$.
Average time ant needs to get out to the woods Commenting on @Igor F.'s post (not enough reputation in this subforum to simply comment): Both terms are geometric series: $\sum_{i=0}^\infty i\cdot (\frac{2}{3})^i \overset{q=2/3}{=}\sum_{i=0}^\infty
37,874
Average time ant needs to get out to the woods
It always take $7$ min to succeed, which happens once. It takes an average of $10$ min to fail. The probability of failing is $2/3$ on each try, or $(2/3)^n$ for n tries. So the total time is ($7 + 10\cdot \sum_n (2/3)^n$) min. Which is $7$ min + $2 \cdot 10$ min $ = 27$.
Average time ant needs to get out to the woods
It always take $7$ min to succeed, which happens once. It takes an average of $10$ min to fail. The probability of failing is $2/3$ on each try, or $(2/3)^n$ for n tries. So the total time is ($7 + 10
Average time ant needs to get out to the woods It always take $7$ min to succeed, which happens once. It takes an average of $10$ min to fail. The probability of failing is $2/3$ on each try, or $(2/3)^n$ for n tries. So the total time is ($7 + 10\cdot \sum_n (2/3)^n$) min. Which is $7$ min + $2 \cdot 10$ min $ = 27$.
Average time ant needs to get out to the woods It always take $7$ min to succeed, which happens once. It takes an average of $10$ min to fail. The probability of failing is $2/3$ on each try, or $(2/3)^n$ for n tries. So the total time is ($7 + 10
37,875
Is it ever good to increase significance level?
Expanding on @EpiGrad 's answer (which is a good answer): There are many reasons to ignore p-values altogether: Principally, they answer a question we are very rarely interested in. If you are going to use p-values, using them as cutoffs often makes little sense. If you are going to use them as cut-offs, you should decide on the cutoff before the analysis Making a more stringent cutoff for type I error means lower power (more type II error). Typical values are .05 for type I and .20 for type II (power = .8). But there is no reason why type II errors are necessarily less bad than type I errors. Suppose you develop a drug that treats a disease that is terminal and rapidly so (e.g. something like Ebola). You test it. Type I error - you say the drug does something when it doesn't, and then give a useless drug to dying people. Type II error - you say the drug does nothing when it does something, and you fail to give a beneficial drug to dying people. Which is worse? Type II, by my book. To quote Prof. David Cox There are no routine statistical questions, only questionable statistical routines
Is it ever good to increase significance level?
Expanding on @EpiGrad 's answer (which is a good answer): There are many reasons to ignore p-values altogether: Principally, they answer a question we are very rarely interested in. If you are going
Is it ever good to increase significance level? Expanding on @EpiGrad 's answer (which is a good answer): There are many reasons to ignore p-values altogether: Principally, they answer a question we are very rarely interested in. If you are going to use p-values, using them as cutoffs often makes little sense. If you are going to use them as cut-offs, you should decide on the cutoff before the analysis Making a more stringent cutoff for type I error means lower power (more type II error). Typical values are .05 for type I and .20 for type II (power = .8). But there is no reason why type II errors are necessarily less bad than type I errors. Suppose you develop a drug that treats a disease that is terminal and rapidly so (e.g. something like Ebola). You test it. Type I error - you say the drug does something when it doesn't, and then give a useless drug to dying people. Type II error - you say the drug does nothing when it does something, and you fail to give a beneficial drug to dying people. Which is worse? Type II, by my book. To quote Prof. David Cox There are no routine statistical questions, only questionable statistical routines
Is it ever good to increase significance level? Expanding on @EpiGrad 's answer (which is a good answer): There are many reasons to ignore p-values altogether: Principally, they answer a question we are very rarely interested in. If you are going
37,876
Is it ever good to increase significance level?
Just if you're not getting significant results? No. Fiddling with the significance level after the experiment is conducted and the results are known is never good practice. There are circumstances where you might chose a more relaxed p-value, but doing it post hoc is just a bad idea.
Is it ever good to increase significance level?
Just if you're not getting significant results? No. Fiddling with the significance level after the experiment is conducted and the results are known is never good practice. There are circumstances whe
Is it ever good to increase significance level? Just if you're not getting significant results? No. Fiddling with the significance level after the experiment is conducted and the results are known is never good practice. There are circumstances where you might chose a more relaxed p-value, but doing it post hoc is just a bad idea.
Is it ever good to increase significance level? Just if you're not getting significant results? No. Fiddling with the significance level after the experiment is conducted and the results are known is never good practice. There are circumstances whe
37,877
Is it ever good to increase significance level?
On the one hand it is somewhat artificial to discount a variable because its p value is higher than 0.01 (that's an unusually stringent criterion). How you get there may be more important than what is the ultimate significance level. A variable that is well grounded on logic or causal links with an acceptable p value may be much more meaningful than a variable with a lower p value but with no meaningful logic supporting it. If you are dealing with hypothesis testing, watch out that the statistical significance is in good part just a function of your sample size. A large sample size will translate into a low standard error and higher statistical significance. And, this process is somewhat artificial as large samples will render immaterial differences statistically significant. If you are dealing within such a domain I recommend you move towards an Effect Size method where the unit of statistical distance is not Standard Error but instead Standard Deviation. And, the latter can't be manipulated by sample size.
Is it ever good to increase significance level?
On the one hand it is somewhat artificial to discount a variable because its p value is higher than 0.01 (that's an unusually stringent criterion). How you get there may be more important than what i
Is it ever good to increase significance level? On the one hand it is somewhat artificial to discount a variable because its p value is higher than 0.01 (that's an unusually stringent criterion). How you get there may be more important than what is the ultimate significance level. A variable that is well grounded on logic or causal links with an acceptable p value may be much more meaningful than a variable with a lower p value but with no meaningful logic supporting it. If you are dealing with hypothesis testing, watch out that the statistical significance is in good part just a function of your sample size. A large sample size will translate into a low standard error and higher statistical significance. And, this process is somewhat artificial as large samples will render immaterial differences statistically significant. If you are dealing within such a domain I recommend you move towards an Effect Size method where the unit of statistical distance is not Standard Error but instead Standard Deviation. And, the latter can't be manipulated by sample size.
Is it ever good to increase significance level? On the one hand it is somewhat artificial to discount a variable because its p value is higher than 0.01 (that's an unusually stringent criterion). How you get there may be more important than what i
37,878
Is it ever good to increase significance level?
I found myself asking the same question and came here looking for good arguments, and I have to say I'm not convinced. Let me explain why I think it is fine to change significance level after an experiment. Whatever you calculate using your chosen significance level a, will have the same value whether you choose it before or after the experiment. In other words, given some results, it is not possible to infer if the choice of a was done before or after. Ethics only becomes an issue if you are unclear about what you are doing. If you say that you measured a significant effect without specifying what you mean by that, it can be misleading. This is irrelevant, though, if you state, as you should, what a you chose. If your data is available, all the better, since your calculations can be easily reproduced by anyone interested. If someone decides to use your results, they will have their own criteria to what magnitude of type I and type II errors they are willing to accept. If you get a significant result using a higher a, it can still be an useful information. It is up to whoever is using your information to decide if the chosen a is low enough for them or not. To illustrate the last argument, I'll draw from the anecdote from @dilip-sarwate. Say a farmer did paint the targets on the side of his barn before and tried to shoot at them. He sees then that the bullets landed outside the targets, but only by a bit. If he decides, afterwards, to increase the radii of the targets, one could call it cheating, but I think it is still valid information: that is, he is not as accurate as he expected to be, but he is still somewhat accurate and one could even say by how much. You then replace an useless result, 'the farmer is not good with a gun', with a more concrete one 'the farmer is accurate to within 5 cm'.
Is it ever good to increase significance level?
I found myself asking the same question and came here looking for good arguments, and I have to say I'm not convinced. Let me explain why I think it is fine to change significance level after an exper
Is it ever good to increase significance level? I found myself asking the same question and came here looking for good arguments, and I have to say I'm not convinced. Let me explain why I think it is fine to change significance level after an experiment. Whatever you calculate using your chosen significance level a, will have the same value whether you choose it before or after the experiment. In other words, given some results, it is not possible to infer if the choice of a was done before or after. Ethics only becomes an issue if you are unclear about what you are doing. If you say that you measured a significant effect without specifying what you mean by that, it can be misleading. This is irrelevant, though, if you state, as you should, what a you chose. If your data is available, all the better, since your calculations can be easily reproduced by anyone interested. If someone decides to use your results, they will have their own criteria to what magnitude of type I and type II errors they are willing to accept. If you get a significant result using a higher a, it can still be an useful information. It is up to whoever is using your information to decide if the chosen a is low enough for them or not. To illustrate the last argument, I'll draw from the anecdote from @dilip-sarwate. Say a farmer did paint the targets on the side of his barn before and tried to shoot at them. He sees then that the bullets landed outside the targets, but only by a bit. If he decides, afterwards, to increase the radii of the targets, one could call it cheating, but I think it is still valid information: that is, he is not as accurate as he expected to be, but he is still somewhat accurate and one could even say by how much. You then replace an useless result, 'the farmer is not good with a gun', with a more concrete one 'the farmer is accurate to within 5 cm'.
Is it ever good to increase significance level? I found myself asking the same question and came here looking for good arguments, and I have to say I'm not convinced. Let me explain why I think it is fine to change significance level after an exper
37,879
Why is my regression insignificant when I merge data that produced two significant regressions?
Without seeing your data, this is difficult to answer definitively. One possibility is that your datasets span different ranges of the independent variable. It is well-known that combining data across different groups can sometimes reverse correlations seen in each group individually. This effect is known as Simpson's Paradox.
Why is my regression insignificant when I merge data that produced two significant regressions?
Without seeing your data, this is difficult to answer definitively. One possibility is that your datasets span different ranges of the independent variable. It is well-known that combining data acros
Why is my regression insignificant when I merge data that produced two significant regressions? Without seeing your data, this is difficult to answer definitively. One possibility is that your datasets span different ranges of the independent variable. It is well-known that combining data across different groups can sometimes reverse correlations seen in each group individually. This effect is known as Simpson's Paradox.
Why is my regression insignificant when I merge data that produced two significant regressions? Without seeing your data, this is difficult to answer definitively. One possibility is that your datasets span different ranges of the independent variable. It is well-known that combining data acros
37,880
Why is my regression insignificant when I merge data that produced two significant regressions?
If your data looks something like this then the reason may be more obvious. Your two original regression lines would be almost parallel and look reasonably plausible but combined they produce a different result which is probably not very helpful. The data for this chart came from using the R code exdf <- data.frame( x=c(-64:-59, -52:-47), y=c(-8.29, -8.36, -9.05, -9.30, -9.20, -9.69, -7.90, -8.34, -8.49, -8.85, -9.38, -9.65), col=c(rep("blue",6), rep("red",6)) ) fitblue <- lm(y ~ x, data=exdf[exdf$col=="blue",]) fitred <- lm(y ~ x, data=exdf[exdf$col=="red" ,]) fitcombo <- lm(y ~ x, data=exdf) plot(y ~ x, data=exdf, col=col) abline(fitblue , col="blue") abline(fitred , col="red" ) abline(fitcombo, col="black") which reports > summary(fitblue) Call: lm(formula = y ~ x, data = exdf[exdf$col == "blue", ]) Residuals: 1 2 3 4 5 6 -0.00619 0.20295 -0.20790 -0.17876 0.20038 -0.01048 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -26.14895 2.91063 -8.984 0.00085 *** x -0.27914 0.04731 -5.900 0.00413 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.1979 on 4 degrees of freedom Multiple R-squared: 0.8969, Adjusted R-squared: 0.8712 F-statistic: 34.81 on 1 and 4 DF, p-value: 0.004128 > summary(fitred) Call: lm(formula = y ~ x, data = exdf[exdf$col == "red", ]) Residuals: 7 8 9 10 11 12 -0.005238 -0.095810 0.103619 0.093048 -0.087524 -0.008095 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -26.06505 1.12832 -23.10 2.08e-05 *** x -0.34943 0.02278 -15.34 0.000105 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.0953 on 4 degrees of freedom Multiple R-squared: 0.9833, Adjusted R-squared: 0.9791 F-statistic: 235.3 on 1 and 4 DF, p-value: 0.0001054 > summary(fitcombo) Call: lm(formula = y ~ x, data = exdf) Residuals: Min 1Q Median 3Q Max -0.8399 -0.4548 -0.0750 0.4774 0.9999 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -9.269561 1.594455 -5.814 0.00017 *** x -0.007109 0.028549 -0.249 0.80839 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.617 on 10 degrees of freedom Multiple R-squared: 0.006163, Adjusted R-squared: -0.09322 F-statistic: 0.06201 on 1 and 10 DF, p-value: 0.8084 not too far away from your statistics and with further work could be made closer
Why is my regression insignificant when I merge data that produced two significant regressions?
If your data looks something like this then the reason may be more obvious. Your two original regression lines would be almost parallel and look reasonably plausible but combined they produce a diffe
Why is my regression insignificant when I merge data that produced two significant regressions? If your data looks something like this then the reason may be more obvious. Your two original regression lines would be almost parallel and look reasonably plausible but combined they produce a different result which is probably not very helpful. The data for this chart came from using the R code exdf <- data.frame( x=c(-64:-59, -52:-47), y=c(-8.29, -8.36, -9.05, -9.30, -9.20, -9.69, -7.90, -8.34, -8.49, -8.85, -9.38, -9.65), col=c(rep("blue",6), rep("red",6)) ) fitblue <- lm(y ~ x, data=exdf[exdf$col=="blue",]) fitred <- lm(y ~ x, data=exdf[exdf$col=="red" ,]) fitcombo <- lm(y ~ x, data=exdf) plot(y ~ x, data=exdf, col=col) abline(fitblue , col="blue") abline(fitred , col="red" ) abline(fitcombo, col="black") which reports > summary(fitblue) Call: lm(formula = y ~ x, data = exdf[exdf$col == "blue", ]) Residuals: 1 2 3 4 5 6 -0.00619 0.20295 -0.20790 -0.17876 0.20038 -0.01048 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -26.14895 2.91063 -8.984 0.00085 *** x -0.27914 0.04731 -5.900 0.00413 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.1979 on 4 degrees of freedom Multiple R-squared: 0.8969, Adjusted R-squared: 0.8712 F-statistic: 34.81 on 1 and 4 DF, p-value: 0.004128 > summary(fitred) Call: lm(formula = y ~ x, data = exdf[exdf$col == "red", ]) Residuals: 7 8 9 10 11 12 -0.005238 -0.095810 0.103619 0.093048 -0.087524 -0.008095 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -26.06505 1.12832 -23.10 2.08e-05 *** x -0.34943 0.02278 -15.34 0.000105 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.0953 on 4 degrees of freedom Multiple R-squared: 0.9833, Adjusted R-squared: 0.9791 F-statistic: 235.3 on 1 and 4 DF, p-value: 0.0001054 > summary(fitcombo) Call: lm(formula = y ~ x, data = exdf) Residuals: Min 1Q Median 3Q Max -0.8399 -0.4548 -0.0750 0.4774 0.9999 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -9.269561 1.594455 -5.814 0.00017 *** x -0.007109 0.028549 -0.249 0.80839 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.617 on 10 degrees of freedom Multiple R-squared: 0.006163, Adjusted R-squared: -0.09322 F-statistic: 0.06201 on 1 and 10 DF, p-value: 0.8084 not too far away from your statistics and with further work could be made closer
Why is my regression insignificant when I merge data that produced two significant regressions? If your data looks something like this then the reason may be more obvious. Your two original regression lines would be almost parallel and look reasonably plausible but combined they produce a diffe
37,881
Why is my regression insignificant when I merge data that produced two significant regressions?
It's also possible the data points in each dataset may have completely different distributions due to outliers and/or nonlinear relationships between $x$ and $y$, and yet still share nearly identical linear regression coefficients, standard errors, and statistically significant $p$-values. Combining the two datasets could create a dataset that no longer has a strong linear relationship. See Anscombe's Quartet. A visual representation of numerous datasets sharing the same summary statistics but radically different scatterplots can be found here. My recommendation would be to closely examine the scatterplots of both datasets.
Why is my regression insignificant when I merge data that produced two significant regressions?
It's also possible the data points in each dataset may have completely different distributions due to outliers and/or nonlinear relationships between $x$ and $y$, and yet still share nearly identical
Why is my regression insignificant when I merge data that produced two significant regressions? It's also possible the data points in each dataset may have completely different distributions due to outliers and/or nonlinear relationships between $x$ and $y$, and yet still share nearly identical linear regression coefficients, standard errors, and statistically significant $p$-values. Combining the two datasets could create a dataset that no longer has a strong linear relationship. See Anscombe's Quartet. A visual representation of numerous datasets sharing the same summary statistics but radically different scatterplots can be found here. My recommendation would be to closely examine the scatterplots of both datasets.
Why is my regression insignificant when I merge data that produced two significant regressions? It's also possible the data points in each dataset may have completely different distributions due to outliers and/or nonlinear relationships between $x$ and $y$, and yet still share nearly identical
37,882
Why is my regression insignificant when I merge data that produced two significant regressions?
For more on Simpson's Paradox see Pearl, J., & Mackenzie, D. (2018). Paradoxes Galore! The Book of Why: The New Science of Cause and Effect (Kindle ed., pp. 2843-3283). New York: Basic Books. Also, see Pearl's Causality. In his book, Pearl gives an example very similar to yours. The problem is that there is a confounding variable that is affecting both the independent variable(s) and the dependent variable. In Pearl's example, the question is, Why is an anti-heart attack drug bad for women, bad for men, but good for people? (when the two gender samples are combined). The answer is that gender is a confounding variable that impacts who takes the drug (women are far more likely), and also the prevalence of heart attack (men are far more likely). The solution to confounding variables is to condition on them. The can be done in two ways: (1) Using regression analysis, make gender a variable; (2) Analyze the average effect of the drug for the two genders separately; then compute the weighted average (weighted by percent in population of the genders, here 1/2) of the effects. Pearl would say that you have to have a model of the phenomenon you are studying, i.e., an exhaustive theory that takes into account all the variables involved in the response. Developing such a model and theory can take months of reading to understand the work of others in the field. However, recall that one left out variable can bias the results and make them meaningless or just plain wrong. Pearl would also write that you cannot extract causality from data; for that you need a theoretical model. However, once you have a theory and a model, you can use data to support them.
Why is my regression insignificant when I merge data that produced two significant regressions?
For more on Simpson's Paradox see Pearl, J., & Mackenzie, D. (2018). Paradoxes Galore! The Book of Why: The New Science of Cause and Effect (Kindle ed., pp. 2843-3283). New York: Basic Books. Also, se
Why is my regression insignificant when I merge data that produced two significant regressions? For more on Simpson's Paradox see Pearl, J., & Mackenzie, D. (2018). Paradoxes Galore! The Book of Why: The New Science of Cause and Effect (Kindle ed., pp. 2843-3283). New York: Basic Books. Also, see Pearl's Causality. In his book, Pearl gives an example very similar to yours. The problem is that there is a confounding variable that is affecting both the independent variable(s) and the dependent variable. In Pearl's example, the question is, Why is an anti-heart attack drug bad for women, bad for men, but good for people? (when the two gender samples are combined). The answer is that gender is a confounding variable that impacts who takes the drug (women are far more likely), and also the prevalence of heart attack (men are far more likely). The solution to confounding variables is to condition on them. The can be done in two ways: (1) Using regression analysis, make gender a variable; (2) Analyze the average effect of the drug for the two genders separately; then compute the weighted average (weighted by percent in population of the genders, here 1/2) of the effects. Pearl would say that you have to have a model of the phenomenon you are studying, i.e., an exhaustive theory that takes into account all the variables involved in the response. Developing such a model and theory can take months of reading to understand the work of others in the field. However, recall that one left out variable can bias the results and make them meaningless or just plain wrong. Pearl would also write that you cannot extract causality from data; for that you need a theoretical model. However, once you have a theory and a model, you can use data to support them.
Why is my regression insignificant when I merge data that produced two significant regressions? For more on Simpson's Paradox see Pearl, J., & Mackenzie, D. (2018). Paradoxes Galore! The Book of Why: The New Science of Cause and Effect (Kindle ed., pp. 2843-3283). New York: Basic Books. Also, se
37,883
Can I interpret logistic regression coefficients and their p-values even if model performance is bad?
1893 observations is a lot. All kinds of hypothesis tests will yield statistical significance even for tiny effects if the sample size is large (we have many threads on this, here is a similar question on ANOVA I recently had). Thus, it looks like there is signal in your data, it's just very weak. Some effects in the world are like this. Your model might indeed be the best you can do, or perhaps you can improve it (but beware of p-hacking!). You can definitely interpret this, just keep the caveat about the weakness of the effect in mind.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad
1893 observations is a lot. All kinds of hypothesis tests will yield statistical significance even for tiny effects if the sample size is large (we have many threads on this, here is a similar questio
Can I interpret logistic regression coefficients and their p-values even if model performance is bad? 1893 observations is a lot. All kinds of hypothesis tests will yield statistical significance even for tiny effects if the sample size is large (we have many threads on this, here is a similar question on ANOVA I recently had). Thus, it looks like there is signal in your data, it's just very weak. Some effects in the world are like this. Your model might indeed be the best you can do, or perhaps you can improve it (but beware of p-hacking!). You can definitely interpret this, just keep the caveat about the weakness of the effect in mind.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad 1893 observations is a lot. All kinds of hypothesis tests will yield statistical significance even for tiny effects if the sample size is large (we have many threads on this, here is a similar questio
37,884
Can I interpret logistic regression coefficients and their p-values even if model performance is bad?
I wanted to add a visual example reproducing results similar to the OP. (I usually understand things when I write the code for them). Here we have 2000 datapoints. The true relationship between x and y is $y = 0.1x$, but the data is very noisy: set.seed(1234) N <- 2000 x <- seq(1, 5, length.out=N) b <- 0.1 y <- b * x + rnorm(n=N, mean=0, sd=1) plot(x, y, pch=19, cex=0.5) A large amount of variation remains unexplained, $R^{2} \approx 0.02$. However, the linear model correctly gives a good estimate of the regression coefficient (~0.12) which is convincingly different from zero ($p \approx 10^{-9}$): fit <- lm(y ~ x) summary(fit) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.05891 0.06156 -0.957 0.339 x 0.11762 0.01915 6.143 9.76e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.9893 on 1998 degrees of freedom Multiple R-squared: 0.01854, Adjusted R-squared: 0.01804 F-statistic: 37.73 on 1 and 1998 DF, p-value: 9.761e-10 So it's ok to interpret this model since the assumptions of the linear regression are satisfied. However, what you want to take away from it is a different question that depends on your context.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad
I wanted to add a visual example reproducing results similar to the OP. (I usually understand things when I write the code for them). Here we have 2000 datapoints. The true relationship between x and
Can I interpret logistic regression coefficients and their p-values even if model performance is bad? I wanted to add a visual example reproducing results similar to the OP. (I usually understand things when I write the code for them). Here we have 2000 datapoints. The true relationship between x and y is $y = 0.1x$, but the data is very noisy: set.seed(1234) N <- 2000 x <- seq(1, 5, length.out=N) b <- 0.1 y <- b * x + rnorm(n=N, mean=0, sd=1) plot(x, y, pch=19, cex=0.5) A large amount of variation remains unexplained, $R^{2} \approx 0.02$. However, the linear model correctly gives a good estimate of the regression coefficient (~0.12) which is convincingly different from zero ($p \approx 10^{-9}$): fit <- lm(y ~ x) summary(fit) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.05891 0.06156 -0.957 0.339 x 0.11762 0.01915 6.143 9.76e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.9893 on 1998 degrees of freedom Multiple R-squared: 0.01854, Adjusted R-squared: 0.01804 F-statistic: 37.73 on 1 and 1998 DF, p-value: 9.761e-10 So it's ok to interpret this model since the assumptions of the linear regression are satisfied. However, what you want to take away from it is a different question that depends on your context.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad I wanted to add a visual example reproducing results similar to the OP. (I usually understand things when I write the code for them). Here we have 2000 datapoints. The true relationship between x and
37,885
Can I interpret logistic regression coefficients and their p-values even if model performance is bad?
It is routine in many areas to do inference with models that have low performance. I cannot think of any examples with $R^2$ values as low as the pseudo $R^2$ you have, but I know I've read papers in high-end journals that do inference on models with linear regression $R^2$ values around $4\%$, maybe even lower. A cause for concern is if you've missed something in the modeling. For instance, it could be that there is a generally upward trend, but only because the data form a checkmark shape. In that case, your model is misleading. For low values of your feature, increase the value actually decreases the outcome, and you might find yourself frustrated if you apply your bogus model to such values only to find the outcome decreasing when the regression says it should increase. However, a good regression modeling strategy should help you avoid such a situation, so if you have been thorough in your modeling, the low performance need not be interpreted as the regression screaming, "I'm worthless," at you.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad
It is routine in many areas to do inference with models that have low performance. I cannot think of any examples with $R^2$ values as low as the pseudo $R^2$ you have, but I know I've read papers in
Can I interpret logistic regression coefficients and their p-values even if model performance is bad? It is routine in many areas to do inference with models that have low performance. I cannot think of any examples with $R^2$ values as low as the pseudo $R^2$ you have, but I know I've read papers in high-end journals that do inference on models with linear regression $R^2$ values around $4\%$, maybe even lower. A cause for concern is if you've missed something in the modeling. For instance, it could be that there is a generally upward trend, but only because the data form a checkmark shape. In that case, your model is misleading. For low values of your feature, increase the value actually decreases the outcome, and you might find yourself frustrated if you apply your bogus model to such values only to find the outcome decreasing when the regression says it should increase. However, a good regression modeling strategy should help you avoid such a situation, so if you have been thorough in your modeling, the low performance need not be interpreted as the regression screaming, "I'm worthless," at you.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad It is routine in many areas to do inference with models that have low performance. I cannot think of any examples with $R^2$ values as low as the pseudo $R^2$ you have, but I know I've read papers in
37,886
Can I interpret logistic regression coefficients and their p-values even if model performance is bad?
If you are a trader and you can get an pseuo-R² of 0.001 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your design gets a pseudo-R² of 0.999 at telling if a bit is 0 or 1, you have a useless piece of silicon. This statement is a copy from the question: Determine how good an AUC is (Area under the Curve of ROC) Whether or not a particular value for R² is actually considered good performance, that depends on the problem. Also note that R² is not a goodness of fit measure. So the value doesn't tell directly whether your model is a good fit or not. Instead, it tells how large the noise/randomness is relative to the deterministic part. (It's background knowledge about the problem that tells whether a particular ratio, a particular R² a particular performance also means whether or not a model is a good fit or not) R² and pseudo-R² can be, due to it's computation never be high, even for the very best model. It is not a measure of goodness of fit that determines whether or not we are close to the true model of the distribution. For instance, there can simply be a lot of noise. Cohen's pseudo-R² is a ratio of deviance $(D_{null}-D_{fitted})/D_{null}$. This value of $D_{fitted}$ does not need to approach zero when the fitted model approaches the perfect model. For binary distributed variables there will always be randomness and we are predicting the population parameters not the binary outcomes. Instead, goodness of fit can be tested with, for instance, a chi-squared test or G-test (but these require multiple measurements at the same conditions, ie same regressor values).
Can I interpret logistic regression coefficients and their p-values even if model performance is bad
If you are a trader and you can get an pseuo-R² of 0.001 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your design gets a pseudo-R² of
Can I interpret logistic regression coefficients and their p-values even if model performance is bad? If you are a trader and you can get an pseuo-R² of 0.001 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your design gets a pseudo-R² of 0.999 at telling if a bit is 0 or 1, you have a useless piece of silicon. This statement is a copy from the question: Determine how good an AUC is (Area under the Curve of ROC) Whether or not a particular value for R² is actually considered good performance, that depends on the problem. Also note that R² is not a goodness of fit measure. So the value doesn't tell directly whether your model is a good fit or not. Instead, it tells how large the noise/randomness is relative to the deterministic part. (It's background knowledge about the problem that tells whether a particular ratio, a particular R² a particular performance also means whether or not a model is a good fit or not) R² and pseudo-R² can be, due to it's computation never be high, even for the very best model. It is not a measure of goodness of fit that determines whether or not we are close to the true model of the distribution. For instance, there can simply be a lot of noise. Cohen's pseudo-R² is a ratio of deviance $(D_{null}-D_{fitted})/D_{null}$. This value of $D_{fitted}$ does not need to approach zero when the fitted model approaches the perfect model. For binary distributed variables there will always be randomness and we are predicting the population parameters not the binary outcomes. Instead, goodness of fit can be tested with, for instance, a chi-squared test or G-test (but these require multiple measurements at the same conditions, ie same regressor values).
Can I interpret logistic regression coefficients and their p-values even if model performance is bad If you are a trader and you can get an pseuo-R² of 0.001 in predicting future financial transactions, you're the richest man in the world. If you are a CPU engineer and your design gets a pseudo-R² of
37,887
Can I interpret logistic regression coefficients and their p-values even if model performance is bad?
I would tentatively say, "yes". Remember that pseudo-$R^2$ is an analogue to $R^2$, which in OLS is variance explained. Pseudo-$R^2$ is not that, but it's roughly similar. So your low pseudo-$R^2$ could mean you're missing an explanatory variable, a random effect etc. (many reasons possible). In other words, it's a not very good model for describing the data. It would thus likely be a poor predictive model. But, if you're just doing a hypothesis test, then even though you have a lot of extra variance that you can't explain, we're still finding a significant difference between the two x1 groups. Again, I'm just saying this tentatively. If you want to know whether you should use this model, it also depends on your study aims and your analysis methods. Do you need an predictive model, or are you just looking to see if x1 has an effect? Do you need to control for multiple comparisons? etc.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad
I would tentatively say, "yes". Remember that pseudo-$R^2$ is an analogue to $R^2$, which in OLS is variance explained. Pseudo-$R^2$ is not that, but it's roughly similar. So your low pseudo-$R^2$ cou
Can I interpret logistic regression coefficients and their p-values even if model performance is bad? I would tentatively say, "yes". Remember that pseudo-$R^2$ is an analogue to $R^2$, which in OLS is variance explained. Pseudo-$R^2$ is not that, but it's roughly similar. So your low pseudo-$R^2$ could mean you're missing an explanatory variable, a random effect etc. (many reasons possible). In other words, it's a not very good model for describing the data. It would thus likely be a poor predictive model. But, if you're just doing a hypothesis test, then even though you have a lot of extra variance that you can't explain, we're still finding a significant difference between the two x1 groups. Again, I'm just saying this tentatively. If you want to know whether you should use this model, it also depends on your study aims and your analysis methods. Do you need an predictive model, or are you just looking to see if x1 has an effect? Do you need to control for multiple comparisons? etc.
Can I interpret logistic regression coefficients and their p-values even if model performance is bad I would tentatively say, "yes". Remember that pseudo-$R^2$ is an analogue to $R^2$, which in OLS is variance explained. Pseudo-$R^2$ is not that, but it's roughly similar. So your low pseudo-$R^2$ cou
37,888
regression for binary classification
Intriguing question, I had this question for a while,. Here is my findings Short Answer You can create any number of classifier you want, but the point is, you can only prove a few of them to be Bayes/universally-consistent! ( Bayes consistency means that classifier is asymptotically optimal, i.e. with infinite data its risk limits Bayes risk, which is optimal risk) The consistency of a classifier, depends on loss function and (inverse)-link function (i.e. mapping from [0 1] probability space to $\mathbb{R}$, and vice versa.) Long answer First, according to Tong's great paper all the (consistent) classifiers are equivalent! except in that they are minimizing different loss functions, and almost every difference between classifiers is a consequence of their loss functions. In fact, he showed that minimizing every loss function leads to optimal decision function (technically, inverse-link function), which is completely function of probabilities (even for SVMs!). His result is summarized in this table (by Hamed): Despite of this unified view over all the classifiers, they are different in their outputs: Probability-Calibrated: for these class the classifiers (e.g. Logistic Regression), output is DIRECTLY within a probability measure, which this in turn not only answers yes/no question of the classifier, but also gives confidence of the of the decision. Not-probability-Calibrated: Other classifiers (e.g. SVM) are real-valued-output classifiers, which you can use some link functions to calibrate the to enforce outputs to be probabilities. Conclusion It really depend on loss-function, link-function, calibration. For example, first line of the table says that, least-squares regression and classification are the same,(if your classifier output is calibrated-probabilities $\eta$, and using the corresponding inverse link function)
regression for binary classification
Intriguing question, I had this question for a while,. Here is my findings Short Answer You can create any number of classifier you want, but the point is, you can only prove a few of them to be Bayes
regression for binary classification Intriguing question, I had this question for a while,. Here is my findings Short Answer You can create any number of classifier you want, but the point is, you can only prove a few of them to be Bayes/universally-consistent! ( Bayes consistency means that classifier is asymptotically optimal, i.e. with infinite data its risk limits Bayes risk, which is optimal risk) The consistency of a classifier, depends on loss function and (inverse)-link function (i.e. mapping from [0 1] probability space to $\mathbb{R}$, and vice versa.) Long answer First, according to Tong's great paper all the (consistent) classifiers are equivalent! except in that they are minimizing different loss functions, and almost every difference between classifiers is a consequence of their loss functions. In fact, he showed that minimizing every loss function leads to optimal decision function (technically, inverse-link function), which is completely function of probabilities (even for SVMs!). His result is summarized in this table (by Hamed): Despite of this unified view over all the classifiers, they are different in their outputs: Probability-Calibrated: for these class the classifiers (e.g. Logistic Regression), output is DIRECTLY within a probability measure, which this in turn not only answers yes/no question of the classifier, but also gives confidence of the of the decision. Not-probability-Calibrated: Other classifiers (e.g. SVM) are real-valued-output classifiers, which you can use some link functions to calibrate the to enforce outputs to be probabilities. Conclusion It really depend on loss-function, link-function, calibration. For example, first line of the table says that, least-squares regression and classification are the same,(if your classifier output is calibrated-probabilities $\eta$, and using the corresponding inverse link function)
regression for binary classification Intriguing question, I had this question for a while,. Here is my findings Short Answer You can create any number of classifier you want, but the point is, you can only prove a few of them to be Bayes
37,889
regression for binary classification
You begin with a misunderstanding. It is important to get the terminology right at the beginning. Logistic regression is not a classifier. It is a direct probability model. You didn't explain why your problem is an all-or-nothing classification problem vs. a risk estimation problem. I have to disagree with the answer above. You will get more efficient/powerful/precise estimates by using maximum likelihood estimation to fit a probability model such as the logistic model, then applying your utilities/cost/loss function to the predicted probabilities to make optimum decisions. If you cannot come up with a utility/loss function it's hard to argue that you should be doing classification in the first place, but you could make the ridiculous assumption that utilities are the same for every observation and make a classification based on predicted probabilities. You will quickly see that classification is arbitrary when you proceed that way. Note that proportion "classified" correct is an improper accuracy scoring rule that is optimized by a bogus model.
regression for binary classification
You begin with a misunderstanding. It is important to get the terminology right at the beginning. Logistic regression is not a classifier. It is a direct probability model. You didn't explain why
regression for binary classification You begin with a misunderstanding. It is important to get the terminology right at the beginning. Logistic regression is not a classifier. It is a direct probability model. You didn't explain why your problem is an all-or-nothing classification problem vs. a risk estimation problem. I have to disagree with the answer above. You will get more efficient/powerful/precise estimates by using maximum likelihood estimation to fit a probability model such as the logistic model, then applying your utilities/cost/loss function to the predicted probabilities to make optimum decisions. If you cannot come up with a utility/loss function it's hard to argue that you should be doing classification in the first place, but you could make the ridiculous assumption that utilities are the same for every observation and make a classification based on predicted probabilities. You will quickly see that classification is arbitrary when you proceed that way. Note that proportion "classified" correct is an improper accuracy scoring rule that is optimized by a bogus model.
regression for binary classification You begin with a misunderstanding. It is important to get the terminology right at the beginning. Logistic regression is not a classifier. It is a direct probability model. You didn't explain why
37,890
regression for binary classification
The key question is whether you are likely to need estimates of the probability of class membership, a ranking, or whether you genuinely only interested in a binary classification. In my experience, you often do want the probabilities as the class frequencies, or the misclassification costs are unknown or variable in operation. If you have a probabilistic classifier you can compensate for these problems after training, if you have a discrete yes/no classifier you can't. One of the guiding principles behind the support vector machine was Prof. Vapnik's idea that in solving a particular problem, you should not solve a more general problem and then simplify the answer. In classification this would mean that if you are only interested in binary classification, then we should not estimate probabilities and then threshold them, because modelling efforts and resources are wasted estimating the changes in probability away from the decision boundary, where they are of no interest. This is a very reasonable idea, and I fully agree, provided you really are only interested in a discrete yes/no classification. As it happens, if you perform least-squares regression on 0/1 targets, you will asymptotically end up with estimates of the probabilities anyway. This is because least-squares results in the output being an estimate of the conditional mean of the target variable. If this is coded as 0/1 then the conditional mean is just the conditional probability of a 1, given the input vector. In short, which method you use depends on the needs of the application, if you need the probabilities or a ranking of the test data, use a probabilistic method (or least-squares etc. for ranking). If you only want the hard classification into discrete classes, use something designed especially for that problem, such as the SVM.
regression for binary classification
The key question is whether you are likely to need estimates of the probability of class membership, a ranking, or whether you genuinely only interested in a binary classification. In my experience,
regression for binary classification The key question is whether you are likely to need estimates of the probability of class membership, a ranking, or whether you genuinely only interested in a binary classification. In my experience, you often do want the probabilities as the class frequencies, or the misclassification costs are unknown or variable in operation. If you have a probabilistic classifier you can compensate for these problems after training, if you have a discrete yes/no classifier you can't. One of the guiding principles behind the support vector machine was Prof. Vapnik's idea that in solving a particular problem, you should not solve a more general problem and then simplify the answer. In classification this would mean that if you are only interested in binary classification, then we should not estimate probabilities and then threshold them, because modelling efforts and resources are wasted estimating the changes in probability away from the decision boundary, where they are of no interest. This is a very reasonable idea, and I fully agree, provided you really are only interested in a discrete yes/no classification. As it happens, if you perform least-squares regression on 0/1 targets, you will asymptotically end up with estimates of the probabilities anyway. This is because least-squares results in the output being an estimate of the conditional mean of the target variable. If this is coded as 0/1 then the conditional mean is just the conditional probability of a 1, given the input vector. In short, which method you use depends on the needs of the application, if you need the probabilities or a ranking of the test data, use a probabilistic method (or least-squares etc. for ranking). If you only want the hard classification into discrete classes, use something designed especially for that problem, such as the SVM.
regression for binary classification The key question is whether you are likely to need estimates of the probability of class membership, a ranking, or whether you genuinely only interested in a binary classification. In my experience,
37,891
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die?
While @dsaxton's answer is correct, I think it makes it more difficult for beginners in statistics to grasp the concept of variance, so I'll offer another answer that helps you get a better "feel" for the what the variance is actually "doing." An equivalent expression for the variance in this case is: $Var(X)$ =$ \sum_{i=1}^6(X_i-\bar{X})^2\over{6}$. Now, you know the mean, $\bar{X}=3.5$, so you simply need to take the die's $i$th's face value $i=1, 2, . . . , 6$, $X_i$ and subtract it from the mean, square it, and divide it by 6. In effect this gives you an average of how far away each die value is from its mean. So $Var(X)$ is given by: ${(1-3.5)^2+(2-3.5)^2+(3-3.5)^2+(4-3.5)^2+(5-3.5)^2+(6-3.5)^2}\over{6}$= $17.5\over{6}$=$105/36$, the same answer @dsaxton provided. We square the values of $X_i-\bar{X}$ because if we don't, then the sum of the values will add to zero and the negative numbers will cancel out the positive numbers.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided
While @dsaxton's answer is correct, I think it makes it more difficult for beginners in statistics to grasp the concept of variance, so I'll offer another answer that helps you get a better "feel" for
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die? While @dsaxton's answer is correct, I think it makes it more difficult for beginners in statistics to grasp the concept of variance, so I'll offer another answer that helps you get a better "feel" for the what the variance is actually "doing." An equivalent expression for the variance in this case is: $Var(X)$ =$ \sum_{i=1}^6(X_i-\bar{X})^2\over{6}$. Now, you know the mean, $\bar{X}=3.5$, so you simply need to take the die's $i$th's face value $i=1, 2, . . . , 6$, $X_i$ and subtract it from the mean, square it, and divide it by 6. In effect this gives you an average of how far away each die value is from its mean. So $Var(X)$ is given by: ${(1-3.5)^2+(2-3.5)^2+(3-3.5)^2+(4-3.5)^2+(5-3.5)^2+(6-3.5)^2}\over{6}$= $17.5\over{6}$=$105/36$, the same answer @dsaxton provided. We square the values of $X_i-\bar{X}$ because if we don't, then the sum of the values will add to zero and the negative numbers will cancel out the positive numbers.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided While @dsaxton's answer is correct, I think it makes it more difficult for beginners in statistics to grasp the concept of variance, so I'll offer another answer that helps you get a better "feel" for
37,892
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die?
If $X$ is the value of the die we already know $\text{E}(X) = 21 / 6$ so we only need to find $\text{E}(X^2)$ since $\text{Var}(X) = \text{E}(X^2) - \text{E}(X)^2$. We can just directly calculate \begin{align} \text{E}(X^2) &= \sum_{k=1}^{6} \frac{k^2}{6} \\ &= \frac{1^2 + 2^2 + 3^2 + 4^2 + 5^2 + 6^2}{6} \\ &= \frac{91}{6} \end{align} which after some arithmetic gives us $\text{Var}(X) = 105 / 36$.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided
If $X$ is the value of the die we already know $\text{E}(X) = 21 / 6$ so we only need to find $\text{E}(X^2)$ since $\text{Var}(X) = \text{E}(X^2) - \text{E}(X)^2$. We can just directly calculate \be
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die? If $X$ is the value of the die we already know $\text{E}(X) = 21 / 6$ so we only need to find $\text{E}(X^2)$ since $\text{Var}(X) = \text{E}(X^2) - \text{E}(X)^2$. We can just directly calculate \begin{align} \text{E}(X^2) &= \sum_{k=1}^{6} \frac{k^2}{6} \\ &= \frac{1^2 + 2^2 + 3^2 + 4^2 + 5^2 + 6^2}{6} \\ &= \frac{91}{6} \end{align} which after some arithmetic gives us $\text{Var}(X) = 105 / 36$.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided If $X$ is the value of the die we already know $\text{E}(X) = 21 / 6$ so we only need to find $\text{E}(X^2)$ since $\text{Var}(X) = \text{E}(X^2) - \text{E}(X)^2$. We can just directly calculate \be
37,893
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die?
This is a discrete uniform distribution. So we can use $\frac{(b-a+1)^2-1}{12}$ to solve for the variance. $\frac{(6-1+1)^2-1}{12}$ = $\frac{6^2-1}{12}$ = $\frac{35}{12}$
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided
This is a discrete uniform distribution. So we can use $\frac{(b-a+1)^2-1}{12}$ to solve for the variance. $\frac{(6-1+1)^2-1}{12}$ = $\frac{6^2-1}{12}$ = $\frac{35}{12}$
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die? This is a discrete uniform distribution. So we can use $\frac{(b-a+1)^2-1}{12}$ to solve for the variance. $\frac{(6-1+1)^2-1}{12}$ = $\frac{6^2-1}{12}$ = $\frac{35}{12}$
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided This is a discrete uniform distribution. So we can use $\frac{(b-a+1)^2-1}{12}$ to solve for the variance. $\frac{(6-1+1)^2-1}{12}$ = $\frac{6^2-1}{12}$ = $\frac{35}{12}$
37,894
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die?
There are already several good answers posted (as well as one in the comments). My goal here is not to replicate those answers, but rather to try and address an apparent confusion about the "definition of variance". In your question you say It seems the variance and standard deviation tacitly ASSUME an a priori normal distribution around an unspecified or unknown order -- but a flat "curve" with no other hidden variables has no variance. And in the answer you posted, you say The answer should be (ahem: is) 0. Apparently the equations for variance assume another unknown variable (another dimension) affecting results. If we call the value of a die roll $x$, then the random variable $x$ will have a discrete uniform distribution. That is, if we denote the probability mass function (PMF) of $x$ by $p[k]\equiv\Pr[x=k]$, then we have $p[k]=\frac{1}{K}$, where $K$ is the number of distinct values $k$ can take (i.e. here $K=6$). Independent of the form of the probability distribution, the mean $\mu$ and variance $\sigma^2$ are always defined in terms of expectations. These definitions are $$ \mu_x\equiv\mathbb{E}[x] \,,\, \sigma^2_x\equiv\mathbb{E}\left[(x-\mu_x)^2\right] $$ (e.g. see Wikipedia). For a discrete random variable such as $x\in\{X_1,\ldots,X_K\}$ with PMF $p[X_k]\equiv\Pr[x=X_k]$, the expectation operator $\mathbb{E}[\,]$ is defined by $$ \mathbb{E}\big[f[x]\big]\equiv\sum_{k=1}^Kf[X_k]p[X_k] $$ where $f[\,]$ is any deterministic function. Your confusion appears to be related to this last part. For the mean $\mu$ you appear to be correctly using $f[x]=x$. However, for the variance you appear to be using $f[x]=p[x]$, i.e. the PMF of $x$. Perhaps the following summary will make things more clear \begin{array} {c|c|c} \text{object }(f) & \text{mean }(\mu_f) & \text{variance }(\sigma_f^2) \\ \hline x & \frac{7}{2} & \frac{105}{36} \\ p[x] = \frac{1}{6} & \frac{1}{6} & 0 \end{array} In other words, the probability distribution $p[x]$ has zero variance, but the die value $x$ certainly has non-zero variance.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided
There are already several good answers posted (as well as one in the comments). My goal here is not to replicate those answers, but rather to try and address an apparent confusion about the "definitio
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die? There are already several good answers posted (as well as one in the comments). My goal here is not to replicate those answers, but rather to try and address an apparent confusion about the "definition of variance". In your question you say It seems the variance and standard deviation tacitly ASSUME an a priori normal distribution around an unspecified or unknown order -- but a flat "curve" with no other hidden variables has no variance. And in the answer you posted, you say The answer should be (ahem: is) 0. Apparently the equations for variance assume another unknown variable (another dimension) affecting results. If we call the value of a die roll $x$, then the random variable $x$ will have a discrete uniform distribution. That is, if we denote the probability mass function (PMF) of $x$ by $p[k]\equiv\Pr[x=k]$, then we have $p[k]=\frac{1}{K}$, where $K$ is the number of distinct values $k$ can take (i.e. here $K=6$). Independent of the form of the probability distribution, the mean $\mu$ and variance $\sigma^2$ are always defined in terms of expectations. These definitions are $$ \mu_x\equiv\mathbb{E}[x] \,,\, \sigma^2_x\equiv\mathbb{E}\left[(x-\mu_x)^2\right] $$ (e.g. see Wikipedia). For a discrete random variable such as $x\in\{X_1,\ldots,X_K\}$ with PMF $p[X_k]\equiv\Pr[x=X_k]$, the expectation operator $\mathbb{E}[\,]$ is defined by $$ \mathbb{E}\big[f[x]\big]\equiv\sum_{k=1}^Kf[X_k]p[X_k] $$ where $f[\,]$ is any deterministic function. Your confusion appears to be related to this last part. For the mean $\mu$ you appear to be correctly using $f[x]=x$. However, for the variance you appear to be using $f[x]=p[x]$, i.e. the PMF of $x$. Perhaps the following summary will make things more clear \begin{array} {c|c|c} \text{object }(f) & \text{mean }(\mu_f) & \text{variance }(\sigma_f^2) \\ \hline x & \frac{7}{2} & \frac{105}{36} \\ p[x] = \frac{1}{6} & \frac{1}{6} & 0 \end{array} In other words, the probability distribution $p[x]$ has zero variance, but the die value $x$ certainly has non-zero variance.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided There are already several good answers posted (as well as one in the comments). My goal here is not to replicate those answers, but rather to try and address an apparent confusion about the "definitio
37,895
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die?
"That doesn't make sense: if the die starts at zero-based numbering, then the variance changes. But, variance shouldn't depend on the numbering of the die as all faces are equally probable. – Marcos Dec 7, 2016 at 20:38" It seems to me the variance is not the 'variance of the probability' of one side over another, but is the 'variance of the face values' from the throws.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided
"That doesn't make sense: if the die starts at zero-based numbering, then the variance changes. But, variance shouldn't depend on the numbering of the die as all faces are equally probable. – Marcos D
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided die? "That doesn't make sense: if the die starts at zero-based numbering, then the variance changes. But, variance shouldn't depend on the numbering of the die as all faces are equally probable. – Marcos Dec 7, 2016 at 20:38" It seems to me the variance is not the 'variance of the probability' of one side over another, but is the 'variance of the face values' from the throws.
What are the variance and standard deviation for the bin counts for n rolls on a standard six-sided "That doesn't make sense: if the die starts at zero-based numbering, then the variance changes. But, variance shouldn't depend on the numbering of the die as all faces are equally probable. – Marcos D
37,896
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous variables? [closed]
It is not true. There's similar number of regression algorithms as classification algorithms in machine learning. Most of the classification algorithms have their regression counterparts: there's $k$-NN and $k$-NN regression, SVM's and SVR's for regression, random forest build of classification, or regression trees, XGBoost can be used for both tasks, there's an infinite number of regression neural networks, etc.
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous
It is not true. There's similar number of regression algorithms as classification algorithms in machine learning. Most of the classification algorithms have their regression counterparts: there's $k$-
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous variables? [closed] It is not true. There's similar number of regression algorithms as classification algorithms in machine learning. Most of the classification algorithms have their regression counterparts: there's $k$-NN and $k$-NN regression, SVM's and SVR's for regression, random forest build of classification, or regression trees, XGBoost can be used for both tasks, there's an infinite number of regression neural networks, etc.
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous It is not true. There's similar number of regression algorithms as classification algorithms in machine learning. Most of the classification algorithms have their regression counterparts: there's $k$-
37,897
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous variables? [closed]
Are there are insights from the machine learning literature that moves away from linear regression using OLS when the goal is predicting a continuous variable? There are many methods other than standard OLS for modelling continuous data. There are even linear regression methods other than OLS (TLS/Deming regression for one). Other classical methods include GLMs, GAMs, quantile regression. Regularised regression also modifies the OLS penalty and therefore is not "just" OLS. I don't know why you think statistics had not moved past OLS without the help of machine learning. Perhaps it would be useful to read an introduction to statistical learning.
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous
Are there are insights from the machine learning literature that moves away from linear regression using OLS when the goal is predicting a continuous variable? There are many methods other than stand
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous variables? [closed] Are there are insights from the machine learning literature that moves away from linear regression using OLS when the goal is predicting a continuous variable? There are many methods other than standard OLS for modelling continuous data. There are even linear regression methods other than OLS (TLS/Deming regression for one). Other classical methods include GLMs, GAMs, quantile regression. Regularised regression also modifies the OLS penalty and therefore is not "just" OLS. I don't know why you think statistics had not moved past OLS without the help of machine learning. Perhaps it would be useful to read an introduction to statistical learning.
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous Are there are insights from the machine learning literature that moves away from linear regression using OLS when the goal is predicting a continuous variable? There are many methods other than stand
37,898
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous variables? [closed]
IMO, deep learning is under the machine learning umbrella, in that it is deep machine learning, instead of "shallow" machine learning methods (e.g., OLS, KNN, SVM, Random Forest). Deep learning and artificial neural networks can be used for regression problems, to add another OLS alternative path for you. Keep in mind that the more features/variables you have, the more data points you need for training and the more compute resources you will need to run the training on. Here are some good starting points: 1) https://machinelearningmastery.com/regression-tutorial-keras-deep-learning-library-python/ 2) https://www.tensorflow.org/tutorials/keras/regression
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous
IMO, deep learning is under the machine learning umbrella, in that it is deep machine learning, instead of "shallow" machine learning methods (e.g., OLS, KNN, SVM, Random Forest). Deep learning and ar
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous variables? [closed] IMO, deep learning is under the machine learning umbrella, in that it is deep machine learning, instead of "shallow" machine learning methods (e.g., OLS, KNN, SVM, Random Forest). Deep learning and artificial neural networks can be used for regression problems, to add another OLS alternative path for you. Keep in mind that the more features/variables you have, the more data points you need for training and the more compute resources you will need to run the training on. Here are some good starting points: 1) https://machinelearningmastery.com/regression-tutorial-keras-deep-learning-library-python/ 2) https://www.tensorflow.org/tutorials/keras/regression
Does machine learning offer alternatives to linear regression (i.e., OLS) for predicting continuous IMO, deep learning is under the machine learning umbrella, in that it is deep machine learning, instead of "shallow" machine learning methods (e.g., OLS, KNN, SVM, Random Forest). Deep learning and ar
37,899
Can PC1 explain more than 90% of variance?
Certainly that can happen. Below is a simulated example in R with just two original variables. As long as they are strongly enough correlated, they can very well be summarized by the projection to a single line, which means that the first principal component explains an arbitrarily large proportion of total variance: library(MASS) set.seed(1) dataset <- mvrnorm(1000,c(0,0),cbind(c(1,0.99),c(0.99,1))) summary(prcomp(dataset)) plot(dataset,las=1,pch=19,cex=0.6) Output: Importance of components: PC1 PC2 Standard deviation 1.460 0.10400 Proportion of Variance 0.995 0.00505 Cumulative Proportion 0.995 1.00000 I very much recommend Making sense of principal component analysis, eigenvectors & eigenvalues.
Can PC1 explain more than 90% of variance?
Certainly that can happen. Below is a simulated example in R with just two original variables. As long as they are strongly enough correlated, they can very well be summarized by the projection to a s
Can PC1 explain more than 90% of variance? Certainly that can happen. Below is a simulated example in R with just two original variables. As long as they are strongly enough correlated, they can very well be summarized by the projection to a single line, which means that the first principal component explains an arbitrarily large proportion of total variance: library(MASS) set.seed(1) dataset <- mvrnorm(1000,c(0,0),cbind(c(1,0.99),c(0.99,1))) summary(prcomp(dataset)) plot(dataset,las=1,pch=19,cex=0.6) Output: Importance of components: PC1 PC2 Standard deviation 1.460 0.10400 Proportion of Variance 0.995 0.00505 Cumulative Proportion 0.995 1.00000 I very much recommend Making sense of principal component analysis, eigenvectors & eigenvalues.
Can PC1 explain more than 90% of variance? Certainly that can happen. Below is a simulated example in R with just two original variables. As long as they are strongly enough correlated, they can very well be summarized by the projection to a s
37,900
Can PC1 explain more than 90% of variance?
In case you need a non-simulated example: I did help.search("morpholog", agrep = FALSE) to find morphological data sets in the set of R packages I happen to have installed on my system. A useful one is ade4::tortues, a data set on 48 painted turtles from Jolicoeur and Mosimann 1960. long, larg, and haut are the length, width, and height of the turtles in mm; because they're all measured in the same units, it shouldn't be necessary to scale the variable before/while computing principal components. library(ade4) ## column 4 is sex pairs(tortues[,1:3], col = tortues[,4], gap = 0) summary(prcomp(tortues[,1:3])) PC1 has 98% of the variance. (Jolicoeur and Mosimann get 97.61%; I get 97.16% if I set scale= TRUE; haven't checked for other issues [transcription errors etc.]). Importance of components: PC1 PC2 PC3 Standard deviation 25.3100 2.40272 2.26449 Proportion of Variance 0.9833 0.00886 0.00787 Cumulative Proportion 0.9833 0.99213 1.00000 Jolicoeur, P. and Mosimann, J. E. (1960) Size and shape variation in the painted turtle. A principal component analysis. Growth, 24, 339-354.
Can PC1 explain more than 90% of variance?
In case you need a non-simulated example: I did help.search("morpholog", agrep = FALSE) to find morphological data sets in the set of R packages I happen to have installed on my system. A useful one
Can PC1 explain more than 90% of variance? In case you need a non-simulated example: I did help.search("morpholog", agrep = FALSE) to find morphological data sets in the set of R packages I happen to have installed on my system. A useful one is ade4::tortues, a data set on 48 painted turtles from Jolicoeur and Mosimann 1960. long, larg, and haut are the length, width, and height of the turtles in mm; because they're all measured in the same units, it shouldn't be necessary to scale the variable before/while computing principal components. library(ade4) ## column 4 is sex pairs(tortues[,1:3], col = tortues[,4], gap = 0) summary(prcomp(tortues[,1:3])) PC1 has 98% of the variance. (Jolicoeur and Mosimann get 97.61%; I get 97.16% if I set scale= TRUE; haven't checked for other issues [transcription errors etc.]). Importance of components: PC1 PC2 PC3 Standard deviation 25.3100 2.40272 2.26449 Proportion of Variance 0.9833 0.00886 0.00787 Cumulative Proportion 0.9833 0.99213 1.00000 Jolicoeur, P. and Mosimann, J. E. (1960) Size and shape variation in the painted turtle. A principal component analysis. Growth, 24, 339-354.
Can PC1 explain more than 90% of variance? In case you need a non-simulated example: I did help.search("morpholog", agrep = FALSE) to find morphological data sets in the set of R packages I happen to have installed on my system. A useful one