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
45,301
Correlated variables in Cox model - which one is best
The usage of correlated predictors in a model is called colinearity, and is not something that you want. You need to use a dimensionality reduction approach. The simplest way to avoid multicolinearity is to perform a principal component analysis (PCA) from the two correlated variables. If the correlation is high, as you are suggesting, then the first component will explain a really high portion of variance. Then, you can use the first component in your subsequent analysis. ( to reduce data dimensionality, you can use MatLab functions pca() or princomp(), and then use biplot to visualize your principal components.) About comparing the two predictors, an accepted approach seems to involve the usage of bootstrap to generate a distribution of correlations for each predictor. Then you can measure the difference between the two distributions with an effect size metric (like Cohens' d). Function bootstrp() is what you need. Hope this helps.
Correlated variables in Cox model - which one is best
The usage of correlated predictors in a model is called colinearity, and is not something that you want. You need to use a dimensionality reduction approach. The simplest way to avoid multicolinearit
Correlated variables in Cox model - which one is best The usage of correlated predictors in a model is called colinearity, and is not something that you want. You need to use a dimensionality reduction approach. The simplest way to avoid multicolinearity is to perform a principal component analysis (PCA) from the two correlated variables. If the correlation is high, as you are suggesting, then the first component will explain a really high portion of variance. Then, you can use the first component in your subsequent analysis. ( to reduce data dimensionality, you can use MatLab functions pca() or princomp(), and then use biplot to visualize your principal components.) About comparing the two predictors, an accepted approach seems to involve the usage of bootstrap to generate a distribution of correlations for each predictor. Then you can measure the difference between the two distributions with an effect size metric (like Cohens' d). Function bootstrp() is what you need. Hope this helps.
Correlated variables in Cox model - which one is best The usage of correlated predictors in a model is called colinearity, and is not something that you want. You need to use a dimensionality reduction approach. The simplest way to avoid multicolinearit
45,302
What do the subscripts in expectations mean in loss function
$J$ is a function respect to the parameter $\theta$. It is "cost function", where our ultimate goal is trying to reduce this the value function by using appropriate $\theta$. $\theta$ is also called "weights", "coefficients", "decision variables", where machine learning is finding the right value for $\theta$. First Let's look at the first part of the equation. The cost function $J$ comes from two things, the true distribution of data and label $P(x,y)$ and the loss function of $L$. The cost function is integrating all the possible values for the true distribution $P(x,y)$, and the Loss. More about the loss function $L$. I think the name is confusing because we have both "cost function" and "loss function". Here is the differences: $J$ is a cost that for all of the data points. and $L$ is the loss for each predicted value and label. The loss function $L$, has $3$ inputs. $(x, y)$ and $\theta$. In many cases, we use $\hat y=f(x,\theta)$ to represent predicted value, and $L(y,\hat y)$ to represent the loss value. The second part of the equation In real world, we will not know the true distribution of data and label, i.e., $P(x,y)$. What we can do, is using data to "minimize the empirical loss". Which is $\frac 1 m$ and $\sum_{i=1}^m$ part, assuming we have $m$ data points. Everything will be more clear with an numerical example. Here is one (discrete on $x$ and $y$). Suppose our true distribution on data $x$ and label $y$ is (think about $x$ is if it is cloudy, and $y$ is if it will rain.) $$ P(x=0,y=0)=0.3 $$ $$ P(x=0,y=1)=0.1 $$ $$ P(x=1,y=0)=0.2 $$ $$ P(x=1,y=1)=0.4 $$ And the loss function is $L$ is 0-1 loss. The cost would be $$\sum_x\sum_yP(x,y)L(y,\hat y)$$ That is the first part of the equation. For second part: in real world, we will not know the true distribution of $P(x,y)$, but have many data points of $(x_i,y_i)$, what we do is trying to minimize $$\frac 1 m \sum_{i=1}^m L(y_i,\hat y_i)$$
What do the subscripts in expectations mean in loss function
$J$ is a function respect to the parameter $\theta$. It is "cost function", where our ultimate goal is trying to reduce this the value function by using appropriate $\theta$. $\theta$ is also called "
What do the subscripts in expectations mean in loss function $J$ is a function respect to the parameter $\theta$. It is "cost function", where our ultimate goal is trying to reduce this the value function by using appropriate $\theta$. $\theta$ is also called "weights", "coefficients", "decision variables", where machine learning is finding the right value for $\theta$. First Let's look at the first part of the equation. The cost function $J$ comes from two things, the true distribution of data and label $P(x,y)$ and the loss function of $L$. The cost function is integrating all the possible values for the true distribution $P(x,y)$, and the Loss. More about the loss function $L$. I think the name is confusing because we have both "cost function" and "loss function". Here is the differences: $J$ is a cost that for all of the data points. and $L$ is the loss for each predicted value and label. The loss function $L$, has $3$ inputs. $(x, y)$ and $\theta$. In many cases, we use $\hat y=f(x,\theta)$ to represent predicted value, and $L(y,\hat y)$ to represent the loss value. The second part of the equation In real world, we will not know the true distribution of data and label, i.e., $P(x,y)$. What we can do, is using data to "minimize the empirical loss". Which is $\frac 1 m$ and $\sum_{i=1}^m$ part, assuming we have $m$ data points. Everything will be more clear with an numerical example. Here is one (discrete on $x$ and $y$). Suppose our true distribution on data $x$ and label $y$ is (think about $x$ is if it is cloudy, and $y$ is if it will rain.) $$ P(x=0,y=0)=0.3 $$ $$ P(x=0,y=1)=0.1 $$ $$ P(x=1,y=0)=0.2 $$ $$ P(x=1,y=1)=0.4 $$ And the loss function is $L$ is 0-1 loss. The cost would be $$\sum_x\sum_yP(x,y)L(y,\hat y)$$ That is the first part of the equation. For second part: in real world, we will not know the true distribution of $P(x,y)$, but have many data points of $(x_i,y_i)$, what we do is trying to minimize $$\frac 1 m \sum_{i=1}^m L(y_i,\hat y_i)$$
What do the subscripts in expectations mean in loss function $J$ is a function respect to the parameter $\theta$. It is "cost function", where our ultimate goal is trying to reduce this the value function by using appropriate $\theta$. $\theta$ is also called "
45,303
What do the subscripts in expectations mean in loss function
It means that this is the distribution under which the expectation is taken. More formally: $$ \mathbb{E}_{x \sim q(x)}\big[~f(x)~\big] := \int q(x) f(x) dx. $$ If clear from the context, the argument to the distribution is often omitted, i.e. $\mathbb{E}_{x \sim q}[f(x)]$
What do the subscripts in expectations mean in loss function
It means that this is the distribution under which the expectation is taken. More formally: $$ \mathbb{E}_{x \sim q(x)}\big[~f(x)~\big] := \int q(x) f(x) dx. $$ If clear from the context, the argumen
What do the subscripts in expectations mean in loss function It means that this is the distribution under which the expectation is taken. More formally: $$ \mathbb{E}_{x \sim q(x)}\big[~f(x)~\big] := \int q(x) f(x) dx. $$ If clear from the context, the argument to the distribution is often omitted, i.e. $\mathbb{E}_{x \sim q}[f(x)]$
What do the subscripts in expectations mean in loss function It means that this is the distribution under which the expectation is taken. More formally: $$ \mathbb{E}_{x \sim q(x)}\big[~f(x)~\big] := \int q(x) f(x) dx. $$ If clear from the context, the argumen
45,304
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)?
Wald confidence intervals: these assume that the sampling distribution of the parameters is multivariate Normal (a much weaker assumption than that the conditional distribution of the residuals is Normal). They are relatively easily to compute (for the fixed-effects parameters) by extracting the parameter values (fixef()) and the standard errors (sqrt(diag(vcov()))) and computing $\beta \pm z \cdot \sigma$ ... Example: library(robustlmm) r <- rlmer(Reaction ~ Days + (1|Subject), sleepstudy) confint.rlmerMod <- function(object,parm,level=0.95) { beta <- fixef(object) if (missing(parm)) parm <- names(beta) se <- sqrt(diag(vcov(object))) z <- qnorm((1+level)/2) ctab <- cbind(beta-z*se,beta+z*se) colnames(ctab) <- stats:::format.perc(c((1-level)/2,(1+level)/2), digits=3) return(ctab[parm,]) } confint(r) ## 2.5 % 97.5 % ## (Intercept) 235.575485 269.27845 ## Days 9.211197 12.04305 if you think the Wald intervals are likely to be nonsymmetric on the original scale, it might be possible to compute confidence intervals on another scale, e.g. the log scale, and back-transform. I don't think that profile likelihood confidence intervals are an option; at the very least you'd have to follow through the theory for robust linear models and see if there was a robust-likelihood analogue that followed the same asymptotic theory. the same problem applies for parametric bootstrapping. nonparametric bootstrapping is a possibility. See e.g. Confidence intervals on predictions for a non-linear mixed model (nlme) , Non-linear mixed model (nlme) with nested random effect, do not know how to include nested random effect when bootstrapping
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)?
Wald confidence intervals: these assume that the sampling distribution of the parameters is multivariate Normal (a much weaker assumption than that the conditional distribution of the residuals is Nor
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)? Wald confidence intervals: these assume that the sampling distribution of the parameters is multivariate Normal (a much weaker assumption than that the conditional distribution of the residuals is Normal). They are relatively easily to compute (for the fixed-effects parameters) by extracting the parameter values (fixef()) and the standard errors (sqrt(diag(vcov()))) and computing $\beta \pm z \cdot \sigma$ ... Example: library(robustlmm) r <- rlmer(Reaction ~ Days + (1|Subject), sleepstudy) confint.rlmerMod <- function(object,parm,level=0.95) { beta <- fixef(object) if (missing(parm)) parm <- names(beta) se <- sqrt(diag(vcov(object))) z <- qnorm((1+level)/2) ctab <- cbind(beta-z*se,beta+z*se) colnames(ctab) <- stats:::format.perc(c((1-level)/2,(1+level)/2), digits=3) return(ctab[parm,]) } confint(r) ## 2.5 % 97.5 % ## (Intercept) 235.575485 269.27845 ## Days 9.211197 12.04305 if you think the Wald intervals are likely to be nonsymmetric on the original scale, it might be possible to compute confidence intervals on another scale, e.g. the log scale, and back-transform. I don't think that profile likelihood confidence intervals are an option; at the very least you'd have to follow through the theory for robust linear models and see if there was a robust-likelihood analogue that followed the same asymptotic theory. the same problem applies for parametric bootstrapping. nonparametric bootstrapping is a possibility. See e.g. Confidence intervals on predictions for a non-linear mixed model (nlme) , Non-linear mixed model (nlme) with nested random effect, do not know how to include nested random effect when bootstrapping
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)? Wald confidence intervals: these assume that the sampling distribution of the parameters is multivariate Normal (a much weaker assumption than that the conditional distribution of the residuals is Nor
45,305
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)?
It is also now possible to obtain confidence intervals of rlmerMod objects using the effects package. Example: library(robustlmm) library(effects) r <- rlmer(Reaction ~ Days + (1|Subject), sleepstudy) as.data.frame(effect("Days",r)) ### Days fit se lower upper ### 0 252.4270 8.597854 235.4601 269.3938 ### 2 273.6812 8.161895 257.5747 289.7877 ### 4 294.9355 7.967757 279.2120 310.6589 ### 7 326.8168 8.161895 310.7103 342.9234 ### 9 348.0711 8.597854 331.1042 365.0379
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)?
It is also now possible to obtain confidence intervals of rlmerMod objects using the effects package. Example: library(robustlmm) library(effects) r <- rlmer(Reaction ~ Days + (1|Subject), sleepstu
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)? It is also now possible to obtain confidence intervals of rlmerMod objects using the effects package. Example: library(robustlmm) library(effects) r <- rlmer(Reaction ~ Days + (1|Subject), sleepstudy) as.data.frame(effect("Days",r)) ### Days fit se lower upper ### 0 252.4270 8.597854 235.4601 269.3938 ### 2 273.6812 8.161895 257.5747 289.7877 ### 4 294.9355 7.967757 279.2120 310.6589 ### 7 326.8168 8.161895 310.7103 342.9234 ### 9 348.0711 8.597854 331.1042 365.0379
How can I get confidence intervals for fixed effects using the rlmer function (robustlmm package)? It is also now possible to obtain confidence intervals of rlmerMod objects using the effects package. Example: library(robustlmm) library(effects) r <- rlmer(Reaction ~ Days + (1|Subject), sleepstu
45,306
Why is a GLM's residual deviance minus twice its log likelihood?
It's not just with the logistic; it's true of the deviance more generally in GLMs. Indeed the idea of taking twice the log of a likelihood ratio arises because of Wilks' theorem relating to likelihood ratio tests, which tells us that $-2\log(\Lambda)$ for a pair of nested models has (asymptotically) a chi-square distribution with df equal to the difference in dimensionality. In the case of GLMs the deviance is formed by comparing with a fully saturated model, where there are as many parameters as observations. Sometimes simply $-2\log\mathcal{L}$ for a given model is termed "deviance" which is (strictly speaking) a misnomer, but if it is only used to calculate differences between (nested) models, this won't lead to any difficulty (the contribution from the fully saturated model cancels out, so these between-model differences will be the same either way).
Why is a GLM's residual deviance minus twice its log likelihood?
It's not just with the logistic; it's true of the deviance more generally in GLMs. Indeed the idea of taking twice the log of a likelihood ratio arises because of Wilks' theorem relating to likelihood
Why is a GLM's residual deviance minus twice its log likelihood? It's not just with the logistic; it's true of the deviance more generally in GLMs. Indeed the idea of taking twice the log of a likelihood ratio arises because of Wilks' theorem relating to likelihood ratio tests, which tells us that $-2\log(\Lambda)$ for a pair of nested models has (asymptotically) a chi-square distribution with df equal to the difference in dimensionality. In the case of GLMs the deviance is formed by comparing with a fully saturated model, where there are as many parameters as observations. Sometimes simply $-2\log\mathcal{L}$ for a given model is termed "deviance" which is (strictly speaking) a misnomer, but if it is only used to calculate differences between (nested) models, this won't lead to any difficulty (the contribution from the fully saturated model cancels out, so these between-model differences will be the same either way).
Why is a GLM's residual deviance minus twice its log likelihood? It's not just with the logistic; it's true of the deviance more generally in GLMs. Indeed the idea of taking twice the log of a likelihood ratio arises because of Wilks' theorem relating to likelihood
45,307
Computing p-value in a problem about people going to a show with certain probability
This question has a unique answer: anything else will only be an approximation or will be based on an inferior hypothesis test. The p-value is $682/969 \approx 70.4\%$. Its calculation is based on sampling without replacement from a population of $20$. The rest of this post provides the reasoning, which relies only on the definition of p-value and some straightforward combinatorial calculations. A probability model for your results can be described by a box with $20$ tickets, one per person. On each ticket is written whether that person went to the show. Your random sample is like taking eight of those tickets out of the box (without replacing them). The statistical characteristics of this model which are yet unknown are completely determined by the number of people who went to this show. Call this number $\theta$. The possible values of $\theta$ are the whole numbers from zero through $20$. Your null hypothesis, $H_0$, is that five or more people went to the show: $\theta \ge 5$. The alternative is that $\theta \lt 5$. To test this hypothesis, the only useful statistic is the count $X$ of the people in your sample who went to the show. (Counting those who did not go will give mathematically equivalent information, obviously.) Evidently small values of $X$ are evidence against $H_0$ and large values are evidence for it. In fact, if $X \ge 5$, you would be certain that $H_0$ is true, because at least five people in your sample went. The p-value therefore is computed from the chance that $X$ could have been less than or equal to the value you observed, which was $2$. This chance can easily be computed by breaking it into three mutually exclusive possibilities: $X=0$ means the entire sample of $8$ tickets came from the $20-\theta$ non-show-going tickets in the box. There are $\binom{20-\theta}{8}$ ways that could happen. $X=1$ means seven of the sample tickets came from the $20-\theta$ non-show-going tickets (there are $\binom{20-\theta}{7}$ ways for that to happen) and one came from the $\theta$ show-going tickets: there are $\binom{\theta}{1}$ ways for that to happen, independently of the choice of the other seven tickets. The total number of such samples therefore is $\binom{20-\theta}{7}\binom{\theta}{1}$. An analogous argument shows there are $\binom{20-\theta}{6}\binom{\theta}{2}$ samples with $X=2$ show-going tickets. Add these three values up and divide by the total number of possible (and equiprobable) samples, $\binom{20}{8}$, to obtain the chances of $X\le 2$ in terms of the unknown $\theta$. Although as it turns out we only need to perform this calculation for $\theta=5$, here are the chances for some of the other values of $\theta$ so you can appreciate the patterns: $$ \begin{array}{rr|cccccc} &\theta & 2 & 3 & 4 & \color{Red} 5 & \color{Red} 6 & \color{Red} \cdots & \color{Red} {14} \\ &\text{Probability} & 1 & \frac{271}{285} & \frac{4103}{4845} & \color{Red}{\frac{682}{969}} & \color{Red}{\frac{176}{323}} & \color{Red}\cdots & \color{Red}{\frac{7}{9690}} \\ &\text{(in decimals)} & 1. & 0.951 & 0.847 & \color{Red} {0.704} & \color{Red} {0.545} & \color{Red}\cdots & \color{Red} {0.001}\\ \end{array} $$ (I started the table at $\theta=2$ because you already observed two show-goers in your sample. I ended it at $\theta=14$ because you already observed six non-show-goers, leaving at most $20-6=14$ show-goers.) When $\theta$ is small (which it is under the alternative hypothesis, consisting only of the possibilities $\{0,1,2,3,4\}$), the chance that $X\le 2$ is high. But as $\theta$ increases, the chance goes down. Among the null hypothesis, which comprises the cases $\theta=5, 6, \ldots, 20$ (tabulated in red), the greatest chance occurs when $\theta=5$, where it is $682/969 \approx 0.704$. This is the p-value. Let's interpret this conclusion to check that it makes sense. The narrative might go like this: I wish to test whether there are five or more show-going tickets in the box. A small number of show-going tickets in my sample would be evidence against that. I saw just two show-going tickets in the sample. There actually is a situation--namely, where exactly five out of the twenty people went to the show--where the chance of observing two or fewer tickets in my sample is as great as $70.4\%$. This is very high, showing my sample is consistent with the null hypothesis. As a further check of this reasoning, consider a scenario in which your sample ought to have a low p-value. Suppose your null hypothesis were that more than half of the 20 people went to the show. The corresponding set of possible values of $\theta$ is $H_0 = \{11, 12, \ldots, 20\}$. The largest chance that $X\le 2$ for any of those situations occurs when $\theta=11$ and is only $4\%$ ($335/8398$). That's a pretty low p-value, allowing you to conclude it's likely there are fewer than $11$ show-going tickets in the box. Indeed, you have seen only two of them and there are just $12$ tickets left in the box, so you would be confident there are fewer than nine show-going tickets among them. Given that only one-quarter of the sample contains show-going tickets, that's a reasonable conclusion.
Computing p-value in a problem about people going to a show with certain probability
This question has a unique answer: anything else will only be an approximation or will be based on an inferior hypothesis test. The p-value is $682/969 \approx 70.4\%$. Its calculation is based on s
Computing p-value in a problem about people going to a show with certain probability This question has a unique answer: anything else will only be an approximation or will be based on an inferior hypothesis test. The p-value is $682/969 \approx 70.4\%$. Its calculation is based on sampling without replacement from a population of $20$. The rest of this post provides the reasoning, which relies only on the definition of p-value and some straightforward combinatorial calculations. A probability model for your results can be described by a box with $20$ tickets, one per person. On each ticket is written whether that person went to the show. Your random sample is like taking eight of those tickets out of the box (without replacing them). The statistical characteristics of this model which are yet unknown are completely determined by the number of people who went to this show. Call this number $\theta$. The possible values of $\theta$ are the whole numbers from zero through $20$. Your null hypothesis, $H_0$, is that five or more people went to the show: $\theta \ge 5$. The alternative is that $\theta \lt 5$. To test this hypothesis, the only useful statistic is the count $X$ of the people in your sample who went to the show. (Counting those who did not go will give mathematically equivalent information, obviously.) Evidently small values of $X$ are evidence against $H_0$ and large values are evidence for it. In fact, if $X \ge 5$, you would be certain that $H_0$ is true, because at least five people in your sample went. The p-value therefore is computed from the chance that $X$ could have been less than or equal to the value you observed, which was $2$. This chance can easily be computed by breaking it into three mutually exclusive possibilities: $X=0$ means the entire sample of $8$ tickets came from the $20-\theta$ non-show-going tickets in the box. There are $\binom{20-\theta}{8}$ ways that could happen. $X=1$ means seven of the sample tickets came from the $20-\theta$ non-show-going tickets (there are $\binom{20-\theta}{7}$ ways for that to happen) and one came from the $\theta$ show-going tickets: there are $\binom{\theta}{1}$ ways for that to happen, independently of the choice of the other seven tickets. The total number of such samples therefore is $\binom{20-\theta}{7}\binom{\theta}{1}$. An analogous argument shows there are $\binom{20-\theta}{6}\binom{\theta}{2}$ samples with $X=2$ show-going tickets. Add these three values up and divide by the total number of possible (and equiprobable) samples, $\binom{20}{8}$, to obtain the chances of $X\le 2$ in terms of the unknown $\theta$. Although as it turns out we only need to perform this calculation for $\theta=5$, here are the chances for some of the other values of $\theta$ so you can appreciate the patterns: $$ \begin{array}{rr|cccccc} &\theta & 2 & 3 & 4 & \color{Red} 5 & \color{Red} 6 & \color{Red} \cdots & \color{Red} {14} \\ &\text{Probability} & 1 & \frac{271}{285} & \frac{4103}{4845} & \color{Red}{\frac{682}{969}} & \color{Red}{\frac{176}{323}} & \color{Red}\cdots & \color{Red}{\frac{7}{9690}} \\ &\text{(in decimals)} & 1. & 0.951 & 0.847 & \color{Red} {0.704} & \color{Red} {0.545} & \color{Red}\cdots & \color{Red} {0.001}\\ \end{array} $$ (I started the table at $\theta=2$ because you already observed two show-goers in your sample. I ended it at $\theta=14$ because you already observed six non-show-goers, leaving at most $20-6=14$ show-goers.) When $\theta$ is small (which it is under the alternative hypothesis, consisting only of the possibilities $\{0,1,2,3,4\}$), the chance that $X\le 2$ is high. But as $\theta$ increases, the chance goes down. Among the null hypothesis, which comprises the cases $\theta=5, 6, \ldots, 20$ (tabulated in red), the greatest chance occurs when $\theta=5$, where it is $682/969 \approx 0.704$. This is the p-value. Let's interpret this conclusion to check that it makes sense. The narrative might go like this: I wish to test whether there are five or more show-going tickets in the box. A small number of show-going tickets in my sample would be evidence against that. I saw just two show-going tickets in the sample. There actually is a situation--namely, where exactly five out of the twenty people went to the show--where the chance of observing two or fewer tickets in my sample is as great as $70.4\%$. This is very high, showing my sample is consistent with the null hypothesis. As a further check of this reasoning, consider a scenario in which your sample ought to have a low p-value. Suppose your null hypothesis were that more than half of the 20 people went to the show. The corresponding set of possible values of $\theta$ is $H_0 = \{11, 12, \ldots, 20\}$. The largest chance that $X\le 2$ for any of those situations occurs when $\theta=11$ and is only $4\%$ ($335/8398$). That's a pretty low p-value, allowing you to conclude it's likely there are fewer than $11$ show-going tickets in the box. Indeed, you have seen only two of them and there are just $12$ tickets left in the box, so you would be confident there are fewer than nine show-going tickets among them. Given that only one-quarter of the sample contains show-going tickets, that's a reasonable conclusion.
Computing p-value in a problem about people going to a show with certain probability This question has a unique answer: anything else will only be an approximation or will be based on an inferior hypothesis test. The p-value is $682/969 \approx 70.4\%$. Its calculation is based on s
45,308
Computing p-value in a problem about people going to a show with certain probability
I think this homework question is a bit unclear. The experiment seems to be handing out the flyer to a population of $20$ people. You want to know what is the probability that $5$ to $20$ people attend as a result. Usually, experiments involve a control group that gets a placebo, but perhaps this is a new band that no one knows about, so the assumption that no one plans to attend in the absence of the treatment flyer is reasonable. Or maybe the organizers really liked this study. The second assumption is that the flyers cannot be shared, so treatment is not "contagious". This is less reasonable, but would complicate the problem too much to relax. In any case, if you think of an experiment as a procedure carried out to verify, refute, or validate a hypothesis, this fits the bill. The problem is that you don't know the take-up rate in the population. To learn it, you sample $8$ receivers at random from the population of $20$, and note that $2$ went. The rate seems to be $1/4$. You might even do a binomial test here and find that you cannot reject the null that $p=0.25$, as in @E L M's answer. The ultimate goal, however, is to to extrapolate from your sample to the population of 20, which is the experiment. The probability that $5$ or more people attend when you hand out $20$ flyers can be calculated by the binomial tail function, which gives your the probability of observing $k=5$ or more successes in $20$ trials when the probability of a success on one trial is $p=\frac{1}{4}$. In Stata, this would be: . display binomialtail(20,5,1/4) .5851585 You can even do this from first principles by subtracting $1 - Pr(k=0)-Pr(k=1)-Pr(k=2)-Pr(k=3)-Pr(k=4)$: di 1-[binomialp(20,0,1/4)+binomialp(20,1,1/4)+binomialp(20,2,1/4)+binomialp(20,3,1/4)+binomialp(20,4,1/4)] .5851585 You could also think of this as a one-sided binomial probability test: . bitesti 20 5 1/4 N Observed k Expected k Assumed p Observed p ------------------------------------------------------------ 20 5 5 0.25000 0.25000 Pr(k >= 5) = 0.585158 (one-sided test) Pr(k <= 5) = 0.617173 (one-sided test) Pr(k <= 5 or k >= 6) = 1.000000 (two-sided test) The first one-sided test gives you the same probability as the tail approach. It is also a p-value. Why? The p-value of a hypothesis test is the probability (calculated assuming $H_0$ is true) of observing any outcome as extreme or more extreme than the observed outcome $(k=5)$, with extreme meaning in the direction of the alternative hypothesis. You reject the null when the p-value is small, in favor of the alternative, because anything as extreme or more is unlikely if the null was true. You don't accept the null, however, the data can only be consistent with it. In R, this can be done with: > binom.test(5,20,1/4, alternative = "greater") Exact binomial test data: 5 and 20 number of successes = 5, number of trials = 20, p-value = 0.5852 alternative hypothesis: true probability of success is greater than 0.25 95 percent confidence interval: 0.1040808 1.0000000 sample estimates: probability of success 0.25
Computing p-value in a problem about people going to a show with certain probability
I think this homework question is a bit unclear. The experiment seems to be handing out the flyer to a population of $20$ people. You want to know what is the probability that $5$ to $20$ people atte
Computing p-value in a problem about people going to a show with certain probability I think this homework question is a bit unclear. The experiment seems to be handing out the flyer to a population of $20$ people. You want to know what is the probability that $5$ to $20$ people attend as a result. Usually, experiments involve a control group that gets a placebo, but perhaps this is a new band that no one knows about, so the assumption that no one plans to attend in the absence of the treatment flyer is reasonable. Or maybe the organizers really liked this study. The second assumption is that the flyers cannot be shared, so treatment is not "contagious". This is less reasonable, but would complicate the problem too much to relax. In any case, if you think of an experiment as a procedure carried out to verify, refute, or validate a hypothesis, this fits the bill. The problem is that you don't know the take-up rate in the population. To learn it, you sample $8$ receivers at random from the population of $20$, and note that $2$ went. The rate seems to be $1/4$. You might even do a binomial test here and find that you cannot reject the null that $p=0.25$, as in @E L M's answer. The ultimate goal, however, is to to extrapolate from your sample to the population of 20, which is the experiment. The probability that $5$ or more people attend when you hand out $20$ flyers can be calculated by the binomial tail function, which gives your the probability of observing $k=5$ or more successes in $20$ trials when the probability of a success on one trial is $p=\frac{1}{4}$. In Stata, this would be: . display binomialtail(20,5,1/4) .5851585 You can even do this from first principles by subtracting $1 - Pr(k=0)-Pr(k=1)-Pr(k=2)-Pr(k=3)-Pr(k=4)$: di 1-[binomialp(20,0,1/4)+binomialp(20,1,1/4)+binomialp(20,2,1/4)+binomialp(20,3,1/4)+binomialp(20,4,1/4)] .5851585 You could also think of this as a one-sided binomial probability test: . bitesti 20 5 1/4 N Observed k Expected k Assumed p Observed p ------------------------------------------------------------ 20 5 5 0.25000 0.25000 Pr(k >= 5) = 0.585158 (one-sided test) Pr(k <= 5) = 0.617173 (one-sided test) Pr(k <= 5 or k >= 6) = 1.000000 (two-sided test) The first one-sided test gives you the same probability as the tail approach. It is also a p-value. Why? The p-value of a hypothesis test is the probability (calculated assuming $H_0$ is true) of observing any outcome as extreme or more extreme than the observed outcome $(k=5)$, with extreme meaning in the direction of the alternative hypothesis. You reject the null when the p-value is small, in favor of the alternative, because anything as extreme or more is unlikely if the null was true. You don't accept the null, however, the data can only be consistent with it. In R, this can be done with: > binom.test(5,20,1/4, alternative = "greater") Exact binomial test data: 5 and 20 number of successes = 5, number of trials = 20, p-value = 0.5852 alternative hypothesis: true probability of success is greater than 0.25 95 percent confidence interval: 0.1040808 1.0000000 sample estimates: probability of success 0.25
Computing p-value in a problem about people going to a show with certain probability I think this homework question is a bit unclear. The experiment seems to be handing out the flyer to a population of $20$ people. You want to know what is the probability that $5$ to $20$ people atte
45,309
Random forest and LASSO regression both give different variable importances
Before going deeper into the comparison make sure that each of the two methods agrees with itself. You can find this out by bootstrapping the entire variable importance process a few times. Plot the original variable importance for each variable vs. the importance estimated from a bootstrap sample. The bootstrap involves taking samples of size $n$ with replacement from the original dataset of $n$ observations, and repeating any analysis. The repetitions have to be "from scratch." Here is what the process looks like in R: n <- NROW(mydata) # mydata = data table, data frame, or matrix for(i in 1 : 5) { s <- sample(1 : n, n, replace=TRUE) f <- whateveranalysis(mydata[s, ]) # Print what you need and look across the 5 bootstraps to # see the volatility }
Random forest and LASSO regression both give different variable importances
Before going deeper into the comparison make sure that each of the two methods agrees with itself. You can find this out by bootstrapping the entire variable importance process a few times. Plot the
Random forest and LASSO regression both give different variable importances Before going deeper into the comparison make sure that each of the two methods agrees with itself. You can find this out by bootstrapping the entire variable importance process a few times. Plot the original variable importance for each variable vs. the importance estimated from a bootstrap sample. The bootstrap involves taking samples of size $n$ with replacement from the original dataset of $n$ observations, and repeating any analysis. The repetitions have to be "from scratch." Here is what the process looks like in R: n <- NROW(mydata) # mydata = data table, data frame, or matrix for(i in 1 : 5) { s <- sample(1 : n, n, replace=TRUE) f <- whateveranalysis(mydata[s, ]) # Print what you need and look across the 5 bootstraps to # see the volatility }
Random forest and LASSO regression both give different variable importances Before going deeper into the comparison make sure that each of the two methods agrees with itself. You can find this out by bootstrapping the entire variable importance process a few times. Plot the
45,310
Random forest and LASSO regression both give different variable importances
No free lunch. You can't really know it beforehand. Unless you have strong reasons to favor one over the other1 you would have to test both solutions to make a proper choice. 1. Say, you really want a linear model and would feel fine with the implications of choosing that over another possible solution that could be actually better, but then you wouldn't even need to test it in the first place.
Random forest and LASSO regression both give different variable importances
No free lunch. You can't really know it beforehand. Unless you have strong reasons to favor one over the other1 you would have to test both solutions to make a proper choice. 1. Say, you really want
Random forest and LASSO regression both give different variable importances No free lunch. You can't really know it beforehand. Unless you have strong reasons to favor one over the other1 you would have to test both solutions to make a proper choice. 1. Say, you really want a linear model and would feel fine with the implications of choosing that over another possible solution that could be actually better, but then you wouldn't even need to test it in the first place.
Random forest and LASSO regression both give different variable importances No free lunch. You can't really know it beforehand. Unless you have strong reasons to favor one over the other1 you would have to test both solutions to make a proper choice. 1. Say, you really want
45,311
Probability that exactly y of n rolls of an r-sided die are unique
There is an efficient, simple, $O(n)$ solution. In expanding the polynomial $$f_{n,r} = \left(x_1+x_2+\cdots+x_r\right)^n = \sum_{i_1,i_2,\ldots,i_r} \binom{n}{i_1,i_2,\ldots,i_r} x_1^{i_1}x_2^{i_2}\cdots x_r^{i_r},$$ for each of the $\binom{r}{y}$ subsets of $y$ of the variables there will be a term like this one $$\binom{n}{1,1,\ldots,1,i_{y+1},\ldots, i_r}\left(x_1x_2\cdots x_y\ x_{y+1}^{i_{y+1}}\cdots x_r^{i_r}\right)$$ whose coefficient gives the number of times at least $y$ of the variables appear just once. This coefficient can be found by differentiating $f_{n,r}$ with respect to each of those $y$ variables, setting the values of those variables to $0$, and setting the values of the remaining $r-y$ variables to $1$, because $$\frac{\partial^y}{\partial x_1\partial x_2\cdots \partial x_y}\left(x_1x_2\cdots x_y\ x_{y+1}^{i_{y+1}}\cdots x_r^{i_r}\right) = x_{y+1}^{i_{y+1}}\cdots x_r^{i_r}$$ evaluates to $1$ and all other terms have at least one of the first $y$ variables as a factor, whence they evaluate to $0$. Computing this derivative for the original expression of $f_{n,r}$ yields (using the falling factorial notation for the coefficient) $$\eqalign{&\frac{\partial^y}{\partial x_1\partial x_2\cdots \partial x_y} \left(x_1+x_2+\cdots+x_r\right)^n \\&= n(n-1)\cdots(n-y+1)\left(x_1+x_2+\cdots+x_r\right)^{n-y} \\ &= n_{(y)}\left(x_1+x_2+\cdots+x_r\right)^{n-y}. }$$ When $y$ of the $x_i$ equal $0$ and the remaining $r-y$ equal $1$, the right hand side evaluates to $$ n_{(y)}(r-y)^{n-y}.$$ Multiplying by $\binom{r}{y}$ to account for all possible combinations of $y$ variables and applying the Principle of Inclusion Exclusion ("PIE") produces the number of times $y$ variables appear exactly once, which is $$\binom{r}{y}\sum_{j=y}^{\min(r,n)} (-1)^{j-y} (r-j)^{n-j} n_{(j)}\binom{r-y}{j-y}.$$ Dividing this by $r^n$ gives the associated probabilities. The computational effort is $O(\min(r,n)-y)$. Nothing comes for free! As in most applications of the PIE, this is an alternating sum of terms that can vary radically in size, with the final result being much smaller than the largest terms. There can be catastrophic loss of precision, so high-precision (or, better yet, exact rational) arithmetic is needed. With that available, the implementation is remarkably short. Here it is in Mathematica: p[n_, k_] := n^k; p[n_, 0] := 1; f[n_, d_, k_] := Binomial[d,k] Sum[(-1)^(j-k) Binomial[d-k,j-k] FactorialPower[n,j] p[d-j,n-j],{j,k,Min[d,n]}] As an example, let's plot the full distribution for a particular $n$ and $r$: With[{n = 100, r = 100}, DiscretePlot[f[n, r, y]/r^n, {y, 0, Min[n, r]}]] As an example, consider the case $n=4$, $r=3$, and values of $y$ from $0$ through $3$. The expansion of $f_{4,3}$ is $$x_1^4+x_2^4+x_3^4 \\\color{blue}{+4 x_2 x_1^3+4 x_3 x_1^3+4 x_1 x_2^3+4 x_3x_2^3+4 x_1 x_3^3+4 x_2x_3^3}\\+6 x_2^2 x_1^2+6 x_2^2 x_3^2+6 x_3^2 x_1^2\\\color{red}{+12 x_1 x_2 x_3^2 +12 x_1 x_2^2 x_3 +12 x_1^2 x_2 x_3}.$$ Consider the calculation for $y=1$. The terms with exactly one $x_1$ in them are $$\color{blue}{4 x_1 x_2^3+4 x_1 x_3^3}+\color{red}{12 x_1 x_2 x_3^2 +12 x_1 x_2^2 x_3}.$$ These coefficients sum to $4+4+12+12=32$. Thus we would estimate the total number of terms with just a single one of the $x_i$ would be $3\times 32=96$. We're not done yet. The terms with one $x_1$ and one other $x_i$ in them are $$\color{red}{12 x_1 x_2 x_3^2 + 12 x_1 x_2^2 x_3}.$$ This tells us that when we counted the $x_1$ terms previously, we overcounted by $12+12 = 24$. The total overcount therefore is $3\times 24 = 72$. We are done now, because there are no terms possible with exactly one instance of three sides. Consequently, the count for $y=1$ is $$96 - 72 + 0 = 24.$$ Indeed, this is the sum of coefficients of $$\color{blue}{4 x_2 x_1^3+4 x_3 x_1^3+4 x_1 x_2^3+4 x_3x_2^3+4 x_1 x_3^3+4 x_2x_3^3}.$$
Probability that exactly y of n rolls of an r-sided die are unique
There is an efficient, simple, $O(n)$ solution. In expanding the polynomial $$f_{n,r} = \left(x_1+x_2+\cdots+x_r\right)^n = \sum_{i_1,i_2,\ldots,i_r} \binom{n}{i_1,i_2,\ldots,i_r} x_1^{i_1}x_2^{i_2}\c
Probability that exactly y of n rolls of an r-sided die are unique There is an efficient, simple, $O(n)$ solution. In expanding the polynomial $$f_{n,r} = \left(x_1+x_2+\cdots+x_r\right)^n = \sum_{i_1,i_2,\ldots,i_r} \binom{n}{i_1,i_2,\ldots,i_r} x_1^{i_1}x_2^{i_2}\cdots x_r^{i_r},$$ for each of the $\binom{r}{y}$ subsets of $y$ of the variables there will be a term like this one $$\binom{n}{1,1,\ldots,1,i_{y+1},\ldots, i_r}\left(x_1x_2\cdots x_y\ x_{y+1}^{i_{y+1}}\cdots x_r^{i_r}\right)$$ whose coefficient gives the number of times at least $y$ of the variables appear just once. This coefficient can be found by differentiating $f_{n,r}$ with respect to each of those $y$ variables, setting the values of those variables to $0$, and setting the values of the remaining $r-y$ variables to $1$, because $$\frac{\partial^y}{\partial x_1\partial x_2\cdots \partial x_y}\left(x_1x_2\cdots x_y\ x_{y+1}^{i_{y+1}}\cdots x_r^{i_r}\right) = x_{y+1}^{i_{y+1}}\cdots x_r^{i_r}$$ evaluates to $1$ and all other terms have at least one of the first $y$ variables as a factor, whence they evaluate to $0$. Computing this derivative for the original expression of $f_{n,r}$ yields (using the falling factorial notation for the coefficient) $$\eqalign{&\frac{\partial^y}{\partial x_1\partial x_2\cdots \partial x_y} \left(x_1+x_2+\cdots+x_r\right)^n \\&= n(n-1)\cdots(n-y+1)\left(x_1+x_2+\cdots+x_r\right)^{n-y} \\ &= n_{(y)}\left(x_1+x_2+\cdots+x_r\right)^{n-y}. }$$ When $y$ of the $x_i$ equal $0$ and the remaining $r-y$ equal $1$, the right hand side evaluates to $$ n_{(y)}(r-y)^{n-y}.$$ Multiplying by $\binom{r}{y}$ to account for all possible combinations of $y$ variables and applying the Principle of Inclusion Exclusion ("PIE") produces the number of times $y$ variables appear exactly once, which is $$\binom{r}{y}\sum_{j=y}^{\min(r,n)} (-1)^{j-y} (r-j)^{n-j} n_{(j)}\binom{r-y}{j-y}.$$ Dividing this by $r^n$ gives the associated probabilities. The computational effort is $O(\min(r,n)-y)$. Nothing comes for free! As in most applications of the PIE, this is an alternating sum of terms that can vary radically in size, with the final result being much smaller than the largest terms. There can be catastrophic loss of precision, so high-precision (or, better yet, exact rational) arithmetic is needed. With that available, the implementation is remarkably short. Here it is in Mathematica: p[n_, k_] := n^k; p[n_, 0] := 1; f[n_, d_, k_] := Binomial[d,k] Sum[(-1)^(j-k) Binomial[d-k,j-k] FactorialPower[n,j] p[d-j,n-j],{j,k,Min[d,n]}] As an example, let's plot the full distribution for a particular $n$ and $r$: With[{n = 100, r = 100}, DiscretePlot[f[n, r, y]/r^n, {y, 0, Min[n, r]}]] As an example, consider the case $n=4$, $r=3$, and values of $y$ from $0$ through $3$. The expansion of $f_{4,3}$ is $$x_1^4+x_2^4+x_3^4 \\\color{blue}{+4 x_2 x_1^3+4 x_3 x_1^3+4 x_1 x_2^3+4 x_3x_2^3+4 x_1 x_3^3+4 x_2x_3^3}\\+6 x_2^2 x_1^2+6 x_2^2 x_3^2+6 x_3^2 x_1^2\\\color{red}{+12 x_1 x_2 x_3^2 +12 x_1 x_2^2 x_3 +12 x_1^2 x_2 x_3}.$$ Consider the calculation for $y=1$. The terms with exactly one $x_1$ in them are $$\color{blue}{4 x_1 x_2^3+4 x_1 x_3^3}+\color{red}{12 x_1 x_2 x_3^2 +12 x_1 x_2^2 x_3}.$$ These coefficients sum to $4+4+12+12=32$. Thus we would estimate the total number of terms with just a single one of the $x_i$ would be $3\times 32=96$. We're not done yet. The terms with one $x_1$ and one other $x_i$ in them are $$\color{red}{12 x_1 x_2 x_3^2 + 12 x_1 x_2^2 x_3}.$$ This tells us that when we counted the $x_1$ terms previously, we overcounted by $12+12 = 24$. The total overcount therefore is $3\times 24 = 72$. We are done now, because there are no terms possible with exactly one instance of three sides. Consequently, the count for $y=1$ is $$96 - 72 + 0 = 24.$$ Indeed, this is the sum of coefficients of $$\color{blue}{4 x_2 x_1^3+4 x_3 x_1^3+4 x_1 x_2^3+4 x_3x_2^3+4 x_1 x_3^3+4 x_2x_3^3}.$$
Probability that exactly y of n rolls of an r-sided die are unique There is an efficient, simple, $O(n)$ solution. In expanding the polynomial $$f_{n,r} = \left(x_1+x_2+\cdots+x_r\right)^n = \sum_{i_1,i_2,\ldots,i_r} \binom{n}{i_1,i_2,\ldots,i_r} x_1^{i_1}x_2^{i_2}\c
45,312
Probability that exactly y of n rolls of an r-sided die are unique
Define $F(n, k)$ to be the number of ways to allocate $k$ options to $n$ flips such that each option appears either 0 or $\geq 2$ times. Then the probability that you see exactly $y$ unique values when you roll a $k$-sided dice $n$ times is: $$ Pr(Y=y) = \frac{{k\choose y}{n\choose y}y!F(n-y, k-y)}{k^n} $$ Basically, there are ${k \choose y}$ ways to select the $y$ unique options from all $k$ options, ${n\choose y}$ ways to select the $y$ rolls for these unique options, and $y!$ orderings of the $y$ options within these rolls. All that remains is to compute $F(n, k)$. There are a few simple cases and then a recursive definition: \begin{align*} F(0, k) &= 1 &\forall~k\geq 0 \\ F(1, k) &= 0 &\forall~k\geq 0 \\ F(n, 0) &= 0 &\forall~n\geq 1 \\ F(n, k) &= F(n, k-1) + \sum_{i=2}^n {n\choose i}F(n-i, k-1) &\forall~n\geq 2, k\geq 1 \end{align*} The recursive step selects an arbitrary option and separately considers the number of allocations for which it appears $0, 2, 3, \ldots, n$ times. This formulation enables the calculation of the entire pmf in $O(n^2k)$ runtime, which should be a good deal more efficient than summing over all valid partitions of the multinomial distribution. Here's an R implementation: uniquePMF <- function(n, k) { F <- matrix(0, nrow=n+1, ncol=k+1) F[1,] <- 1 for (.k in 1:k) { for (.n in 2:n) { F[.n+1,.k+1] <- F[.n+1,.k] + sum(choose(.n, 2:.n)*F[.n-(2:.n)+1,.k]) } } out <- sapply(0:min(n, k), function(y) choose(k, y)*choose(n, y)*factorial(y)*F[n-y+1,k-y+1]) / k^n names(out) <- 0:min(n, k) out } This returns your hand-calculated results for the $n=2, k=3$ case: uniquePMF(2, 3) # 0 1 2 # 0.3333333 0.0000000 0.6666667 It can also comfortably handle larger instances (here $n=k=100$): plot(0:100, uniquePMF(100, 100), xlab="y", ylab="Pr(Y=y)")
Probability that exactly y of n rolls of an r-sided die are unique
Define $F(n, k)$ to be the number of ways to allocate $k$ options to $n$ flips such that each option appears either 0 or $\geq 2$ times. Then the probability that you see exactly $y$ unique values whe
Probability that exactly y of n rolls of an r-sided die are unique Define $F(n, k)$ to be the number of ways to allocate $k$ options to $n$ flips such that each option appears either 0 or $\geq 2$ times. Then the probability that you see exactly $y$ unique values when you roll a $k$-sided dice $n$ times is: $$ Pr(Y=y) = \frac{{k\choose y}{n\choose y}y!F(n-y, k-y)}{k^n} $$ Basically, there are ${k \choose y}$ ways to select the $y$ unique options from all $k$ options, ${n\choose y}$ ways to select the $y$ rolls for these unique options, and $y!$ orderings of the $y$ options within these rolls. All that remains is to compute $F(n, k)$. There are a few simple cases and then a recursive definition: \begin{align*} F(0, k) &= 1 &\forall~k\geq 0 \\ F(1, k) &= 0 &\forall~k\geq 0 \\ F(n, 0) &= 0 &\forall~n\geq 1 \\ F(n, k) &= F(n, k-1) + \sum_{i=2}^n {n\choose i}F(n-i, k-1) &\forall~n\geq 2, k\geq 1 \end{align*} The recursive step selects an arbitrary option and separately considers the number of allocations for which it appears $0, 2, 3, \ldots, n$ times. This formulation enables the calculation of the entire pmf in $O(n^2k)$ runtime, which should be a good deal more efficient than summing over all valid partitions of the multinomial distribution. Here's an R implementation: uniquePMF <- function(n, k) { F <- matrix(0, nrow=n+1, ncol=k+1) F[1,] <- 1 for (.k in 1:k) { for (.n in 2:n) { F[.n+1,.k+1] <- F[.n+1,.k] + sum(choose(.n, 2:.n)*F[.n-(2:.n)+1,.k]) } } out <- sapply(0:min(n, k), function(y) choose(k, y)*choose(n, y)*factorial(y)*F[n-y+1,k-y+1]) / k^n names(out) <- 0:min(n, k) out } This returns your hand-calculated results for the $n=2, k=3$ case: uniquePMF(2, 3) # 0 1 2 # 0.3333333 0.0000000 0.6666667 It can also comfortably handle larger instances (here $n=k=100$): plot(0:100, uniquePMF(100, 100), xlab="y", ylab="Pr(Y=y)")
Probability that exactly y of n rolls of an r-sided die are unique Define $F(n, k)$ to be the number of ways to allocate $k$ options to $n$ flips such that each option appears either 0 or $\geq 2$ times. Then the probability that you see exactly $y$ unique values whe
45,313
Probability that exactly y of n rolls of an r-sided die are unique
This is basically a generalized coupon-collector problem. I don't think you're going to find an easy closed form solution to it. In general, the distribution of dice throws is multinomial: $$\binom{n}{a_1,a_2,\cdots,a_r}(1/r)^n,$$ where $a_i$ represents the number of times $i$ is rolled, and $a_1+\cdots+a_r=n$. Then the answer is: $$(1/r)^n\sum\binom{n}{a_1,a_2,\cdots,a_r},$$ where the sum is over all combinations of $a_i$ such that exactly $y$ of them are nonzero. I.E. you are looking at all partitions of $n=a_1+\cdots+a_r$ such that exactly $y$ are nonzero. You can use some symmetry to simplify this further by just summing over all combinations of $n=a_1+\cdots+a_y$ with $a_i>0$ for $i=1,2,\cdots,y$ and $a_i=0$ for $i>y$, and then accounting for their multiplicity via $\binom{n}{a_1}\binom{n-a_1}{a_2}\cdots$.
Probability that exactly y of n rolls of an r-sided die are unique
This is basically a generalized coupon-collector problem. I don't think you're going to find an easy closed form solution to it. In general, the distribution of dice throws is multinomial: $$\binom{n}
Probability that exactly y of n rolls of an r-sided die are unique This is basically a generalized coupon-collector problem. I don't think you're going to find an easy closed form solution to it. In general, the distribution of dice throws is multinomial: $$\binom{n}{a_1,a_2,\cdots,a_r}(1/r)^n,$$ where $a_i$ represents the number of times $i$ is rolled, and $a_1+\cdots+a_r=n$. Then the answer is: $$(1/r)^n\sum\binom{n}{a_1,a_2,\cdots,a_r},$$ where the sum is over all combinations of $a_i$ such that exactly $y$ of them are nonzero. I.E. you are looking at all partitions of $n=a_1+\cdots+a_r$ such that exactly $y$ are nonzero. You can use some symmetry to simplify this further by just summing over all combinations of $n=a_1+\cdots+a_y$ with $a_i>0$ for $i=1,2,\cdots,y$ and $a_i=0$ for $i>y$, and then accounting for their multiplicity via $\binom{n}{a_1}\binom{n-a_1}{a_2}\cdots$.
Probability that exactly y of n rolls of an r-sided die are unique This is basically a generalized coupon-collector problem. I don't think you're going to find an easy closed form solution to it. In general, the distribution of dice throws is multinomial: $$\binom{n}
45,314
Second Moment of Beta distribution
I guess you mean the right thing that the first moment does not allow you to apply the method-of-moments strategy of equating a population moment to a function of the parameter you aim to estimate, as the moment condition does not identify the parameter here. This is intuitive in case of the mean when the parameters of the beta distribution are equal to each other, as the mean (as you show) then always is equal to $1/2$, no matter what $\alpha$ generated the data, so the data will not be informative about $\alpha$. Or, from a more positive angle: if the parameters are identical, you do not need data to find the mean of the distribution. You can utilize either $E(X^2)$ or $Var(X)$ to estimate $\alpha$ - this highlights the fact that method-of-moment estimators are not unique. Working with the variance seems convenient here, as $$ Var(X)=\frac{1}{8\alpha+4}, $$ which can be easily solved for $\alpha$ to get $$ \alpha=\frac{1-4Var(X)}{8Var(X)} $$ Solving $$ E(X^2)=\frac{\alpha + 1}{4\alpha + 2} $$ for $\alpha$ is of course not difficult, either, leading to $$ \alpha=\frac{1-2E(X^2)}{4E(X^2)-1} $$ As method-of-moment estimators are generally consistent, estimators using these expressions will of course produce similar values in large samples, but are not numerically equivalent: X <- rbeta(10000, shape1 = 2, shape2 = 2) Xbarsq <- mean(X^2) VX <- Xbarsq - mean(X)^2 > alpha1 <- (1-2*Xbarsq)/(4*Xbarsq-1) [1] 2.033679 > alpha2 <- (1-4*VX)/(8*VX) [1] 1.986139 Following up on @Glen_b's suggestion to also think about the sampling distribution, it does seem to be the case that the MoM estimator based on the variance is substantially more efficient. Here are kernel density estimates from a little Monte Carlo study: It ought to be possible to compute the asymptotic variances of the two estimators via the delta method, but I leave that for other interested readers :-).
Second Moment of Beta distribution
I guess you mean the right thing that the first moment does not allow you to apply the method-of-moments strategy of equating a population moment to a function of the parameter you aim to estimate, as
Second Moment of Beta distribution I guess you mean the right thing that the first moment does not allow you to apply the method-of-moments strategy of equating a population moment to a function of the parameter you aim to estimate, as the moment condition does not identify the parameter here. This is intuitive in case of the mean when the parameters of the beta distribution are equal to each other, as the mean (as you show) then always is equal to $1/2$, no matter what $\alpha$ generated the data, so the data will not be informative about $\alpha$. Or, from a more positive angle: if the parameters are identical, you do not need data to find the mean of the distribution. You can utilize either $E(X^2)$ or $Var(X)$ to estimate $\alpha$ - this highlights the fact that method-of-moment estimators are not unique. Working with the variance seems convenient here, as $$ Var(X)=\frac{1}{8\alpha+4}, $$ which can be easily solved for $\alpha$ to get $$ \alpha=\frac{1-4Var(X)}{8Var(X)} $$ Solving $$ E(X^2)=\frac{\alpha + 1}{4\alpha + 2} $$ for $\alpha$ is of course not difficult, either, leading to $$ \alpha=\frac{1-2E(X^2)}{4E(X^2)-1} $$ As method-of-moment estimators are generally consistent, estimators using these expressions will of course produce similar values in large samples, but are not numerically equivalent: X <- rbeta(10000, shape1 = 2, shape2 = 2) Xbarsq <- mean(X^2) VX <- Xbarsq - mean(X)^2 > alpha1 <- (1-2*Xbarsq)/(4*Xbarsq-1) [1] 2.033679 > alpha2 <- (1-4*VX)/(8*VX) [1] 1.986139 Following up on @Glen_b's suggestion to also think about the sampling distribution, it does seem to be the case that the MoM estimator based on the variance is substantially more efficient. Here are kernel density estimates from a little Monte Carlo study: It ought to be possible to compute the asymptotic variances of the two estimators via the delta method, but I leave that for other interested readers :-).
Second Moment of Beta distribution I guess you mean the right thing that the first moment does not allow you to apply the method-of-moments strategy of equating a population moment to a function of the parameter you aim to estimate, as
45,315
Second Moment of Beta distribution
Your approach (i.e. the logic by which you decided to look at the second moment) looks right. Your algebra also looks right. It's not necessary to calculate any further moments to estimate $\alpha$ but once you have an estimator it is generally of interest to compute its variance (and if possible, the sampling distribution of the estimator)
Second Moment of Beta distribution
Your approach (i.e. the logic by which you decided to look at the second moment) looks right. Your algebra also looks right. It's not necessary to calculate any further moments to estimate $\alpha$ bu
Second Moment of Beta distribution Your approach (i.e. the logic by which you decided to look at the second moment) looks right. Your algebra also looks right. It's not necessary to calculate any further moments to estimate $\alpha$ but once you have an estimator it is generally of interest to compute its variance (and if possible, the sampling distribution of the estimator)
Second Moment of Beta distribution Your approach (i.e. the logic by which you decided to look at the second moment) looks right. Your algebra also looks right. It's not necessary to calculate any further moments to estimate $\alpha$ bu
45,316
How to choose appropriate bandwidth for kernel regression?
I would recommend you to read this beautiful article by Racine and Li published in the Journal of Econometrics in 2004. They develop a framework to estimate regression functions nonparametrically using kernel methods, with mixed types of covariates (categorical or continuous regressors). Among other results, they show consistency of the cross-validated estimates. This is a classical article in the nonparametric econometrics literature. The main method for choosing bandwidth parameters is, undoubtfully, the cross-validation procedure. However, other methods exist such as bootstraping (a quick google search gives: a PhD thesis about choosing bandwidths for np kernel regression. If you have a large sample, leave-one-out CV may not be the way to go for computational reasons. Moreover, if the data consist of time-series, the CV method may not be valid anymore. What you can do is proceed with hold-out validation. Assume you have $T$ observations. Split the sample into two parts: the estimation sample (observation 1 to $T-k$) and a hold-out sample (obs $T-k+1$ to $T$). Compute the estimator using the estimation sample (first $T-k$ obs) as a function of $h$. Compute the out-of-sample prediction for the hold-out sample (last $k$ obs) as a function of $h$. Minimize the squared prediction error with respect to $h$. Recompute $h$ using the same procedure as new data come in. Also, if the Nadaraya-Watson estimator is indeed a np kernel estimator, this is not the case for Lowess, which is a local polynomial regression method. You could also fit your regression function using the Sieves (i.e. through a basis expansion of the function) based on wavelets for example given the structure of your data. Finally, the np kernel estimation of densities is extremely similar to that of the conditional mean, which is what you have in mind when you talk about 'regression'. A np kernel regression considers estimating $E(Y|X)$, where $Y$ is the dependent variable and $X$ is a (hopefully) exogenous predictor. Replacing Y by $I(Y\leq y)$ - where $I$ denotes the indicator function that equates $1$ when the event inside the brackets occurs - gives the conditional mean expression $E(I(Y\leq y)|X)$. Now, run a bunch of np kernel regression on $E(I(Y\leq y)|X)$ for various values of $y$. This will provide an estimate the conditional cumulative distribution of $Y$ given $X$. Now take a derivative with respect to $y$, you have a density. So what's the difference after all? Just a matter of choosing the dependent variable. The method is the same, unless you want to re-scale and impose restrictions on the CDF maybe...
How to choose appropriate bandwidth for kernel regression?
I would recommend you to read this beautiful article by Racine and Li published in the Journal of Econometrics in 2004. They develop a framework to estimate regression functions nonparametrically usin
How to choose appropriate bandwidth for kernel regression? I would recommend you to read this beautiful article by Racine and Li published in the Journal of Econometrics in 2004. They develop a framework to estimate regression functions nonparametrically using kernel methods, with mixed types of covariates (categorical or continuous regressors). Among other results, they show consistency of the cross-validated estimates. This is a classical article in the nonparametric econometrics literature. The main method for choosing bandwidth parameters is, undoubtfully, the cross-validation procedure. However, other methods exist such as bootstraping (a quick google search gives: a PhD thesis about choosing bandwidths for np kernel regression. If you have a large sample, leave-one-out CV may not be the way to go for computational reasons. Moreover, if the data consist of time-series, the CV method may not be valid anymore. What you can do is proceed with hold-out validation. Assume you have $T$ observations. Split the sample into two parts: the estimation sample (observation 1 to $T-k$) and a hold-out sample (obs $T-k+1$ to $T$). Compute the estimator using the estimation sample (first $T-k$ obs) as a function of $h$. Compute the out-of-sample prediction for the hold-out sample (last $k$ obs) as a function of $h$. Minimize the squared prediction error with respect to $h$. Recompute $h$ using the same procedure as new data come in. Also, if the Nadaraya-Watson estimator is indeed a np kernel estimator, this is not the case for Lowess, which is a local polynomial regression method. You could also fit your regression function using the Sieves (i.e. through a basis expansion of the function) based on wavelets for example given the structure of your data. Finally, the np kernel estimation of densities is extremely similar to that of the conditional mean, which is what you have in mind when you talk about 'regression'. A np kernel regression considers estimating $E(Y|X)$, where $Y$ is the dependent variable and $X$ is a (hopefully) exogenous predictor. Replacing Y by $I(Y\leq y)$ - where $I$ denotes the indicator function that equates $1$ when the event inside the brackets occurs - gives the conditional mean expression $E(I(Y\leq y)|X)$. Now, run a bunch of np kernel regression on $E(I(Y\leq y)|X)$ for various values of $y$. This will provide an estimate the conditional cumulative distribution of $Y$ given $X$. Now take a derivative with respect to $y$, you have a density. So what's the difference after all? Just a matter of choosing the dependent variable. The method is the same, unless you want to re-scale and impose restrictions on the CDF maybe...
How to choose appropriate bandwidth for kernel regression? I would recommend you to read this beautiful article by Racine and Li published in the Journal of Econometrics in 2004. They develop a framework to estimate regression functions nonparametrically usin
45,317
How to choose appropriate bandwidth for kernel regression?
Here is what I could find in study notes from my econometrics class: Average squared error (ASE) is given as: $$ASE = \frac{1}{n} \sum_{j=1}^n[\widehat{m}_h(X_j)-{m}_h(X_j)]^2 w(X_j)$$ where $\widehat{m}_h(X_j)$ is the fitted value from the kernel regression, $w(x)= \sum_{i=1}^n \frac{K(\frac{x-X_i}{h})}{\sum_{j=1}^nK(\frac{x-X_j}{h})}$ with K being the chosen kernel function and $h$ is the bandwith. The mean average squared error (MASE) is as follows: $$MASE=E[ASE\vert X_1=x_1,...,X_n=x_n]$$ The suggested approach for finding the optimal (in a minimum MASE sense) bandwith $h$ is cross validation: $$CV(h)=\frac{1}{n}\sum_{i=1}^n[Y_i-\widehat{m}_{h,i-1}(X_j)]^2w(X_i)$$ where this must be minimized for $h$. It can be shown that MSE at a given x is a function of both variance and bias, and depends on the number of data points being 'close' and the curvature of the function.
How to choose appropriate bandwidth for kernel regression?
Here is what I could find in study notes from my econometrics class: Average squared error (ASE) is given as: $$ASE = \frac{1}{n} \sum_{j=1}^n[\widehat{m}_h(X_j)-{m}_h(X_j)]^2 w(X_j)$$ where $\widehat
How to choose appropriate bandwidth for kernel regression? Here is what I could find in study notes from my econometrics class: Average squared error (ASE) is given as: $$ASE = \frac{1}{n} \sum_{j=1}^n[\widehat{m}_h(X_j)-{m}_h(X_j)]^2 w(X_j)$$ where $\widehat{m}_h(X_j)$ is the fitted value from the kernel regression, $w(x)= \sum_{i=1}^n \frac{K(\frac{x-X_i}{h})}{\sum_{j=1}^nK(\frac{x-X_j}{h})}$ with K being the chosen kernel function and $h$ is the bandwith. The mean average squared error (MASE) is as follows: $$MASE=E[ASE\vert X_1=x_1,...,X_n=x_n]$$ The suggested approach for finding the optimal (in a minimum MASE sense) bandwith $h$ is cross validation: $$CV(h)=\frac{1}{n}\sum_{i=1}^n[Y_i-\widehat{m}_{h,i-1}(X_j)]^2w(X_i)$$ where this must be minimized for $h$. It can be shown that MSE at a given x is a function of both variance and bias, and depends on the number of data points being 'close' and the curvature of the function.
How to choose appropriate bandwidth for kernel regression? Here is what I could find in study notes from my econometrics class: Average squared error (ASE) is given as: $$ASE = \frac{1}{n} \sum_{j=1}^n[\widehat{m}_h(X_j)-{m}_h(X_j)]^2 w(X_j)$$ where $\widehat
45,318
Standard deviation for weighted sum of normal distributions
(I am assuming $H_1$ and $H_0$ are independent) Let $f_H = pf_1(x) + (1-p)f_0(x)$, where $f_1$ and $f_0$ are pdfs of $H_1$ and $H_0$. Then the random variable $H$ is the mixture of two normal distributions. For the mean of $H$ $$E(H) = \int x\left(pf_1(x) + (1-p)f_0(x) \right) dx = p\mu_1 + (1-p)\mu_0. $$ Similarly for the second moment of H \begin{align*} E(H^2)& = \int x^2 \left(pf_1(x) + (1-p)f_0(x) \right) dx\\ & = pE(H_1^2) + (1-p)E(H_0)^2\\ & = p(\sigma_1^2 + \mu_1^2) + (1-p)(\sigma_0^2 + \mu_0^2) \end{align*} Finally, \begin{align*} Var(H) & = E(H^2) - [E(H)]^2\\ & = p(\sigma_1^2 + \mu_1^2) + (1-p)(\sigma_0^2 + \mu_0^2) - \left[p\mu_1 + (1-p)\mu_0 \right]^2\\ & = \left[p\sigma_1^2 + (1-p)\sigma_0^2\right] + [p\mu_1^2 + (1-p)\mu_0^2]- \left[p\mu_1 + (1-p)\mu_0 \right]^2\\ & = p\sigma^2_1+(1−p)\sigma^2_0+p(1−p)(\mu_1−\mu_0)^2 \end{align*} Taking the square root of $Var(H)$, you get the standard deviation.
Standard deviation for weighted sum of normal distributions
(I am assuming $H_1$ and $H_0$ are independent) Let $f_H = pf_1(x) + (1-p)f_0(x)$, where $f_1$ and $f_0$ are pdfs of $H_1$ and $H_0$. Then the random variable $H$ is the mixture of two normal distribu
Standard deviation for weighted sum of normal distributions (I am assuming $H_1$ and $H_0$ are independent) Let $f_H = pf_1(x) + (1-p)f_0(x)$, where $f_1$ and $f_0$ are pdfs of $H_1$ and $H_0$. Then the random variable $H$ is the mixture of two normal distributions. For the mean of $H$ $$E(H) = \int x\left(pf_1(x) + (1-p)f_0(x) \right) dx = p\mu_1 + (1-p)\mu_0. $$ Similarly for the second moment of H \begin{align*} E(H^2)& = \int x^2 \left(pf_1(x) + (1-p)f_0(x) \right) dx\\ & = pE(H_1^2) + (1-p)E(H_0)^2\\ & = p(\sigma_1^2 + \mu_1^2) + (1-p)(\sigma_0^2 + \mu_0^2) \end{align*} Finally, \begin{align*} Var(H) & = E(H^2) - [E(H)]^2\\ & = p(\sigma_1^2 + \mu_1^2) + (1-p)(\sigma_0^2 + \mu_0^2) - \left[p\mu_1 + (1-p)\mu_0 \right]^2\\ & = \left[p\sigma_1^2 + (1-p)\sigma_0^2\right] + [p\mu_1^2 + (1-p)\mu_0^2]- \left[p\mu_1 + (1-p)\mu_0 \right]^2\\ & = p\sigma^2_1+(1−p)\sigma^2_0+p(1−p)(\mu_1−\mu_0)^2 \end{align*} Taking the square root of $Var(H)$, you get the standard deviation.
Standard deviation for weighted sum of normal distributions (I am assuming $H_1$ and $H_0$ are independent) Let $f_H = pf_1(x) + (1-p)f_0(x)$, where $f_1$ and $f_0$ are pdfs of $H_1$ and $H_0$. Then the random variable $H$ is the mixture of two normal distribu
45,319
Standard deviation for weighted sum of normal distributions
Let $Z$ denote a Bernoulli random variable with parameter $p$. Then, the random variable $H$ can be thought of as having conditional density $N(\mu_i, \sigma_i^2)$ according as $Z$ equals $i$, $i=0,1$, and thus unconditional density $$f_H(x) = pf_{H_1}(x) + (1-p)f_{H_0}(x).$$ The unconditional mean is thus the weighted sum of conditional means, viz. $$\mu_H = p\mu_1 + (1-p)\mu_0$$ while the unconditional (or total) variance is given by the total variance formula: mean of the conditional variance plus the variance of the conditional mean The first quantity is clearly $p\sigma_1^2 + (1-p)\sigma_0^2$. On the other hand, the conditional mean takes on value $\mu_1$ and $\mu_0$with probabilities $p$ and $1-p$ respectively and thus has variance \begin{align}p\mu_1^2 + (1-p)\mu_0^2 - \left(p\mu_1 + (1-p)\mu_0\right)^2 &= (p-p^2)\mu_1^2 + (1-p-(1-p)^2)\mu_0^2 -2p(1-p)\mu_0\mu_1\\ &= p(1-p)(\mu_1-\mu_0)^2 \end{align} Adding these two quantities together, we have that $$\sigma_H^2 = p\sigma_1^2 + (1-p)\sigma_0^2 + p(1-p)(\mu_1-\mu_0)^2$$ as in Greenparker's answer.
Standard deviation for weighted sum of normal distributions
Let $Z$ denote a Bernoulli random variable with parameter $p$. Then, the random variable $H$ can be thought of as having conditional density $N(\mu_i, \sigma_i^2)$ according as $Z$ equals $i$, $i=0,1$
Standard deviation for weighted sum of normal distributions Let $Z$ denote a Bernoulli random variable with parameter $p$. Then, the random variable $H$ can be thought of as having conditional density $N(\mu_i, \sigma_i^2)$ according as $Z$ equals $i$, $i=0,1$, and thus unconditional density $$f_H(x) = pf_{H_1}(x) + (1-p)f_{H_0}(x).$$ The unconditional mean is thus the weighted sum of conditional means, viz. $$\mu_H = p\mu_1 + (1-p)\mu_0$$ while the unconditional (or total) variance is given by the total variance formula: mean of the conditional variance plus the variance of the conditional mean The first quantity is clearly $p\sigma_1^2 + (1-p)\sigma_0^2$. On the other hand, the conditional mean takes on value $\mu_1$ and $\mu_0$with probabilities $p$ and $1-p$ respectively and thus has variance \begin{align}p\mu_1^2 + (1-p)\mu_0^2 - \left(p\mu_1 + (1-p)\mu_0\right)^2 &= (p-p^2)\mu_1^2 + (1-p-(1-p)^2)\mu_0^2 -2p(1-p)\mu_0\mu_1\\ &= p(1-p)(\mu_1-\mu_0)^2 \end{align} Adding these two quantities together, we have that $$\sigma_H^2 = p\sigma_1^2 + (1-p)\sigma_0^2 + p(1-p)(\mu_1-\mu_0)^2$$ as in Greenparker's answer.
Standard deviation for weighted sum of normal distributions Let $Z$ denote a Bernoulli random variable with parameter $p$. Then, the random variable $H$ can be thought of as having conditional density $N(\mu_i, \sigma_i^2)$ according as $Z$ equals $i$, $i=0,1$
45,320
Why aren't the diagonal counts used in McNemar's test?
The tag info for McNemar's test (once supplied by me, and later possibly modified): A repeated-measures test for categorical data. Given that two variables with the same 2 categories (McNemar test) or k categories (McNemar-Bowker test) form a square contingency table, the test's question is whether population proportion in every off-diagonal cell is equal to that in the symmetric cell. The 2x2 McNemar's test can be seen also as a "marginal homogeneity" test. Please note first of all that McNemar's / McNemar-Bowker is generally not meant to be the test of marginal homogeneity. There exist a marginal homogeneity test for CxC table which is not the same as McNemar-Bowker test of axial symmetry in CxC table. But in the specific case of 2x2 table the symmetry McNemar's test becomes also the test of marginal homogeneity. (To add, the above mentioned CxC marginal homogeneity test is actually based internally on repeated application of McNemar's test to all possible 2x2 subtables). (To add yet another info: 2x2 McNemar's test is equivalent to Sign test performed on dichotomous data; and both can be made to return exact or asymptotic p-value.) So, you are both right (in a specific case) and not so right (generally) saying that McNemar's test is a marginal homogeneity test. First of all, it is the axial symmetry test. It is used in pre-post studies or match-pair studies to compare symmetric frequencies in the table; the row and the column categories must be same entities. The H0 is that in population all off-diagonal proportions are equal to their symmetric cell proportions vs H1 that at least one proportion differs from its symmetric one. It is not strange therefore that an off-diagonal symmetry test ignores diagonal entries altogether. But there is another repeated measures categorical test for CxC contingency table with the same row/column categories - which does take the diagonal entries into account - the well-known Cohen's kappa statistic & test. Use it if you want to consider diagonal. But it tests different hypothesis: H0 = diagonal and off-diagonal proportions even vs H1 = off-diagonal proportions dominate (diagonal is canyon) or diagonal proportions dominate (ridge). Kappa does not consider specifically symmetric cells. @ted's intuition about McNemar's But the difference looks a lot like noise if the total number of observations is 1MM is misplaced. To repeat it: the diagonal entries in McNemar's (they would be called "ties", in terminology of Sign test) is conceptually outside of its test hypothesis. The hypothesis is about the binomial question "who wins statistically more often, A or B? or are they about draw by account?". So diagonal, ties, are treated as if "no answer, or don't know" response and thence the observations irrelevant to the experiment. They should be excluded from the sample at the time of testing. Despite they are irrelevant to the H0/H1 they are relevant to the test's power - since being excluded they diminish the effective sample size on which the test is based. Instead of exclusion, you might choose to randomly assign the ties under 1/2 probability either to "A wins" or "B wins", i.e. to treat ties as "chance lost data". This approach will not bias NcNemar's test but will weaken its power (see it). But if you need to include the diagonal into your test concept (specifically, that under H0 there is even chance to fall into any off-diagonal as well as in any diagonal cell) - then McNemar's test shouldn't interest you. Choose kappa for example, or some other criterion/test. There are a number of them designed specifically to compare classification performances. Comparing two classifiers is like comparing two rates. Inclusion an observation in a diagonal cell such as a is an effective result of the works of the classifiers. Logically, it should be taken into account. As in kappa. But McNemar is primarily for repeated measures settings for the same set of observations. Those found themselves in cell a just remained indifferent to the effects of the factor; and as long as the test issue is what is the direction of the effect whenever it exists - the cell can't help answer it.
Why aren't the diagonal counts used in McNemar's test?
The tag info for McNemar's test (once supplied by me, and later possibly modified): A repeated-measures test for categorical data. Given that two variables with the same 2 categories (McNemar test)
Why aren't the diagonal counts used in McNemar's test? The tag info for McNemar's test (once supplied by me, and later possibly modified): A repeated-measures test for categorical data. Given that two variables with the same 2 categories (McNemar test) or k categories (McNemar-Bowker test) form a square contingency table, the test's question is whether population proportion in every off-diagonal cell is equal to that in the symmetric cell. The 2x2 McNemar's test can be seen also as a "marginal homogeneity" test. Please note first of all that McNemar's / McNemar-Bowker is generally not meant to be the test of marginal homogeneity. There exist a marginal homogeneity test for CxC table which is not the same as McNemar-Bowker test of axial symmetry in CxC table. But in the specific case of 2x2 table the symmetry McNemar's test becomes also the test of marginal homogeneity. (To add, the above mentioned CxC marginal homogeneity test is actually based internally on repeated application of McNemar's test to all possible 2x2 subtables). (To add yet another info: 2x2 McNemar's test is equivalent to Sign test performed on dichotomous data; and both can be made to return exact or asymptotic p-value.) So, you are both right (in a specific case) and not so right (generally) saying that McNemar's test is a marginal homogeneity test. First of all, it is the axial symmetry test. It is used in pre-post studies or match-pair studies to compare symmetric frequencies in the table; the row and the column categories must be same entities. The H0 is that in population all off-diagonal proportions are equal to their symmetric cell proportions vs H1 that at least one proportion differs from its symmetric one. It is not strange therefore that an off-diagonal symmetry test ignores diagonal entries altogether. But there is another repeated measures categorical test for CxC contingency table with the same row/column categories - which does take the diagonal entries into account - the well-known Cohen's kappa statistic & test. Use it if you want to consider diagonal. But it tests different hypothesis: H0 = diagonal and off-diagonal proportions even vs H1 = off-diagonal proportions dominate (diagonal is canyon) or diagonal proportions dominate (ridge). Kappa does not consider specifically symmetric cells. @ted's intuition about McNemar's But the difference looks a lot like noise if the total number of observations is 1MM is misplaced. To repeat it: the diagonal entries in McNemar's (they would be called "ties", in terminology of Sign test) is conceptually outside of its test hypothesis. The hypothesis is about the binomial question "who wins statistically more often, A or B? or are they about draw by account?". So diagonal, ties, are treated as if "no answer, or don't know" response and thence the observations irrelevant to the experiment. They should be excluded from the sample at the time of testing. Despite they are irrelevant to the H0/H1 they are relevant to the test's power - since being excluded they diminish the effective sample size on which the test is based. Instead of exclusion, you might choose to randomly assign the ties under 1/2 probability either to "A wins" or "B wins", i.e. to treat ties as "chance lost data". This approach will not bias NcNemar's test but will weaken its power (see it). But if you need to include the diagonal into your test concept (specifically, that under H0 there is even chance to fall into any off-diagonal as well as in any diagonal cell) - then McNemar's test shouldn't interest you. Choose kappa for example, or some other criterion/test. There are a number of them designed specifically to compare classification performances. Comparing two classifiers is like comparing two rates. Inclusion an observation in a diagonal cell such as a is an effective result of the works of the classifiers. Logically, it should be taken into account. As in kappa. But McNemar is primarily for repeated measures settings for the same set of observations. Those found themselves in cell a just remained indifferent to the effects of the factor; and as long as the test issue is what is the direction of the effect whenever it exists - the cell can't help answer it.
Why aren't the diagonal counts used in McNemar's test? The tag info for McNemar's test (once supplied by me, and later possibly modified): A repeated-measures test for categorical data. Given that two variables with the same 2 categories (McNemar test)
45,321
Why aren't the diagonal counts used in McNemar's test?
Intuitively, since "Cell $a$" is in the first row and first column, including $a$ in your test wouldn't help to assess the difference between the row marginal and the column marginal. If your row is $a+b$ and your column is $a+c$, to test if $a+b=a+c$, you only need to test $b=c$. Including $a$ is irrelevant to the extent that we want to test for equality of the row and column marginals. McNemar's test is used to detect a difference in paired data - often (but not always) this is applied to before and after data. When you describe "Cell $a$" above, that would be the cell corresponding to the same state before and after. For example, if you are testing whether or or not dogs fetch a stick better after a training session, $a$ would indicate the number of dogs who fetched a stick before the training session and who fetched a stick after the training session. Cell $d$ would indicate the number of dogs who did not fetch a stick before training and who did not fetch a stick after training. If we're interested in seeing the difference between the "before" and "after" results, then we only care about cells $b$ and $c$.
Why aren't the diagonal counts used in McNemar's test?
Intuitively, since "Cell $a$" is in the first row and first column, including $a$ in your test wouldn't help to assess the difference between the row marginal and the column marginal. If your row is
Why aren't the diagonal counts used in McNemar's test? Intuitively, since "Cell $a$" is in the first row and first column, including $a$ in your test wouldn't help to assess the difference between the row marginal and the column marginal. If your row is $a+b$ and your column is $a+c$, to test if $a+b=a+c$, you only need to test $b=c$. Including $a$ is irrelevant to the extent that we want to test for equality of the row and column marginals. McNemar's test is used to detect a difference in paired data - often (but not always) this is applied to before and after data. When you describe "Cell $a$" above, that would be the cell corresponding to the same state before and after. For example, if you are testing whether or or not dogs fetch a stick better after a training session, $a$ would indicate the number of dogs who fetched a stick before the training session and who fetched a stick after the training session. Cell $d$ would indicate the number of dogs who did not fetch a stick before training and who did not fetch a stick after training. If we're interested in seeing the difference between the "before" and "after" results, then we only care about cells $b$ and $c$.
Why aren't the diagonal counts used in McNemar's test? Intuitively, since "Cell $a$" is in the first row and first column, including $a$ in your test wouldn't help to assess the difference between the row marginal and the column marginal. If your row is
45,322
Why aren't the diagonal counts used in McNemar's test?
Your intuition is reasonable, but incorrect. (As you note, that state of affairs is very common in probability and statistics.) Statistical significance vs. effect size / practical significance You state: The difference in number of misclassifications between A and B seems large in table #1, but small in table #2. Thus, McNemar's test seems unsuitable for determining whether A and B's performance is significantly different since it ignores the counts in cell "a". Let me change that to: The difference in number of misclassifications between A and B seems large in table #1, but small in table #2. Thus, McNemar's test seems unsuitable for determining whether A and B's performance is significantly meaningfully different since it ignores the counts in cell "a". In general, hypothesis tests are intended to let us determine if we can be confident that there is, in fact, a difference. This does not mean that the difference is terribly important. The magnitude of a difference is the effect size. Whether that effect size is something you would care about (under the assumption you believed it), is a question of practical significance.
Why aren't the diagonal counts used in McNemar's test?
Your intuition is reasonable, but incorrect. (As you note, that state of affairs is very common in probability and statistics.) Statistical significance vs. effect size / practical significance You s
Why aren't the diagonal counts used in McNemar's test? Your intuition is reasonable, but incorrect. (As you note, that state of affairs is very common in probability and statistics.) Statistical significance vs. effect size / practical significance You state: The difference in number of misclassifications between A and B seems large in table #1, but small in table #2. Thus, McNemar's test seems unsuitable for determining whether A and B's performance is significantly different since it ignores the counts in cell "a". Let me change that to: The difference in number of misclassifications between A and B seems large in table #1, but small in table #2. Thus, McNemar's test seems unsuitable for determining whether A and B's performance is significantly meaningfully different since it ignores the counts in cell "a". In general, hypothesis tests are intended to let us determine if we can be confident that there is, in fact, a difference. This does not mean that the difference is terribly important. The magnitude of a difference is the effect size. Whether that effect size is something you would care about (under the assumption you believed it), is a question of practical significance.
Why aren't the diagonal counts used in McNemar's test? Your intuition is reasonable, but incorrect. (As you note, that state of affairs is very common in probability and statistics.) Statistical significance vs. effect size / practical significance You s
45,323
Check for significant difference between numbers of sightings per cardinal direction
First off, methods such as ANOVA and Kruskal-Wallis pay no attention to the circular nature of data such as yours. It's not clear how you imagine applying either, but if you intend to regard direction as a categorical predictor, you would be ignoring any structure to the measurement scale other than the directions being different. More generally, note that statistical methods essentially do not provide proofs; at best, they provide indications, point to conclusions, or aid decisions. Your problem falls squarely within circular statistics, itself part of the statistics of directions. Problems to do with animal movements have historically helped stimulate this field. An appropriate test of a null hypothesis of uniformity of direction as compared with an alternative hypothesis of unimodality, i.e. whether there is a single preferred direction, is the Rayleigh test, which for your data yields a $P$-value of about 0.003, i.e. the idea of a preferred direction is well supported. More interesting and more important is what that preferred direction is, and my calculations yield a vector mean of 348$^\circ$, 12$^\circ$ W of N. The vector strength is 58%. That is a measure of variability with a minimum of 0 and a maximum of 1 or 100% if all directions agree. It is more commonly known as the mean resultant length; it can be considered as a measure of consistency, an excellent term occasionally used in this sense in circular statistics. Here is a graph produced in Stata showing the results of calculations with user-written programs (my own). Circular statistics are also well supported in R. I recommend a circular histogram like this, with bars proportional to frequency sitting on the sides of a regular polygon, over the much more common rose diagrams, which often are dimensionally ambiguous (is it sector radius or sector area that represents frequency?) and rarely avoid an ugly convergence of sector boundaries at their centre. I'd also suggest, although this is a little controversial, that for data like yours a standard histogram works well, so long as you rotate the scale so that mean or modal directions are roughly in the middle. https://en.wikipedia.org/wiki/Directional_statistics gives an introduction and some excellent references. The books recommended there by E. Batschelet and N.I. Fisher are scientist-friendly.
Check for significant difference between numbers of sightings per cardinal direction
First off, methods such as ANOVA and Kruskal-Wallis pay no attention to the circular nature of data such as yours. It's not clear how you imagine applying either, but if you intend to regard direction
Check for significant difference between numbers of sightings per cardinal direction First off, methods such as ANOVA and Kruskal-Wallis pay no attention to the circular nature of data such as yours. It's not clear how you imagine applying either, but if you intend to regard direction as a categorical predictor, you would be ignoring any structure to the measurement scale other than the directions being different. More generally, note that statistical methods essentially do not provide proofs; at best, they provide indications, point to conclusions, or aid decisions. Your problem falls squarely within circular statistics, itself part of the statistics of directions. Problems to do with animal movements have historically helped stimulate this field. An appropriate test of a null hypothesis of uniformity of direction as compared with an alternative hypothesis of unimodality, i.e. whether there is a single preferred direction, is the Rayleigh test, which for your data yields a $P$-value of about 0.003, i.e. the idea of a preferred direction is well supported. More interesting and more important is what that preferred direction is, and my calculations yield a vector mean of 348$^\circ$, 12$^\circ$ W of N. The vector strength is 58%. That is a measure of variability with a minimum of 0 and a maximum of 1 or 100% if all directions agree. It is more commonly known as the mean resultant length; it can be considered as a measure of consistency, an excellent term occasionally used in this sense in circular statistics. Here is a graph produced in Stata showing the results of calculations with user-written programs (my own). Circular statistics are also well supported in R. I recommend a circular histogram like this, with bars proportional to frequency sitting on the sides of a regular polygon, over the much more common rose diagrams, which often are dimensionally ambiguous (is it sector radius or sector area that represents frequency?) and rarely avoid an ugly convergence of sector boundaries at their centre. I'd also suggest, although this is a little controversial, that for data like yours a standard histogram works well, so long as you rotate the scale so that mean or modal directions are roughly in the middle. https://en.wikipedia.org/wiki/Directional_statistics gives an introduction and some excellent references. The books recommended there by E. Batschelet and N.I. Fisher are scientist-friendly.
Check for significant difference between numbers of sightings per cardinal direction First off, methods such as ANOVA and Kruskal-Wallis pay no attention to the circular nature of data such as yours. It's not clear how you imagine applying either, but if you intend to regard direction
45,324
ARMA (1,1) Variance Calculation
It is better to write your model like this: $$r_t=\alpha + \phi_1 r_{t-1} + \theta_1 a_{t-1} + a_{t}$$ where, {$a_t$} is white noise series. First, multiply the model by $a_t$ and take expectation: \begin{align} E(r_t a_t)&=\alpha E(a_t)+ \phi_1 E(r_{t-1}a_t)+\theta_1 E(a_{t-1}a_t)+ E(a_t^2)\\ &=E(a_t^2)=\sigma^2 \end{align} Here, we make use of the fact that $E(a_t r_{t-1})=0$, $E(a_t)=0$ and $E(a_{t-1}a_t)=0$. Taking the variance of original equation, we have \begin{align} Var(r_t)&=\phi_1^2 Var(r_{t-1})+\theta_1^2\sigma^2+\sigma^2+2 \phi_1 \theta_1 E(r_{t-1} a_{t-1}) \\ &=\phi_1^2 Var(r_{t-1})+\theta_1^2\sigma^2+\sigma^2+2 \phi_1 \theta_1 \sigma^2 \end{align} If $r_t$ is weakly stationary, then $Var(r_t)=Var(r_{t-1})$, so $$Var(r_t)=\frac{(1+2\phi_1 \theta_1 + \theta_1^2)\sigma^2}{1-\phi_1^2}$$
ARMA (1,1) Variance Calculation
It is better to write your model like this: $$r_t=\alpha + \phi_1 r_{t-1} + \theta_1 a_{t-1} + a_{t}$$ where, {$a_t$} is white noise series. First, multiply the model by $a_t$ and take expectation:
ARMA (1,1) Variance Calculation It is better to write your model like this: $$r_t=\alpha + \phi_1 r_{t-1} + \theta_1 a_{t-1} + a_{t}$$ where, {$a_t$} is white noise series. First, multiply the model by $a_t$ and take expectation: \begin{align} E(r_t a_t)&=\alpha E(a_t)+ \phi_1 E(r_{t-1}a_t)+\theta_1 E(a_{t-1}a_t)+ E(a_t^2)\\ &=E(a_t^2)=\sigma^2 \end{align} Here, we make use of the fact that $E(a_t r_{t-1})=0$, $E(a_t)=0$ and $E(a_{t-1}a_t)=0$. Taking the variance of original equation, we have \begin{align} Var(r_t)&=\phi_1^2 Var(r_{t-1})+\theta_1^2\sigma^2+\sigma^2+2 \phi_1 \theta_1 E(r_{t-1} a_{t-1}) \\ &=\phi_1^2 Var(r_{t-1})+\theta_1^2\sigma^2+\sigma^2+2 \phi_1 \theta_1 \sigma^2 \end{align} If $r_t$ is weakly stationary, then $Var(r_t)=Var(r_{t-1})$, so $$Var(r_t)=\frac{(1+2\phi_1 \theta_1 + \theta_1^2)\sigma^2}{1-\phi_1^2}$$
ARMA (1,1) Variance Calculation It is better to write your model like this: $$r_t=\alpha + \phi_1 r_{t-1} + \theta_1 a_{t-1} + a_{t}$$ where, {$a_t$} is white noise series. First, multiply the model by $a_t$ and take expectation:
45,325
Dimension reduction using PCA in Matlab
If you type help pca you will see loads of information about the function. If you only output one argument, it will return the principal coefficients, sometimes called the loadings. The $27578\times151$ matrix you received contains the first loading in the first row, the second in the second row and so on. If you ask for two outputs, you obtain [V, U] = pca(X); where V contains the loadings and U the score values. You reconstruct the input data by U*V'. In order to perform dimensionality reduction, you must select the first n components of both matrices as U(:, 1:n) and V(:, 1:n) and perform the approximated reconstruction as U(:, 1:n)*V(:, 1:n)'.
Dimension reduction using PCA in Matlab
If you type help pca you will see loads of information about the function. If you only output one argument, it will return the principal coefficients, sometimes called the loadings. The $27578\times15
Dimension reduction using PCA in Matlab If you type help pca you will see loads of information about the function. If you only output one argument, it will return the principal coefficients, sometimes called the loadings. The $27578\times151$ matrix you received contains the first loading in the first row, the second in the second row and so on. If you ask for two outputs, you obtain [V, U] = pca(X); where V contains the loadings and U the score values. You reconstruct the input data by U*V'. In order to perform dimensionality reduction, you must select the first n components of both matrices as U(:, 1:n) and V(:, 1:n) and perform the approximated reconstruction as U(:, 1:n)*V(:, 1:n)'.
Dimension reduction using PCA in Matlab If you type help pca you will see loads of information about the function. If you only output one argument, it will return the principal coefficients, sometimes called the loadings. The $27578\times15
45,326
Dimension reduction using PCA in Matlab
The output of PCA is a matrix of your principle components. So, this matrix contains a set of new signals but now these components are ordered in terms of how much of the datasets variance they capture. The first principle component in the matrix coeff(1,:) describes the most variance to the last component coeff(27578,:) which captures the least. So you simply need to choose $k$ dimensions you want to reduce your new inputs to like so coeff(1:k,:) One method suggested here would be to select the first $k$ components that still captures 99% of the variance of your dataset. Thus you would have reduced dimension inputs but still describe your data well.
Dimension reduction using PCA in Matlab
The output of PCA is a matrix of your principle components. So, this matrix contains a set of new signals but now these components are ordered in terms of how much of the datasets variance they captur
Dimension reduction using PCA in Matlab The output of PCA is a matrix of your principle components. So, this matrix contains a set of new signals but now these components are ordered in terms of how much of the datasets variance they capture. The first principle component in the matrix coeff(1,:) describes the most variance to the last component coeff(27578,:) which captures the least. So you simply need to choose $k$ dimensions you want to reduce your new inputs to like so coeff(1:k,:) One method suggested here would be to select the first $k$ components that still captures 99% of the variance of your dataset. Thus you would have reduced dimension inputs but still describe your data well.
Dimension reduction using PCA in Matlab The output of PCA is a matrix of your principle components. So, this matrix contains a set of new signals but now these components are ordered in terms of how much of the datasets variance they captur
45,327
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem
If $\epsilon$ is a constant, then this has linear regret. Suppose that the initial estimate is perfect. Then you pull the `best' arm with probability $1-\epsilon$ and pull an imperfect arm with probability $\epsilon$, giving expected regret $\epsilon T = \Theta(T)$. However the parameter $\epsilon$ is typically set to be a decreasing function of the iteration $t$. The trick is to decrease fast enough that the regret is close to the optimal $\sqrt{T}$ (or $\Delta \log(T)$ in the distribution dependent case), but slow enough that the estimate of which arm to choose converges to the optimum. For details on how to choose $\epsilon$, see Auer et al., who set it proportional to $1/t$.
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem
If $\epsilon$ is a constant, then this has linear regret. Suppose that the initial estimate is perfect. Then you pull the `best' arm with probability $1-\epsilon$ and pull an imperfect arm with probab
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem If $\epsilon$ is a constant, then this has linear regret. Suppose that the initial estimate is perfect. Then you pull the `best' arm with probability $1-\epsilon$ and pull an imperfect arm with probability $\epsilon$, giving expected regret $\epsilon T = \Theta(T)$. However the parameter $\epsilon$ is typically set to be a decreasing function of the iteration $t$. The trick is to decrease fast enough that the regret is close to the optimal $\sqrt{T}$ (or $\Delta \log(T)$ in the distribution dependent case), but slow enough that the estimate of which arm to choose converges to the optimum. For details on how to choose $\epsilon$, see Auer et al., who set it proportional to $1/t$.
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem If $\epsilon$ is a constant, then this has linear regret. Suppose that the initial estimate is perfect. Then you pull the `best' arm with probability $1-\epsilon$ and pull an imperfect arm with probab
45,328
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem
So this is what I think about this problem: At each time step $T$, the $ϵ$-greedy algorithm selects between optimal arm $a_k$ with probability $1-ϵ$, and all non-optimal arms $a_i,1≤i≤K∧i≠k$ with probability $ϵ$, where $K$ is the total number of arms, and $k = arg max_{ 1 \leq i\leq K }\hat\mu_i$ , where $μ ̂_i$ is the empirical expectation of arm $a_i$. From the above argument we can deduce the following: if $ϵ$ is chosen to be small, that is the probability of selecting a non-optimal arm is very small, which means that probability of a super-linear growth of expected cumulative regret is also very small; and for very small $ϵ$, super-linear expected cumulative regret can be technically ruled out. Now, for each time step $T$, the expected regret is: $(1-ϵ)(μ_T^*-μ ̂_{k_T})+ϵ∑_{1≤i≤K∧i≠k}(μ_T^*-μ ̂_{i_T} )$ where $μ_T^*$ is the value of $μ^*$ at time step $T$, and $μ^*=max_{1≤i≤K}⁡μ_i$ , where $μ_i$ is the actual underlying expectation of arm $a_i$. However as the true expectation is unknown, $μ^*$ can be redefined as: $μ^*=max_{1≤i≤K}⁡μ ̂_i$. Note that by the (re)definition of $μ^*$, $μ_T^*=μ ̂_{k_T}$. Thus, for each time step $T$, the expected regret becomes: $ϵ∑_{1≤i≤K∧i≠k}(μ_T^*-μ ̂_{i_T} )$. Now let $μ_{nonOptMax}=max_{1≤i≤K∧i≠k}μ ̂_i$. It is easy to see that at each time step $T$, the expected regret is at minimum: $ϵ∑_{1≤i≤K∧i≠k}(μ_T^*-μ_{nonOptMax_T}) = ϵ(K-1)(μ_T^*-μ_{nonOptMax_T})$ As $ϵ≥0$, and $μ_T^*>μ_{nonOptMax_T}$(under the assumption that not all expected values $µ_i = E(X_i)$ are the same), $ϵ(K-1)(μ_T^*-μ_{nonOptMax_T})>0$, and thus, expected regret at each time step $T$ is $> 0$. From this, we can deduce that cumulative expected regret is definitely not sub linear. We can thereby conclude that the growth of the cumulative expected regret is linear. P.S.: Please let me know what you think about this argument.
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem
So this is what I think about this problem: At each time step $T$, the $ϵ$-greedy algorithm selects between optimal arm $a_k$ with probability $1-ϵ$, and all non-optimal arms $a_i,1≤i≤K∧i≠k$ with prob
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem So this is what I think about this problem: At each time step $T$, the $ϵ$-greedy algorithm selects between optimal arm $a_k$ with probability $1-ϵ$, and all non-optimal arms $a_i,1≤i≤K∧i≠k$ with probability $ϵ$, where $K$ is the total number of arms, and $k = arg max_{ 1 \leq i\leq K }\hat\mu_i$ , where $μ ̂_i$ is the empirical expectation of arm $a_i$. From the above argument we can deduce the following: if $ϵ$ is chosen to be small, that is the probability of selecting a non-optimal arm is very small, which means that probability of a super-linear growth of expected cumulative regret is also very small; and for very small $ϵ$, super-linear expected cumulative regret can be technically ruled out. Now, for each time step $T$, the expected regret is: $(1-ϵ)(μ_T^*-μ ̂_{k_T})+ϵ∑_{1≤i≤K∧i≠k}(μ_T^*-μ ̂_{i_T} )$ where $μ_T^*$ is the value of $μ^*$ at time step $T$, and $μ^*=max_{1≤i≤K}⁡μ_i$ , where $μ_i$ is the actual underlying expectation of arm $a_i$. However as the true expectation is unknown, $μ^*$ can be redefined as: $μ^*=max_{1≤i≤K}⁡μ ̂_i$. Note that by the (re)definition of $μ^*$, $μ_T^*=μ ̂_{k_T}$. Thus, for each time step $T$, the expected regret becomes: $ϵ∑_{1≤i≤K∧i≠k}(μ_T^*-μ ̂_{i_T} )$. Now let $μ_{nonOptMax}=max_{1≤i≤K∧i≠k}μ ̂_i$. It is easy to see that at each time step $T$, the expected regret is at minimum: $ϵ∑_{1≤i≤K∧i≠k}(μ_T^*-μ_{nonOptMax_T}) = ϵ(K-1)(μ_T^*-μ_{nonOptMax_T})$ As $ϵ≥0$, and $μ_T^*>μ_{nonOptMax_T}$(under the assumption that not all expected values $µ_i = E(X_i)$ are the same), $ϵ(K-1)(μ_T^*-μ_{nonOptMax_T})>0$, and thus, expected regret at each time step $T$ is $> 0$. From this, we can deduce that cumulative expected regret is definitely not sub linear. We can thereby conclude that the growth of the cumulative expected regret is linear. P.S.: Please let me know what you think about this argument.
Linear Regret for epsilon-greedy algorithm in Multi-Armed Bandit problem So this is what I think about this problem: At each time step $T$, the $ϵ$-greedy algorithm selects between optimal arm $a_k$ with probability $1-ϵ$, and all non-optimal arms $a_i,1≤i≤K∧i≠k$ with prob
45,329
Ensemble classifier methods: should we use the class probabilties or the classification itself in stacking models?
What you're asking is the difference between voting (using classifications) and averaging (using probabilities), and as far as things go, it's up to preference and/or performance. Try both and see what works best, and if there is not a significant difference, pick one that you feel better about. I'll try to explain the feeling better part now. Voting might sound a bit un-natural as you've said since it ignores if the probability is 0.1 or 0.49 - however take this example. Gradient boosted tree (GBT) models are really prone to overfitting. That's why all the parameters need to be tweaked carefully and why a small change leads to a massively better generalized performance (check kaggle for reference). In this case, overfitting might mean that the GBT model will be very sure for an instance with $p_1 = 0.85$. However, two different, simpler models will not be that sure and will output $p_2 = 0.39$ and $p_3 = 0.32$ respectively. The average is $p_{avg}=0.52$ and the sample is classified according to the GBT model, even though 2/3 of your models did not agree with this. In case that you used voting, the classification would obviously be different. So, what's the conclusion here? If some of your classifiers are prone to overfitting hard and providing large probability errors for missclassified samples (which you can test for with various loss measures) but performs well otherwise, perhaps you should use voting for the error to be fixed by other classifiers. If the probability errors for the missclassified samples are within reasonable bounds, then you might be better off using probabilities, since there is no information loss and that is usually a good thing. Overall, I doubt there is an absolutely correct way to do this, and it definitely differs from task to task and ensemble to ensemble.
Ensemble classifier methods: should we use the class probabilties or the classification itself in st
What you're asking is the difference between voting (using classifications) and averaging (using probabilities), and as far as things go, it's up to preference and/or performance. Try both and see wha
Ensemble classifier methods: should we use the class probabilties or the classification itself in stacking models? What you're asking is the difference between voting (using classifications) and averaging (using probabilities), and as far as things go, it's up to preference and/or performance. Try both and see what works best, and if there is not a significant difference, pick one that you feel better about. I'll try to explain the feeling better part now. Voting might sound a bit un-natural as you've said since it ignores if the probability is 0.1 or 0.49 - however take this example. Gradient boosted tree (GBT) models are really prone to overfitting. That's why all the parameters need to be tweaked carefully and why a small change leads to a massively better generalized performance (check kaggle for reference). In this case, overfitting might mean that the GBT model will be very sure for an instance with $p_1 = 0.85$. However, two different, simpler models will not be that sure and will output $p_2 = 0.39$ and $p_3 = 0.32$ respectively. The average is $p_{avg}=0.52$ and the sample is classified according to the GBT model, even though 2/3 of your models did not agree with this. In case that you used voting, the classification would obviously be different. So, what's the conclusion here? If some of your classifiers are prone to overfitting hard and providing large probability errors for missclassified samples (which you can test for with various loss measures) but performs well otherwise, perhaps you should use voting for the error to be fixed by other classifiers. If the probability errors for the missclassified samples are within reasonable bounds, then you might be better off using probabilities, since there is no information loss and that is usually a good thing. Overall, I doubt there is an absolutely correct way to do this, and it definitely differs from task to task and ensemble to ensemble.
Ensemble classifier methods: should we use the class probabilties or the classification itself in st What you're asking is the difference between voting (using classifications) and averaging (using probabilities), and as far as things go, it's up to preference and/or performance. Try both and see wha
45,330
Ensemble classifier methods: should we use the class probabilties or the classification itself in stacking models?
The answer by mttk is quite nice. I will just add that you could also extract the probabilities and use them as input to a meta-classifier such as a simple logistic regression. This will automatically adjust for differences in the way classifiers produce probability estimates (i.e. classifier A almost exclusively produces probabilities on the range [0.4, 0.6], whereas classifier B almost exclusively produces probabilities near 0 or 1).
Ensemble classifier methods: should we use the class probabilties or the classification itself in st
The answer by mttk is quite nice. I will just add that you could also extract the probabilities and use them as input to a meta-classifier such as a simple logistic regression. This will automatically
Ensemble classifier methods: should we use the class probabilties or the classification itself in stacking models? The answer by mttk is quite nice. I will just add that you could also extract the probabilities and use them as input to a meta-classifier such as a simple logistic regression. This will automatically adjust for differences in the way classifiers produce probability estimates (i.e. classifier A almost exclusively produces probabilities on the range [0.4, 0.6], whereas classifier B almost exclusively produces probabilities near 0 or 1).
Ensemble classifier methods: should we use the class probabilties or the classification itself in st The answer by mttk is quite nice. I will just add that you could also extract the probabilities and use them as input to a meta-classifier such as a simple logistic regression. This will automatically
45,331
Seasonal adjustment a la Hyndman
First, the model involves additive seasonality. It is not complicated -- just a simple Fourier approximation to the seasonal term. Yes, the original post missed the subscripts on the coefficients; the post has been subsequently edited. In stage 1 of your proposal, you ignore the autocorrelation in the residuals which means the coefficients are poorly estimated. It is much better to take the autocorrelation into account. Further, the AIC will be wrong if you do not take the autocorrelated errors into account. In stage 2, you fit an ARIMA model to the fitted values. This makes little sense. The fitted values will be purely periodic. You need the ARIMA process on the residuals. You are wrong to say that stages 1 and 2 can be done sequentially. The correlated errors matter. Just because the Fourier terms are deterministic and possibly uncorrelated with other regressors does not make the estimation efficient.
Seasonal adjustment a la Hyndman
First, the model involves additive seasonality. It is not complicated -- just a simple Fourier approximation to the seasonal term. Yes, the original post missed the subscripts on the coefficients; the
Seasonal adjustment a la Hyndman First, the model involves additive seasonality. It is not complicated -- just a simple Fourier approximation to the seasonal term. Yes, the original post missed the subscripts on the coefficients; the post has been subsequently edited. In stage 1 of your proposal, you ignore the autocorrelation in the residuals which means the coefficients are poorly estimated. It is much better to take the autocorrelation into account. Further, the AIC will be wrong if you do not take the autocorrelated errors into account. In stage 2, you fit an ARIMA model to the fitted values. This makes little sense. The fitted values will be purely periodic. You need the ARIMA process on the residuals. You are wrong to say that stages 1 and 2 can be done sequentially. The correlated errors matter. Just because the Fourier terms are deterministic and possibly uncorrelated with other regressors does not make the estimation efficient.
Seasonal adjustment a la Hyndman First, the model involves additive seasonality. It is not complicated -- just a simple Fourier approximation to the seasonal term. Yes, the original post missed the subscripts on the coefficients; the
45,332
Confidence Interval on the Geometric Distribution Expected Value?
If one knows the population parameter of a geometric, one of course knows the population mean exactly, so a confidence interval for that would be of zero width. Assuming we only have sample information, we can construct a confidence interval for the population mean of a geometric random variable. Since your lowest value is 1, I assume we're dealing with the "number of trials" form of the geometric. Large sample: The population mean of a Geometric(p) variate is $1/p$; the variance is $(1-p)/p^2$, so the variance of a sample mean will be $(1-p)/(np^2)$. The statistic $Q_A=\frac{\bar{X}-1/p}{\sqrt{(1-p)/(np^2)}}\:$ (*) will be asymptotically standard normal. A large sample interval for $p$ could be "backed out" from that. Which is to say, we can make an interval for $Q_A$, and then find the values of $p$ which make $Q_A$ satisfy that condition (of being in the interval). e.g. if $\bar{x}=3.14$ and $n=100$ I get an asymptotic 95% interval for $p$ to be $(0.265, 0.368)$ (just by seeing which values for $p$ make that expression for $Q_A$ above stay between -1.96 and 1.96). Hence an interval for $1/p$ (the population mean) would be $(1/0.368,1/0.265)$, or $(2.72,3.77)$. Note that this is not an interval that's symmetric about the usual point estimate. A more sophisticated approach (in the sense of letting you more directly get the bounds) would attempt to solve the expression for $p^{\:(\dagger)}\:$ (using $Z_\frac{\alpha}{2}$ in place of 1.96), I think this just gives a quadratic in $p$, so it's probably not onerous, but if you only need to do it once, hardly worthwhile. $\dagger$ Or, essentially as easily, one could directly rewrite the expression for $\frac{1}{p}$ and produce an interval for the population mean more directly. Edit: Here it is for completeness' sake. Define $\bar x$ to be the sample mean, $n$ the sample size (the number of geometric(p) values available), and $z$ to be the critical $Z_{\frac{\alpha}{2}}$ value. Further, define: $A=2(1-\frac{z^2}{n})$ $B=2\bar{x}-\frac{z^2}{n}$ $m=\frac{B}{A}\quad$ (the midpoint) $h=\sqrt{m^2-2\bar{x}/A}\quad$ (the half-width) then an approximate $1-\alpha$ interval for $\mu=\frac{1}{p}$ is $(m-h,m+h)$. In very large samples, one might make a further approximation and substitute $1/\bar{X}$ for $p$ in the denominator of the formula for $Q_A$, which would yield a simpler - and now symmetric - interval for $1/p$. On the data used above I get $(2.63,3.65)$ for that interval. The fact that there's a fairly big difference from the previous interval suggests that the sample size of n=100 probably wasn't quite large enough in this case to apply the faster-but-even-more-approximate approach. Indeed, the fairly strong lack of symmetry of the earlier interval about 3.14 suggests the same thing. Small sample: You can probably also do something with the small sample case. e.g. one approach might try to use pivotal quantities, but I haven't tried to check yet if one can construct a suitable pivot in this case. There might not be one. Pondering a little further, it seems to me that there may be an approach that is similar to the way the chi-squared distribution can be used to give an interval for a Poisson parameter. I believe there's a similar relationship between an incomplete beta integral and the negative binomial (of which the geometric is a special case), so it should be possible to get an interval that way. In particular it suggests that perhaps $F$ tables (or equivalent functions in some package) could then be used to get limits on an interval for $p$, and hence for $\mu=1/p$.
Confidence Interval on the Geometric Distribution Expected Value?
If one knows the population parameter of a geometric, one of course knows the population mean exactly, so a confidence interval for that would be of zero width. Assuming we only have sample informatio
Confidence Interval on the Geometric Distribution Expected Value? If one knows the population parameter of a geometric, one of course knows the population mean exactly, so a confidence interval for that would be of zero width. Assuming we only have sample information, we can construct a confidence interval for the population mean of a geometric random variable. Since your lowest value is 1, I assume we're dealing with the "number of trials" form of the geometric. Large sample: The population mean of a Geometric(p) variate is $1/p$; the variance is $(1-p)/p^2$, so the variance of a sample mean will be $(1-p)/(np^2)$. The statistic $Q_A=\frac{\bar{X}-1/p}{\sqrt{(1-p)/(np^2)}}\:$ (*) will be asymptotically standard normal. A large sample interval for $p$ could be "backed out" from that. Which is to say, we can make an interval for $Q_A$, and then find the values of $p$ which make $Q_A$ satisfy that condition (of being in the interval). e.g. if $\bar{x}=3.14$ and $n=100$ I get an asymptotic 95% interval for $p$ to be $(0.265, 0.368)$ (just by seeing which values for $p$ make that expression for $Q_A$ above stay between -1.96 and 1.96). Hence an interval for $1/p$ (the population mean) would be $(1/0.368,1/0.265)$, or $(2.72,3.77)$. Note that this is not an interval that's symmetric about the usual point estimate. A more sophisticated approach (in the sense of letting you more directly get the bounds) would attempt to solve the expression for $p^{\:(\dagger)}\:$ (using $Z_\frac{\alpha}{2}$ in place of 1.96), I think this just gives a quadratic in $p$, so it's probably not onerous, but if you only need to do it once, hardly worthwhile. $\dagger$ Or, essentially as easily, one could directly rewrite the expression for $\frac{1}{p}$ and produce an interval for the population mean more directly. Edit: Here it is for completeness' sake. Define $\bar x$ to be the sample mean, $n$ the sample size (the number of geometric(p) values available), and $z$ to be the critical $Z_{\frac{\alpha}{2}}$ value. Further, define: $A=2(1-\frac{z^2}{n})$ $B=2\bar{x}-\frac{z^2}{n}$ $m=\frac{B}{A}\quad$ (the midpoint) $h=\sqrt{m^2-2\bar{x}/A}\quad$ (the half-width) then an approximate $1-\alpha$ interval for $\mu=\frac{1}{p}$ is $(m-h,m+h)$. In very large samples, one might make a further approximation and substitute $1/\bar{X}$ for $p$ in the denominator of the formula for $Q_A$, which would yield a simpler - and now symmetric - interval for $1/p$. On the data used above I get $(2.63,3.65)$ for that interval. The fact that there's a fairly big difference from the previous interval suggests that the sample size of n=100 probably wasn't quite large enough in this case to apply the faster-but-even-more-approximate approach. Indeed, the fairly strong lack of symmetry of the earlier interval about 3.14 suggests the same thing. Small sample: You can probably also do something with the small sample case. e.g. one approach might try to use pivotal quantities, but I haven't tried to check yet if one can construct a suitable pivot in this case. There might not be one. Pondering a little further, it seems to me that there may be an approach that is similar to the way the chi-squared distribution can be used to give an interval for a Poisson parameter. I believe there's a similar relationship between an incomplete beta integral and the negative binomial (of which the geometric is a special case), so it should be possible to get an interval that way. In particular it suggests that perhaps $F$ tables (or equivalent functions in some package) could then be used to get limits on an interval for $p$, and hence for $\mu=1/p$.
Confidence Interval on the Geometric Distribution Expected Value? If one knows the population parameter of a geometric, one of course knows the population mean exactly, so a confidence interval for that would be of zero width. Assuming we only have sample informatio
45,333
Confidence Interval on the Geometric Distribution Expected Value?
Same as mtauraso, I don't have 50 rep to comment on the above excellent answer by Glen_b. I actually had to do this for one of my models, and I ended up doing this for p, which I just realized you did for 1/p. Here's the derivations anyway. Define $\bar x$ to be the sample mean, $n$ the sample size (the number of geometric(p) values available), and $z$ to be the critical $Z_{\frac{\alpha}{2}}$ value. Then, we have, $z=\frac{\bar{X}-1/p}{\sqrt{(1-p)/(np^2)}}\: \implies z^2=\frac{(\bar{X}-1/p)^2}{(1-p)/(np^2)}\:$ $\Rightarrow p^2\bar{X}^2-p(2\bar{X}-z^2/n)+(1-z^2/n)\:=0$ So, if we define: $A=2\bar{x}$; $B=2\bar{x}-\frac{z^2}{n}$ ; $C=(1-\frac{z^2}{n})$ then, the rest follows as - $m=\frac{B}{A}\quad$ (the midpoint) $h=\sqrt{m^2-2C/A}\quad$ (the half-width) then an approximate $1-\alpha$ interval for $p$ is $(m-h,m+h)$. For getting at $1-\alpha$ interval for $\mu=\frac{1}{p}$: $\Rightarrow 1/p^2(1-z^2/n)-1/p(2\bar{X}-z^2/n)+\bar{X}^2\:=0$ And by defining how Glen_b defined, we get: $A=2(1-\frac{z^2}{n})$; $B=2\bar{x}-\frac{z^2}{n}$ $m=\frac{B}{A}\quad$ (the midpoint) $h=\sqrt{m^2-2\bar{x}/A}\quad$ (the half-width) then an approximate $1-\alpha$ interval for $\mu=\frac{1}{p}$ is $(m-h,m+h)$.
Confidence Interval on the Geometric Distribution Expected Value?
Same as mtauraso, I don't have 50 rep to comment on the above excellent answer by Glen_b. I actually had to do this for one of my models, and I ended up doing this for p, which I just realized you di
Confidence Interval on the Geometric Distribution Expected Value? Same as mtauraso, I don't have 50 rep to comment on the above excellent answer by Glen_b. I actually had to do this for one of my models, and I ended up doing this for p, which I just realized you did for 1/p. Here's the derivations anyway. Define $\bar x$ to be the sample mean, $n$ the sample size (the number of geometric(p) values available), and $z$ to be the critical $Z_{\frac{\alpha}{2}}$ value. Then, we have, $z=\frac{\bar{X}-1/p}{\sqrt{(1-p)/(np^2)}}\: \implies z^2=\frac{(\bar{X}-1/p)^2}{(1-p)/(np^2)}\:$ $\Rightarrow p^2\bar{X}^2-p(2\bar{X}-z^2/n)+(1-z^2/n)\:=0$ So, if we define: $A=2\bar{x}$; $B=2\bar{x}-\frac{z^2}{n}$ ; $C=(1-\frac{z^2}{n})$ then, the rest follows as - $m=\frac{B}{A}\quad$ (the midpoint) $h=\sqrt{m^2-2C/A}\quad$ (the half-width) then an approximate $1-\alpha$ interval for $p$ is $(m-h,m+h)$. For getting at $1-\alpha$ interval for $\mu=\frac{1}{p}$: $\Rightarrow 1/p^2(1-z^2/n)-1/p(2\bar{X}-z^2/n)+\bar{X}^2\:=0$ And by defining how Glen_b defined, we get: $A=2(1-\frac{z^2}{n})$; $B=2\bar{x}-\frac{z^2}{n}$ $m=\frac{B}{A}\quad$ (the midpoint) $h=\sqrt{m^2-2\bar{x}/A}\quad$ (the half-width) then an approximate $1-\alpha$ interval for $\mu=\frac{1}{p}$ is $(m-h,m+h)$.
Confidence Interval on the Geometric Distribution Expected Value? Same as mtauraso, I don't have 50 rep to comment on the above excellent answer by Glen_b. I actually had to do this for one of my models, and I ended up doing this for p, which I just realized you di
45,334
Confidence Interval on the Geometric Distribution Expected Value?
I don't have 50 rep otherwise this would be a comment on Glen_b's excellent answer above, which made confidence intervals on the geometric distribution make sense to me. I'm happy to remove this if its in violation of site norms/rules, but the result I worked out may be helpful for other folks coming upon this answer for the first time. I'm attempting to use the worked out version of the confidence interval at the bottom of the answer with $\bar{x}=3.14$ and $n=100$ attempting to replicate the $(0.265, 0.368)$ confidence interval for p. I don't get values that make sense for the (m+h,m-h) confidence interval on $\bar{x}$, furthermore my confidence interval calculated via the rewritten form below doesn't have properties I would expect. I don't see $h->0$ as $n->\infty$. I agree that the inequality involving $Q_A$ and $Z_{a/2}$ results in a quadratic relation for $p$ which can be solved for. When I solve that relation I get: $$ m = \Big(\frac{1}{\bar{x}}-\frac{z^2}{2n\bar{x}^2}\Big)\\ h = \frac{z\sqrt{z^2+4n\bar{x}(\bar{x}-1)}}{2n\bar{x}^2} $$ My confidence interval for $p$ is $(m-h,m+h)$, and the rest of the setup the same. I get a confidence interval of $(0.265,0.368)$ for the example above and the asymptotic behavior of $h$ as $n$ increases is what I would expect.
Confidence Interval on the Geometric Distribution Expected Value?
I don't have 50 rep otherwise this would be a comment on Glen_b's excellent answer above, which made confidence intervals on the geometric distribution make sense to me. I'm happy to remove this if it
Confidence Interval on the Geometric Distribution Expected Value? I don't have 50 rep otherwise this would be a comment on Glen_b's excellent answer above, which made confidence intervals on the geometric distribution make sense to me. I'm happy to remove this if its in violation of site norms/rules, but the result I worked out may be helpful for other folks coming upon this answer for the first time. I'm attempting to use the worked out version of the confidence interval at the bottom of the answer with $\bar{x}=3.14$ and $n=100$ attempting to replicate the $(0.265, 0.368)$ confidence interval for p. I don't get values that make sense for the (m+h,m-h) confidence interval on $\bar{x}$, furthermore my confidence interval calculated via the rewritten form below doesn't have properties I would expect. I don't see $h->0$ as $n->\infty$. I agree that the inequality involving $Q_A$ and $Z_{a/2}$ results in a quadratic relation for $p$ which can be solved for. When I solve that relation I get: $$ m = \Big(\frac{1}{\bar{x}}-\frac{z^2}{2n\bar{x}^2}\Big)\\ h = \frac{z\sqrt{z^2+4n\bar{x}(\bar{x}-1)}}{2n\bar{x}^2} $$ My confidence interval for $p$ is $(m-h,m+h)$, and the rest of the setup the same. I get a confidence interval of $(0.265,0.368)$ for the example above and the asymptotic behavior of $h$ as $n$ increases is what I would expect.
Confidence Interval on the Geometric Distribution Expected Value? I don't have 50 rep otherwise this would be a comment on Glen_b's excellent answer above, which made confidence intervals on the geometric distribution make sense to me. I'm happy to remove this if it
45,335
Going from daily probability to annual rate: more complicated than I thought?
A randomly-chosen fish on a randomly-chosen day with discharge $Q_i$ will remain in place with probability $1-f(Q_i)$. So it'll remain in place for the whole year with probability $\prod_i \left( 1-f(Q_i) \right)^{d_i}$, and so your $P_\textrm{annual}$ is one minus that. Assuming I've understood your notation, that is.
Going from daily probability to annual rate: more complicated than I thought?
A randomly-chosen fish on a randomly-chosen day with discharge $Q_i$ will remain in place with probability $1-f(Q_i)$. So it'll remain in place for the whole year with probability $\prod_i \left( 1-f
Going from daily probability to annual rate: more complicated than I thought? A randomly-chosen fish on a randomly-chosen day with discharge $Q_i$ will remain in place with probability $1-f(Q_i)$. So it'll remain in place for the whole year with probability $\prod_i \left( 1-f(Q_i) \right)^{d_i}$, and so your $P_\textrm{annual}$ is one minus that. Assuming I've understood your notation, that is.
Going from daily probability to annual rate: more complicated than I thought? A randomly-chosen fish on a randomly-chosen day with discharge $Q_i$ will remain in place with probability $1-f(Q_i)$. So it'll remain in place for the whole year with probability $\prod_i \left( 1-f
45,336
Going from daily probability to annual rate: more complicated than I thought?
As a sanity check, consider a constant daily "escapement probability" of 0.0004 (0.04%), without replacement of escaped fish back into the lake. After 365 days, the probability that an individual hasn't escaped is $(1-0.0004)^{365}$, 0.864, or a 13.6% probability of having escaped. That's about equivalent to the annual escape probability based on tagging and recapture in the cited paper. So you should be looking for a typical daily escape probability of 0.04% to account for an annual rate of about 13%. From page 646 of the cited paper: "Model averaging indicated that daily escapement probability was approximately 0.01%"; that's only a 3.6% annualized rate, similar to what you are finding. You should note, however, that the authors state earlier on that page, at the end of Methods: "Escapement estimates obtained from Program MARK ... only provided a daily estimate of escapement that could not be extrapolated to an annual escapement rate." (Emphasis added). I am not familiar with the analysis program, but evidently its estimates as provided in this paper cannot reliably be used in the way that you intend. You might want to check with the authors of the study (or of the analysis program) for why this is the case. Also, you should note that for 3 months during the study "daily discharge rates increased to 85 $m^3/s$" (page 649), above the upper limit of the plot in Figure 5 showing the relation deduced between "emigration probability" and discharge. "Escapement increased exponentially as mean daily discharge increased from 8 to 61 $m^3/s$" (page 646), so it's maybe not surprising that daily escapement estimates based mostly on low-discharge conditions would underestimate the annual escape rate.
Going from daily probability to annual rate: more complicated than I thought?
As a sanity check, consider a constant daily "escapement probability" of 0.0004 (0.04%), without replacement of escaped fish back into the lake. After 365 days, the probability that an individual hasn
Going from daily probability to annual rate: more complicated than I thought? As a sanity check, consider a constant daily "escapement probability" of 0.0004 (0.04%), without replacement of escaped fish back into the lake. After 365 days, the probability that an individual hasn't escaped is $(1-0.0004)^{365}$, 0.864, or a 13.6% probability of having escaped. That's about equivalent to the annual escape probability based on tagging and recapture in the cited paper. So you should be looking for a typical daily escape probability of 0.04% to account for an annual rate of about 13%. From page 646 of the cited paper: "Model averaging indicated that daily escapement probability was approximately 0.01%"; that's only a 3.6% annualized rate, similar to what you are finding. You should note, however, that the authors state earlier on that page, at the end of Methods: "Escapement estimates obtained from Program MARK ... only provided a daily estimate of escapement that could not be extrapolated to an annual escapement rate." (Emphasis added). I am not familiar with the analysis program, but evidently its estimates as provided in this paper cannot reliably be used in the way that you intend. You might want to check with the authors of the study (or of the analysis program) for why this is the case. Also, you should note that for 3 months during the study "daily discharge rates increased to 85 $m^3/s$" (page 649), above the upper limit of the plot in Figure 5 showing the relation deduced between "emigration probability" and discharge. "Escapement increased exponentially as mean daily discharge increased from 8 to 61 $m^3/s$" (page 646), so it's maybe not surprising that daily escapement estimates based mostly on low-discharge conditions would underestimate the annual escape rate.
Going from daily probability to annual rate: more complicated than I thought? As a sanity check, consider a constant daily "escapement probability" of 0.0004 (0.04%), without replacement of escaped fish back into the lake. After 365 days, the probability that an individual hasn
45,337
calculating regression sum of square in R
SS(Regression) = SS(Total) - S(Residual) You can get SS(Total) by: SSTotal <- var( brainIQ$PIQ ) * (nrow(brainIQ)-1) SSE <- sum( mylm$resid^2 ) SSreg <- SSTotal - SSE The degrees of freedom for the "Regression" row are the sum of the degrees of freedom for the corresponding components of the Regression (in this case: Brain, Height, and Weight). Then to get the rest: dfE <- mylm$df.residual dfReg <- nrow(brainIQ) - 1 - dfE MSreg <- SSreg / dfReg MSE <- SSE / dfE Fstat <- MSreg / MSE pval <- pf( Fstat , dfReg, dfE , lower.tail=FALSE )
calculating regression sum of square in R
SS(Regression) = SS(Total) - S(Residual) You can get SS(Total) by: SSTotal <- var( brainIQ$PIQ ) * (nrow(brainIQ)-1) SSE <- sum( mylm$resid^2 ) SSreg <- SSTotal - SSE The degrees of freedo
calculating regression sum of square in R SS(Regression) = SS(Total) - S(Residual) You can get SS(Total) by: SSTotal <- var( brainIQ$PIQ ) * (nrow(brainIQ)-1) SSE <- sum( mylm$resid^2 ) SSreg <- SSTotal - SSE The degrees of freedom for the "Regression" row are the sum of the degrees of freedom for the corresponding components of the Regression (in this case: Brain, Height, and Weight). Then to get the rest: dfE <- mylm$df.residual dfReg <- nrow(brainIQ) - 1 - dfE MSreg <- SSreg / dfReg MSE <- SSE / dfE Fstat <- MSreg / MSE pval <- pf( Fstat , dfReg, dfE , lower.tail=FALSE )
calculating regression sum of square in R SS(Regression) = SS(Total) - S(Residual) You can get SS(Total) by: SSTotal <- var( brainIQ$PIQ ) * (nrow(brainIQ)-1) SSE <- sum( mylm$resid^2 ) SSreg <- SSTotal - SSE The degrees of freedo
45,338
calculating regression sum of square in R
If you have built a linear model already, you can compute the regression sum of squares with one line. Using your model: sum((mylm$fitted.values - mean(mylm$fitted.values))^2) This takes advantage of the fact that the mean of the response is equal to the mean of the fitted values. UPDATE: As @whuber pointed out, the line above assumes that the model includes a constant ("intercept") in the span of its design matrix. The line below does not make this assumption and will work more generally: sum((mylm$fitted.values - mean(mylm$model$y))^2)
calculating regression sum of square in R
If you have built a linear model already, you can compute the regression sum of squares with one line. Using your model: sum((mylm$fitted.values - mean(mylm$fitted.values))^2) This takes advantage of
calculating regression sum of square in R If you have built a linear model already, you can compute the regression sum of squares with one line. Using your model: sum((mylm$fitted.values - mean(mylm$fitted.values))^2) This takes advantage of the fact that the mean of the response is equal to the mean of the fitted values. UPDATE: As @whuber pointed out, the line above assumes that the model includes a constant ("intercept") in the span of its design matrix. The line below does not make this assumption and will work more generally: sum((mylm$fitted.values - mean(mylm$model$y))^2)
calculating regression sum of square in R If you have built a linear model already, you can compute the regression sum of squares with one line. Using your model: sum((mylm$fitted.values - mean(mylm$fitted.values))^2) This takes advantage of
45,339
calculating regression sum of square in R
I found matrix approach to solve this problem: Here we can calculate SSR and Total sum of square. # Y matrix Y <- as.matrix(brainIQ$PIQ, ncol=1) n= nrow(Y) J = matrix(1, nrow=n, ncol=n) # Total sum of Square SSTO = t(Y) %*% Y - (1/n)*t(Y)%*%J%*%Y X <- as.matrix(cbind(1, brainIQ[,-1])) b = solve(t(X)%*%X)%*%t(X)%*%Y # regression sum of square SSR = t(b)%*%t(X)%*%Y - (1/n)%*%t(Y)%*%J%*%Y > SSR [,1] [1,] 5572.744 > SSTO [,1] [1,] 18894.55 Here - SSR(Brain, Height, Weight) = SSR(Brain) + SSR(Height|Brain) + SSR (Weight|Height, Brain) - which is actually sequential sum of square output from anova. mylm <- lm(PIQ ~ Brain + Height + Weight, data = brainIQ) # SSR(Brain, Height, Weight) sum(anova(mylm)[-4,2]) # Total sum of square sum(anova(mylm)[,2])
calculating regression sum of square in R
I found matrix approach to solve this problem: Here we can calculate SSR and Total sum of square. # Y matrix Y <- as.matrix(brainIQ$PIQ, ncol=1) n= nrow(Y) J = matrix(1, nrow=n, ncol
calculating regression sum of square in R I found matrix approach to solve this problem: Here we can calculate SSR and Total sum of square. # Y matrix Y <- as.matrix(brainIQ$PIQ, ncol=1) n= nrow(Y) J = matrix(1, nrow=n, ncol=n) # Total sum of Square SSTO = t(Y) %*% Y - (1/n)*t(Y)%*%J%*%Y X <- as.matrix(cbind(1, brainIQ[,-1])) b = solve(t(X)%*%X)%*%t(X)%*%Y # regression sum of square SSR = t(b)%*%t(X)%*%Y - (1/n)%*%t(Y)%*%J%*%Y > SSR [,1] [1,] 5572.744 > SSTO [,1] [1,] 18894.55 Here - SSR(Brain, Height, Weight) = SSR(Brain) + SSR(Height|Brain) + SSR (Weight|Height, Brain) - which is actually sequential sum of square output from anova. mylm <- lm(PIQ ~ Brain + Height + Weight, data = brainIQ) # SSR(Brain, Height, Weight) sum(anova(mylm)[-4,2]) # Total sum of square sum(anova(mylm)[,2])
calculating regression sum of square in R I found matrix approach to solve this problem: Here we can calculate SSR and Total sum of square. # Y matrix Y <- as.matrix(brainIQ$PIQ, ncol=1) n= nrow(Y) J = matrix(1, nrow=n, ncol
45,340
Simpson's Paradox & Random Effects
In Simpson's paradox there is a reversal of the sign of the correlation between two variables, or equivalently, a flip in the sign of regression coefficients (slopes) due to an unaccounted for confounding variable. In the following illustration, we are looking at the relationship between a fictitious biochemical marker ("Marker X") in blood, and a second level in a blood test ("Marker Y"). We are pooling together the data from four different studies. Initially we look at a "successful" meta-analysis to eventually contrast it with a scenario where Simpson's paradox rears its head. Scenario 1: As the data is aggregated we end up with a situation best modeled as a mixed-model with random effects explaining the variability between different studies (unit effects) of the form $\boldsymbol{y} = X \boldsymbol{\beta} + Z \boldsymbol{u} + \boldsymbol{\epsilon}$ with $\boldsymbol u$ corresponding to the intecepts of the fitted lines through the $y\sim x$ data cloud for each individual study. This model accounts for the possible presence of a substantial amount of dispersion in the data. Here's what it would look like (code): with the data from each study color coded on the plot to the left, and aggregated on the right. The situation is not ideal, because there is quite a bit of spread in the values from different datasets. The study would probably be much more likely to be published and quoted with something like this: So perfect an overlap between studies that an ordinary least square (OLS) fit would probably be better than a mixed model with random effects. However, in either instance, the presence of over-dispersion doesn't raise the possibility of a confounder variable. On the other hand... Scenario 2: ... we can encounter an often plotted distribution in the data cloud such that fitting a linear regression with mixed-effects ends up with negative (or positive) slopes for each one of the individual studies, only to reverse sign when the data is aggregated: This is the Simpson's effect. If we look into the results in the data behind these plots, the cor(y,x) for each individual subgroup ranged between -0.238 and -0.302; yet, when the data was aggregated, the combined correlation was 0.473. Naturally the sign of the regression slopes was also opposite. Of note, the mixed-effect regression with random intersects was a better model than the OLS on the aggregate data. Already on the plot, one can have an intuition that the data is not just disperse, but it is stretched along the $x$ axis, precisely by an unknown "lurking" variable, which may not be immediately apparent. This can be objectivized by looking at the correlation between the $x$ variable and the $y\,\,intercept$ for each subgroup, and contrasting it with scenario 1. Graphically, in the case with Simpson's effect (scenario 2), the higher the $x$ values, the higher the $y\,\,intercepts$ (left plot), as opposed to the lack of correlation in scenario 1 (right plot). The correlation in the first case between $x$ and the $y\,\,intercepts$ was 0.7876 with a statistically significant (p -> 0) slope when doing a regression. In contradistinction, the correlation in scenario 1 between $x$ and the $y\,\,intercepts$ was 0. A follow-up question is what type of clinical scenario could possibly follow this pattern (scenario 2)?
Simpson's Paradox & Random Effects
In Simpson's paradox there is a reversal of the sign of the correlation between two variables, or equivalently, a flip in the sign of regression coefficients (slopes) due to an unaccounted for confoun
Simpson's Paradox & Random Effects In Simpson's paradox there is a reversal of the sign of the correlation between two variables, or equivalently, a flip in the sign of regression coefficients (slopes) due to an unaccounted for confounding variable. In the following illustration, we are looking at the relationship between a fictitious biochemical marker ("Marker X") in blood, and a second level in a blood test ("Marker Y"). We are pooling together the data from four different studies. Initially we look at a "successful" meta-analysis to eventually contrast it with a scenario where Simpson's paradox rears its head. Scenario 1: As the data is aggregated we end up with a situation best modeled as a mixed-model with random effects explaining the variability between different studies (unit effects) of the form $\boldsymbol{y} = X \boldsymbol{\beta} + Z \boldsymbol{u} + \boldsymbol{\epsilon}$ with $\boldsymbol u$ corresponding to the intecepts of the fitted lines through the $y\sim x$ data cloud for each individual study. This model accounts for the possible presence of a substantial amount of dispersion in the data. Here's what it would look like (code): with the data from each study color coded on the plot to the left, and aggregated on the right. The situation is not ideal, because there is quite a bit of spread in the values from different datasets. The study would probably be much more likely to be published and quoted with something like this: So perfect an overlap between studies that an ordinary least square (OLS) fit would probably be better than a mixed model with random effects. However, in either instance, the presence of over-dispersion doesn't raise the possibility of a confounder variable. On the other hand... Scenario 2: ... we can encounter an often plotted distribution in the data cloud such that fitting a linear regression with mixed-effects ends up with negative (or positive) slopes for each one of the individual studies, only to reverse sign when the data is aggregated: This is the Simpson's effect. If we look into the results in the data behind these plots, the cor(y,x) for each individual subgroup ranged between -0.238 and -0.302; yet, when the data was aggregated, the combined correlation was 0.473. Naturally the sign of the regression slopes was also opposite. Of note, the mixed-effect regression with random intersects was a better model than the OLS on the aggregate data. Already on the plot, one can have an intuition that the data is not just disperse, but it is stretched along the $x$ axis, precisely by an unknown "lurking" variable, which may not be immediately apparent. This can be objectivized by looking at the correlation between the $x$ variable and the $y\,\,intercept$ for each subgroup, and contrasting it with scenario 1. Graphically, in the case with Simpson's effect (scenario 2), the higher the $x$ values, the higher the $y\,\,intercepts$ (left plot), as opposed to the lack of correlation in scenario 1 (right plot). The correlation in the first case between $x$ and the $y\,\,intercepts$ was 0.7876 with a statistically significant (p -> 0) slope when doing a regression. In contradistinction, the correlation in scenario 1 between $x$ and the $y\,\,intercepts$ was 0. A follow-up question is what type of clinical scenario could possibly follow this pattern (scenario 2)?
Simpson's Paradox & Random Effects In Simpson's paradox there is a reversal of the sign of the correlation between two variables, or equivalently, a flip in the sign of regression coefficients (slopes) due to an unaccounted for confoun
45,341
glmnet - compute maximal lambda value
The smallest value of lambda for which no parameters are selected may be computed by $\max_j \frac{1}{\alpha n} \sum_{i=1}^n [Y_i - \bar Y (1- \bar Y)] X_{ij}$ See my example: n <- 500 p <- 3 b <- c(-5,3,2,0) X <- cbind(rep(1,n),scale(matrix(rnorm(p*n),nrow=n))) Y <- rbinom(n,1,prob = exp(X%*%b)/(1 + exp(X%*%b))) alpha <- .5 max( abs(t(Y - mean(Y)*(1-mean(Y))) %*% X ) )/ ( alpha * n) # largest lambda value glmnet(x=X,y=Y,family="binomial",alpha = alpha,standardize=FALSE)$lambda[1] # largest lambda value This comes out of the coordinate descent algorithm from this paper: Friedman, Jerome, Trevor Hastie, and Rob Tibshirani. "Regularization paths for generalized linear models via coordinate descent." Journal of statistical software 33.1 (2010): 1.
glmnet - compute maximal lambda value
The smallest value of lambda for which no parameters are selected may be computed by $\max_j \frac{1}{\alpha n} \sum_{i=1}^n [Y_i - \bar Y (1- \bar Y)] X_{ij}$ See my example: n <- 500 p <- 3 b <- c(-
glmnet - compute maximal lambda value The smallest value of lambda for which no parameters are selected may be computed by $\max_j \frac{1}{\alpha n} \sum_{i=1}^n [Y_i - \bar Y (1- \bar Y)] X_{ij}$ See my example: n <- 500 p <- 3 b <- c(-5,3,2,0) X <- cbind(rep(1,n),scale(matrix(rnorm(p*n),nrow=n))) Y <- rbinom(n,1,prob = exp(X%*%b)/(1 + exp(X%*%b))) alpha <- .5 max( abs(t(Y - mean(Y)*(1-mean(Y))) %*% X ) )/ ( alpha * n) # largest lambda value glmnet(x=X,y=Y,family="binomial",alpha = alpha,standardize=FALSE)$lambda[1] # largest lambda value This comes out of the coordinate descent algorithm from this paper: Friedman, Jerome, Trevor Hastie, and Rob Tibshirani. "Regularization paths for generalized linear models via coordinate descent." Journal of statistical software 33.1 (2010): 1.
glmnet - compute maximal lambda value The smallest value of lambda for which no parameters are selected may be computed by $\max_j \frac{1}{\alpha n} \sum_{i=1}^n [Y_i - \bar Y (1- \bar Y)] X_{ij}$ See my example: n <- 500 p <- 3 b <- c(-
45,342
glmnet - compute maximal lambda value
Here is an example: library(glmnet) n <- 500L x1 <- rnorm(n, 2.0, 0.5) x2 <- rnorm(n, -1.0, 2) y <- factor(rbinom(n, 1L, plogis(-0.6 + 1.0 * x1 - 0.8 * x2))) X <- matrix(c(x1, x2), ncol = 2) mod <- glmnet(X, y, "binomial") Now you can see the degrees of freedom and corresponding lambda by simply: > print(mod) Call: glmnet(x = X, y = y, family = "binomial") Df %Dev Lambda [1,] 0 -1.026e-14 0.149300 [2,] 1 3.314e-02 0.136000 [3,] 1 6.073e-02 0.123900 ... So in this case the coefficients are all 0 when lambda is 0.149300 (or higher). To confirm: > coef(mod, s = 0.149300) 3 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) 1.688296 V1 . V2 . > coef(mod, s = 0.136000) 3 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) 1.64233062 V1 . V2 -0.04946726 Note that the vectors for the degrees of freedom and lambda can also be accessed via mod$df and mod$lambda, and you can also change the values of lambda which glmnet tries (if say you wanted to home in on "lambda_max") using for example: mod <- glmnet(X, y, "binomial", lambda = seq(0.149, 0.151, by = 0.0001))
glmnet - compute maximal lambda value
Here is an example: library(glmnet) n <- 500L x1 <- rnorm(n, 2.0, 0.5) x2 <- rnorm(n, -1.0, 2) y <- factor(rbinom(n, 1L, plogis(-0.6 + 1.0 * x1 - 0.8 * x2))) X <- matrix(c(x1, x2), ncol = 2) mod <
glmnet - compute maximal lambda value Here is an example: library(glmnet) n <- 500L x1 <- rnorm(n, 2.0, 0.5) x2 <- rnorm(n, -1.0, 2) y <- factor(rbinom(n, 1L, plogis(-0.6 + 1.0 * x1 - 0.8 * x2))) X <- matrix(c(x1, x2), ncol = 2) mod <- glmnet(X, y, "binomial") Now you can see the degrees of freedom and corresponding lambda by simply: > print(mod) Call: glmnet(x = X, y = y, family = "binomial") Df %Dev Lambda [1,] 0 -1.026e-14 0.149300 [2,] 1 3.314e-02 0.136000 [3,] 1 6.073e-02 0.123900 ... So in this case the coefficients are all 0 when lambda is 0.149300 (or higher). To confirm: > coef(mod, s = 0.149300) 3 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) 1.688296 V1 . V2 . > coef(mod, s = 0.136000) 3 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) 1.64233062 V1 . V2 -0.04946726 Note that the vectors for the degrees of freedom and lambda can also be accessed via mod$df and mod$lambda, and you can also change the values of lambda which glmnet tries (if say you wanted to home in on "lambda_max") using for example: mod <- glmnet(X, y, "binomial", lambda = seq(0.149, 0.151, by = 0.0001))
glmnet - compute maximal lambda value Here is an example: library(glmnet) n <- 500L x1 <- rnorm(n, 2.0, 0.5) x2 <- rnorm(n, -1.0, 2) y <- factor(rbinom(n, 1L, plogis(-0.6 + 1.0 * x1 - 0.8 * x2))) X <- matrix(c(x1, x2), ncol = 2) mod <
45,343
Checking quality of clustering of labeled-class data
There are many many measures that can be used on labeled data. For example, if you run k-means wiht $k=3$ on the mouse data set: you get the following evaluation result (using ELKI): Clearly, it did not work very well. If you know this toy data set, k-means just doesn't work well on it, because the clusters have too different size. These are external evaluation measures. They work well if the labels correspond to clusters. If you are using classification data, the labels may not at all correspond to clusters; but some classes may form one big cluster, or a class may split into multiple clusters. There may also be outliers. They work well on synthetic data, but real data just never has such labels already. So while such measures are a nice thing for experimenting, they have big issues... IMHO, their results can be totally misleading. A clustering algorithm that works perfectly well may score really bad on such a measure, if the labels do not correspond to the data clustering structure. Clustering just is not classification. It's rather orthogonal.
Checking quality of clustering of labeled-class data
There are many many measures that can be used on labeled data. For example, if you run k-means wiht $k=3$ on the mouse data set: you get the following evaluation result (using ELKI): Clearly, it did
Checking quality of clustering of labeled-class data There are many many measures that can be used on labeled data. For example, if you run k-means wiht $k=3$ on the mouse data set: you get the following evaluation result (using ELKI): Clearly, it did not work very well. If you know this toy data set, k-means just doesn't work well on it, because the clusters have too different size. These are external evaluation measures. They work well if the labels correspond to clusters. If you are using classification data, the labels may not at all correspond to clusters; but some classes may form one big cluster, or a class may split into multiple clusters. There may also be outliers. They work well on synthetic data, but real data just never has such labels already. So while such measures are a nice thing for experimenting, they have big issues... IMHO, their results can be totally misleading. A clustering algorithm that works perfectly well may score really bad on such a measure, if the labels do not correspond to the data clustering structure. Clustering just is not classification. It's rather orthogonal.
Checking quality of clustering of labeled-class data There are many many measures that can be used on labeled data. For example, if you run k-means wiht $k=3$ on the mouse data set: you get the following evaluation result (using ELKI): Clearly, it did
45,344
Checking quality of clustering of labeled-class data
If your data is labeled that is the true classification of your data set. Then you can apply any of the know clustering methods (hierarchical, kmeans or model-based clustering) and use the adjustedRandIndex. This is a function in R in the mclust package. Adjusted Rand Index indicates how similars the clusters are, and when the value is 1 it means that they are identical. Hence you will compare the tue clustering with the result of the different clustering methods. There is another function in R that does approx the same thing it is call Error Rate or something like this and it computes the proportion of the truly identified clusters from the clustering method you have chosen.
Checking quality of clustering of labeled-class data
If your data is labeled that is the true classification of your data set. Then you can apply any of the know clustering methods (hierarchical, kmeans or model-based clustering) and use the adjustedRan
Checking quality of clustering of labeled-class data If your data is labeled that is the true classification of your data set. Then you can apply any of the know clustering methods (hierarchical, kmeans or model-based clustering) and use the adjustedRandIndex. This is a function in R in the mclust package. Adjusted Rand Index indicates how similars the clusters are, and when the value is 1 it means that they are identical. Hence you will compare the tue clustering with the result of the different clustering methods. There is another function in R that does approx the same thing it is call Error Rate or something like this and it computes the proportion of the truly identified clusters from the clustering method you have chosen.
Checking quality of clustering of labeled-class data If your data is labeled that is the true classification of your data set. Then you can apply any of the know clustering methods (hierarchical, kmeans or model-based clustering) and use the adjustedRan
45,345
Checking quality of clustering of labeled-class data
Clustering is usually used for unsupervised classification - that is, when you are trying to discover groups that might exist but that you don't know about. If you want to classify units into known groups, you could look at multinomial logistic regression or at classification trees and related methods.
Checking quality of clustering of labeled-class data
Clustering is usually used for unsupervised classification - that is, when you are trying to discover groups that might exist but that you don't know about. If you want to classify units into known g
Checking quality of clustering of labeled-class data Clustering is usually used for unsupervised classification - that is, when you are trying to discover groups that might exist but that you don't know about. If you want to classify units into known groups, you could look at multinomial logistic regression or at classification trees and related methods.
Checking quality of clustering of labeled-class data Clustering is usually used for unsupervised classification - that is, when you are trying to discover groups that might exist but that you don't know about. If you want to classify units into known g
45,346
How to select the 'best' trim value for the mean function?
Given a sample $\pmb x=\{x_i\}_{i=1}^n$ and, for an integer $1\leq m\leq n$ denoting $x_{(m)}$ the $m$-th largest entry of $\pmb x$, and $\alpha\in(0,0.5)$ define the $\alpha$ trimmed mean as: $$\hat{\mu}_{\alpha}=\frac{1}{(1-2\alpha)n}\sum_{i=[n\alpha]+1}^{n-[n\alpha]}x_{(i)}$$ For any symmetric continuous distribution $F_X$, $\hat{\mu}_{\alpha}$ is unbiased for the centre of symmetry and (assuming without loss of generality that $F_X$ is centred at 0) the asymptotic variance of $\hat{\mu}_{\alpha}$ is: $$V(\hat{\mu}_{\alpha})=\frac{2}{(1-2\alpha)^2}\left(\int_0^{F^{-1}(1-\alpha)}x^2dF_X(x)+\alpha(F^{-1}_X(1-\alpha))^2\right)$$. so from an estimation accuracy (at uncontaminated samples from symmetric distributions) point of view, if $F_X$ is light tailed, to increase efficiency (equivalently, to decrease the asymptotic variance), you would pick $\alpha=0$. Of course, the breakdown point of the trimmed mean is $\alpha$, so to increase robustness, you would pick $\alpha=0.5$. Note that this trade-off only holds under the conditions elicited above. For heavy tailed symmetric distributions, you can increase robustness and ARE by increasing $\alpha$. For example, for a $t_3$ distribution, the ARE of the 0.25 trimmed mean is about 15% better than that of the 0.05-trimmed mean. Note also that the two criteria (robustness vs efficiency) don't balance: the loss in estimation accuracy due to choosing a too big value of $\alpha$ in contaminated settings can potentially far exceed the loss in estimation accuracy due to choosing a too small value of $\alpha$ on clean data. More precisely, denoting $F^{\varepsilon}_X$ the contaminated distribution obtained by contaminating a square integrable, continuous distribution $F_X$ by a proportion $\varepsilon<0.5$ of arbitrary values, then, the supremum over all such contaminated distributions $F^{\varepsilon}_X$ of the relative asymptotic efficiency of the 0-trimmed vs the 0.5 one: $$(1)\quad\underset{F^{\varepsilon}_X}{\sup}\frac{V(\hat{\mu}_0)}{V(\hat{\mu}_{0.5})}$$ is unbounded. However, the reciprocal of $(1)$ is always bounded (see [2], p75). Unless you are willing to assume more about the rate of contamination of the sample and the distribution of the good part of the data, there is no way to resolve this issue with the trimmed mean. A single parameter $\alpha$ controls for both robustness and accuracy so that you have to trade them off. An alternative is to take another estimator, one pre-tuned to attain high efficiency for a fixed breakdown point for a given distribution of the good part of the data. Consider the MM estimator[0]: library(robustbase) x<-c(rnorm(10,0,1),rnorm(40,11,1)) #sample lmrob(x~1)$coef #MM estimate of location or the $\tau$ estimator of location[1]: scaleTau2(x,mu.too=TRUE)[1] Like the trimmed mean, both the $\tau$ and MM estimates are unbiased and asymptotically normal at symmetric distributions. In contrast to trimmed means, these estimator use two parameters so you can set the breakdown point independently of the ARE. Consequently, you can achieve an ARE arbitrarily close to 1 and maintain the 50% breakdown point. For example, by default, the MM estimator is tuned to achieve 95% efficiency at the Gaussian model (i.e. if the uncontaminated part of the data is Gaussian) with a breakdown point of 50%. The $\tau$ estimator of location is slightly less efficient at the Gaussian model (80%) but retains the same (or better) efficiency against a range of alternative distributions (for the good part of the data), including the Cauchy (again with a breakdown point of 50%). See more in the paper below (they concern regression but mean estimation is a particular case of regression). [0] Yohai, V.J. (1987) High breakdown-point and high efficiency estimates for regression. The Annals of Statistics 15, 642--65. [1] Yohai, V.J. and Zamar, R.H. (1988). High breakdown-point estimates of regression by means of the minimization of an efficient scale. Journal of the American Statistical Association 83, 406–413. [2] Staudte, R.G. and Sheather, S.J. (1990). Robust Estimation and Testing.
How to select the 'best' trim value for the mean function?
Given a sample $\pmb x=\{x_i\}_{i=1}^n$ and, for an integer $1\leq m\leq n$ denoting $x_{(m)}$ the $m$-th largest entry of $\pmb x$, and $\alpha\in(0,0.5)$ define the $\alpha$ trimmed mean as: $$\hat{
How to select the 'best' trim value for the mean function? Given a sample $\pmb x=\{x_i\}_{i=1}^n$ and, for an integer $1\leq m\leq n$ denoting $x_{(m)}$ the $m$-th largest entry of $\pmb x$, and $\alpha\in(0,0.5)$ define the $\alpha$ trimmed mean as: $$\hat{\mu}_{\alpha}=\frac{1}{(1-2\alpha)n}\sum_{i=[n\alpha]+1}^{n-[n\alpha]}x_{(i)}$$ For any symmetric continuous distribution $F_X$, $\hat{\mu}_{\alpha}$ is unbiased for the centre of symmetry and (assuming without loss of generality that $F_X$ is centred at 0) the asymptotic variance of $\hat{\mu}_{\alpha}$ is: $$V(\hat{\mu}_{\alpha})=\frac{2}{(1-2\alpha)^2}\left(\int_0^{F^{-1}(1-\alpha)}x^2dF_X(x)+\alpha(F^{-1}_X(1-\alpha))^2\right)$$. so from an estimation accuracy (at uncontaminated samples from symmetric distributions) point of view, if $F_X$ is light tailed, to increase efficiency (equivalently, to decrease the asymptotic variance), you would pick $\alpha=0$. Of course, the breakdown point of the trimmed mean is $\alpha$, so to increase robustness, you would pick $\alpha=0.5$. Note that this trade-off only holds under the conditions elicited above. For heavy tailed symmetric distributions, you can increase robustness and ARE by increasing $\alpha$. For example, for a $t_3$ distribution, the ARE of the 0.25 trimmed mean is about 15% better than that of the 0.05-trimmed mean. Note also that the two criteria (robustness vs efficiency) don't balance: the loss in estimation accuracy due to choosing a too big value of $\alpha$ in contaminated settings can potentially far exceed the loss in estimation accuracy due to choosing a too small value of $\alpha$ on clean data. More precisely, denoting $F^{\varepsilon}_X$ the contaminated distribution obtained by contaminating a square integrable, continuous distribution $F_X$ by a proportion $\varepsilon<0.5$ of arbitrary values, then, the supremum over all such contaminated distributions $F^{\varepsilon}_X$ of the relative asymptotic efficiency of the 0-trimmed vs the 0.5 one: $$(1)\quad\underset{F^{\varepsilon}_X}{\sup}\frac{V(\hat{\mu}_0)}{V(\hat{\mu}_{0.5})}$$ is unbounded. However, the reciprocal of $(1)$ is always bounded (see [2], p75). Unless you are willing to assume more about the rate of contamination of the sample and the distribution of the good part of the data, there is no way to resolve this issue with the trimmed mean. A single parameter $\alpha$ controls for both robustness and accuracy so that you have to trade them off. An alternative is to take another estimator, one pre-tuned to attain high efficiency for a fixed breakdown point for a given distribution of the good part of the data. Consider the MM estimator[0]: library(robustbase) x<-c(rnorm(10,0,1),rnorm(40,11,1)) #sample lmrob(x~1)$coef #MM estimate of location or the $\tau$ estimator of location[1]: scaleTau2(x,mu.too=TRUE)[1] Like the trimmed mean, both the $\tau$ and MM estimates are unbiased and asymptotically normal at symmetric distributions. In contrast to trimmed means, these estimator use two parameters so you can set the breakdown point independently of the ARE. Consequently, you can achieve an ARE arbitrarily close to 1 and maintain the 50% breakdown point. For example, by default, the MM estimator is tuned to achieve 95% efficiency at the Gaussian model (i.e. if the uncontaminated part of the data is Gaussian) with a breakdown point of 50%. The $\tau$ estimator of location is slightly less efficient at the Gaussian model (80%) but retains the same (or better) efficiency against a range of alternative distributions (for the good part of the data), including the Cauchy (again with a breakdown point of 50%). See more in the paper below (they concern regression but mean estimation is a particular case of regression). [0] Yohai, V.J. (1987) High breakdown-point and high efficiency estimates for regression. The Annals of Statistics 15, 642--65. [1] Yohai, V.J. and Zamar, R.H. (1988). High breakdown-point estimates of regression by means of the minimization of an efficient scale. Journal of the American Statistical Association 83, 406–413. [2] Staudte, R.G. and Sheather, S.J. (1990). Robust Estimation and Testing.
How to select the 'best' trim value for the mean function? Given a sample $\pmb x=\{x_i\}_{i=1}^n$ and, for an integer $1\leq m\leq n$ denoting $x_{(m)}$ the $m$-th largest entry of $\pmb x$, and $\alpha\in(0,0.5)$ define the $\alpha$ trimmed mean as: $$\hat{
45,347
Why are these file sizes not normally distributed?
CLT applies to the mean of samples from a distribution. If you bootstrap the mean of your data you'll find that the distribution of the mean of your data is normal. The file sizes of the images are neither generated under these conditions, nor do they have the assumptions in which the CLT apply, so it's not expected that the distribution be normal.
Why are these file sizes not normally distributed?
CLT applies to the mean of samples from a distribution. If you bootstrap the mean of your data you'll find that the distribution of the mean of your data is normal. The file sizes of the images are ne
Why are these file sizes not normally distributed? CLT applies to the mean of samples from a distribution. If you bootstrap the mean of your data you'll find that the distribution of the mean of your data is normal. The file sizes of the images are neither generated under these conditions, nor do they have the assumptions in which the CLT apply, so it's not expected that the distribution be normal.
Why are these file sizes not normally distributed? CLT applies to the mean of samples from a distribution. If you bootstrap the mean of your data you'll find that the distribution of the mean of your data is normal. The file sizes of the images are ne
45,348
Why are these file sizes not normally distributed?
Please take a look of the definition for Central-Limit-Theorem: This statement tells us that you only get a normal distribution for the sample means given enough sample size. There is no assumption to the underlying distribution that it needs to be normal.
Why are these file sizes not normally distributed?
Please take a look of the definition for Central-Limit-Theorem: This statement tells us that you only get a normal distribution for the sample means given enough sample size. There is no assumption t
Why are these file sizes not normally distributed? Please take a look of the definition for Central-Limit-Theorem: This statement tells us that you only get a normal distribution for the sample means given enough sample size. There is no assumption to the underlying distribution that it needs to be normal.
Why are these file sizes not normally distributed? Please take a look of the definition for Central-Limit-Theorem: This statement tells us that you only get a normal distribution for the sample means given enough sample size. There is no assumption t
45,349
Why are these file sizes not normally distributed?
The standard central limit theorem holds under some conditions, one of which is independance of observed events. Were these captured images in such a way that parameters of the images had no correlations between them ? It's kind of reassuring to think that if you were filming a periodic phenomenon (say, the position of the sun at the same time every day), you wouldn't end up with a normal distribution in parameters of the images. There are some other theorems showing that convergence to the normal distribution still occurs when events are not totally uncorrelated. These theorems rely on complex hypotheses, some of them stating that observed events have to be "not too much correlated".
Why are these file sizes not normally distributed?
The standard central limit theorem holds under some conditions, one of which is independance of observed events. Were these captured images in such a way that parameters of the images had no correlati
Why are these file sizes not normally distributed? The standard central limit theorem holds under some conditions, one of which is independance of observed events. Were these captured images in such a way that parameters of the images had no correlations between them ? It's kind of reassuring to think that if you were filming a periodic phenomenon (say, the position of the sun at the same time every day), you wouldn't end up with a normal distribution in parameters of the images. There are some other theorems showing that convergence to the normal distribution still occurs when events are not totally uncorrelated. These theorems rely on complex hypotheses, some of them stating that observed events have to be "not too much correlated".
Why are these file sizes not normally distributed? The standard central limit theorem holds under some conditions, one of which is independance of observed events. Were these captured images in such a way that parameters of the images had no correlati
45,350
Sparsity in Lasso and advantage over ridge (Statistical Learning) [duplicate]
The lasso penalty will force some of the coefficients quickly to zero. This means that variables are removed from the model, hence the sparsity. Ridge regression will more or less compress the coefficients to become smaller. This does not necessarily result in 0 coefficients and removal of variables. See the picture above, taken from onlinecourses.science.psu.edu/stat857/node/158 The circles represent the error function and the magenta area the possible values for the parameters. You can see that in the left graph that the function is likely to hit the possible value space on one of the corners, on the axes. This implies that β1 is 0. On the right, where the space of allowed values is round due to the quadratic constraint, the function can hit the possible space in more arbitrary places
Sparsity in Lasso and advantage over ridge (Statistical Learning) [duplicate]
The lasso penalty will force some of the coefficients quickly to zero. This means that variables are removed from the model, hence the sparsity. Ridge regression will more or less compress the coeffi
Sparsity in Lasso and advantage over ridge (Statistical Learning) [duplicate] The lasso penalty will force some of the coefficients quickly to zero. This means that variables are removed from the model, hence the sparsity. Ridge regression will more or less compress the coefficients to become smaller. This does not necessarily result in 0 coefficients and removal of variables. See the picture above, taken from onlinecourses.science.psu.edu/stat857/node/158 The circles represent the error function and the magenta area the possible values for the parameters. You can see that in the left graph that the function is likely to hit the possible value space on one of the corners, on the axes. This implies that β1 is 0. On the right, where the space of allowed values is round due to the quadratic constraint, the function can hit the possible space in more arbitrary places
Sparsity in Lasso and advantage over ridge (Statistical Learning) [duplicate] The lasso penalty will force some of the coefficients quickly to zero. This means that variables are removed from the model, hence the sparsity. Ridge regression will more or less compress the coeffi
45,351
How to combine weak classfiers to get a strong one?
Practically speaking bagging, boosting, and stacking all constitute reasonable ways to combine the weak predictions, as others have mentioned. Taking that one step further though, trying as many of them as possible and seeing what performs best is common the context of competitive machine learning too (e.g. You might try a stacked classifier as well as well as a simple average ensembler and choose the better of the two as per performance on some hold-out data). In fact, if accuracy is your only goal then you're likely better off having a few different ensembling techniques in mind like this and focusing on the diversity of the classifiers being ensembled rather than how they're combined. Since the best ensemble technique will depend on your problem and and data and there is no approach that's always best, your time is better spent just making the ensemble choice another part of the training process rather than worrying about making a single correct choice. Theoretically speaking though, and as an attempt to answer the question more directly, I think there are some probabilistic arguments that could be used to justify the best way to "suppress" the weak classifiers. IMO the reasoning behind Bayesian Model Averaging and Information-Criteria-Based Averaging is pretty enlightening and has ties to some of the approaches in Machine Learning like weighting classifiers via binomial deviance. For example, here's a process for combining classifiers through the use of akaike weights (as an example of information-criteria based model averaging): ** Note this is all assuming the classifiers are pretty well calibrated and that actual out-of-sample deviance is used in cross-validation rather than an estimate of it like AIC Suppose you have $K$ classifiers fit to training data and each of those classifiers then makes $N$ predictions on test data. You could then compute the "likelihood" of each models predictions as follows: $$ L_k = \Pi_{i=1}^n{ P_{M_k}(y_i)}$$ where: $L_k$ = Likelihood of predictions from model $k$ $y_i$ = Response $i$ in the test data $P_{M_k}(y_i)$ = The probability that classifier $k$ attributes to $y_i$ Given the likelihood of the predicted data, the weight or relative likelihood of each classifier, $w_{M_k}$ could then be defined as: $$L_{max} = \max{L_k} $$ $$w_{M_k} = \frac{e^{2log(L_{max}/L_k)}}{\sum_{j=1}^{k}{e^{2log(L_{max}/L_k)}}}$$ The weights for each model, $w_{M_k}$, can then be interpreted as the probability that classifier $M_k$ is the true model and an expected outcome coming from an ensemble of all $k$ classifiers would have an expected value equal to the sum of the probability of each classifier times its prediction: $$ y_{new} = \sum_{j=1}^k { w_{M_k} \cdot M_k(X_{new}) }.$$ I hope the notation doesn't bog you down but the point is that there are theoretical ways (the Bayesian ones are especially interesting) to determine what probability each model in an ensemble should have and then use that to make predictions, rather than some more heuristic weighting or equal-voting scheme. These more intuitive averaging strategies don't generally perform better in empirical studies (or so it seems), but I thought throwing the notion of them into the mix might help you like they helped me.
How to combine weak classfiers to get a strong one?
Practically speaking bagging, boosting, and stacking all constitute reasonable ways to combine the weak predictions, as others have mentioned. Taking that one step further though, trying as many of t
How to combine weak classfiers to get a strong one? Practically speaking bagging, boosting, and stacking all constitute reasonable ways to combine the weak predictions, as others have mentioned. Taking that one step further though, trying as many of them as possible and seeing what performs best is common the context of competitive machine learning too (e.g. You might try a stacked classifier as well as well as a simple average ensembler and choose the better of the two as per performance on some hold-out data). In fact, if accuracy is your only goal then you're likely better off having a few different ensembling techniques in mind like this and focusing on the diversity of the classifiers being ensembled rather than how they're combined. Since the best ensemble technique will depend on your problem and and data and there is no approach that's always best, your time is better spent just making the ensemble choice another part of the training process rather than worrying about making a single correct choice. Theoretically speaking though, and as an attempt to answer the question more directly, I think there are some probabilistic arguments that could be used to justify the best way to "suppress" the weak classifiers. IMO the reasoning behind Bayesian Model Averaging and Information-Criteria-Based Averaging is pretty enlightening and has ties to some of the approaches in Machine Learning like weighting classifiers via binomial deviance. For example, here's a process for combining classifiers through the use of akaike weights (as an example of information-criteria based model averaging): ** Note this is all assuming the classifiers are pretty well calibrated and that actual out-of-sample deviance is used in cross-validation rather than an estimate of it like AIC Suppose you have $K$ classifiers fit to training data and each of those classifiers then makes $N$ predictions on test data. You could then compute the "likelihood" of each models predictions as follows: $$ L_k = \Pi_{i=1}^n{ P_{M_k}(y_i)}$$ where: $L_k$ = Likelihood of predictions from model $k$ $y_i$ = Response $i$ in the test data $P_{M_k}(y_i)$ = The probability that classifier $k$ attributes to $y_i$ Given the likelihood of the predicted data, the weight or relative likelihood of each classifier, $w_{M_k}$ could then be defined as: $$L_{max} = \max{L_k} $$ $$w_{M_k} = \frac{e^{2log(L_{max}/L_k)}}{\sum_{j=1}^{k}{e^{2log(L_{max}/L_k)}}}$$ The weights for each model, $w_{M_k}$, can then be interpreted as the probability that classifier $M_k$ is the true model and an expected outcome coming from an ensemble of all $k$ classifiers would have an expected value equal to the sum of the probability of each classifier times its prediction: $$ y_{new} = \sum_{j=1}^k { w_{M_k} \cdot M_k(X_{new}) }.$$ I hope the notation doesn't bog you down but the point is that there are theoretical ways (the Bayesian ones are especially interesting) to determine what probability each model in an ensemble should have and then use that to make predictions, rather than some more heuristic weighting or equal-voting scheme. These more intuitive averaging strategies don't generally perform better in empirical studies (or so it seems), but I thought throwing the notion of them into the mix might help you like they helped me.
How to combine weak classfiers to get a strong one? Practically speaking bagging, boosting, and stacking all constitute reasonable ways to combine the weak predictions, as others have mentioned. Taking that one step further though, trying as many of t
45,352
How to combine weak classfiers to get a strong one?
As you might surmise from the diversity of comments, combining weak learners into strong ones isn't a task with a single, "correct" approach, but a field of approaches with varying levels of known strengths and drawbacks. For a brief introduction, the wikipedia entry for ensemble learning is a reasonable place to start. There you'll find reference to many of the methods discussed in comments, such as averaging predictions or combining them using logistic regression. In particular, here's an excerpt from the section on stacking: Stacking (sometimes called stacked generalization) involves training a learning algorithm to combine the predictions of several other learning algorithms. First, all of the other algorithms are trained using the available data, then a combiner algorithm is trained to make a final prediction using all the predictions of the other algorithms as additional inputs. If an arbitrary combiner algorithm is used, then stacking can theoretically represent any of the ensemble techniques described in this article, although in practice, a single-layer logistic regression model is often used as the combiner. The of questions in your edit seem to me best answered in individual cases using cross-validation. Whether @Tim's suggestion of inverse-error-weighted mean performs better than @yasin.yazici's logistic regression will, I suspect, vary depending on the algorithms and dataset. Will a single-layer neural net using the classifications features produce good results? Could be, as neural nets can learn non-linear functions. Maybe it will learn that when two of the probabilities agree, they're nearly always right, and produce a hidden layer node that weights these two very highly. But until you try those and compare them, who knows? Thankfully, cross-validation provides a means of comparing each of those approaches for a given, practical problem.
How to combine weak classfiers to get a strong one?
As you might surmise from the diversity of comments, combining weak learners into strong ones isn't a task with a single, "correct" approach, but a field of approaches with varying levels of known str
How to combine weak classfiers to get a strong one? As you might surmise from the diversity of comments, combining weak learners into strong ones isn't a task with a single, "correct" approach, but a field of approaches with varying levels of known strengths and drawbacks. For a brief introduction, the wikipedia entry for ensemble learning is a reasonable place to start. There you'll find reference to many of the methods discussed in comments, such as averaging predictions or combining them using logistic regression. In particular, here's an excerpt from the section on stacking: Stacking (sometimes called stacked generalization) involves training a learning algorithm to combine the predictions of several other learning algorithms. First, all of the other algorithms are trained using the available data, then a combiner algorithm is trained to make a final prediction using all the predictions of the other algorithms as additional inputs. If an arbitrary combiner algorithm is used, then stacking can theoretically represent any of the ensemble techniques described in this article, although in practice, a single-layer logistic regression model is often used as the combiner. The of questions in your edit seem to me best answered in individual cases using cross-validation. Whether @Tim's suggestion of inverse-error-weighted mean performs better than @yasin.yazici's logistic regression will, I suspect, vary depending on the algorithms and dataset. Will a single-layer neural net using the classifications features produce good results? Could be, as neural nets can learn non-linear functions. Maybe it will learn that when two of the probabilities agree, they're nearly always right, and produce a hidden layer node that weights these two very highly. But until you try those and compare them, who knows? Thankfully, cross-validation provides a means of comparing each of those approaches for a given, practical problem.
How to combine weak classfiers to get a strong one? As you might surmise from the diversity of comments, combining weak learners into strong ones isn't a task with a single, "correct" approach, but a field of approaches with varying levels of known str
45,353
How to combine weak classfiers to get a strong one?
Combining weak learners into a strong one is exactly what boosting is designed for. Boosting is a specific example of ensemble method. "Improved Boosting Algorithms Using Confidence-rated Predictions" is a popular algorithm (over 3000 citations) that uses the confidence of the weak learner. Note that there is a big difference between the regular use of boosting and your problem. In regular boosting, you have the ability to train a weak learner on the data set of your choice. The boosting algorithm deals with building the proper data sets and combining the data set. Here, you are already given the weak learners. If you can train new learners, you can ignore those you already have and use boosting in the regular way. Otherwise, since the weak learners are known, you might be able to aggregate them in a better way by treating them as regular features and build a classifier on top of them.
How to combine weak classfiers to get a strong one?
Combining weak learners into a strong one is exactly what boosting is designed for. Boosting is a specific example of ensemble method. "Improved Boosting Algorithms Using Confidence-rated Predictions
How to combine weak classfiers to get a strong one? Combining weak learners into a strong one is exactly what boosting is designed for. Boosting is a specific example of ensemble method. "Improved Boosting Algorithms Using Confidence-rated Predictions" is a popular algorithm (over 3000 citations) that uses the confidence of the weak learner. Note that there is a big difference between the regular use of boosting and your problem. In regular boosting, you have the ability to train a weak learner on the data set of your choice. The boosting algorithm deals with building the proper data sets and combining the data set. Here, you are already given the weak learners. If you can train new learners, you can ignore those you already have and use boosting in the regular way. Otherwise, since the weak learners are known, you might be able to aggregate them in a better way by treating them as regular features and build a classifier on top of them.
How to combine weak classfiers to get a strong one? Combining weak learners into a strong one is exactly what boosting is designed for. Boosting is a specific example of ensemble method. "Improved Boosting Algorithms Using Confidence-rated Predictions
45,354
How to add a third variable to a bar plot?
I'd avoid bar charts here. A dot chart like this scores more highly on most criteria for such data. The term "dot chart" (or "dot plot") is overloaded in statistical graphics. This flavour is often called a Cleveland dot chart after William S. Cleveland, who promoted its use from the mid-1980s on. See a link to Cleveland's website here Key points: Bars can just take up a lot of space and a lot of ink. Here the grades and the averages are all more than 50%. We can give up the less important idea that the scale should start at 0 in favour of the more important idea that we should do justice to the interesting variation. We can use sorting to help see some patterns. You said semester was important, so that we can respect that. Within each semester we sort first on the grades. We could sort on the averages or the differences. Using open or hollow circles o and plus signs + as two symbols means that we can see where values differ (easy) and also where they are close (more difficult). o and + don't occlude each other even when values are identical. As a bonus, some typos in course names were corrected. It seems that you care about the Departments, course numbers and course names. In other problems, such text descriptors would often be shortened. Here there is enough space, especially when you start the scale at 50. You had to choose a small font in your design, but that can be avoided. Here is a variation in which the grades are sorted by the difference (grade $-$ average): Something often has to be downplayed. In this design I give up on the idea of showing differences explicitly: they are just implicit. For the record, this was done with the Stata code below. Something similar should be trivial in all major statistical programs. graph dot (asis) Avg (asis) Grade, over(Course, sort(2) descending) exclude0 yla(50(10)100) scheme(s1color) marker(1, ms(Oh)) marker(2, ms(plus)) linetype(line) lines(lc(gs12) lw(vthin)) over(Semester) nofill graph dot (asis) Avg (asis) Grade, over(Course, sort(Diff) descending) exclude0 yla(50(10)100) scheme(s1color) marker(1, ms(Oh)) marker(2, ms(plus)) linetype(line) lines(lc(gs12) lw(vthin)) over(Semester) nofill Note: I looked at your links after thinking up my suggestion. It's a weakness of both that they don't suggest this basic kind of graph. Threads here mentioning such plots include this, this and this. Last but not least, references as well as a detailed example can be found here.
How to add a third variable to a bar plot?
I'd avoid bar charts here. A dot chart like this scores more highly on most criteria for such data. The term "dot chart" (or "dot plot") is overloaded in statistical graphics. This flavour is often ca
How to add a third variable to a bar plot? I'd avoid bar charts here. A dot chart like this scores more highly on most criteria for such data. The term "dot chart" (or "dot plot") is overloaded in statistical graphics. This flavour is often called a Cleveland dot chart after William S. Cleveland, who promoted its use from the mid-1980s on. See a link to Cleveland's website here Key points: Bars can just take up a lot of space and a lot of ink. Here the grades and the averages are all more than 50%. We can give up the less important idea that the scale should start at 0 in favour of the more important idea that we should do justice to the interesting variation. We can use sorting to help see some patterns. You said semester was important, so that we can respect that. Within each semester we sort first on the grades. We could sort on the averages or the differences. Using open or hollow circles o and plus signs + as two symbols means that we can see where values differ (easy) and also where they are close (more difficult). o and + don't occlude each other even when values are identical. As a bonus, some typos in course names were corrected. It seems that you care about the Departments, course numbers and course names. In other problems, such text descriptors would often be shortened. Here there is enough space, especially when you start the scale at 50. You had to choose a small font in your design, but that can be avoided. Here is a variation in which the grades are sorted by the difference (grade $-$ average): Something often has to be downplayed. In this design I give up on the idea of showing differences explicitly: they are just implicit. For the record, this was done with the Stata code below. Something similar should be trivial in all major statistical programs. graph dot (asis) Avg (asis) Grade, over(Course, sort(2) descending) exclude0 yla(50(10)100) scheme(s1color) marker(1, ms(Oh)) marker(2, ms(plus)) linetype(line) lines(lc(gs12) lw(vthin)) over(Semester) nofill graph dot (asis) Avg (asis) Grade, over(Course, sort(Diff) descending) exclude0 yla(50(10)100) scheme(s1color) marker(1, ms(Oh)) marker(2, ms(plus)) linetype(line) lines(lc(gs12) lw(vthin)) over(Semester) nofill Note: I looked at your links after thinking up my suggestion. It's a weakness of both that they don't suggest this basic kind of graph. Threads here mentioning such plots include this, this and this. Last but not least, references as well as a detailed example can be found here.
How to add a third variable to a bar plot? I'd avoid bar charts here. A dot chart like this scores more highly on most criteria for such data. The term "dot chart" (or "dot plot") is overloaded in statistical graphics. This flavour is often ca
45,355
$E(X)E(1/X) \leq (a + b)^2 / 4ab$
I know it's stated in the problem, but I figured I'd put it in the answer bank: For some line $cx+d$ that cuts through $\frac{1}{X}$ at the points x=a and x = b, it's easy to show that $ c = - \frac{1}{ab} $ and $d = \frac{a+b}{ab} $, So, $ \frac{1}{X} \le - \frac{1}{ab} X + \frac{a+b}{ab} $, and therefore: $$ E(\frac{1}{X}) \le - \frac{1}{ab} E(X) + \frac{a+b}{ab} $$ $$ abE(\frac{1}{X}) + E(X) \le (a+b) $$ Now, because both sides of the inequality are positive, it follows that: $$ [abE(\frac{1}{X}) + E(X)]^2 \le (a+b)^2 $$ $$ (ab)^2E(\frac{1}{X})^2 + 2abE(\frac{1}{X})E(X) + E(X)^2 \le (a+b)^2 $$ Then, for the LHS, we can see that $2abE(\frac{1}{X})E(X) \le (ab)^2E(\frac{1}{X})^2 + E(X)^2$ because $0 \le (ab)^2E(\frac{1}{X})^2 - 2abE(\frac{1}{X})*E(X) + E(X)^2 = [abE(\frac{1}{X}) - E(X)]^2 $ SO, $$ 4abE(\frac{1}{X})E(X) \le (ab)^2E(\frac{1}{X})^2 + 2abE(\frac{1}{X})E(X) + E(X)^2 \le (a+b)^2 $$ and therefore: $$ E(\frac{1}{X})E(X) \le \frac{(a+b)^2}{4ab} $$
$E(X)E(1/X) \leq (a + b)^2 / 4ab$
I know it's stated in the problem, but I figured I'd put it in the answer bank: For some line $cx+d$ that cuts through $\frac{1}{X}$ at the points x=a and x = b, it's easy to show that $ c = - \frac{1
$E(X)E(1/X) \leq (a + b)^2 / 4ab$ I know it's stated in the problem, but I figured I'd put it in the answer bank: For some line $cx+d$ that cuts through $\frac{1}{X}$ at the points x=a and x = b, it's easy to show that $ c = - \frac{1}{ab} $ and $d = \frac{a+b}{ab} $, So, $ \frac{1}{X} \le - \frac{1}{ab} X + \frac{a+b}{ab} $, and therefore: $$ E(\frac{1}{X}) \le - \frac{1}{ab} E(X) + \frac{a+b}{ab} $$ $$ abE(\frac{1}{X}) + E(X) \le (a+b) $$ Now, because both sides of the inequality are positive, it follows that: $$ [abE(\frac{1}{X}) + E(X)]^2 \le (a+b)^2 $$ $$ (ab)^2E(\frac{1}{X})^2 + 2abE(\frac{1}{X})E(X) + E(X)^2 \le (a+b)^2 $$ Then, for the LHS, we can see that $2abE(\frac{1}{X})E(X) \le (ab)^2E(\frac{1}{X})^2 + E(X)^2$ because $0 \le (ab)^2E(\frac{1}{X})^2 - 2abE(\frac{1}{X})*E(X) + E(X)^2 = [abE(\frac{1}{X}) - E(X)]^2 $ SO, $$ 4abE(\frac{1}{X})E(X) \le (ab)^2E(\frac{1}{X})^2 + 2abE(\frac{1}{X})E(X) + E(X)^2 \le (a+b)^2 $$ and therefore: $$ E(\frac{1}{X})E(X) \le \frac{(a+b)^2}{4ab} $$
$E(X)E(1/X) \leq (a + b)^2 / 4ab$ I know it's stated in the problem, but I figured I'd put it in the answer bank: For some line $cx+d$ that cuts through $\frac{1}{X}$ at the points x=a and x = b, it's easy to show that $ c = - \frac{1
45,356
$E(X)E(1/X) \leq (a + b)^2 / 4ab$
Once we observe that both sides of the inequality are scale invariant, it follows immediately by combining two simple, well-known inequalities, of which the most notable is that correlation coefficients cannot be less than $\newcommand{\e}{\mathbb{E}}-1$. The Cauchy-Schwarz Inequality guarantees that the correlation coefficient $\rho(X,Y)$ of any two random variables $X$ and $Y$ lies between $-1$ and $1$. Using the definition of correlation and focusing on the lower bound of $-1$ allows us to express this inequality in the form $$-\text{sd}(X)\text{sd}(Y) \le \rho(X,Y)\text{sd}(X)\text{sd}(Y) = \text{Cov}(X,Y) = \e[XY] - \e[X]\e[Y].$$ If we let $Y=1/X$, the product $\e[X]\e[1/X]$ is recognizable right there at the very end (which of course is what inspired this approach). Using the simplification $\e[XY]=\e[X/X]=\e[1]=1$, isolate the last term algebraically to obtain $$\e[X]\e[1/X] \le 1 + \text{sd}(X)\text{sd}(1/X).$$ When a variable's values are confined to an interval $[a,b]$, its variance is limited by the value $(b-a)^2/4$. This is proven in several elegant, elementary, and informative ways at Variance of a bounded random variable; it comes down to the fact that variances cannot be negative. Consequently $$\text{sd}(X)\text{sd}(1/X) \le (b-a)^2/4.$$ We may freely rescale $X$ because the left side of this inequality does not thereby change. Select a scale in which $ab=1$ (which is possible because both $a$ and $b$ are positive). This allows us to rewrite the preceding in a form where the right hand side is obviously scale invariant, too: $$\text{sd}(X)\text{sd}(1/X) \le \frac{(b-a)^2}{4} = \frac{1}{ab}\frac{(b-a)^2}{4}=\frac{(b-a)^2}{4ab}.$$ These two inequalities finish the job: $$\e[X]\e[1/X] \le 1 + \text{sd}(X)\text{sd}(1/X) \le 1 + \frac{(b-a)^2}{4ab} = \frac{(a+b)^2}{4ab}.$$
$E(X)E(1/X) \leq (a + b)^2 / 4ab$
Once we observe that both sides of the inequality are scale invariant, it follows immediately by combining two simple, well-known inequalities, of which the most notable is that correlation coefficien
$E(X)E(1/X) \leq (a + b)^2 / 4ab$ Once we observe that both sides of the inequality are scale invariant, it follows immediately by combining two simple, well-known inequalities, of which the most notable is that correlation coefficients cannot be less than $\newcommand{\e}{\mathbb{E}}-1$. The Cauchy-Schwarz Inequality guarantees that the correlation coefficient $\rho(X,Y)$ of any two random variables $X$ and $Y$ lies between $-1$ and $1$. Using the definition of correlation and focusing on the lower bound of $-1$ allows us to express this inequality in the form $$-\text{sd}(X)\text{sd}(Y) \le \rho(X,Y)\text{sd}(X)\text{sd}(Y) = \text{Cov}(X,Y) = \e[XY] - \e[X]\e[Y].$$ If we let $Y=1/X$, the product $\e[X]\e[1/X]$ is recognizable right there at the very end (which of course is what inspired this approach). Using the simplification $\e[XY]=\e[X/X]=\e[1]=1$, isolate the last term algebraically to obtain $$\e[X]\e[1/X] \le 1 + \text{sd}(X)\text{sd}(1/X).$$ When a variable's values are confined to an interval $[a,b]$, its variance is limited by the value $(b-a)^2/4$. This is proven in several elegant, elementary, and informative ways at Variance of a bounded random variable; it comes down to the fact that variances cannot be negative. Consequently $$\text{sd}(X)\text{sd}(1/X) \le (b-a)^2/4.$$ We may freely rescale $X$ because the left side of this inequality does not thereby change. Select a scale in which $ab=1$ (which is possible because both $a$ and $b$ are positive). This allows us to rewrite the preceding in a form where the right hand side is obviously scale invariant, too: $$\text{sd}(X)\text{sd}(1/X) \le \frac{(b-a)^2}{4} = \frac{1}{ab}\frac{(b-a)^2}{4}=\frac{(b-a)^2}{4ab}.$$ These two inequalities finish the job: $$\e[X]\e[1/X] \le 1 + \text{sd}(X)\text{sd}(1/X) \le 1 + \frac{(b-a)^2}{4ab} = \frac{(a+b)^2}{4ab}.$$
$E(X)E(1/X) \leq (a + b)^2 / 4ab$ Once we observe that both sides of the inequality are scale invariant, it follows immediately by combining two simple, well-known inequalities, of which the most notable is that correlation coefficien
45,357
Machine learning classifiers
Rules of thumb can only get you so far, but scikit-learn's cheat sheet is quite helpful for basic guidance. Here's a blog post by the creator of said diagram.
Machine learning classifiers
Rules of thumb can only get you so far, but scikit-learn's cheat sheet is quite helpful for basic guidance. Here's a blog post by the creator of said diagram.
Machine learning classifiers Rules of thumb can only get you so far, but scikit-learn's cheat sheet is quite helpful for basic guidance. Here's a blog post by the creator of said diagram.
Machine learning classifiers Rules of thumb can only get you so far, but scikit-learn's cheat sheet is quite helpful for basic guidance. Here's a blog post by the creator of said diagram.
45,358
The meaning of scale and location in the Pearson correlation context
In this case, scale and location are more general. Given two random variables $X$ and $Y$, the correlation is scale and location invariant in the sense that $cor(X,Y) = cor(X_{T},Y_{T})$, if $X_{T} = a + bX$, and $Y_{T} = c + dY$, and $b$ and $d$ have the same sign (either both positive or both negative). Note that if $b > 0$ and $d < 0$ (and vice versa), $cor(X,Y) \neq cor(X_{T},Y_{T})$ because the sign of the correlation between the transformed random variables will be inverted. Example: $$X = 1,2,3,4,5$$ $$Y = 1,2,3,4,5$$ $$cor(X,Y) = 1$$ If $X_{T} = 1 + 2 X$ and $Y_{T} = 2 + 3 Y$ , then $$X_{T} = 3,5,7,9,11$$ $$Y_{T} = 5 ,8, 11, 14, 17$$ $$ cor(X_{T},{Y_{T}}) = 1 $$ But, if $X_{T} = 1 + 2 X$ and $Y_{T} = 2 - 3 Y$, then $$X_{T} = 3,5,7,9,11$$ $$Y_{T} = -1, -4, -7, -10, -13$$ $$cor(X_{T},{Y_{T}}) = - 1 $$
The meaning of scale and location in the Pearson correlation context
In this case, scale and location are more general. Given two random variables $X$ and $Y$, the correlation is scale and location invariant in the sense that $cor(X,Y) = cor(X_{T},Y_{T})$, if $X_{T} =
The meaning of scale and location in the Pearson correlation context In this case, scale and location are more general. Given two random variables $X$ and $Y$, the correlation is scale and location invariant in the sense that $cor(X,Y) = cor(X_{T},Y_{T})$, if $X_{T} = a + bX$, and $Y_{T} = c + dY$, and $b$ and $d$ have the same sign (either both positive or both negative). Note that if $b > 0$ and $d < 0$ (and vice versa), $cor(X,Y) \neq cor(X_{T},Y_{T})$ because the sign of the correlation between the transformed random variables will be inverted. Example: $$X = 1,2,3,4,5$$ $$Y = 1,2,3,4,5$$ $$cor(X,Y) = 1$$ If $X_{T} = 1 + 2 X$ and $Y_{T} = 2 + 3 Y$ , then $$X_{T} = 3,5,7,9,11$$ $$Y_{T} = 5 ,8, 11, 14, 17$$ $$ cor(X_{T},{Y_{T}}) = 1 $$ But, if $X_{T} = 1 + 2 X$ and $Y_{T} = 2 - 3 Y$, then $$X_{T} = 3,5,7,9,11$$ $$Y_{T} = -1, -4, -7, -10, -13$$ $$cor(X_{T},{Y_{T}}) = - 1 $$
The meaning of scale and location in the Pearson correlation context In this case, scale and location are more general. Given two random variables $X$ and $Y$, the correlation is scale and location invariant in the sense that $cor(X,Y) = cor(X_{T},Y_{T})$, if $X_{T} =
45,359
The meaning of scale and location in the Pearson correlation context
No, scale and location are more general in this case. A scale and location transformation of a variable X is a deterministic function of X defined as Y=f (X)=aX+b. For the correlation coefficient to be scale and location invariant is the same as saying that for a and b real, the correlation coefficient of X and Y will be the same. If you look at the definition of the correlation coefficient, and use definitions related to expectation and variance of a linear transformation of a variable, you can work to that result.
The meaning of scale and location in the Pearson correlation context
No, scale and location are more general in this case. A scale and location transformation of a variable X is a deterministic function of X defined as Y=f (X)=aX+b. For the correlation coefficient to b
The meaning of scale and location in the Pearson correlation context No, scale and location are more general in this case. A scale and location transformation of a variable X is a deterministic function of X defined as Y=f (X)=aX+b. For the correlation coefficient to be scale and location invariant is the same as saying that for a and b real, the correlation coefficient of X and Y will be the same. If you look at the definition of the correlation coefficient, and use definitions related to expectation and variance of a linear transformation of a variable, you can work to that result.
The meaning of scale and location in the Pearson correlation context No, scale and location are more general in this case. A scale and location transformation of a variable X is a deterministic function of X defined as Y=f (X)=aX+b. For the correlation coefficient to b
45,360
Maximum likelihood in the GJR-GARCH(1,1) model
A conditional volatility model such as the GARCH model is defined by the mean equation \begin{equation} r_t = \mu + \sigma_t z_t = \mu + \varepsilon_t \end{equation} and the GARCH equation (this is for the simple GARCH) \begin{equation} \sigma^2_t = \omega + \alpha \varepsilon_{t-1}^2 + \beta \sigma_{t-1}^2 \end{equation} To perform maximum-likelihood estimation, we must make distributional assumptions on $z_t$. It is typically assumed to be i.i.d. $N(0,1)$. Conditional on the informationset at time t, we have that \begin{equation} r_t \sim N(\mu, \sigma_t^2) \end{equation} or \begin{equation} \varepsilon_t = r_t - \mu \sim N(0, \sigma_t^2) \end{equation} However when we perform maximum-likelihood estimation, we are interested in the joint distribution \begin{equation} f(\varepsilon_1,...,\varepsilon_T; \theta) \end{equation} where $\theta$ is the parameter vector. Using iteratively that the joint distribution is equal to the product of the conditional and the marginal density, we obtain \begin{eqnarray} f(\varepsilon_0,...,\varepsilon_T; \theta) &=& f(\varepsilon_0;\theta)f(\varepsilon_1,...,\varepsilon_T\vert \varepsilon_0 ;\theta) \\ &=& f(\varepsilon_0;\theta) \prod_{t=1}^T f(\varepsilon_t \vert \varepsilon_{t-1},...,\varepsilon_{0} ;\theta) \\ &=& f(\varepsilon_0;\theta) \prod_{t=1}^T f(\varepsilon_t \vert \varepsilon_{t-1};\theta) \\ &=& f(\varepsilon_0;\theta) \prod_{t=1}^T \frac{1}{\sqrt{2\pi \sigma_t^2}}\exp\left(-\frac{\varepsilon_t^2}{2\sigma_t^2}\right) \end{eqnarray} Dropping $f(\varepsilon_0;\theta)$ and taking logs, we obtain the (conditional) log-likelihood function \begin{equation} L(\theta) = \sum_{t=1}^T \frac{1}{2} \left[-\log2\pi-\log(\sigma_t^2) -\frac{\varepsilon_t^2}{\sigma_t^2}\right] \end{equation} To question 1): The exact same steps can be followed for the GJR-GARCH model. The log-likelihood functions are similar but not the same due to the different specification for $\sigma_t^2$. To question 2): One is free to use whatever assumption about the distribution of the innovations, but the calculations will become more tedious. As far as I know, Filtered Historical Simulation is used to performe e.g. VaR forecast. The "fitted" innovations are bootstrapped to better fit the actual empirical distribution. Estimation is still performed using Gaussian (quasi) maximum-likelihood.
Maximum likelihood in the GJR-GARCH(1,1) model
A conditional volatility model such as the GARCH model is defined by the mean equation \begin{equation} r_t = \mu + \sigma_t z_t = \mu + \varepsilon_t \end{equation} and the GARCH equation (this is fo
Maximum likelihood in the GJR-GARCH(1,1) model A conditional volatility model such as the GARCH model is defined by the mean equation \begin{equation} r_t = \mu + \sigma_t z_t = \mu + \varepsilon_t \end{equation} and the GARCH equation (this is for the simple GARCH) \begin{equation} \sigma^2_t = \omega + \alpha \varepsilon_{t-1}^2 + \beta \sigma_{t-1}^2 \end{equation} To perform maximum-likelihood estimation, we must make distributional assumptions on $z_t$. It is typically assumed to be i.i.d. $N(0,1)$. Conditional on the informationset at time t, we have that \begin{equation} r_t \sim N(\mu, \sigma_t^2) \end{equation} or \begin{equation} \varepsilon_t = r_t - \mu \sim N(0, \sigma_t^2) \end{equation} However when we perform maximum-likelihood estimation, we are interested in the joint distribution \begin{equation} f(\varepsilon_1,...,\varepsilon_T; \theta) \end{equation} where $\theta$ is the parameter vector. Using iteratively that the joint distribution is equal to the product of the conditional and the marginal density, we obtain \begin{eqnarray} f(\varepsilon_0,...,\varepsilon_T; \theta) &=& f(\varepsilon_0;\theta)f(\varepsilon_1,...,\varepsilon_T\vert \varepsilon_0 ;\theta) \\ &=& f(\varepsilon_0;\theta) \prod_{t=1}^T f(\varepsilon_t \vert \varepsilon_{t-1},...,\varepsilon_{0} ;\theta) \\ &=& f(\varepsilon_0;\theta) \prod_{t=1}^T f(\varepsilon_t \vert \varepsilon_{t-1};\theta) \\ &=& f(\varepsilon_0;\theta) \prod_{t=1}^T \frac{1}{\sqrt{2\pi \sigma_t^2}}\exp\left(-\frac{\varepsilon_t^2}{2\sigma_t^2}\right) \end{eqnarray} Dropping $f(\varepsilon_0;\theta)$ and taking logs, we obtain the (conditional) log-likelihood function \begin{equation} L(\theta) = \sum_{t=1}^T \frac{1}{2} \left[-\log2\pi-\log(\sigma_t^2) -\frac{\varepsilon_t^2}{\sigma_t^2}\right] \end{equation} To question 1): The exact same steps can be followed for the GJR-GARCH model. The log-likelihood functions are similar but not the same due to the different specification for $\sigma_t^2$. To question 2): One is free to use whatever assumption about the distribution of the innovations, but the calculations will become more tedious. As far as I know, Filtered Historical Simulation is used to performe e.g. VaR forecast. The "fitted" innovations are bootstrapped to better fit the actual empirical distribution. Estimation is still performed using Gaussian (quasi) maximum-likelihood.
Maximum likelihood in the GJR-GARCH(1,1) model A conditional volatility model such as the GARCH model is defined by the mean equation \begin{equation} r_t = \mu + \sigma_t z_t = \mu + \varepsilon_t \end{equation} and the GARCH equation (this is fo
45,361
Saturated model - why is it perfectly fitted?
One way to get some intuition for staturation is to look carefully at parameter indices. I'll use an example from contingency table analysis, because I think it's a little bit clearer than the regression context (and also because regression versions have already been pointed to). Consider the log linear models of a two way contingency table $C$. Notationally, the $i$th row and $j$th column value is denoted $C_{ij}$. Textbooks define a sequence of models for the log of the expected or mean value of the these entries $E[C_{ij}]$, in the same way that regression models build a model of the expected value of some $E[Y_i]$ in terms of some function of covariates. Assuming you have some intuition for the idea of link functions (here the log) and the idea of modeling the expected value of something rather than its actual value, then the intuition for saturation comes like this: The simplest model of $C$ says that $$ \log E[C_{ij}] = \lambda $$ this implies that all entries should, according to the model, have the same expected value because the parameter $\lambda$ has no index, meaning it applies to all $i$ and all $j$. (Simplifying slightly, parameters are distinct only when they have an index that can vary, and they can have as many possible distinct values as there are possible values of that index.) The next two most complex models $$ \log E[C_{ij}] = \lambda + \lambda_i $$ and $$ \log E[C_{ij}] = \lambda + \lambda_j $$ say that each row (column) has the same expected value but different rows (columns) can have different expected values, because the new parameters are indexed by $i$ but not $j$ ($j$ but not $i$) These models allow as many different expected cell values as there are rows (columns) but that's still fewer distinct values than there are cell entries in total, so the model is not saturated and the expected values won't typically coincide exactly with the actual values. Finally the most complex model in this sequence is $$ \log E[C_{ij}] = \lambda + \lambda_j + \lambda_j + \lambda_{ij} $$ The indexing indicates that there can be as many distinct expected values as there are entries in the table. Entries in $C$ are labelled by all combinations of $i$ and $j$ and the model has parameters corresponding to all combinations of $i$ and $j$ too, so every cell can effectively get its own parameter. When that is the case (and when we fit by Maximum Likelihood) the expected cell value coincide with the actual cell values. In more detail, and comparing with the second model: the expected cell values in row $i$ are forced to be all the same, even though the actual cell values in row $i$ probably aren't, so we can interpret the difference between the two as unmodelled variation from a mean. In the final model there is no variation around the model's expected values for each cell, because there are no other cells with the same mean to compare it with, so the expected cell value are also the actual values. Addendum: There is a completely parallel development of these ideas based not on the parameters of various different types of model, but on which table sums and margins each model must respect. In this sequence, the first of our models need only agree with $C$ about what the total sum of the entries is. In the second model it must agree about the total sum and also get the same row totals as $C$. In the third model it must agree about the total sum and also get the same column totals as $C$. And in the final model it must reflect all the entry values. But if you have the intuition about the parameters then it should make sense why these margin capturing relationships hold.
Saturated model - why is it perfectly fitted?
One way to get some intuition for staturation is to look carefully at parameter indices. I'll use an example from contingency table analysis, because I think it's a little bit clearer than the regres
Saturated model - why is it perfectly fitted? One way to get some intuition for staturation is to look carefully at parameter indices. I'll use an example from contingency table analysis, because I think it's a little bit clearer than the regression context (and also because regression versions have already been pointed to). Consider the log linear models of a two way contingency table $C$. Notationally, the $i$th row and $j$th column value is denoted $C_{ij}$. Textbooks define a sequence of models for the log of the expected or mean value of the these entries $E[C_{ij}]$, in the same way that regression models build a model of the expected value of some $E[Y_i]$ in terms of some function of covariates. Assuming you have some intuition for the idea of link functions (here the log) and the idea of modeling the expected value of something rather than its actual value, then the intuition for saturation comes like this: The simplest model of $C$ says that $$ \log E[C_{ij}] = \lambda $$ this implies that all entries should, according to the model, have the same expected value because the parameter $\lambda$ has no index, meaning it applies to all $i$ and all $j$. (Simplifying slightly, parameters are distinct only when they have an index that can vary, and they can have as many possible distinct values as there are possible values of that index.) The next two most complex models $$ \log E[C_{ij}] = \lambda + \lambda_i $$ and $$ \log E[C_{ij}] = \lambda + \lambda_j $$ say that each row (column) has the same expected value but different rows (columns) can have different expected values, because the new parameters are indexed by $i$ but not $j$ ($j$ but not $i$) These models allow as many different expected cell values as there are rows (columns) but that's still fewer distinct values than there are cell entries in total, so the model is not saturated and the expected values won't typically coincide exactly with the actual values. Finally the most complex model in this sequence is $$ \log E[C_{ij}] = \lambda + \lambda_j + \lambda_j + \lambda_{ij} $$ The indexing indicates that there can be as many distinct expected values as there are entries in the table. Entries in $C$ are labelled by all combinations of $i$ and $j$ and the model has parameters corresponding to all combinations of $i$ and $j$ too, so every cell can effectively get its own parameter. When that is the case (and when we fit by Maximum Likelihood) the expected cell value coincide with the actual cell values. In more detail, and comparing with the second model: the expected cell values in row $i$ are forced to be all the same, even though the actual cell values in row $i$ probably aren't, so we can interpret the difference between the two as unmodelled variation from a mean. In the final model there is no variation around the model's expected values for each cell, because there are no other cells with the same mean to compare it with, so the expected cell value are also the actual values. Addendum: There is a completely parallel development of these ideas based not on the parameters of various different types of model, but on which table sums and margins each model must respect. In this sequence, the first of our models need only agree with $C$ about what the total sum of the entries is. In the second model it must agree about the total sum and also get the same row totals as $C$. In the third model it must agree about the total sum and also get the same column totals as $C$. And in the final model it must reflect all the entry values. But if you have the intuition about the parameters then it should make sense why these margin capturing relationships hold.
Saturated model - why is it perfectly fitted? One way to get some intuition for staturation is to look carefully at parameter indices. I'll use an example from contingency table analysis, because I think it's a little bit clearer than the regres
45,362
Saturated model - why is it perfectly fitted?
Saturated essentially means "perfectly fitted". In a saturated model there are as many estimated parameters as there are observations. Take a simple case of only 2 observations. Say "height" is the DV and one person is male and one female. Now a model with just "sex" as an IV will fit perfectly. In a linear model, the intercept would be the average height of the two people and the effect of (say) maleness with be the difference between the man and the woman.
Saturated model - why is it perfectly fitted?
Saturated essentially means "perfectly fitted". In a saturated model there are as many estimated parameters as there are observations. Take a simple case of only 2 observations. Say "height" is the
Saturated model - why is it perfectly fitted? Saturated essentially means "perfectly fitted". In a saturated model there are as many estimated parameters as there are observations. Take a simple case of only 2 observations. Say "height" is the DV and one person is male and one female. Now a model with just "sex" as an IV will fit perfectly. In a linear model, the intercept would be the average height of the two people and the effect of (say) maleness with be the difference between the man and the woman.
Saturated model - why is it perfectly fitted? Saturated essentially means "perfectly fitted". In a saturated model there are as many estimated parameters as there are observations. Take a simple case of only 2 observations. Say "height" is the
45,363
Saturated model - why is it perfectly fitted?
Looking at the answers to this thread A saturated model is one in which there are as many estimated parameters as data points. Consider the case of linear regression. You have a sample of size $n$ and $k$ regressors including the constant term. Then you essentially are trying to "solve" (i.e. find the $k$ unknown parameters that satisfy) a set of linear equations $$\begin{align} y_1 = b_1 + b_2x_{21} + ...+ b_{k}x_{k1} \\ y_2 = b_1 + b_2x_{22} + ...+ b_{k}x_{k2}\\ ...\\ y_n = b_1 + b_2x_{2n} + ...+ b_{k}x_{kn}\\ \end{align}$$ In matrix notation $$\mathbf Y_{n \times 1} = \mathbf X_{n \times k}\mathbf b_{k \times 1}$$ As long as $k<n$ the system cannot be solved exactly, because we have more equations than unknowns, and so we resort to an approximate solution, under some optimality criterion, say, a parameter vector that minimizes the sum of squared deviations. But if $k=n$ then we have as many unknowns as equations. This is reflected in the fact that now, the matrix $\mathbf X$ has become a square matrix, and we are looking at $$\mathbf Y_{n \times 1} = \mathbf X_{n \times n}\mathbf b_{n \times 1}$$ Then from high-school algebra, we know that as long as the $\mathbf X$ matrix is invertible ("determinant not zero"), then the system has a unique solution $$\mathbf b_{n \times 1} = \mathbf X^{-1}_{n \times n}\mathbf Y_{n \times 1}$$ But this is a solution in the mathematical, exact sense, of the calculated parameter vector satisfying exactly each and everyone of the $n$ equations - no "residuals" -which, in statistical terminology, is the equivalent of "perfect fit".
Saturated model - why is it perfectly fitted?
Looking at the answers to this thread A saturated model is one in which there are as many estimated parameters as data points. Consider the case of linear regression. You have a sample of size $n
Saturated model - why is it perfectly fitted? Looking at the answers to this thread A saturated model is one in which there are as many estimated parameters as data points. Consider the case of linear regression. You have a sample of size $n$ and $k$ regressors including the constant term. Then you essentially are trying to "solve" (i.e. find the $k$ unknown parameters that satisfy) a set of linear equations $$\begin{align} y_1 = b_1 + b_2x_{21} + ...+ b_{k}x_{k1} \\ y_2 = b_1 + b_2x_{22} + ...+ b_{k}x_{k2}\\ ...\\ y_n = b_1 + b_2x_{2n} + ...+ b_{k}x_{kn}\\ \end{align}$$ In matrix notation $$\mathbf Y_{n \times 1} = \mathbf X_{n \times k}\mathbf b_{k \times 1}$$ As long as $k<n$ the system cannot be solved exactly, because we have more equations than unknowns, and so we resort to an approximate solution, under some optimality criterion, say, a parameter vector that minimizes the sum of squared deviations. But if $k=n$ then we have as many unknowns as equations. This is reflected in the fact that now, the matrix $\mathbf X$ has become a square matrix, and we are looking at $$\mathbf Y_{n \times 1} = \mathbf X_{n \times n}\mathbf b_{n \times 1}$$ Then from high-school algebra, we know that as long as the $\mathbf X$ matrix is invertible ("determinant not zero"), then the system has a unique solution $$\mathbf b_{n \times 1} = \mathbf X^{-1}_{n \times n}\mathbf Y_{n \times 1}$$ But this is a solution in the mathematical, exact sense, of the calculated parameter vector satisfying exactly each and everyone of the $n$ equations - no "residuals" -which, in statistical terminology, is the equivalent of "perfect fit".
Saturated model - why is it perfectly fitted? Looking at the answers to this thread A saturated model is one in which there are as many estimated parameters as data points. Consider the case of linear regression. You have a sample of size $n
45,364
Null hypothesis for linear regression
I am confused about the null hypothesis for linear regression. The issue applies to null hypotheses more broadly than regression What does that translate to in terms of null hypothesis? You should get used to stating nulls before you look at p-values. Am I rejecting the null hypothesis that the coefficient for that variable is 0 Yes, as long as it's the population coefficient, ($\beta_i$) you're talking about (obviously - with continuous response - the estimate of the coefficient isn't 0). or am I accepting a null hypothesis that the coefficient is != 0? Null hypotheses would generally be null - either 'no effect' or some conventionally accepted value. In this case, the population coefficient being 0 is a classical 'no effect' null. More prosaically, when testing a point hypothesis against a composite alternative (a two-sided alternative in this case), one takes the point hypothesis as the null, because that's the one under which we can compute the distribution of the test statistic (more generally, using an open set for a null presents certain problems, even when both are composite). With a pair of point hypotheses, one is (at least mechanically) free to make either one the null (and even then one still would generally want to make the one that's most clearly "null" the null -- if either of them is; that is to choose the 'no effect' or conventionally-accepted one the null).
Null hypothesis for linear regression
I am confused about the null hypothesis for linear regression. The issue applies to null hypotheses more broadly than regression What does that translate to in terms of null hypothesis? You should
Null hypothesis for linear regression I am confused about the null hypothesis for linear regression. The issue applies to null hypotheses more broadly than regression What does that translate to in terms of null hypothesis? You should get used to stating nulls before you look at p-values. Am I rejecting the null hypothesis that the coefficient for that variable is 0 Yes, as long as it's the population coefficient, ($\beta_i$) you're talking about (obviously - with continuous response - the estimate of the coefficient isn't 0). or am I accepting a null hypothesis that the coefficient is != 0? Null hypotheses would generally be null - either 'no effect' or some conventionally accepted value. In this case, the population coefficient being 0 is a classical 'no effect' null. More prosaically, when testing a point hypothesis against a composite alternative (a two-sided alternative in this case), one takes the point hypothesis as the null, because that's the one under which we can compute the distribution of the test statistic (more generally, using an open set for a null presents certain problems, even when both are composite). With a pair of point hypotheses, one is (at least mechanically) free to make either one the null (and even then one still would generally want to make the one that's most clearly "null" the null -- if either of them is; that is to choose the 'no effect' or conventionally-accepted one the null).
Null hypothesis for linear regression I am confused about the null hypothesis for linear regression. The issue applies to null hypotheses more broadly than regression What does that translate to in terms of null hypothesis? You should
45,365
Null hypothesis for linear regression
The P-Value in regression output in R tests the null hypothesis that the coefficient equals 0.
Null hypothesis for linear regression
The P-Value in regression output in R tests the null hypothesis that the coefficient equals 0.
Null hypothesis for linear regression The P-Value in regression output in R tests the null hypothesis that the coefficient equals 0.
Null hypothesis for linear regression The P-Value in regression output in R tests the null hypothesis that the coefficient equals 0.
45,366
Null hypothesis for linear regression
Any regression equation is given by y = a + b*x + u, where 'a' and 'b' are the intercept and slope of the best fit line and 'u' is the disturbance term. Imagine b=0; the equation would then be y = a + 0*x + u = a + u. Notice that the 'x' has disappeared. It simply means that there is no relationship between y and x. Thus are test hypothesis would be, Ho: b=0; Ha: b != 0 Next step is to compare the critical values with the test statistic. If the test stat lies within the Rejection region then we knockout the Null hypothesis. Alternatively, the p-value also relays this information by pointing out how much probability remains between the test stat and the end tails.
Null hypothesis for linear regression
Any regression equation is given by y = a + b*x + u, where 'a' and 'b' are the intercept and slope of the best fit line and 'u' is the disturbance term. Imagine b=0; the equation would then be y = a
Null hypothesis for linear regression Any regression equation is given by y = a + b*x + u, where 'a' and 'b' are the intercept and slope of the best fit line and 'u' is the disturbance term. Imagine b=0; the equation would then be y = a + 0*x + u = a + u. Notice that the 'x' has disappeared. It simply means that there is no relationship between y and x. Thus are test hypothesis would be, Ho: b=0; Ha: b != 0 Next step is to compare the critical values with the test statistic. If the test stat lies within the Rejection region then we knockout the Null hypothesis. Alternatively, the p-value also relays this information by pointing out how much probability remains between the test stat and the end tails.
Null hypothesis for linear regression Any regression equation is given by y = a + b*x + u, where 'a' and 'b' are the intercept and slope of the best fit line and 'u' is the disturbance term. Imagine b=0; the equation would then be y = a
45,367
Determining number of factors in exploratory factor analysis
There are several approaches to determining the number of factors to extract for exploratory factor analysis (EFA). However, practically all of them boil down to be either visual, or analytical. Visual approaches are mostly based on visual representation of factors' eigenvalues (so called scree plot - see this page and this page), depending on extracted factor number. A scree plot allows to determine the number of factors to extract by detecting an area, where the curve makes relatively sharp drop (called "elbow"). Note that the scree plot term is also applicable to principal component analysis (PCA) - for a basic example, see this page. Analytical approaches are based on various criteria and heuristics, including Kaiser criterion (eigenvalue greater than one), variance explained criterion (this heuristic's cut-off values vary from 0.8-0.9 to as low as 0.5, depending on researcher's specific goals), parallel analysis, Very Simple Structure (VSS) criterion, Velicer's MAP test and other techniques (see more details here and here, as well as via links within). While I've tried to answer your question briefly and give mainly an overview of the topic, there are many nice answers to similar or related questions on Cross Validated, which I highly recommend you to review. For example, for PCA vs. EFA basic arguments, see this discussion. For much more advanced arguments on this topic, see this and this discussion. For applying VSS criterion, using R, see this discussion. For parallel analysis, see this discussion.
Determining number of factors in exploratory factor analysis
There are several approaches to determining the number of factors to extract for exploratory factor analysis (EFA). However, practically all of them boil down to be either visual, or analytical. Visua
Determining number of factors in exploratory factor analysis There are several approaches to determining the number of factors to extract for exploratory factor analysis (EFA). However, practically all of them boil down to be either visual, or analytical. Visual approaches are mostly based on visual representation of factors' eigenvalues (so called scree plot - see this page and this page), depending on extracted factor number. A scree plot allows to determine the number of factors to extract by detecting an area, where the curve makes relatively sharp drop (called "elbow"). Note that the scree plot term is also applicable to principal component analysis (PCA) - for a basic example, see this page. Analytical approaches are based on various criteria and heuristics, including Kaiser criterion (eigenvalue greater than one), variance explained criterion (this heuristic's cut-off values vary from 0.8-0.9 to as low as 0.5, depending on researcher's specific goals), parallel analysis, Very Simple Structure (VSS) criterion, Velicer's MAP test and other techniques (see more details here and here, as well as via links within). While I've tried to answer your question briefly and give mainly an overview of the topic, there are many nice answers to similar or related questions on Cross Validated, which I highly recommend you to review. For example, for PCA vs. EFA basic arguments, see this discussion. For much more advanced arguments on this topic, see this and this discussion. For applying VSS criterion, using R, see this discussion. For parallel analysis, see this discussion.
Determining number of factors in exploratory factor analysis There are several approaches to determining the number of factors to extract for exploratory factor analysis (EFA). However, practically all of them boil down to be either visual, or analytical. Visua
45,368
Determining number of factors in exploratory factor analysis
I think that I cant help you specifically with R, but a common step on verifying the number of factors is to either look at the loadings and retaining as many factors as those ones with a value of 1 or more. This is the most straight way to pick the factors. If you want, you can manage to get the "scree plot", wich gives you a more visual insight on the number of factors but is more subjective. In that plot, when you get a "fall" in the curve plotted might indicate the number of factors. This approach is good when you want to reduce the number of variables of a big dataset with many variables highly correlated. So two is the number of factors to extract in your case. Instead, if you want to really cluster variables and this factor has a meaning on people or economic behavior, you might want to select only the two or three highest loadings, because you will be able to access the Component Plot in Rotated Space, i.e. the graphical representation of the variables in a two-dimensional (or three-dimensional) space, wich gives you clues on interpreting the factor if this is your goal. Since you put the theoretical references for your studies at the end of your work, you will be telling others that you are not doing something sparse - it´s based on proofs stated by others. Statistically speaking, you could run a correlation analysis between the scores obtained from the pca with the response variable, for example. If the PCA was ok and the original variables are also correlated with this response variable, your factor will also be and you´ll have a very solid and understandable number to convince people. Hope this helped you in some way.If I have said anything wrong, anyone please correct me.
Determining number of factors in exploratory factor analysis
I think that I cant help you specifically with R, but a common step on verifying the number of factors is to either look at the loadings and retaining as many factors as those ones with a value of 1 o
Determining number of factors in exploratory factor analysis I think that I cant help you specifically with R, but a common step on verifying the number of factors is to either look at the loadings and retaining as many factors as those ones with a value of 1 or more. This is the most straight way to pick the factors. If you want, you can manage to get the "scree plot", wich gives you a more visual insight on the number of factors but is more subjective. In that plot, when you get a "fall" in the curve plotted might indicate the number of factors. This approach is good when you want to reduce the number of variables of a big dataset with many variables highly correlated. So two is the number of factors to extract in your case. Instead, if you want to really cluster variables and this factor has a meaning on people or economic behavior, you might want to select only the two or three highest loadings, because you will be able to access the Component Plot in Rotated Space, i.e. the graphical representation of the variables in a two-dimensional (or three-dimensional) space, wich gives you clues on interpreting the factor if this is your goal. Since you put the theoretical references for your studies at the end of your work, you will be telling others that you are not doing something sparse - it´s based on proofs stated by others. Statistically speaking, you could run a correlation analysis between the scores obtained from the pca with the response variable, for example. If the PCA was ok and the original variables are also correlated with this response variable, your factor will also be and you´ll have a very solid and understandable number to convince people. Hope this helped you in some way.If I have said anything wrong, anyone please correct me.
Determining number of factors in exploratory factor analysis I think that I cant help you specifically with R, but a common step on verifying the number of factors is to either look at the loadings and retaining as many factors as those ones with a value of 1 o
45,369
Bias/variance tradeoff tutorial
It depends exactly what you'd like to know about bias/variance, but a good theoretical description of the problem is in Andrew Ng's CS229 Lecture Notes. [EDIT: updated link] In general, this tradeoff is about model complexity - how many parameters are you trying to estimate, and how "free/independent" are they. This can be formalized using learning theory, as in Andrew's notes, but just the general intuition is probably enough for practical applications. To answer your specific examples: feature selection should decrease variance (since we will end up fitting fewer parameters), hopefully without increasing bias too much (if done well). I'm not sure what you mean by "scaling", but that's probably an implementation-level detail that won't be too related to the more abstract bias/variance issues.
Bias/variance tradeoff tutorial
It depends exactly what you'd like to know about bias/variance, but a good theoretical description of the problem is in Andrew Ng's CS229 Lecture Notes. [EDIT: updated link] In general, this tradeoff
Bias/variance tradeoff tutorial It depends exactly what you'd like to know about bias/variance, but a good theoretical description of the problem is in Andrew Ng's CS229 Lecture Notes. [EDIT: updated link] In general, this tradeoff is about model complexity - how many parameters are you trying to estimate, and how "free/independent" are they. This can be formalized using learning theory, as in Andrew's notes, but just the general intuition is probably enough for practical applications. To answer your specific examples: feature selection should decrease variance (since we will end up fitting fewer parameters), hopefully without increasing bias too much (if done well). I'm not sure what you mean by "scaling", but that's probably an implementation-level detail that won't be too related to the more abstract bias/variance issues.
Bias/variance tradeoff tutorial It depends exactly what you'd like to know about bias/variance, but a good theoretical description of the problem is in Andrew Ng's CS229 Lecture Notes. [EDIT: updated link] In general, this tradeoff
45,370
Bias/variance tradeoff tutorial
A nice and intuitive explanation is found in this book. It accompanies the ISLR book with more code and simulations. The author is using simulation to show the decomposition of the MSE and also shows graphically the trade off as model complexity increases
Bias/variance tradeoff tutorial
A nice and intuitive explanation is found in this book. It accompanies the ISLR book with more code and simulations. The author is using simulation to show the decomposition of the MSE and also shows
Bias/variance tradeoff tutorial A nice and intuitive explanation is found in this book. It accompanies the ISLR book with more code and simulations. The author is using simulation to show the decomposition of the MSE and also shows graphically the trade off as model complexity increases
Bias/variance tradeoff tutorial A nice and intuitive explanation is found in this book. It accompanies the ISLR book with more code and simulations. The author is using simulation to show the decomposition of the MSE and also shows
45,371
Bias/variance tradeoff tutorial
I think the article Choosing Prediction Over Explanation in Psychology: Lessons From Machine Learning by Tal Yarkoni and Jacob Westfall will give you some insights into the bias-variance trade-off: http://jakewestfall.org/publications/Yarkoni_Westfall_choosing_prediction.pdf.
Bias/variance tradeoff tutorial
I think the article Choosing Prediction Over Explanation in Psychology: Lessons From Machine Learning by Tal Yarkoni and Jacob Westfall will give you some insights into the bias-variance trade-off: ht
Bias/variance tradeoff tutorial I think the article Choosing Prediction Over Explanation in Psychology: Lessons From Machine Learning by Tal Yarkoni and Jacob Westfall will give you some insights into the bias-variance trade-off: http://jakewestfall.org/publications/Yarkoni_Westfall_choosing_prediction.pdf.
Bias/variance tradeoff tutorial I think the article Choosing Prediction Over Explanation in Psychology: Lessons From Machine Learning by Tal Yarkoni and Jacob Westfall will give you some insights into the bias-variance trade-off: ht
45,372
Computing the Variance of an MLE
Combining @Xi'an comments and @wolfies' answer, we have that $$1/T_n = \frac 1n \sum_{i=1}^n (-\ln X_i)$$ But $-\ln X_i \sim {\rm Exp}(1/\theta)$ (where $1/\theta$ is the scale parameter), which essentially is a Gamma distribution with shape parameter $1$, and so by the summation properties of the Gamma distribution, $$\sum_{i=1}^n (-\ln X_i) \sim {\rm Gamma}(n, 1/\theta)$$. Using the scaling properties of the Gamma distribution we obtain $$1/T_n \sim {\rm Gamma}(n, 1/(n\theta)) $$ Then the inverse of $1/T_n$ (i.e. $T_n$) follows an Inverse Gamma distribution, with same shape paramater and reciprocal scale parameter $$T_n \sim {\rm InvGamma}(n, n\theta)$$ that has variance $$ {\rm Var} (T_n) = \frac {n^2\theta^2}{(n-1)^2(n-2)}$$ as the Mathematica software gave. The leading term in the numerator is $n^2$ while the leading term in the denominator is $n^3$ so the limit of the variance of $T_n$ with respect to $n$ goes to zero.
Computing the Variance of an MLE
Combining @Xi'an comments and @wolfies' answer, we have that $$1/T_n = \frac 1n \sum_{i=1}^n (-\ln X_i)$$ But $-\ln X_i \sim {\rm Exp}(1/\theta)$ (where $1/\theta$ is the scale parameter), which essen
Computing the Variance of an MLE Combining @Xi'an comments and @wolfies' answer, we have that $$1/T_n = \frac 1n \sum_{i=1}^n (-\ln X_i)$$ But $-\ln X_i \sim {\rm Exp}(1/\theta)$ (where $1/\theta$ is the scale parameter), which essentially is a Gamma distribution with shape parameter $1$, and so by the summation properties of the Gamma distribution, $$\sum_{i=1}^n (-\ln X_i) \sim {\rm Gamma}(n, 1/\theta)$$. Using the scaling properties of the Gamma distribution we obtain $$1/T_n \sim {\rm Gamma}(n, 1/(n\theta)) $$ Then the inverse of $1/T_n$ (i.e. $T_n$) follows an Inverse Gamma distribution, with same shape paramater and reciprocal scale parameter $$T_n \sim {\rm InvGamma}(n, n\theta)$$ that has variance $$ {\rm Var} (T_n) = \frac {n^2\theta^2}{(n-1)^2(n-2)}$$ as the Mathematica software gave. The leading term in the numerator is $n^2$ while the leading term in the denominator is $n^3$ so the limit of the variance of $T_n$ with respect to $n$ goes to zero.
Computing the Variance of an MLE Combining @Xi'an comments and @wolfies' answer, we have that $$1/T_n = \frac 1n \sum_{i=1}^n (-\ln X_i)$$ But $-\ln X_i \sim {\rm Exp}(1/\theta)$ (where $1/\theta$ is the scale parameter), which essen
45,373
Computing the Variance of an MLE
Did you try to compute the Fisher information? Get the second derivative of the Log Likelihood, multiply by -1, and take the reciprocal. Evaluate at the MLE . Asymptotically, this approximates the variance of the MLE.
Computing the Variance of an MLE
Did you try to compute the Fisher information? Get the second derivative of the Log Likelihood, multiply by -1, and take the reciprocal. Evaluate at the MLE . Asymptotically, this approximates the var
Computing the Variance of an MLE Did you try to compute the Fisher information? Get the second derivative of the Log Likelihood, multiply by -1, and take the reciprocal. Evaluate at the MLE . Asymptotically, this approximates the variance of the MLE.
Computing the Variance of an MLE Did you try to compute the Fisher information? Get the second derivative of the Log Likelihood, multiply by -1, and take the reciprocal. Evaluate at the MLE . Asymptotically, this approximates the var
45,374
Computing the Variance of an MLE
The Problem Let $(X_1, \dots, X_n)$ denote a random sample of size $n$ drawn on $$X \sim \text{PowerFunction}(\theta,1) \quad \text{ with pdf} \quad f(x) = \theta x^{\theta-1} \text{ where } \quad 0<x<1.$$ Let $Z = -\sum_{i=1}^{n}\ln(X_i). \quad$ Find: $\quad Var\big[\dfrac{n}{Z}\big]$ Solution Let $Y = -ln(X)$. Then, by any of the usual methods of transformation, $Y \sim \text{Exponential}(\theta)$ with pdf $\theta e^{-\theta y}$. Next, the sum of $n$ iid Exponentials with rate $\theta$ is well-known to be $\text{Gamma}(n, 1/\theta)$ so $Z \sim \text{Gamma}(n, 1/\theta)$ with pdf, say, $g(z)$: We seek $Var(\frac{n}{Z})$: where I am using the Var function from the mathStatica package for Mathematica to automate the calculation. The limit of the latter tends to 0, as $n \rightarrow \infty$, as required.
Computing the Variance of an MLE
The Problem Let $(X_1, \dots, X_n)$ denote a random sample of size $n$ drawn on $$X \sim \text{PowerFunction}(\theta,1) \quad \text{ with pdf} \quad f(x) = \theta x^{\theta-1} \text{ where } \quad 0<
Computing the Variance of an MLE The Problem Let $(X_1, \dots, X_n)$ denote a random sample of size $n$ drawn on $$X \sim \text{PowerFunction}(\theta,1) \quad \text{ with pdf} \quad f(x) = \theta x^{\theta-1} \text{ where } \quad 0<x<1.$$ Let $Z = -\sum_{i=1}^{n}\ln(X_i). \quad$ Find: $\quad Var\big[\dfrac{n}{Z}\big]$ Solution Let $Y = -ln(X)$. Then, by any of the usual methods of transformation, $Y \sim \text{Exponential}(\theta)$ with pdf $\theta e^{-\theta y}$. Next, the sum of $n$ iid Exponentials with rate $\theta$ is well-known to be $\text{Gamma}(n, 1/\theta)$ so $Z \sim \text{Gamma}(n, 1/\theta)$ with pdf, say, $g(z)$: We seek $Var(\frac{n}{Z})$: where I am using the Var function from the mathStatica package for Mathematica to automate the calculation. The limit of the latter tends to 0, as $n \rightarrow \infty$, as required.
Computing the Variance of an MLE The Problem Let $(X_1, \dots, X_n)$ denote a random sample of size $n$ drawn on $$X \sim \text{PowerFunction}(\theta,1) \quad \text{ with pdf} \quad f(x) = \theta x^{\theta-1} \text{ where } \quad 0<
45,375
Bonferroni correction on multiple Kruskal-Wallis tests
You would use the Bonferroni for a one-way test. But let's be clear: You would not use the Bonferroni adjustment on the Kruskal-Wallis test itself. The Kruskal-Wallis test is an omnibus test, controlling for an overall false-positive rate. You would use the Bonferroni for post hoc Dunn's pairwise tests. Indeed, Dunn introduced the "Bonferroni" adjustment. You could also consider using more powerful family-wise error rate adjustment methods, such as the Holm-Sidak method, or still more-powerful false discovery rate adjustment methods, such as the Benjamini-Hochberg adjustment. These and other multiple comparisons adjustments are implemented specifically for Dunn's test in Stata (within Stata type net describe dunntest, from(https://alexisdinno.com/stata)), and in R (see http://cran.r-project.org/web/packages/dunn.test/). You might also consider using the more powerful Conover-Iman post hoc (only) test statistic. This test is implemented for Stata (within Stata type net describe conovertest, from(https://alexisdinno.com/stata)), and for R in the conover.test package, and includes the same selection of multiple comparisons adjustment procedures. EDIT: I missed that you seem to be wanting something like a multivariate (multiple dependent variables) nonparametric one-way ANOVA. Katz and McSweeney offer such a generalization of the Kruskal-Wallis test, although I am not aware of an implementation in software. They also provide post hoc Scheffé-like univariate and multivariate procedures, which ought to be amenable to multiple comparisons adjustments. Their test is likewise omnibus for all variables. References Conover, W. J. (1999). Practical Nonparametric Statistics. Wiley, Hoboken, NJ, 3rd edition. Conover, W. J. and Iman, R. L. (1979). On multiple-comparisons procedures. Technical Report. LA-7677-MS, Los Alamos Scientific Laboratory. Dunn, O. J. (1964). Multiple comparisons using rank sums. Technometrics, 6(3):241–252. Katz, B. M. and Mcsweeney, M. (1980). A multivariate Kruskal-Wallis test with post hoc procedures. Multivariate Behavioral Research, 15:281–297.
Bonferroni correction on multiple Kruskal-Wallis tests
You would use the Bonferroni for a one-way test. But let's be clear: You would not use the Bonferroni adjustment on the Kruskal-Wallis test itself. The Kruskal-Wallis test is an omnibus test, controll
Bonferroni correction on multiple Kruskal-Wallis tests You would use the Bonferroni for a one-way test. But let's be clear: You would not use the Bonferroni adjustment on the Kruskal-Wallis test itself. The Kruskal-Wallis test is an omnibus test, controlling for an overall false-positive rate. You would use the Bonferroni for post hoc Dunn's pairwise tests. Indeed, Dunn introduced the "Bonferroni" adjustment. You could also consider using more powerful family-wise error rate adjustment methods, such as the Holm-Sidak method, or still more-powerful false discovery rate adjustment methods, such as the Benjamini-Hochberg adjustment. These and other multiple comparisons adjustments are implemented specifically for Dunn's test in Stata (within Stata type net describe dunntest, from(https://alexisdinno.com/stata)), and in R (see http://cran.r-project.org/web/packages/dunn.test/). You might also consider using the more powerful Conover-Iman post hoc (only) test statistic. This test is implemented for Stata (within Stata type net describe conovertest, from(https://alexisdinno.com/stata)), and for R in the conover.test package, and includes the same selection of multiple comparisons adjustment procedures. EDIT: I missed that you seem to be wanting something like a multivariate (multiple dependent variables) nonparametric one-way ANOVA. Katz and McSweeney offer such a generalization of the Kruskal-Wallis test, although I am not aware of an implementation in software. They also provide post hoc Scheffé-like univariate and multivariate procedures, which ought to be amenable to multiple comparisons adjustments. Their test is likewise omnibus for all variables. References Conover, W. J. (1999). Practical Nonparametric Statistics. Wiley, Hoboken, NJ, 3rd edition. Conover, W. J. and Iman, R. L. (1979). On multiple-comparisons procedures. Technical Report. LA-7677-MS, Los Alamos Scientific Laboratory. Dunn, O. J. (1964). Multiple comparisons using rank sums. Technometrics, 6(3):241–252. Katz, B. M. and Mcsweeney, M. (1980). A multivariate Kruskal-Wallis test with post hoc procedures. Multivariate Behavioral Research, 15:281–297.
Bonferroni correction on multiple Kruskal-Wallis tests You would use the Bonferroni for a one-way test. But let's be clear: You would not use the Bonferroni adjustment on the Kruskal-Wallis test itself. The Kruskal-Wallis test is an omnibus test, controll
45,376
How to tell if a mixture of Gaussians will be multimodal
I doubt you will find an explicit solution. The number of modes is the number of roots of the first derivative of the density function - which is quite messy - I am quite sure you can't find an explicit solution.
How to tell if a mixture of Gaussians will be multimodal
I doubt you will find an explicit solution. The number of modes is the number of roots of the first derivative of the density function - which is quite messy - I am quite sure you can't find an explic
How to tell if a mixture of Gaussians will be multimodal I doubt you will find an explicit solution. The number of modes is the number of roots of the first derivative of the density function - which is quite messy - I am quite sure you can't find an explicit solution.
How to tell if a mixture of Gaussians will be multimodal I doubt you will find an explicit solution. The number of modes is the number of roots of the first derivative of the density function - which is quite messy - I am quite sure you can't find an explic
45,377
How to tell if a mixture of Gaussians will be multimodal
Miguel Carrera-Perpinan has a webpage on this topic with associated software. This does not directly solve your question, but indicates that unidimensional Gaussian mixtures with $k$ components have at most $k$ modes; unidimensional non-Gaussian mixtures with $k$ components may have more than $k$ modes; multidimensional mixtures with $k$ components may have more than $k$ modes. In the unidimensional Gaussian, a component will induce a mode near its mean if the variance is small enough (relative to the other variances) and if the weight is large enough (relative to the other weights). This may suggest a specific numerical way to check for modes by changing the variance of one component until a mode appears or disappears near a component mean. Obviously, running EM algorithms starting from each normal mean should indicate whether or not this component induces a local mode. Else, you may always follow Larry Wasserman's advice: "mixtures, like tequila, are inherently evil and should be avoided at all costs."
How to tell if a mixture of Gaussians will be multimodal
Miguel Carrera-Perpinan has a webpage on this topic with associated software. This does not directly solve your question, but indicates that unidimensional Gaussian mixtures with $k$ components have
How to tell if a mixture of Gaussians will be multimodal Miguel Carrera-Perpinan has a webpage on this topic with associated software. This does not directly solve your question, but indicates that unidimensional Gaussian mixtures with $k$ components have at most $k$ modes; unidimensional non-Gaussian mixtures with $k$ components may have more than $k$ modes; multidimensional mixtures with $k$ components may have more than $k$ modes. In the unidimensional Gaussian, a component will induce a mode near its mean if the variance is small enough (relative to the other variances) and if the weight is large enough (relative to the other weights). This may suggest a specific numerical way to check for modes by changing the variance of one component until a mode appears or disappears near a component mean. Obviously, running EM algorithms starting from each normal mean should indicate whether or not this component induces a local mode. Else, you may always follow Larry Wasserman's advice: "mixtures, like tequila, are inherently evil and should be avoided at all costs."
How to tell if a mixture of Gaussians will be multimodal Miguel Carrera-Perpinan has a webpage on this topic with associated software. This does not directly solve your question, but indicates that unidimensional Gaussian mixtures with $k$ components have
45,378
Transforming a variable when original variable does not have explantory power
This depends on if you are a purist, a pragmatist, or a data dredger. The purist will only ever try one transformation, and that is based only on the science and previous knowledge and will be chosen before any data is collected (or looked at). This is the safest approach, but can also loose out on gaining insight from the data. The data dredger will try every possible transformation until they find one that gives them the answer that they want. This can result in impressive results, but also ends in over fitting models and unreproducible results. The pragmatist (the largest and most productive group) recognizes that there are things that we can learn from the data, but also is wary of over fitting the data. They will look at a few possible transforms that are justified by the science, or try splines or other smooths with a reasonable smoothness constraint. They will also do things like cross-validation to make sure that their experimenting has not resulted in over fitting and reign things back if it has. They will then also be honest about what they did (explaining which transforms were experimented with in the discussion) and look for validation in a follow-up study. I recommend the pragmatic approach.
Transforming a variable when original variable does not have explantory power
This depends on if you are a purist, a pragmatist, or a data dredger. The purist will only ever try one transformation, and that is based only on the science and previous knowledge and will be chose
Transforming a variable when original variable does not have explantory power This depends on if you are a purist, a pragmatist, or a data dredger. The purist will only ever try one transformation, and that is based only on the science and previous knowledge and will be chosen before any data is collected (or looked at). This is the safest approach, but can also loose out on gaining insight from the data. The data dredger will try every possible transformation until they find one that gives them the answer that they want. This can result in impressive results, but also ends in over fitting models and unreproducible results. The pragmatist (the largest and most productive group) recognizes that there are things that we can learn from the data, but also is wary of over fitting the data. They will look at a few possible transforms that are justified by the science, or try splines or other smooths with a reasonable smoothness constraint. They will also do things like cross-validation to make sure that their experimenting has not resulted in over fitting and reign things back if it has. They will then also be honest about what they did (explaining which transforms were experimented with in the discussion) and look for validation in a follow-up study. I recommend the pragmatic approach.
Transforming a variable when original variable does not have explantory power This depends on if you are a purist, a pragmatist, or a data dredger. The purist will only ever try one transformation, and that is based only on the science and previous knowledge and will be chose
45,379
Transforming a variable when original variable does not have explantory power
It's a legitimate practice you are describing. As a matter of fact, having all variables linear is a simplification out of necessity. Usually, we don't know what is a true relationship between variables, so we model them linearly. If you happen to know the relationships, often non-linear, then definitely go for it. Here's an example, where the true process is $y_t=sin(\beta t)+\varepsilon_t$. First I model it with $y_t=\beta' t+\varepsilon_t$, then model with a proper specification. In the first case the coefficient comes not significant, in the second case it's significant. MATLAB Code: rng(0); x = (1:100)'/100*pi; % data generating process y = sin(x) + randn(100,1)/2; % fit linear x fit = fitlm(x,y) % fit sin(x) fit2 = fitlm(sin(x),y) plot([y fit.Fitted fit2.Fitted]) legend({'actual' ,'fitted x','fitted sin x'}) OUTPUT: fit = Linear regression model: y ~ 1 + x1 Estimated Coefficients: Estimate SE tStat pValue ________ ________ _______ __________ (Intercept) 0.89621 0.12771 7.0177 2.9539e-10 x1 -0.12487 0.069885 -1.7868 0.077068 Number of observations: 100, Error degrees of freedom: 98 Root Mean Squared Error: 0.634 R-squared: 0.0315, Adjusted R-Squared 0.0217 F-statistic vs. constant model: 3.19, p-value = 0.0771 fit2 = Linear regression model: y ~ 1 + x1 Estimated Coefficients: Estimate SE tStat pValue ________ _______ ______ __________ (Intercept) 0.13799 0.13389 1.0306 0.30527 x1 0.87991 0.18936 4.6468 1.0507e-05 Number of observations: 100, Error degrees of freedom: 98 Root Mean Squared Error: 0.583 R-squared: 0.181, Adjusted R-Squared 0.172 F-statistic vs. constant model: 21.6, p-value = 1.05e-05
Transforming a variable when original variable does not have explantory power
It's a legitimate practice you are describing. As a matter of fact, having all variables linear is a simplification out of necessity. Usually, we don't know what is a true relationship between variabl
Transforming a variable when original variable does not have explantory power It's a legitimate practice you are describing. As a matter of fact, having all variables linear is a simplification out of necessity. Usually, we don't know what is a true relationship between variables, so we model them linearly. If you happen to know the relationships, often non-linear, then definitely go for it. Here's an example, where the true process is $y_t=sin(\beta t)+\varepsilon_t$. First I model it with $y_t=\beta' t+\varepsilon_t$, then model with a proper specification. In the first case the coefficient comes not significant, in the second case it's significant. MATLAB Code: rng(0); x = (1:100)'/100*pi; % data generating process y = sin(x) + randn(100,1)/2; % fit linear x fit = fitlm(x,y) % fit sin(x) fit2 = fitlm(sin(x),y) plot([y fit.Fitted fit2.Fitted]) legend({'actual' ,'fitted x','fitted sin x'}) OUTPUT: fit = Linear regression model: y ~ 1 + x1 Estimated Coefficients: Estimate SE tStat pValue ________ ________ _______ __________ (Intercept) 0.89621 0.12771 7.0177 2.9539e-10 x1 -0.12487 0.069885 -1.7868 0.077068 Number of observations: 100, Error degrees of freedom: 98 Root Mean Squared Error: 0.634 R-squared: 0.0315, Adjusted R-Squared 0.0217 F-statistic vs. constant model: 3.19, p-value = 0.0771 fit2 = Linear regression model: y ~ 1 + x1 Estimated Coefficients: Estimate SE tStat pValue ________ _______ ______ __________ (Intercept) 0.13799 0.13389 1.0306 0.30527 x1 0.87991 0.18936 4.6468 1.0507e-05 Number of observations: 100, Error degrees of freedom: 98 Root Mean Squared Error: 0.583 R-squared: 0.181, Adjusted R-Squared 0.172 F-statistic vs. constant model: 21.6, p-value = 1.05e-05
Transforming a variable when original variable does not have explantory power It's a legitimate practice you are describing. As a matter of fact, having all variables linear is a simplification out of necessity. Usually, we don't know what is a true relationship between variabl
45,380
Transforming a variable when original variable does not have explantory power
This is absolutely good practice! If the true relationship between your response and the explanatory variables is logarithmic then your model ought to reflect this. Of course, we never know for sure the nature of the true relationship so we do things like plot the data or fit the model in different ways (with and without a log transformation) and assess fit.
Transforming a variable when original variable does not have explantory power
This is absolutely good practice! If the true relationship between your response and the explanatory variables is logarithmic then your model ought to reflect this. Of course, we never know for sure t
Transforming a variable when original variable does not have explantory power This is absolutely good practice! If the true relationship between your response and the explanatory variables is logarithmic then your model ought to reflect this. Of course, we never know for sure the nature of the true relationship so we do things like plot the data or fit the model in different ways (with and without a log transformation) and assess fit.
Transforming a variable when original variable does not have explantory power This is absolutely good practice! If the true relationship between your response and the explanatory variables is logarithmic then your model ought to reflect this. Of course, we never know for sure t
45,381
Confidence intervals for maximum likelihood estimator with constraints
Your question is easy to answer if you are not too serious about $\theta_i\in[0,1]$. Is $\theta_i\in(0,1)$ good enough? Let's say it is. Then, instead of maximizing the likelihood function $L(\theta)$ in $\theta$, you are going to do a change of variables, and instead you maximize the likelihood function $L(\alpha)=L(\theta(\alpha))$ in $\alpha$. What's $\theta(\alpha)$, you ask? Well, if $\theta$ is a $K$ dimensional vector, then we let $\alpha$ be a $(K-1)$ dimensional vector and set: \begin{align} \theta_1 &= \frac{\exp(\alpha_1)}{1+\sum exp(\alpha_k)} \\ \theta_2 &= \frac{\exp(\alpha_2)}{1+\sum exp(\alpha_k)} \\ &\vdots\\ \theta_{K-1} &= \frac{\exp(\alpha_{K-1})}{1+\sum exp(\alpha_k)} \\ \theta_K &= \frac{1}{1+\sum exp(\alpha_k)} \\ \end{align} After you substitute $\alpha$ into your likelihood function, you can maximize it unconstrained. The $\alpha$ can be any real number. The $\theta(\alpha)$ function magically imposes all your constraints on $\theta$. So, now the usual theorems proving consistency and aymptotic normality of the MLE follow. What about $\theta$, though? Well, after you have estimated the $\alpha$, you just substitute them into the formulas above to get your estimator for $\theta$. What is the distribution of $\theta$? It is asymptotically normal with mean $\theta_0$, the true value of $\theta$, and variance $V(\hat{\theta})=\frac{\partial \theta}{\partial \alpha}' \ V(\hat{\alpha}) \frac{\partial \theta}{\partial \alpha}$. As you say, $V(\hat{\theta})$ won't be full rank. Obviously, it can't be full rank. Why not? Because we know the variance of $\sum \hat{\theta}_i$ has to be zero---this sum is always 1, so its variance must be zero. A non-invertible variance matrix is not a problem, however, unless you are using it for some purpose it can't be used for (say to test the null hypothesis that $\sum \theta_i = 1$). If you are trying to do that, then the error message telling you that you can't divide by zero is an excellent warning that you are doing something silly. What if you are serious about including the endpoints of your interval? Well, that's much harder. What I would suggest is that you think about whether you are really serious. For example, if the $\theta_i$ are probabilities (and that's what your constraints make me think they are), then you really should not be expecting the usual maximum likelihood procedures to give you correct standard errors. For example, if $\theta_1$ is the probability of heads and $\theta_2$ is the probability of tails, and your dataset looks like ten heads in a row, then the maximum likelihood estimate is $\hat{\theta}_1=1$ and $\hat{\theta}_2=0$. What's the variance of the maximum likelihood estimator evaluated at this estimate? Zero. If you want to test the null hypothesis that $\theta_1=0.5$, what do you do? You sure don't do this: "Reject null if $\left|\frac{\hat{\theta}_1-0.5}{\sqrt{\hat{V}(\hat{\theta}_1)}}\right|>1.96$" Instead, you calculate the probability that you get ten heads in a row with a fair coin. If that probability is lower than whatever significance level you picked, then you reject.
Confidence intervals for maximum likelihood estimator with constraints
Your question is easy to answer if you are not too serious about $\theta_i\in[0,1]$. Is $\theta_i\in(0,1)$ good enough? Let's say it is. Then, instead of maximizing the likelihood function $L(\thet
Confidence intervals for maximum likelihood estimator with constraints Your question is easy to answer if you are not too serious about $\theta_i\in[0,1]$. Is $\theta_i\in(0,1)$ good enough? Let's say it is. Then, instead of maximizing the likelihood function $L(\theta)$ in $\theta$, you are going to do a change of variables, and instead you maximize the likelihood function $L(\alpha)=L(\theta(\alpha))$ in $\alpha$. What's $\theta(\alpha)$, you ask? Well, if $\theta$ is a $K$ dimensional vector, then we let $\alpha$ be a $(K-1)$ dimensional vector and set: \begin{align} \theta_1 &= \frac{\exp(\alpha_1)}{1+\sum exp(\alpha_k)} \\ \theta_2 &= \frac{\exp(\alpha_2)}{1+\sum exp(\alpha_k)} \\ &\vdots\\ \theta_{K-1} &= \frac{\exp(\alpha_{K-1})}{1+\sum exp(\alpha_k)} \\ \theta_K &= \frac{1}{1+\sum exp(\alpha_k)} \\ \end{align} After you substitute $\alpha$ into your likelihood function, you can maximize it unconstrained. The $\alpha$ can be any real number. The $\theta(\alpha)$ function magically imposes all your constraints on $\theta$. So, now the usual theorems proving consistency and aymptotic normality of the MLE follow. What about $\theta$, though? Well, after you have estimated the $\alpha$, you just substitute them into the formulas above to get your estimator for $\theta$. What is the distribution of $\theta$? It is asymptotically normal with mean $\theta_0$, the true value of $\theta$, and variance $V(\hat{\theta})=\frac{\partial \theta}{\partial \alpha}' \ V(\hat{\alpha}) \frac{\partial \theta}{\partial \alpha}$. As you say, $V(\hat{\theta})$ won't be full rank. Obviously, it can't be full rank. Why not? Because we know the variance of $\sum \hat{\theta}_i$ has to be zero---this sum is always 1, so its variance must be zero. A non-invertible variance matrix is not a problem, however, unless you are using it for some purpose it can't be used for (say to test the null hypothesis that $\sum \theta_i = 1$). If you are trying to do that, then the error message telling you that you can't divide by zero is an excellent warning that you are doing something silly. What if you are serious about including the endpoints of your interval? Well, that's much harder. What I would suggest is that you think about whether you are really serious. For example, if the $\theta_i$ are probabilities (and that's what your constraints make me think they are), then you really should not be expecting the usual maximum likelihood procedures to give you correct standard errors. For example, if $\theta_1$ is the probability of heads and $\theta_2$ is the probability of tails, and your dataset looks like ten heads in a row, then the maximum likelihood estimate is $\hat{\theta}_1=1$ and $\hat{\theta}_2=0$. What's the variance of the maximum likelihood estimator evaluated at this estimate? Zero. If you want to test the null hypothesis that $\theta_1=0.5$, what do you do? You sure don't do this: "Reject null if $\left|\frac{\hat{\theta}_1-0.5}{\sqrt{\hat{V}(\hat{\theta}_1)}}\right|>1.96$" Instead, you calculate the probability that you get ten heads in a row with a fair coin. If that probability is lower than whatever significance level you picked, then you reject.
Confidence intervals for maximum likelihood estimator with constraints Your question is easy to answer if you are not too serious about $\theta_i\in[0,1]$. Is $\theta_i\in(0,1)$ good enough? Let's say it is. Then, instead of maximizing the likelihood function $L(\thet
45,382
Confidence intervals for maximum likelihood estimator with constraints
There are some regularity conditions on the theorem that tells us that the MLE is asymptotically normal (full details here: http://en.wikipedia.org/wiki/Maximum_likelihood#Asymptotic_normality). Notice the condition that says $f(x|θ) > 0$ and is twice continuously differentiable in $\theta$ in some neighborhood $N$ of $θ_0$ where $θ_0$ is the true value. In other words, if the true value $\theta_0$ is on the boundary of the parameter space (i.e, 0 or 1) then the conditions of this theorem are not satisfied. If a closed form solution is what you desire, then I would search for a closed form solution of your MLE and try to find a distribution of that random variable. I suspect this will not be trivial so you may have to re-ask the question with more information provided. I also recommend this resource as guidance: http://www.stat.tamu.edu/~suhasini/teaching613/nonstandard_methods.pdf If a closed form solution is not desired, bootstrapping is the quickest way to go here.
Confidence intervals for maximum likelihood estimator with constraints
There are some regularity conditions on the theorem that tells us that the MLE is asymptotically normal (full details here: http://en.wikipedia.org/wiki/Maximum_likelihood#Asymptotic_normality). Notic
Confidence intervals for maximum likelihood estimator with constraints There are some regularity conditions on the theorem that tells us that the MLE is asymptotically normal (full details here: http://en.wikipedia.org/wiki/Maximum_likelihood#Asymptotic_normality). Notice the condition that says $f(x|θ) > 0$ and is twice continuously differentiable in $\theta$ in some neighborhood $N$ of $θ_0$ where $θ_0$ is the true value. In other words, if the true value $\theta_0$ is on the boundary of the parameter space (i.e, 0 or 1) then the conditions of this theorem are not satisfied. If a closed form solution is what you desire, then I would search for a closed form solution of your MLE and try to find a distribution of that random variable. I suspect this will not be trivial so you may have to re-ask the question with more information provided. I also recommend this resource as guidance: http://www.stat.tamu.edu/~suhasini/teaching613/nonstandard_methods.pdf If a closed form solution is not desired, bootstrapping is the quickest way to go here.
Confidence intervals for maximum likelihood estimator with constraints There are some regularity conditions on the theorem that tells us that the MLE is asymptotically normal (full details here: http://en.wikipedia.org/wiki/Maximum_likelihood#Asymptotic_normality). Notic
45,383
Diagonal elements of the inverted correlation matrix
Yes, it is true: the diagonal elements can never be less than unity. By permuting the order of the variables, any diagonal element can be made to appear in the upper left corner, so it suffices to study that element. The statement is trivially true for $n=1$. For $n\gt 1$, any $n$ by $n$ correlation matrix can be written in block form as $$\mathbb C = \pmatrix{ 1 & \mathbf {\vec e} \\ \mathbf e &\mathbb D}$$ where $\mathbb D$ is the correlation matrix of variables $2, 3, \ldots, n$ and $\mathbf {\vec e}$ is the transpose of the column vector $\mathbf e$ containing the correlations between the first variable and the remaining variables. Assume for the moment that $\mathbb C$ is invertible. By Cramer's Rule, the upper left corner of its inverse is $$\left(\mathbb C^{-1}\right)_{11} = \det \mathbb D / \det \mathbb C.$$ If we can prove that this ratio cannot be less than $1$, we are done in the general case (even for singular $\mathbb C$), because the entries in the inverse are continuous functions of $\mathbb C$ and the non-invertible ones form a lower-dimensional submanifold of the space of all such $\mathbb C$. The problem is reduced, then, to showing that determinants of invertible correlation matrices cannot increase as the number of variables is increased. Invertibility of $\mathbb C$ implies $\mathbb D$ is invertible, enabling allows row-reduction to simplify the top row. This will help us relate the determinant of $\mathbb C$ to that of $\mathbb D$. Reduction of that row amounts to left-multiplication by the inverse of $$\mathbb P = \pmatrix{ 1 & \mathbf {\vec e}\,\mathbb D ^{-1} \\ \mathbf 0 &\mathbf 1_{n-1,n-1}},$$ showing that $$ \mathbb C = \mathbb P\pmatrix{ 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e &\mathbf {\vec 0} \\ \mathbf e &\mathbb D}.$$ Taking determinants yields $$\det \mathbb C = \det \mathbb P \det \pmatrix{ 1 - \mathbf {\vec e}\,\mathbb D ^{-1} \,\mathbf e &\mathbf {\vec 0} \\ \mathbf e &\mathbb D} = \left( 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \right)\det \mathbb D$$ because $\det \mathbb P = \det(1)\det \mathbf{1}_{n-1,n-1}=1$. Since $\mathbb D$, being an invertible correlation matrix in its own right, is positive-definite, and $\mathbb C$ is positive definite, we immediately deduce that $\mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \ge 0$. $\det \mathbb D \gt 0$. $\det \mathbb C \gt 0$. Therefore $1 \ge 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \gt 0$, whence $\det \mathbb C \le \det \mathbb D$, QED.
Diagonal elements of the inverted correlation matrix
Yes, it is true: the diagonal elements can never be less than unity. By permuting the order of the variables, any diagonal element can be made to appear in the upper left corner, so it suffices to stu
Diagonal elements of the inverted correlation matrix Yes, it is true: the diagonal elements can never be less than unity. By permuting the order of the variables, any diagonal element can be made to appear in the upper left corner, so it suffices to study that element. The statement is trivially true for $n=1$. For $n\gt 1$, any $n$ by $n$ correlation matrix can be written in block form as $$\mathbb C = \pmatrix{ 1 & \mathbf {\vec e} \\ \mathbf e &\mathbb D}$$ where $\mathbb D$ is the correlation matrix of variables $2, 3, \ldots, n$ and $\mathbf {\vec e}$ is the transpose of the column vector $\mathbf e$ containing the correlations between the first variable and the remaining variables. Assume for the moment that $\mathbb C$ is invertible. By Cramer's Rule, the upper left corner of its inverse is $$\left(\mathbb C^{-1}\right)_{11} = \det \mathbb D / \det \mathbb C.$$ If we can prove that this ratio cannot be less than $1$, we are done in the general case (even for singular $\mathbb C$), because the entries in the inverse are continuous functions of $\mathbb C$ and the non-invertible ones form a lower-dimensional submanifold of the space of all such $\mathbb C$. The problem is reduced, then, to showing that determinants of invertible correlation matrices cannot increase as the number of variables is increased. Invertibility of $\mathbb C$ implies $\mathbb D$ is invertible, enabling allows row-reduction to simplify the top row. This will help us relate the determinant of $\mathbb C$ to that of $\mathbb D$. Reduction of that row amounts to left-multiplication by the inverse of $$\mathbb P = \pmatrix{ 1 & \mathbf {\vec e}\,\mathbb D ^{-1} \\ \mathbf 0 &\mathbf 1_{n-1,n-1}},$$ showing that $$ \mathbb C = \mathbb P\pmatrix{ 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e &\mathbf {\vec 0} \\ \mathbf e &\mathbb D}.$$ Taking determinants yields $$\det \mathbb C = \det \mathbb P \det \pmatrix{ 1 - \mathbf {\vec e}\,\mathbb D ^{-1} \,\mathbf e &\mathbf {\vec 0} \\ \mathbf e &\mathbb D} = \left( 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \right)\det \mathbb D$$ because $\det \mathbb P = \det(1)\det \mathbf{1}_{n-1,n-1}=1$. Since $\mathbb D$, being an invertible correlation matrix in its own right, is positive-definite, and $\mathbb C$ is positive definite, we immediately deduce that $\mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \ge 0$. $\det \mathbb D \gt 0$. $\det \mathbb C \gt 0$. Therefore $1 \ge 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \gt 0$, whence $\det \mathbb C \le \det \mathbb D$, QED.
Diagonal elements of the inverted correlation matrix Yes, it is true: the diagonal elements can never be less than unity. By permuting the order of the variables, any diagonal element can be made to appear in the upper left corner, so it suffices to stu
45,384
Which font to use in a plot to maximize clarity?
Contrary to your currently accepted answer, although obviously there is an artistic element to the design of quantitative graphics (as emphasized by The National Geographic), there do exist objective principles and good advice based on them. This is not wholly a "matter of personal preference." Fine map-making is an art; it is also a science, and the one should complement the other on equal terms. (Charles Riddiford, quoted in the Smithsonian article, ibid.) But what exactly is the "science?" It is helpful to look into the literature on cartography (map making): people have been making maps much longer than they have been making statistical graphics, yet the same principles of construction and interpretation apply. For a good list of references to the literature, consult the Wikipedia article on cartographic labeling. Practical advice given by a major vendor of cartographic software for making Web graphics can be found at http://mappingcenter.esri.com/index.cfm?fa=ask.answers&q=1469. Good web fonts have a generous amount of space between each character, as well as the amount of whitespace within the characters (glyphs) themselves. A tall x-height also opens up the space within a character. These properties are what make these fonts so legible on screen. The accepted answer to a parallel question on our sister site, GIS, recommends TypeBrewer, software to help ... explore typographic alternatives and see the impact that various elements of type have on the overall look and feel of a [graphic]. Standard textbooks on cartographic design have extensive analyses and discussions of typographics. Borden Dent, author of the popular Cartography: Thematic Map Design (Fifth Edition, McGraw-Hill, 1999) writes [Graphic] lettering should be viewed first as a functional symbol on the map, and only secondarily as an aesthetic object. By "map lettering" Dent means the "selection of lettering type and its placement" on the graphic. Selection elements include style and size; placement elements include position and spacing. Dent discusses several kinds of research, including psychological experiments intended to identify typographic principles that communicate information quickly, clearly and accurately; as well as empirical experiments that characterize how maps are actually made. As one might imagine, much of this is contradictory, but some general tendencies emerge. They lead to advice that ranges from considerations about labeling points (e.g., not all positions of labels relative to point symbols are equally effective; don't use point symbols that can be confused with letters; avoid other "distracting" elements nearby) to labeling linear and polygonal features. Much attention is also paid to titles, axes, legends, and other auxiliary matter that is essential for communicating quantitative information. One particularly intriguing experimental finding is that Choice of typeface has little effect on legibility in the [graphic] context. (Quoting Richard J. Phillips, Elizabeth Noyes, and R. J. Audley, "Searching for Names on Maps," Cartographic Journal 15 (1978): 72-76.) Instead, other aspects are more important, especially consistency of the type in the graphic and its presence in an associated legend: when the reader knows what kind of typeface to expect, they can search more quickly and accurately within the graphic itself. Surely this has implications for certain kinds of statistical graphics, such as those used to display and summarize raw data. This leads to a final caution: it is evident that one's design choices for making statistical graphics will depend partly on the intended purpose for the graphic, on the medium (such as a Web page versus print) and on how the audience is intended to interact with and use the graphic. Although such considerations would seem to make typographical choices almost arbitrary and uniquely personal, we should nevertheless seek to understand the visual and psychological principles that underlie how people read and make sense of maps and statistical graphics so that we can make well reasoned choices that are likely to work well in each application.
Which font to use in a plot to maximize clarity?
Contrary to your currently accepted answer, although obviously there is an artistic element to the design of quantitative graphics (as emphasized by The National Geographic), there do exist objective
Which font to use in a plot to maximize clarity? Contrary to your currently accepted answer, although obviously there is an artistic element to the design of quantitative graphics (as emphasized by The National Geographic), there do exist objective principles and good advice based on them. This is not wholly a "matter of personal preference." Fine map-making is an art; it is also a science, and the one should complement the other on equal terms. (Charles Riddiford, quoted in the Smithsonian article, ibid.) But what exactly is the "science?" It is helpful to look into the literature on cartography (map making): people have been making maps much longer than they have been making statistical graphics, yet the same principles of construction and interpretation apply. For a good list of references to the literature, consult the Wikipedia article on cartographic labeling. Practical advice given by a major vendor of cartographic software for making Web graphics can be found at http://mappingcenter.esri.com/index.cfm?fa=ask.answers&q=1469. Good web fonts have a generous amount of space between each character, as well as the amount of whitespace within the characters (glyphs) themselves. A tall x-height also opens up the space within a character. These properties are what make these fonts so legible on screen. The accepted answer to a parallel question on our sister site, GIS, recommends TypeBrewer, software to help ... explore typographic alternatives and see the impact that various elements of type have on the overall look and feel of a [graphic]. Standard textbooks on cartographic design have extensive analyses and discussions of typographics. Borden Dent, author of the popular Cartography: Thematic Map Design (Fifth Edition, McGraw-Hill, 1999) writes [Graphic] lettering should be viewed first as a functional symbol on the map, and only secondarily as an aesthetic object. By "map lettering" Dent means the "selection of lettering type and its placement" on the graphic. Selection elements include style and size; placement elements include position and spacing. Dent discusses several kinds of research, including psychological experiments intended to identify typographic principles that communicate information quickly, clearly and accurately; as well as empirical experiments that characterize how maps are actually made. As one might imagine, much of this is contradictory, but some general tendencies emerge. They lead to advice that ranges from considerations about labeling points (e.g., not all positions of labels relative to point symbols are equally effective; don't use point symbols that can be confused with letters; avoid other "distracting" elements nearby) to labeling linear and polygonal features. Much attention is also paid to titles, axes, legends, and other auxiliary matter that is essential for communicating quantitative information. One particularly intriguing experimental finding is that Choice of typeface has little effect on legibility in the [graphic] context. (Quoting Richard J. Phillips, Elizabeth Noyes, and R. J. Audley, "Searching for Names on Maps," Cartographic Journal 15 (1978): 72-76.) Instead, other aspects are more important, especially consistency of the type in the graphic and its presence in an associated legend: when the reader knows what kind of typeface to expect, they can search more quickly and accurately within the graphic itself. Surely this has implications for certain kinds of statistical graphics, such as those used to display and summarize raw data. This leads to a final caution: it is evident that one's design choices for making statistical graphics will depend partly on the intended purpose for the graphic, on the medium (such as a Web page versus print) and on how the audience is intended to interact with and use the graphic. Although such considerations would seem to make typographical choices almost arbitrary and uniquely personal, we should nevertheless seek to understand the visual and psychological principles that underlie how people read and make sense of maps and statistical graphics so that we can make well reasoned choices that are likely to work well in each application.
Which font to use in a plot to maximize clarity? Contrary to your currently accepted answer, although obviously there is an artistic element to the design of quantitative graphics (as emphasized by The National Geographic), there do exist objective
45,385
Which font to use in a plot to maximize clarity?
This thread covers the topic pretty well I think. One thing that has not been mentioned there however is Normschrift (German for "standard font"). It is a type of font that has been standardized in various DIN and ISO norms, and it completely removes any ambiguity from the letters and numbers. It's probably not the prettiest font, but it is commonly used in technical drawings and CAD plots. Here is one example of it. However, after all, I think it stills remains a matter of personal preference.* Just try to use a font that matches well with the font you used for your body, e.g. avoid fonts that are too similar (e.g. Arial and Helvetica). *Edit: "A matter of personal preference" is not supposed to mean that everything is completely arbitrary and there are no rules you should follow. There are. However, they are not as strict as 'Always use this very font, no alternatives accepted.' See also my comment on whuber's answer. Note: I would have posted this as a comment rather than as an answer, but I did not have the reputation to do so...
Which font to use in a plot to maximize clarity?
This thread covers the topic pretty well I think. One thing that has not been mentioned there however is Normschrift (German for "standard font"). It is a type of font that has been standardized in va
Which font to use in a plot to maximize clarity? This thread covers the topic pretty well I think. One thing that has not been mentioned there however is Normschrift (German for "standard font"). It is a type of font that has been standardized in various DIN and ISO norms, and it completely removes any ambiguity from the letters and numbers. It's probably not the prettiest font, but it is commonly used in technical drawings and CAD plots. Here is one example of it. However, after all, I think it stills remains a matter of personal preference.* Just try to use a font that matches well with the font you used for your body, e.g. avoid fonts that are too similar (e.g. Arial and Helvetica). *Edit: "A matter of personal preference" is not supposed to mean that everything is completely arbitrary and there are no rules you should follow. There are. However, they are not as strict as 'Always use this very font, no alternatives accepted.' See also my comment on whuber's answer. Note: I would have posted this as a comment rather than as an answer, but I did not have the reputation to do so...
Which font to use in a plot to maximize clarity? This thread covers the topic pretty well I think. One thing that has not been mentioned there however is Normschrift (German for "standard font"). It is a type of font that has been standardized in va
45,386
Hierarchical or TwoStep cluster analysis for binary data?
1) The tech support reply that you link to and which reads that hierarchical clustering is less appropriate for binary data than two-step clustering is, is incorrect for me. It is true that when there is a substantial amount of distances between objects which are not of unique value ("tied" or "duplicate" distances) - which is quite expectable a situation with any few-valued discrete data, not only binary data, - the results of clustering will strongly depend on the order of processing of the objects. But this scandal accompanies any clustering method, any method directly or indirectly basing itself on some distance/similarity measure. If there are some ties in a quantity which determine clusters - that can show up, as unstable solutions. The unstability caused by ties is thus natural and cannot be an argument against this or that method potentially suffering from it. In the particular case of the linked note, you can make certain that two-step cluster method will also - like hierarchical method - give from time to time different results under different sort order of the observations in the provided dataset. So, I don't see any advantage of one method over the other in that respect. 2) Hierarchical cluster is well suited for binary data because it allows to select from a great many distance functions invented for binary data and theoretically more sound for them than simply Euclidean distance. However, some methods of agglomeration will call for (squared) Euclidean distance only. Here's a few of points to remember about hierarchical clustering. One important issue about binary/dichotomous data when selecting a similarity function is whether your data is ordinal binary (asymmetric categories: present vs absent) or nominal binary (symmetric categories: this vs that) for you. In other words, should 0-0 match be a ground of similarity or not? (You may want to read answers like this, this.) 3) Two-step cluster method of SPSS could be used with binary/dichotomous data as an alternative to hierarchical (and to some other) methods (some related answers this, this). However, two-step's processing of categorical variables employs log-likelihood distance which is right for nominal, not "ordinal binary" categories. So, if you treat your data as the latter, you have problems. Treating the variables as quantitative (interval) won't solve it. In some specific cases it is possible to convert a number of binary features into one or more multinomial nominal features quite effectively; in general, it would be quite a tricky task to do it without losing information. An experienced analyst may experiment with optimal scaling techniques and multiple correspondence analysis to see if multiple binary features can be well replaced by a smaller number of equivalent quantitative ones.
Hierarchical or TwoStep cluster analysis for binary data?
1) The tech support reply that you link to and which reads that hierarchical clustering is less appropriate for binary data than two-step clustering is, is incorrect for me. It is true that when there
Hierarchical or TwoStep cluster analysis for binary data? 1) The tech support reply that you link to and which reads that hierarchical clustering is less appropriate for binary data than two-step clustering is, is incorrect for me. It is true that when there is a substantial amount of distances between objects which are not of unique value ("tied" or "duplicate" distances) - which is quite expectable a situation with any few-valued discrete data, not only binary data, - the results of clustering will strongly depend on the order of processing of the objects. But this scandal accompanies any clustering method, any method directly or indirectly basing itself on some distance/similarity measure. If there are some ties in a quantity which determine clusters - that can show up, as unstable solutions. The unstability caused by ties is thus natural and cannot be an argument against this or that method potentially suffering from it. In the particular case of the linked note, you can make certain that two-step cluster method will also - like hierarchical method - give from time to time different results under different sort order of the observations in the provided dataset. So, I don't see any advantage of one method over the other in that respect. 2) Hierarchical cluster is well suited for binary data because it allows to select from a great many distance functions invented for binary data and theoretically more sound for them than simply Euclidean distance. However, some methods of agglomeration will call for (squared) Euclidean distance only. Here's a few of points to remember about hierarchical clustering. One important issue about binary/dichotomous data when selecting a similarity function is whether your data is ordinal binary (asymmetric categories: present vs absent) or nominal binary (symmetric categories: this vs that) for you. In other words, should 0-0 match be a ground of similarity or not? (You may want to read answers like this, this.) 3) Two-step cluster method of SPSS could be used with binary/dichotomous data as an alternative to hierarchical (and to some other) methods (some related answers this, this). However, two-step's processing of categorical variables employs log-likelihood distance which is right for nominal, not "ordinal binary" categories. So, if you treat your data as the latter, you have problems. Treating the variables as quantitative (interval) won't solve it. In some specific cases it is possible to convert a number of binary features into one or more multinomial nominal features quite effectively; in general, it would be quite a tricky task to do it without losing information. An experienced analyst may experiment with optimal scaling techniques and multiple correspondence analysis to see if multiple binary features can be well replaced by a smaller number of equivalent quantitative ones.
Hierarchical or TwoStep cluster analysis for binary data? 1) The tech support reply that you link to and which reads that hierarchical clustering is less appropriate for binary data than two-step clustering is, is incorrect for me. It is true that when there
45,387
Numbers too large for R. How to approximate probability mass function?
Pretty much any decent stats package will provide a log-gamma or log-factorial function. You mention R; it has: lgamma which is the log of the gamma function lfactorial which is the log of the factorial function lchoose which is the log of the binomial coefficient. using any of these, you can work out the log of the desired probability. If it's not going to cause underflow to do so, you can always exponentiate it at the end. See ?gamma An alternative if you don't have such a function is to keep all the terms from each binomial coefficient in bins (that is, if there's an "11" from expanding a binomial coefficient on a numerator, add '1' to an "11" bin, and if there's an "11" on a denominator, subtract '1'. After you've made your way through all of the coefficients, you can multiply and divide in such an order as to keep the result not too far from 1 (at least until you run out of numerator terms). An advantage of this approach is that you can keep results as exact fractions if you wish. (You can make it more sophisticated by then cancelling common factors before starting the multiplication and division ... but that's not likely to be worthwhile if you just want a numeric answer.) A third alternative is to generate approximate answers via Stirling's approximation, but this shouldn't be necessary (if I was working it out in my head, I'd do it this way).
Numbers too large for R. How to approximate probability mass function?
Pretty much any decent stats package will provide a log-gamma or log-factorial function. You mention R; it has: lgamma which is the log of the gamma function lfactorial which is the log of the factor
Numbers too large for R. How to approximate probability mass function? Pretty much any decent stats package will provide a log-gamma or log-factorial function. You mention R; it has: lgamma which is the log of the gamma function lfactorial which is the log of the factorial function lchoose which is the log of the binomial coefficient. using any of these, you can work out the log of the desired probability. If it's not going to cause underflow to do so, you can always exponentiate it at the end. See ?gamma An alternative if you don't have such a function is to keep all the terms from each binomial coefficient in bins (that is, if there's an "11" from expanding a binomial coefficient on a numerator, add '1' to an "11" bin, and if there's an "11" on a denominator, subtract '1'. After you've made your way through all of the coefficients, you can multiply and divide in such an order as to keep the result not too far from 1 (at least until you run out of numerator terms). An advantage of this approach is that you can keep results as exact fractions if you wish. (You can make it more sophisticated by then cancelling common factors before starting the multiplication and division ... but that's not likely to be worthwhile if you just want a numeric answer.) A third alternative is to generate approximate answers via Stirling's approximation, but this shouldn't be necessary (if I was working it out in my head, I'd do it this way).
Numbers too large for R. How to approximate probability mass function? Pretty much any decent stats package will provide a log-gamma or log-factorial function. You mention R; it has: lgamma which is the log of the gamma function lfactorial which is the log of the factor
45,388
Do mean, variance and median exist for a continuous random variable with continuous PDF over the real axis and a well defined CDF?
Since you already apparently answered your own question in respect of everything but the median, I'll address that. [However, while the mean for the Cauchy is undefined, I'd contend that it's possible to argue that the variance of the Cauchy is infinity (while its usually given as undefined because the mean is undefined, I think we could at least make an argument that it should be infinity, since variance can be defined without reference to the mean). I don't know that a value of infinity is necessarily poorly defined, but "undefined" would certainly seem to be. In any case, there will be situations where the variance doesn't exist, so either way your point is still okay.] Note that the definition of the median is not unique. If there's a region with density zero, with half the probability either side of that region, the definition of the median you give is satisfied by every $m$ in the region. So the question arises as to whether that's enough to consider that definition of the median "not well-defined". Wikipedia gives: an expression is well-defined if it is unambiguous and its objects are independent of their representation So the question comes down to whether we regard a definition we specify as "the median" is unambiguous when it can be any value in an interval. Perhaps "a median" would be more appropriate. (Of course we can follow some convention and define it uniquely, but we're dealing with the definition in your question.) Judging by some of the examples on that wikipedia page, I think it can be argued that the median isn't well-defined. Note that my discussion is entirely based on taking it to be an attempt to define the median as a point. If we allow that the median is more generally an interval, as Henry suggested in comments below, then it's well-defined.
Do mean, variance and median exist for a continuous random variable with continuous PDF over the rea
Since you already apparently answered your own question in respect of everything but the median, I'll address that. [However, while the mean for the Cauchy is undefined, I'd contend that it's possibl
Do mean, variance and median exist for a continuous random variable with continuous PDF over the real axis and a well defined CDF? Since you already apparently answered your own question in respect of everything but the median, I'll address that. [However, while the mean for the Cauchy is undefined, I'd contend that it's possible to argue that the variance of the Cauchy is infinity (while its usually given as undefined because the mean is undefined, I think we could at least make an argument that it should be infinity, since variance can be defined without reference to the mean). I don't know that a value of infinity is necessarily poorly defined, but "undefined" would certainly seem to be. In any case, there will be situations where the variance doesn't exist, so either way your point is still okay.] Note that the definition of the median is not unique. If there's a region with density zero, with half the probability either side of that region, the definition of the median you give is satisfied by every $m$ in the region. So the question arises as to whether that's enough to consider that definition of the median "not well-defined". Wikipedia gives: an expression is well-defined if it is unambiguous and its objects are independent of their representation So the question comes down to whether we regard a definition we specify as "the median" is unambiguous when it can be any value in an interval. Perhaps "a median" would be more appropriate. (Of course we can follow some convention and define it uniquely, but we're dealing with the definition in your question.) Judging by some of the examples on that wikipedia page, I think it can be argued that the median isn't well-defined. Note that my discussion is entirely based on taking it to be an attempt to define the median as a point. If we allow that the median is more generally an interval, as Henry suggested in comments below, then it's well-defined.
Do mean, variance and median exist for a continuous random variable with continuous PDF over the rea Since you already apparently answered your own question in respect of everything but the median, I'll address that. [However, while the mean for the Cauchy is undefined, I'd contend that it's possibl
45,389
Name for combining related graphics
Stephen Few (unsuccessfully) addressed this issue in a 2007 article, Dashboard Confusion Revisited and suggested the term "faceted analytical display": A “faceted analytical display” is a set of interactive charts (primarily graphs and tables) that simultaneously reside on a single screen, each of which presents a somewhat different view of a common dataset, and is used to analyze that information. which he differentiates from "dashboards": The greatest clarification that is needed today is a distinction between dashboards, which are used for monitoring what's going on, and displays that combine several charts on a screen for the purpose of analysis. However, the distinction hasn't been embraced. I most often hear "dashboard" or something generically descriptive like "set of graphs" for such displays. In a 2007 white paper for Tableau Software, Three Blind Men and an Elephant, Few continues to promote "faceted analytical display" while noting that Tableau uses the term "dashboard". Perhaps the best we can hope for at keeping a distinction is a qualification of "dashboard" such as "static dashboard" or "analytic dashboard". Or a portmanteau like "graphboard".
Name for combining related graphics
Stephen Few (unsuccessfully) addressed this issue in a 2007 article, Dashboard Confusion Revisited and suggested the term "faceted analytical display": A “faceted analytical display” is a set of inte
Name for combining related graphics Stephen Few (unsuccessfully) addressed this issue in a 2007 article, Dashboard Confusion Revisited and suggested the term "faceted analytical display": A “faceted analytical display” is a set of interactive charts (primarily graphs and tables) that simultaneously reside on a single screen, each of which presents a somewhat different view of a common dataset, and is used to analyze that information. which he differentiates from "dashboards": The greatest clarification that is needed today is a distinction between dashboards, which are used for monitoring what's going on, and displays that combine several charts on a screen for the purpose of analysis. However, the distinction hasn't been embraced. I most often hear "dashboard" or something generically descriptive like "set of graphs" for such displays. In a 2007 white paper for Tableau Software, Three Blind Men and an Elephant, Few continues to promote "faceted analytical display" while noting that Tableau uses the term "dashboard". Perhaps the best we can hope for at keeping a distinction is a qualification of "dashboard" such as "static dashboard" or "analytic dashboard". Or a portmanteau like "graphboard".
Name for combining related graphics Stephen Few (unsuccessfully) addressed this issue in a 2007 article, Dashboard Confusion Revisited and suggested the term "faceted analytical display": A “faceted analytical display” is a set of inte
45,390
Name for combining related graphics
As I dug through Bertin (1983) on page 32 he describes a collection of a series of diagrams, tables, maps, etc. as a demonstrational unit. ...the graphic representation will lead to a series of diagrams, double-entry tables..., maps etc...at the moment of publication, the entire set of diagrams must be conceived as a demonstrational unit. The layout must be considered a scientific problem, linked to the imperatives of reading and comparison, before it can be treated as an aesthetic problem. p. 32 Bertin, Jacques. (1983). Semiology of graphics: Diagrams, networks, maps. Madison, WI: University of Wisconsin Press.
Name for combining related graphics
As I dug through Bertin (1983) on page 32 he describes a collection of a series of diagrams, tables, maps, etc. as a demonstrational unit. ...the graphic representation will lead to a series of diagr
Name for combining related graphics As I dug through Bertin (1983) on page 32 he describes a collection of a series of diagrams, tables, maps, etc. as a demonstrational unit. ...the graphic representation will lead to a series of diagrams, double-entry tables..., maps etc...at the moment of publication, the entire set of diagrams must be conceived as a demonstrational unit. The layout must be considered a scientific problem, linked to the imperatives of reading and comparison, before it can be treated as an aesthetic problem. p. 32 Bertin, Jacques. (1983). Semiology of graphics: Diagrams, networks, maps. Madison, WI: University of Wisconsin Press.
Name for combining related graphics As I dug through Bertin (1983) on page 32 he describes a collection of a series of diagrams, tables, maps, etc. as a demonstrational unit. ...the graphic representation will lead to a series of diagr
45,391
Design of matrix of contrasts in R
Your last 2 contrasts are right, but the first 3 are wrong. We can verify this by figuring out the linear combinations of coefficients that give each group mean, and then constructing the desired contrasts by adding and subtracting these linear combinations to form new ones that test the hypotheses you're interested in. Here are the linear combinations that give each group mean (note that I shortened "factor" to "fac" for both of the factor names): group <- paste0(dataset$facX, dataset$fac2) group <- aggregate(model.matrix(model) ~ group, FUN=mean) rownames(group) <- group$group (group <- group[,-1]) # (Intercept) facX2 fac2B fac2C facX2:fac2B facX2:fac2C # 1A 1 0 0 0 0 0 # 1B 1 0 1 0 0 0 # 1C 1 0 0 1 0 0 # 2A 1 1 0 0 0 0 # 2B 1 1 1 0 1 0 # 2C 1 1 0 1 0 1 So now we can construct the matrix of contrasts by adding and substracting the rows of the matrix above: rbind(group["1A",] - group["2C",], group["1B",] - group["2B",], group["2B",] - group["2C",], group["1A",] - group["1C",], group["1A",] - group["2A",]) # (Intercept) facX2 fac2B fac2C facX2:fac2B facX2:fac2C # 1A 0 -1 0 -1 0 -1 # 1B 0 -1 0 0 -1 0 # 2B 0 0 1 -1 1 -1 # 1A1 0 0 0 -1 0 0 # 1A2 0 -1 0 0 0 0 As you can see, the last 2 rows match what you wrote in your question but the first 3 rows do not match.
Design of matrix of contrasts in R
Your last 2 contrasts are right, but the first 3 are wrong. We can verify this by figuring out the linear combinations of coefficients that give each group mean, and then constructing the desired cont
Design of matrix of contrasts in R Your last 2 contrasts are right, but the first 3 are wrong. We can verify this by figuring out the linear combinations of coefficients that give each group mean, and then constructing the desired contrasts by adding and subtracting these linear combinations to form new ones that test the hypotheses you're interested in. Here are the linear combinations that give each group mean (note that I shortened "factor" to "fac" for both of the factor names): group <- paste0(dataset$facX, dataset$fac2) group <- aggregate(model.matrix(model) ~ group, FUN=mean) rownames(group) <- group$group (group <- group[,-1]) # (Intercept) facX2 fac2B fac2C facX2:fac2B facX2:fac2C # 1A 1 0 0 0 0 0 # 1B 1 0 1 0 0 0 # 1C 1 0 0 1 0 0 # 2A 1 1 0 0 0 0 # 2B 1 1 1 0 1 0 # 2C 1 1 0 1 0 1 So now we can construct the matrix of contrasts by adding and substracting the rows of the matrix above: rbind(group["1A",] - group["2C",], group["1B",] - group["2B",], group["2B",] - group["2C",], group["1A",] - group["1C",], group["1A",] - group["2A",]) # (Intercept) facX2 fac2B fac2C facX2:fac2B facX2:fac2C # 1A 0 -1 0 -1 0 -1 # 1B 0 -1 0 0 -1 0 # 2B 0 0 1 -1 1 -1 # 1A1 0 0 0 -1 0 0 # 1A2 0 -1 0 0 0 0 As you can see, the last 2 rows match what you wrote in your question but the first 3 rows do not match.
Design of matrix of contrasts in R Your last 2 contrasts are right, but the first 3 are wrong. We can verify this by figuring out the linear combinations of coefficients that give each group mean, and then constructing the desired cont
45,392
What is the z-value of glm model parameters?
It is the test-statistic for the Wald-test that the parameter is 0. It is the parameter divided by the standard error. If the null-hypothesis is true (i.e. the parameter is 0 in the population) and we were to draw many samples from our population and compute the z-statistic in each of them, then those z-statistics will follow a standard normal distribution.
What is the z-value of glm model parameters?
It is the test-statistic for the Wald-test that the parameter is 0. It is the parameter divided by the standard error. If the null-hypothesis is true (i.e. the parameter is 0 in the population) and we
What is the z-value of glm model parameters? It is the test-statistic for the Wald-test that the parameter is 0. It is the parameter divided by the standard error. If the null-hypothesis is true (i.e. the parameter is 0 in the population) and we were to draw many samples from our population and compute the z-statistic in each of them, then those z-statistics will follow a standard normal distribution.
What is the z-value of glm model parameters? It is the test-statistic for the Wald-test that the parameter is 0. It is the parameter divided by the standard error. If the null-hypothesis is true (i.e. the parameter is 0 in the population) and we
45,393
High p-values for logistic regression variable that perfectly separates?
This is the well-known Hauck-Donner effect whereby standard errors of maximum likelihood estimates blow up. The basic idea is that as the separation becomes complete, the estimate of the standard error blows up faster than the estimate of the log odds ratio, rendering Wald $\chi^2$ statistics useless (and $P$-values large). Use likelihood ratio tests instead. These are unaffected by complete separation. Why are you cutting continuous predictors? It seems strange to assume effects that are not only piecewise flat but that are discontinuous at the cuts. This is causing part of your problem.
High p-values for logistic regression variable that perfectly separates?
This is the well-known Hauck-Donner effect whereby standard errors of maximum likelihood estimates blow up. The basic idea is that as the separation becomes complete, the estimate of the standard err
High p-values for logistic regression variable that perfectly separates? This is the well-known Hauck-Donner effect whereby standard errors of maximum likelihood estimates blow up. The basic idea is that as the separation becomes complete, the estimate of the standard error blows up faster than the estimate of the log odds ratio, rendering Wald $\chi^2$ statistics useless (and $P$-values large). Use likelihood ratio tests instead. These are unaffected by complete separation. Why are you cutting continuous predictors? It seems strange to assume effects that are not only piecewise flat but that are discontinuous at the cuts. This is causing part of your problem.
High p-values for logistic regression variable that perfectly separates? This is the well-known Hauck-Donner effect whereby standard errors of maximum likelihood estimates blow up. The basic idea is that as the separation becomes complete, the estimate of the standard err
45,394
Imputation by regression in R [closed]
Even though this thread is a bit old, I am sure some people are still trying to find a solution in this thread. Therefore I want to add an example how you could use the mice package for regression imputation: library("mice") # Example data data <- data.frame(x1 = c(1, 6, 15, 8, 5, 1, 7, 4), x2 = c(2, 13, 12, 1, 6, 6, 1, 2), x3 = c(NA, 7, 3, NA, 1, 2, 7, 3), x4 = c(4, 1, 12, 7, 12, 1, 6, 6), x5 = c(5, 11, NA, 8, 8, 11, 5, 6), x6 = c(6, 4, 8, 9, 3, 9, 6, 12), x7 = c(14, NA, 3, 4, 12, 5, 10, 10), x8 = c(5, 9, 7, 6, 12, 2, 6, 3), x9 = c(2, 6, 12, 1, 2, 2, 7, 1)) # Deterministic regression imputation via mice imp <- mice(data, method = "norm.predict", m = 1) # Store data data_imp <- complete(imp) With a larger dataset, You could also add a stochastic error term to the imputed values with the "norm.nob" method: # Stochastic regression imputation imp <- mice(data, method = "norm.nob", m = 1) You can find further information on regression imputation in the following two links: Deterministic vs. stochastic regression imputation & examples in R Flexible Imputation of Missing Data of Stef van Buuren, the author of mice
Imputation by regression in R [closed]
Even though this thread is a bit old, I am sure some people are still trying to find a solution in this thread. Therefore I want to add an example how you could use the mice package for regression imp
Imputation by regression in R [closed] Even though this thread is a bit old, I am sure some people are still trying to find a solution in this thread. Therefore I want to add an example how you could use the mice package for regression imputation: library("mice") # Example data data <- data.frame(x1 = c(1, 6, 15, 8, 5, 1, 7, 4), x2 = c(2, 13, 12, 1, 6, 6, 1, 2), x3 = c(NA, 7, 3, NA, 1, 2, 7, 3), x4 = c(4, 1, 12, 7, 12, 1, 6, 6), x5 = c(5, 11, NA, 8, 8, 11, 5, 6), x6 = c(6, 4, 8, 9, 3, 9, 6, 12), x7 = c(14, NA, 3, 4, 12, 5, 10, 10), x8 = c(5, 9, 7, 6, 12, 2, 6, 3), x9 = c(2, 6, 12, 1, 2, 2, 7, 1)) # Deterministic regression imputation via mice imp <- mice(data, method = "norm.predict", m = 1) # Store data data_imp <- complete(imp) With a larger dataset, You could also add a stochastic error term to the imputed values with the "norm.nob" method: # Stochastic regression imputation imp <- mice(data, method = "norm.nob", m = 1) You can find further information on regression imputation in the following two links: Deterministic vs. stochastic regression imputation & examples in R Flexible Imputation of Missing Data of Stef van Buuren, the author of mice
Imputation by regression in R [closed] Even though this thread is a bit old, I am sure some people are still trying to find a solution in this thread. Therefore I want to add an example how you could use the mice package for regression imp
45,395
Entropy of Cauchy (Lorentz) Distribution
As shown at How does entropy depend on location and scale?, the integral is easily reduced (via an appropriate change of variable) to the case $\gamma=1$, for which $$H = \int_{-\infty}^{\infty} \frac{\log(1+x^2)}{1+x^2}\,dx.$$ Letting $x=\tan(\theta)$ implies $dx = \sec^2(\theta)d\theta$ whence, since $1+\tan^2(\theta) = 1/\cos^2(\theta)$, $$H = -2\int_{-\pi/2}^{\pi/2} \log(\cos(\theta))d\theta = -4\int_{0}^{\pi/2} \log(\cos(\theta))d\theta .$$ There is an elementary way to compute this integral. Write $I= \int_{0}^{\pi/2} \log(\cos(\theta))d\theta$. Because $\cos$ on this interval $[0, \pi/2]$ is just the reflection of $\sin$, it is also the case that $I= \int_{0}^{\pi/2} \log(\sin(\theta))d\theta.$ Add the integrands: $$\log\cos(\theta) + \log\sin(\theta) = \log(\cos(\theta)\sin(\theta)) = \log(\sin(2\theta)/2) = \log\sin(2\theta) - \log(2).$$ Therefore $$2I = \int_0^{\pi/2} \left(\log\sin(2\theta) - \log(2)\right)d\theta =-\frac{\pi}{2} \log(2) + \int_0^{\pi/2} \log\sin(2\theta) d\theta.$$ Changing variables to $t=2\theta$ in the integral shows that $$\int_0^{\pi/2} \log\sin(2\theta) d\theta = \frac{1}{2}\int_0^{\pi} \log\sin(t) dt = \frac{1}{2}\left(\int_0^{\pi/2} + \int_{\pi/2}^\pi\right)\log\sin(t)dt \\= \frac{1}{2}(I+I) = I$$ because $\sin$ on the interval $[\pi/2,\pi]$ merely retraces the values it attained on the interval $[0,\pi/2]$. Consequently $2I = -\frac{\pi}{2} \log(2) + I,$ giving the solution $I = -\frac{\pi}{2} \log(2)$. We conclude that $$H = -4I = 2\pi\log(2).$$ An alternative approach factors $1+x^2 = (1 + ix)(1-ix)$ to re-express the integrand as $$\frac{\log(1+x^2)}{1+x^2} = \frac{1}{2}\left(\frac{i}{x-i} + \frac{i}{x+i}\right)\log(1+ix) + \frac{1}{2}\left(\frac{i}{x-i} + \frac{i}{x+i}\right)\log(1-ix)$$ The integral of the first term on the right can be expressed as the limiting value as $R\to\infty$ of a contour integral from $-R$ to $+R$ followed by tracing the lower semi-circle of radius $R$ back to $-R.$ For $R\gt 1$ the interior of the region bounded by this path clearly has a single pole only at $x=-i$ where the residue is $$\operatorname{Res}_{x=-i}\left(\left(\frac{i}{x-i} + \frac{i}{x+i}\right)\log(1+ix)\right) = i\left.\log(1 + ix)\right|_{x=-i} = i\log(2),$$ whence (because this is a negatively oriented path) the Residue Theorem says $$\oint \left(\frac{1}{1+ix} + \frac{1}{1-ix}\right)\log(1+ix) \mathrm{d}x = -2\pi i (i\log(2)) = 2\pi\log(2).$$ Because the integrand on the circle is $o(\log(R)/R)$ which grows vanishingly small as $R\to\infty,$ in the limit we obtain $$\int_{-\infty}^\infty \frac{1}{2}\left(\frac{1}{1+ix} + \frac{1}{1-ix}\right)\log(1+ix) \mathrm{d}x = \pi\log(2).$$ The second term of the integrand is equal to the first (use the substitution $x\to -x$), whence $H=2(\pi\log(2)) = 2\pi\log(2),$ just as before.
Entropy of Cauchy (Lorentz) Distribution
As shown at How does entropy depend on location and scale?, the integral is easily reduced (via an appropriate change of variable) to the case $\gamma=1$, for which $$H = \int_{-\infty}^{\infty} \frac
Entropy of Cauchy (Lorentz) Distribution As shown at How does entropy depend on location and scale?, the integral is easily reduced (via an appropriate change of variable) to the case $\gamma=1$, for which $$H = \int_{-\infty}^{\infty} \frac{\log(1+x^2)}{1+x^2}\,dx.$$ Letting $x=\tan(\theta)$ implies $dx = \sec^2(\theta)d\theta$ whence, since $1+\tan^2(\theta) = 1/\cos^2(\theta)$, $$H = -2\int_{-\pi/2}^{\pi/2} \log(\cos(\theta))d\theta = -4\int_{0}^{\pi/2} \log(\cos(\theta))d\theta .$$ There is an elementary way to compute this integral. Write $I= \int_{0}^{\pi/2} \log(\cos(\theta))d\theta$. Because $\cos$ on this interval $[0, \pi/2]$ is just the reflection of $\sin$, it is also the case that $I= \int_{0}^{\pi/2} \log(\sin(\theta))d\theta.$ Add the integrands: $$\log\cos(\theta) + \log\sin(\theta) = \log(\cos(\theta)\sin(\theta)) = \log(\sin(2\theta)/2) = \log\sin(2\theta) - \log(2).$$ Therefore $$2I = \int_0^{\pi/2} \left(\log\sin(2\theta) - \log(2)\right)d\theta =-\frac{\pi}{2} \log(2) + \int_0^{\pi/2} \log\sin(2\theta) d\theta.$$ Changing variables to $t=2\theta$ in the integral shows that $$\int_0^{\pi/2} \log\sin(2\theta) d\theta = \frac{1}{2}\int_0^{\pi} \log\sin(t) dt = \frac{1}{2}\left(\int_0^{\pi/2} + \int_{\pi/2}^\pi\right)\log\sin(t)dt \\= \frac{1}{2}(I+I) = I$$ because $\sin$ on the interval $[\pi/2,\pi]$ merely retraces the values it attained on the interval $[0,\pi/2]$. Consequently $2I = -\frac{\pi}{2} \log(2) + I,$ giving the solution $I = -\frac{\pi}{2} \log(2)$. We conclude that $$H = -4I = 2\pi\log(2).$$ An alternative approach factors $1+x^2 = (1 + ix)(1-ix)$ to re-express the integrand as $$\frac{\log(1+x^2)}{1+x^2} = \frac{1}{2}\left(\frac{i}{x-i} + \frac{i}{x+i}\right)\log(1+ix) + \frac{1}{2}\left(\frac{i}{x-i} + \frac{i}{x+i}\right)\log(1-ix)$$ The integral of the first term on the right can be expressed as the limiting value as $R\to\infty$ of a contour integral from $-R$ to $+R$ followed by tracing the lower semi-circle of radius $R$ back to $-R.$ For $R\gt 1$ the interior of the region bounded by this path clearly has a single pole only at $x=-i$ where the residue is $$\operatorname{Res}_{x=-i}\left(\left(\frac{i}{x-i} + \frac{i}{x+i}\right)\log(1+ix)\right) = i\left.\log(1 + ix)\right|_{x=-i} = i\log(2),$$ whence (because this is a negatively oriented path) the Residue Theorem says $$\oint \left(\frac{1}{1+ix} + \frac{1}{1-ix}\right)\log(1+ix) \mathrm{d}x = -2\pi i (i\log(2)) = 2\pi\log(2).$$ Because the integrand on the circle is $o(\log(R)/R)$ which grows vanishingly small as $R\to\infty,$ in the limit we obtain $$\int_{-\infty}^\infty \frac{1}{2}\left(\frac{1}{1+ix} + \frac{1}{1-ix}\right)\log(1+ix) \mathrm{d}x = \pi\log(2).$$ The second term of the integrand is equal to the first (use the substitution $x\to -x$), whence $H=2(\pi\log(2)) = 2\pi\log(2),$ just as before.
Entropy of Cauchy (Lorentz) Distribution As shown at How does entropy depend on location and scale?, the integral is easily reduced (via an appropriate change of variable) to the case $\gamma=1$, for which $$H = \int_{-\infty}^{\infty} \frac
45,396
Entropy of Cauchy (Lorentz) Distribution
This is not a full-scaled answer but just a modest extension of @whuber's answer. If we take that $\gamma = 1$, so pdf of Cauchy distribution boils down to the following: $$ p(x) = \frac {1} {\pi (1 + x^2)},$$ where $\pi$ is just a scaling factor (see the picture). So, if we define differential entropy for valid pdf, its formula is as follows: $$H = \int_{-\infty}^{\infty} \frac{\log(\pi (1+x^2))}{\pi(1+x^2)}\,dx $$ We can expand it a bit for analysis: $$ H = \frac{\log(\pi)}{\pi} \int_{-\infty}^{\infty} \frac{1}{1+x^2}\,dx + \frac{1} {\pi} \int_{-\infty}^{\infty} \frac{\log(1+x^2)}{1+x^2}\,dx = $$ $$ = \frac{\log(\pi)}{\pi} H_1 + \frac{1} {\pi} H_2 $$ Step 1 It can be shown that $H_1 = \pi $ because anti-derivative of the integrand is $\arctan(x)$. Step 2 The part $H_2$ is in detail elaborated in the accepted answer, where we can put $2$ inside $\log$. $$H_2 = 2\pi\log(2) = \pi \log(4).$$ Step 3 Now we may combine everything to get: $$ H = \frac{\log(\pi)}{\pi} H_1 + \frac{1} {\pi} H_2 = \frac{\log(\pi)}{\pi} \pi + \frac{1} {\pi} \pi \log(4) = \log(\pi) + \log(4). $$ Conclusion: Now we get the expected result. $$ H(\gamma = 1) = \log(4\pi).$$
Entropy of Cauchy (Lorentz) Distribution
This is not a full-scaled answer but just a modest extension of @whuber's answer. If we take that $\gamma = 1$, so pdf of Cauchy distribution boils down to the following: $$ p(x) = \frac {1} {\pi (1 +
Entropy of Cauchy (Lorentz) Distribution This is not a full-scaled answer but just a modest extension of @whuber's answer. If we take that $\gamma = 1$, so pdf of Cauchy distribution boils down to the following: $$ p(x) = \frac {1} {\pi (1 + x^2)},$$ where $\pi$ is just a scaling factor (see the picture). So, if we define differential entropy for valid pdf, its formula is as follows: $$H = \int_{-\infty}^{\infty} \frac{\log(\pi (1+x^2))}{\pi(1+x^2)}\,dx $$ We can expand it a bit for analysis: $$ H = \frac{\log(\pi)}{\pi} \int_{-\infty}^{\infty} \frac{1}{1+x^2}\,dx + \frac{1} {\pi} \int_{-\infty}^{\infty} \frac{\log(1+x^2)}{1+x^2}\,dx = $$ $$ = \frac{\log(\pi)}{\pi} H_1 + \frac{1} {\pi} H_2 $$ Step 1 It can be shown that $H_1 = \pi $ because anti-derivative of the integrand is $\arctan(x)$. Step 2 The part $H_2$ is in detail elaborated in the accepted answer, where we can put $2$ inside $\log$. $$H_2 = 2\pi\log(2) = \pi \log(4).$$ Step 3 Now we may combine everything to get: $$ H = \frac{\log(\pi)}{\pi} H_1 + \frac{1} {\pi} H_2 = \frac{\log(\pi)}{\pi} \pi + \frac{1} {\pi} \pi \log(4) = \log(\pi) + \log(4). $$ Conclusion: Now we get the expected result. $$ H(\gamma = 1) = \log(4\pi).$$
Entropy of Cauchy (Lorentz) Distribution This is not a full-scaled answer but just a modest extension of @whuber's answer. If we take that $\gamma = 1$, so pdf of Cauchy distribution boils down to the following: $$ p(x) = \frac {1} {\pi (1 +
45,397
Multivariate regression with weighted least squares in python?
It's still not entirely clear to me what you want to do, but if your weights are 1d, you can (ab)use sm.WLS to do this. import numpy as np import statsmodels.api as sm np.random.seed(12345) N = 30 X = np.random.uniform(-20, 20, size=(N,10)) beta = np.random.randn(11) X = sm.add_constant(X) weights = np.random.uniform(1, 20, size=(N,)) weights = weights/weights.sum() y = np.dot(X, beta) + weights*np.random.uniform(-100, 100, size=(N,)) Y = np.c_[y,y,y] mod = sm.WLS(Y, X, weights=1/weights).fit() If your weights are not 1d, WLS will indeed break, because it's not designed for this case. You can use a loop over WLS or just roll your own solution depending on what exactly you want to do. weights = np.random.uniform(1, 20, size=(N,3)) weights = weights/weights.sum(0) y = np.dot(X, beta)[:,None] + weights*np.random.uniform(-100, 100, size=(N,3)) This is the entirety of the WLS solution for each equation, assuming this is what you want to do beta_hat = np.array([np.linalg.pinv(1/weights[:,i,None]**.5 * X).dot(y[:,i]) for i in range(3)])
Multivariate regression with weighted least squares in python?
It's still not entirely clear to me what you want to do, but if your weights are 1d, you can (ab)use sm.WLS to do this. import numpy as np import statsmodels.api as sm np.random.seed(12345) N = 30 X
Multivariate regression with weighted least squares in python? It's still not entirely clear to me what you want to do, but if your weights are 1d, you can (ab)use sm.WLS to do this. import numpy as np import statsmodels.api as sm np.random.seed(12345) N = 30 X = np.random.uniform(-20, 20, size=(N,10)) beta = np.random.randn(11) X = sm.add_constant(X) weights = np.random.uniform(1, 20, size=(N,)) weights = weights/weights.sum() y = np.dot(X, beta) + weights*np.random.uniform(-100, 100, size=(N,)) Y = np.c_[y,y,y] mod = sm.WLS(Y, X, weights=1/weights).fit() If your weights are not 1d, WLS will indeed break, because it's not designed for this case. You can use a loop over WLS or just roll your own solution depending on what exactly you want to do. weights = np.random.uniform(1, 20, size=(N,3)) weights = weights/weights.sum(0) y = np.dot(X, beta)[:,None] + weights*np.random.uniform(-100, 100, size=(N,3)) This is the entirety of the WLS solution for each equation, assuming this is what you want to do beta_hat = np.array([np.linalg.pinv(1/weights[:,i,None]**.5 * X).dot(y[:,i]) for i in range(3)])
Multivariate regression with weighted least squares in python? It's still not entirely clear to me what you want to do, but if your weights are 1d, you can (ab)use sm.WLS to do this. import numpy as np import statsmodels.api as sm np.random.seed(12345) N = 30 X
45,398
Multivariate regression with weighted least squares in python?
In module sklearn, linear_model provides many regression functions, which will satisfy your demand. For example, lasso.fit(X,y) where y has shape = (n_samples,) or (n_samples, n_targets). In your situation, n_targets = 2.
Multivariate regression with weighted least squares in python?
In module sklearn, linear_model provides many regression functions, which will satisfy your demand. For example, lasso.fit(X,y) where y has shape = (n_samples,) or (n_samples, n_targets). In your sit
Multivariate regression with weighted least squares in python? In module sklearn, linear_model provides many regression functions, which will satisfy your demand. For example, lasso.fit(X,y) where y has shape = (n_samples,) or (n_samples, n_targets). In your situation, n_targets = 2.
Multivariate regression with weighted least squares in python? In module sklearn, linear_model provides many regression functions, which will satisfy your demand. For example, lasso.fit(X,y) where y has shape = (n_samples,) or (n_samples, n_targets). In your sit
45,399
Estimation issues for OLS with bounded response variable
Though I agree with Glen_b that rates like this are scaled counts, whether or not you want to use a count model depends on what the denominator in that scaled count is. If $y$ is something like the market share of Ford in the US, then the denominator is in the millions, and you should probably treat $y$ as continuous. So, I'll answer the question of what you should do when it is OK to treat $y$ as a continuous variable. Specifically, $y_{it}$ is then the probability that a randomly selected member of group $i$ passes the test at time $t$. We want to let $y$ depend on some variable(s) $x$ but in a way which respects the facts that 1) $x\beta$ can be any real number and 2) $y$ nevertheless is a probability and must stay between 0 and 1. What we want to do, I guess, is come up with a function $g(x\beta)$ so that we can model $y=g(x\beta)$ in a way which respects the nature of $y$ as a probability and will accept any real number as its argument. In addition, so that the relationship between $y$ and $x$ is not too hard to interpret, let's also require that $g$ be monotone increasing. So, do we know of any functions which have the real line as their domain, the interval $(0,1)$ as their range, and are strictly increasing? That's an easy question, right? The cumulative distribution function of every single continuous random variable (with density strictly positive on the real line) is such a function. So, let's consider $F$ as the CDF for some continuous random variable. We might then model: \begin{align} y_{it} &= F(x_{it}\beta) \end{align} Hmmm. There is no error term. Two observations with the exact same $x$ will have to have the exact same $y$. That's no good. So, we need an error term. Do we put it inside the $F$ or outside? If we put it outside, then we are back to having to worry about giving it some weird distribution which keeps $y$ between 0 and 1, no matter what $F(x\beta)$ turns out to be. So, let's put it inside the $F$ and not worry about its distribution: \begin{align} y_{it} &= F(x_{it}\beta+\epsilon_{it}) \end{align} Now, how do we estimate it? Not with OLS because $F$ isn't linear. Not with NLS because the error term is in the wrong place (gotta be outside the $F$ for that). Maximum likelihood, maybe, if we are willing to assume a distribution for $\epsilon$. I'm allergic to assuming distributions for error terms, so not that. I like OLS, and I stubbornly want to use it. The right-hand-side of the equation above looks almost OK for OLS---the stuff inside the $F$ is just right. If only we could dig out that stuff inside the $F$. But, since $F$ is strictly increasing, it has an inverse $F^{-1}$ and this means we can dig out that good right-hand-side, hiding there inside the icky $F$: \begin{align} y_{it} &= F(x_{it}\beta+\epsilon_{it})\\ F^{-1}(y_{it}) &= F^{-1}(F(x_{it}\beta+\epsilon_{it}))\\ F^{-1}(y_{it}) &= x_i\beta+\epsilon_{it} \end{align} As long as you know $F$, you can just run this regression. Read in $y$ and $x$. Transform $y$ by running it through $F^{-1}$. Run the regression by OLS. Furthermore, you can use all the various techniques you know to deal with various problems with your data. Fix heteroskedasticity the way you always would, with Huber-White standard errors. Correct for clustering as you normally would. Is one of the $x$s endogenous? Use instrumental variables in the usual way. Or, in your case, I guess you are worried about either serial correlation or unobserved heterogeneity in your groups, so you want to estimate in first differences. No problem: \begin{align} F^{-1}(y_{it}) &= x_{it}\beta+\epsilon_{it}\\ F^{-1}(y_{it}) - F^{-1}(y_{it-1}) &= (x_{it}-x_{it-1})\beta+\epsilon_{it}-\epsilon_{it-1}\\ \Delta F^{-1}(y_{it}) &= \Delta x_{it}\beta+\Delta \epsilon_{it} \end{align} What to use for $F$? The most common choice is the logistic distribution. This has inverse function equal to $ln\left( \frac{y_{it}}{1-y_{it}} \right)$. This regression is then called a grouped data logit or a grouped data logistic regression. The second most common is normal which has an inverse function with no closed form. That regression is called a grouped data probit. Here is how it goes in R: mydata <- data.frame(y=c(0.5,0.3,0.2,0.8,0.1,0.4),x=c(17,4,-12,1,3,5), i=c(1,1,1,2,2,2),t=c(1,2,3,1,2,3)) attach(mydata) # Apply logit transform logity <- log(y/(1-y)) # Difference data and deal with boundary between i's Dly <- logity[1:5]-logity[2:6] Dx <- x[1:5]-x[2:6] Dly <- Dly[i[2:6]==i[1:5]] Dx <- Dx[i[2:6]==i[1:5]] summary(lm(Dly~Dx)) There are a couple of caveats. First, this will not work if you have any observations with either $y=1$ or $y=0$. Second, although you can interpret the sign and significance of the coefficients from your regression just the way you would for a normal regression model, you cannot interpret their magnitude in the same way (because the model is non-linear). Third, you cannot make predicted values in the way you naturally want to, as $\hat{y}=F(x\hat{\beta}_{\text{OLS}})$. This, again, is because $F$ is non-linear, so you can't just pass an expectation through it to get $\epsilon$ to go away. These latter two caveats (especially the last one) are called the re-transformation problem. You can find questions and answers on it at this site.
Estimation issues for OLS with bounded response variable
Though I agree with Glen_b that rates like this are scaled counts, whether or not you want to use a count model depends on what the denominator in that scaled count is. If $y$ is something like the m
Estimation issues for OLS with bounded response variable Though I agree with Glen_b that rates like this are scaled counts, whether or not you want to use a count model depends on what the denominator in that scaled count is. If $y$ is something like the market share of Ford in the US, then the denominator is in the millions, and you should probably treat $y$ as continuous. So, I'll answer the question of what you should do when it is OK to treat $y$ as a continuous variable. Specifically, $y_{it}$ is then the probability that a randomly selected member of group $i$ passes the test at time $t$. We want to let $y$ depend on some variable(s) $x$ but in a way which respects the facts that 1) $x\beta$ can be any real number and 2) $y$ nevertheless is a probability and must stay between 0 and 1. What we want to do, I guess, is come up with a function $g(x\beta)$ so that we can model $y=g(x\beta)$ in a way which respects the nature of $y$ as a probability and will accept any real number as its argument. In addition, so that the relationship between $y$ and $x$ is not too hard to interpret, let's also require that $g$ be monotone increasing. So, do we know of any functions which have the real line as their domain, the interval $(0,1)$ as their range, and are strictly increasing? That's an easy question, right? The cumulative distribution function of every single continuous random variable (with density strictly positive on the real line) is such a function. So, let's consider $F$ as the CDF for some continuous random variable. We might then model: \begin{align} y_{it} &= F(x_{it}\beta) \end{align} Hmmm. There is no error term. Two observations with the exact same $x$ will have to have the exact same $y$. That's no good. So, we need an error term. Do we put it inside the $F$ or outside? If we put it outside, then we are back to having to worry about giving it some weird distribution which keeps $y$ between 0 and 1, no matter what $F(x\beta)$ turns out to be. So, let's put it inside the $F$ and not worry about its distribution: \begin{align} y_{it} &= F(x_{it}\beta+\epsilon_{it}) \end{align} Now, how do we estimate it? Not with OLS because $F$ isn't linear. Not with NLS because the error term is in the wrong place (gotta be outside the $F$ for that). Maximum likelihood, maybe, if we are willing to assume a distribution for $\epsilon$. I'm allergic to assuming distributions for error terms, so not that. I like OLS, and I stubbornly want to use it. The right-hand-side of the equation above looks almost OK for OLS---the stuff inside the $F$ is just right. If only we could dig out that stuff inside the $F$. But, since $F$ is strictly increasing, it has an inverse $F^{-1}$ and this means we can dig out that good right-hand-side, hiding there inside the icky $F$: \begin{align} y_{it} &= F(x_{it}\beta+\epsilon_{it})\\ F^{-1}(y_{it}) &= F^{-1}(F(x_{it}\beta+\epsilon_{it}))\\ F^{-1}(y_{it}) &= x_i\beta+\epsilon_{it} \end{align} As long as you know $F$, you can just run this regression. Read in $y$ and $x$. Transform $y$ by running it through $F^{-1}$. Run the regression by OLS. Furthermore, you can use all the various techniques you know to deal with various problems with your data. Fix heteroskedasticity the way you always would, with Huber-White standard errors. Correct for clustering as you normally would. Is one of the $x$s endogenous? Use instrumental variables in the usual way. Or, in your case, I guess you are worried about either serial correlation or unobserved heterogeneity in your groups, so you want to estimate in first differences. No problem: \begin{align} F^{-1}(y_{it}) &= x_{it}\beta+\epsilon_{it}\\ F^{-1}(y_{it}) - F^{-1}(y_{it-1}) &= (x_{it}-x_{it-1})\beta+\epsilon_{it}-\epsilon_{it-1}\\ \Delta F^{-1}(y_{it}) &= \Delta x_{it}\beta+\Delta \epsilon_{it} \end{align} What to use for $F$? The most common choice is the logistic distribution. This has inverse function equal to $ln\left( \frac{y_{it}}{1-y_{it}} \right)$. This regression is then called a grouped data logit or a grouped data logistic regression. The second most common is normal which has an inverse function with no closed form. That regression is called a grouped data probit. Here is how it goes in R: mydata <- data.frame(y=c(0.5,0.3,0.2,0.8,0.1,0.4),x=c(17,4,-12,1,3,5), i=c(1,1,1,2,2,2),t=c(1,2,3,1,2,3)) attach(mydata) # Apply logit transform logity <- log(y/(1-y)) # Difference data and deal with boundary between i's Dly <- logity[1:5]-logity[2:6] Dx <- x[1:5]-x[2:6] Dly <- Dly[i[2:6]==i[1:5]] Dx <- Dx[i[2:6]==i[1:5]] summary(lm(Dly~Dx)) There are a couple of caveats. First, this will not work if you have any observations with either $y=1$ or $y=0$. Second, although you can interpret the sign and significance of the coefficients from your regression just the way you would for a normal regression model, you cannot interpret their magnitude in the same way (because the model is non-linear). Third, you cannot make predicted values in the way you naturally want to, as $\hat{y}=F(x\hat{\beta}_{\text{OLS}})$. This, again, is because $F$ is non-linear, so you can't just pass an expectation through it to get $\epsilon$ to go away. These latter two caveats (especially the last one) are called the re-transformation problem. You can find questions and answers on it at this site.
Estimation issues for OLS with bounded response variable Though I agree with Glen_b that rates like this are scaled counts, whether or not you want to use a count model depends on what the denominator in that scaled count is. If $y$ is something like the m
45,400
Estimation issues for OLS with bounded response variable
Sample participation rates and pass rates are scaled counts. You should not use OLS on bounded variables - they will be neither linear (straight lines are not even possible, except over limited ranges) nor will they have constant variance (also not even possible, except over limited ranges), and proper account should be taken of the fact that they're count data (discrete). The problems you note should be encompassed within a suitable model for what is known about the data. A typical model for such a proportion would be based on a binomial assumption for the counts, which would normally be fitted via a GLM. If you need to deal in differences it becomes a little more involved, but it should still start with a suitable model, and then if approximations come in, they should come in near the end of the process of building a model rather than the start.
Estimation issues for OLS with bounded response variable
Sample participation rates and pass rates are scaled counts. You should not use OLS on bounded variables - they will be neither linear (straight lines are not even possible, except over limited range
Estimation issues for OLS with bounded response variable Sample participation rates and pass rates are scaled counts. You should not use OLS on bounded variables - they will be neither linear (straight lines are not even possible, except over limited ranges) nor will they have constant variance (also not even possible, except over limited ranges), and proper account should be taken of the fact that they're count data (discrete). The problems you note should be encompassed within a suitable model for what is known about the data. A typical model for such a proportion would be based on a binomial assumption for the counts, which would normally be fitted via a GLM. If you need to deal in differences it becomes a little more involved, but it should still start with a suitable model, and then if approximations come in, they should come in near the end of the process of building a model rather than the start.
Estimation issues for OLS with bounded response variable Sample participation rates and pass rates are scaled counts. You should not use OLS on bounded variables - they will be neither linear (straight lines are not even possible, except over limited range