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 |
|---|---|---|---|---|---|---|
30,401 | Non-linear SVM classification with RBF kernel | Let $\mathcal{X}$ represent your input space i.e the space where your data points resides. Consider a function $\Phi:\mathcal{X} \rightarrow \mathcal{F}$ such that it takes a point from your input space $\mathcal{X}$ and maps it to a point in $\mathcal{F}$. Now, let us say that we have mapped all your data points from $\mathcal{X}$ to this new space $\mathcal{F}$. Now, if you try to solve the normal linear svm in this new space $\mathcal{F}$ instead of $\mathcal{X}$, you will notice that all the earlier working simply look the same, except that all the points $x_i$ are represented as $\Phi(x_i)$ and instead of using $x^Ty$ (dot product) which is the natural inner product for Euclidean space, we replace it with $\langle \Phi(x), \Phi(y) \rangle$ which represents the natural inner product in the new space $\mathcal{F}$. So, at the end, your $w^*$ would look like,
$$
w^*=\sum_{i \in SV} h_i y_i \Phi(x_i)
$$
and hence,
$$
\langle w^*, \Phi(x) \rangle = \sum_{i \in SV} h_i y_i \langle \Phi(x_i), \Phi(x) \rangle
$$
Similarly,
$$
b^*=\frac{1}{|SV|}\sum_{i \in SV}\left(y_i - \sum_{j=1}^N\left(h_j y_j \langle \Phi(x_j), \Phi(x_i)\rangle\right)\right)
$$
and your classification rule looks like: $c_x=\text{sign}(\langle w, \Phi(x) \rangle+b)$.
So far so good, there is nothing new, since we have simply applied the normal linear SVM to just a different space. However, the magic part is this -
Let us say that there exists a function $k:\mathcal{X}\times\mathcal{X}\rightarrow \mathbb{R}$ such that $k(x_i, x_j) = \langle \Phi(x_i), \Phi(x_j) \rangle$. Then, we can replace all the dot products above with $k(x_i, x_j)$. Such a $k$ is called a kernel function.
Therefore, your $w^*$ and $b^*$ look like,
$$
\langle w^*, \Phi(x) \rangle = \sum_{i \in SV} h_i y_i k(x_i, x)
$$
$$
b^*=\frac{1}{|SV|}\sum_{i \in SV}\left(y_i - \sum_{j=1}^N\left(h_j y_j k(x_j, x_i)\right)\right)
$$
For which kernel functions is the above substitution valid? Well, that's a slightly involved question and you might want to take up proper reading material to understand those implications. However, I will just add that the above holds true for RBF Kernel.
To answer your question, "Is the situation so that all the support vectors are needed for the classification?"
Yes. As you may notice above, we compute the inner product of $w$ with $x$ instead of computing $w$ explicitly. This requires us to retain all the support vectors for classification.
Note: The $h_i$'s in the final section here are solution to dual of the SVM in the space $\mathcal{F}$ and not $\mathcal{X}$. Does that mean that we need to know $\Phi$ function explicitly? Luckily, no. If you look at the dual objective, it consists only of inner product and since we have $k$ that allows us to compute the inner product directly, we don't need to know $\Phi$ explicitly. The dual objective simply looks like,
$$
\max \sum_i h_i - \sum_{i,j} y_i y_j h_i h_j k(x_i, x_j) \\
\text{subject to : } \sum_i y_i h_i = 0, h_i \geq 0
$$ | Non-linear SVM classification with RBF kernel | Let $\mathcal{X}$ represent your input space i.e the space where your data points resides. Consider a function $\Phi:\mathcal{X} \rightarrow \mathcal{F}$ such that it takes a point from your input spa | Non-linear SVM classification with RBF kernel
Let $\mathcal{X}$ represent your input space i.e the space where your data points resides. Consider a function $\Phi:\mathcal{X} \rightarrow \mathcal{F}$ such that it takes a point from your input space $\mathcal{X}$ and maps it to a point in $\mathcal{F}$. Now, let us say that we have mapped all your data points from $\mathcal{X}$ to this new space $\mathcal{F}$. Now, if you try to solve the normal linear svm in this new space $\mathcal{F}$ instead of $\mathcal{X}$, you will notice that all the earlier working simply look the same, except that all the points $x_i$ are represented as $\Phi(x_i)$ and instead of using $x^Ty$ (dot product) which is the natural inner product for Euclidean space, we replace it with $\langle \Phi(x), \Phi(y) \rangle$ which represents the natural inner product in the new space $\mathcal{F}$. So, at the end, your $w^*$ would look like,
$$
w^*=\sum_{i \in SV} h_i y_i \Phi(x_i)
$$
and hence,
$$
\langle w^*, \Phi(x) \rangle = \sum_{i \in SV} h_i y_i \langle \Phi(x_i), \Phi(x) \rangle
$$
Similarly,
$$
b^*=\frac{1}{|SV|}\sum_{i \in SV}\left(y_i - \sum_{j=1}^N\left(h_j y_j \langle \Phi(x_j), \Phi(x_i)\rangle\right)\right)
$$
and your classification rule looks like: $c_x=\text{sign}(\langle w, \Phi(x) \rangle+b)$.
So far so good, there is nothing new, since we have simply applied the normal linear SVM to just a different space. However, the magic part is this -
Let us say that there exists a function $k:\mathcal{X}\times\mathcal{X}\rightarrow \mathbb{R}$ such that $k(x_i, x_j) = \langle \Phi(x_i), \Phi(x_j) \rangle$. Then, we can replace all the dot products above with $k(x_i, x_j)$. Such a $k$ is called a kernel function.
Therefore, your $w^*$ and $b^*$ look like,
$$
\langle w^*, \Phi(x) \rangle = \sum_{i \in SV} h_i y_i k(x_i, x)
$$
$$
b^*=\frac{1}{|SV|}\sum_{i \in SV}\left(y_i - \sum_{j=1}^N\left(h_j y_j k(x_j, x_i)\right)\right)
$$
For which kernel functions is the above substitution valid? Well, that's a slightly involved question and you might want to take up proper reading material to understand those implications. However, I will just add that the above holds true for RBF Kernel.
To answer your question, "Is the situation so that all the support vectors are needed for the classification?"
Yes. As you may notice above, we compute the inner product of $w$ with $x$ instead of computing $w$ explicitly. This requires us to retain all the support vectors for classification.
Note: The $h_i$'s in the final section here are solution to dual of the SVM in the space $\mathcal{F}$ and not $\mathcal{X}$. Does that mean that we need to know $\Phi$ function explicitly? Luckily, no. If you look at the dual objective, it consists only of inner product and since we have $k$ that allows us to compute the inner product directly, we don't need to know $\Phi$ explicitly. The dual objective simply looks like,
$$
\max \sum_i h_i - \sum_{i,j} y_i y_j h_i h_j k(x_i, x_j) \\
\text{subject to : } \sum_i y_i h_i = 0, h_i \geq 0
$$ | Non-linear SVM classification with RBF kernel
Let $\mathcal{X}$ represent your input space i.e the space where your data points resides. Consider a function $\Phi:\mathcal{X} \rightarrow \mathcal{F}$ such that it takes a point from your input spa |
30,402 | Connection between sum of normally distributed random variables and mixture of normal distributions | It's important to make the distinction between a sum of normal random variables and a mixture of normal random variables.
As an example, consider independent random variables $X_1\sim N(\mu_1,\sigma_1^2)$, $X_2\sim N(\mu_2,\sigma_2^2)$, $\alpha_1\in\left[0,1\right]$, and $\alpha_2=1-\alpha_1$.
Let $Y=X_1+X_2$. $Y$ is the sum of two independent normal random variables. What's the probability that $Y$ is less than or equal to zero, $P(Y\leq0)$? It's simply the probability that a $N(\mu_1+\mu_2,\sigma_1^2+\sigma_2^2)$ random variable is less than or equal to zero because the sum of two independent normal random variables is another normal random variable whose mean is the sum of the means and whose variance is the sum of the variances.
Let $Z$ be a mixture of $X_1$ and $X_2$ with respective weights $\alpha_1$ and $\alpha_2$. Notice that $Z\neq \alpha_1X_1+\alpha_2X_2$. The fact that $Z$ is defined as a mixture with those specific weights means that the CDF of $Z$ is $F_Z(z)=\alpha_1F_1(z)+\alpha_2F_2(z)$, where $F_1$ and $F_2$ are the CDFs of $X_1$ and $X_2$, respectively. So what is the probability that $Z$ is less than or equal to zero, $P(Z\leq0)$? It's $F_Z(0)=\alpha_1F_1(0)+\alpha_2F_2(0)$. | Connection between sum of normally distributed random variables and mixture of normal distributions | It's important to make the distinction between a sum of normal random variables and a mixture of normal random variables.
As an example, consider independent random variables $X_1\sim N(\mu_1,\sigma_1 | Connection between sum of normally distributed random variables and mixture of normal distributions
It's important to make the distinction between a sum of normal random variables and a mixture of normal random variables.
As an example, consider independent random variables $X_1\sim N(\mu_1,\sigma_1^2)$, $X_2\sim N(\mu_2,\sigma_2^2)$, $\alpha_1\in\left[0,1\right]$, and $\alpha_2=1-\alpha_1$.
Let $Y=X_1+X_2$. $Y$ is the sum of two independent normal random variables. What's the probability that $Y$ is less than or equal to zero, $P(Y\leq0)$? It's simply the probability that a $N(\mu_1+\mu_2,\sigma_1^2+\sigma_2^2)$ random variable is less than or equal to zero because the sum of two independent normal random variables is another normal random variable whose mean is the sum of the means and whose variance is the sum of the variances.
Let $Z$ be a mixture of $X_1$ and $X_2$ with respective weights $\alpha_1$ and $\alpha_2$. Notice that $Z\neq \alpha_1X_1+\alpha_2X_2$. The fact that $Z$ is defined as a mixture with those specific weights means that the CDF of $Z$ is $F_Z(z)=\alpha_1F_1(z)+\alpha_2F_2(z)$, where $F_1$ and $F_2$ are the CDFs of $X_1$ and $X_2$, respectively. So what is the probability that $Z$ is less than or equal to zero, $P(Z\leq0)$? It's $F_Z(0)=\alpha_1F_1(0)+\alpha_2F_2(0)$. | Connection between sum of normally distributed random variables and mixture of normal distributions
It's important to make the distinction between a sum of normal random variables and a mixture of normal random variables.
As an example, consider independent random variables $X_1\sim N(\mu_1,\sigma_1 |
30,403 | Connection between sum of normally distributed random variables and mixture of normal distributions | Max has correctly pointed out the difference between sums of independent normals and mixtures of normals. However, he did not show directly how that answers your question.
Simply stated the two distributions are vastly different. The sum is normally distributed. A mixture of two or three normals is not. In fact, it will be bimodal when two distributions are included with very different means and nearly equal weights. When one distribution has a high weight and the other is far to the right with a small weight this will induce skewness and possibly kurtosis that is larger than for a normal distribution. In the case of three distributions with the middle having a weight of 0.8 and the other two equally shifted one to the right and the other to the left with a weight of 0.1, each the distribution will be symmetric with heavy tails. Plot some of the densities and the non-normality will be obvious. | Connection between sum of normally distributed random variables and mixture of normal distributions | Max has correctly pointed out the difference between sums of independent normals and mixtures of normals. However, he did not show directly how that answers your question.
Simply stated the two distri | Connection between sum of normally distributed random variables and mixture of normal distributions
Max has correctly pointed out the difference between sums of independent normals and mixtures of normals. However, he did not show directly how that answers your question.
Simply stated the two distributions are vastly different. The sum is normally distributed. A mixture of two or three normals is not. In fact, it will be bimodal when two distributions are included with very different means and nearly equal weights. When one distribution has a high weight and the other is far to the right with a small weight this will induce skewness and possibly kurtosis that is larger than for a normal distribution. In the case of three distributions with the middle having a weight of 0.8 and the other two equally shifted one to the right and the other to the left with a weight of 0.1, each the distribution will be symmetric with heavy tails. Plot some of the densities and the non-normality will be obvious. | Connection between sum of normally distributed random variables and mixture of normal distributions
Max has correctly pointed out the difference between sums of independent normals and mixtures of normals. However, he did not show directly how that answers your question.
Simply stated the two distri |
30,404 | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | Remember that the difference between significant and non-significant is not (always) statistically significant
Now, more to the point of your question, model 1 is called pooled regression, and model 2 unpooled regression. As you noted, in pooled regression, you assume that the groups aren't relevant, which means that the variance between groups is set to zero.
In the unpooled regression, with an intercept per group, you set the variance to infinity.
In general, I'd favor an intermediate solution, which is a hierarchical model or partial pooled regression (or shrinkage estimator). You can fit this model in R with the lmer4 package.
Finally, take a look at this paper by Gelman, in which he argues why hierarchical models helps with the multiple comparisons problems (in your case, are the coefficients per group different? How do we correct a p-value for multiple comparisons).
For instance, in your case,
library(lme4)
summary(lmer( leg ~ head + (1 | site)) # varying intercept model
If you want to fit a varying-intercept, varying slope (the third model), just run
summary(lmer( leg ~ head + (1 | site) + (0+head|site) )) # varying intercept, varying-slope model
Then you can take a look at the group variance and see if it's different from zero (the pooled regression isn't the better model) and far from infinity (unpooled regression).
update:
After the comments (see below), I decided to expand my answer.
The purpose of a hierarchical model, specially in cases like this, is to model the variation by groups (in this case, Sites). So, instead of running an ANOVA to test if a model is different from another, I'd take a look at the predictions of my model and see if the predictions by group is better in the hierarchical models vs the pooled regression (classical regression).
Now, I ran my sugestions above and foudn that
ranef(lmer( leg ~ head + (1 | site) + (0+head|site) )
Would return zero as estimates of varying slope (varying effect of head by site).
then I ran
ranef(lmer( leg ~ head + (head| site))
And I got a non-zero estimates for the varying effect of head. I don't know yet why this happened, since it's the first time I found this. I'm really sorry for this problem, but, in my defense, I just followed the specification outlined in the help of the lmer function.
(See the example with the data sleepstudy). I'll try to understand what's happening and I'll report here when (if) I understand what's happening. | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | Remember that the difference between significant and non-significant is not (always) statistically significant
Now, more to the point of your question, model 1 is called pooled regression, and model 2 | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
Remember that the difference between significant and non-significant is not (always) statistically significant
Now, more to the point of your question, model 1 is called pooled regression, and model 2 unpooled regression. As you noted, in pooled regression, you assume that the groups aren't relevant, which means that the variance between groups is set to zero.
In the unpooled regression, with an intercept per group, you set the variance to infinity.
In general, I'd favor an intermediate solution, which is a hierarchical model or partial pooled regression (or shrinkage estimator). You can fit this model in R with the lmer4 package.
Finally, take a look at this paper by Gelman, in which he argues why hierarchical models helps with the multiple comparisons problems (in your case, are the coefficients per group different? How do we correct a p-value for multiple comparisons).
For instance, in your case,
library(lme4)
summary(lmer( leg ~ head + (1 | site)) # varying intercept model
If you want to fit a varying-intercept, varying slope (the third model), just run
summary(lmer( leg ~ head + (1 | site) + (0+head|site) )) # varying intercept, varying-slope model
Then you can take a look at the group variance and see if it's different from zero (the pooled regression isn't the better model) and far from infinity (unpooled regression).
update:
After the comments (see below), I decided to expand my answer.
The purpose of a hierarchical model, specially in cases like this, is to model the variation by groups (in this case, Sites). So, instead of running an ANOVA to test if a model is different from another, I'd take a look at the predictions of my model and see if the predictions by group is better in the hierarchical models vs the pooled regression (classical regression).
Now, I ran my sugestions above and foudn that
ranef(lmer( leg ~ head + (1 | site) + (0+head|site) )
Would return zero as estimates of varying slope (varying effect of head by site).
then I ran
ranef(lmer( leg ~ head + (head| site))
And I got a non-zero estimates for the varying effect of head. I don't know yet why this happened, since it's the first time I found this. I'm really sorry for this problem, but, in my defense, I just followed the specification outlined in the help of the lmer function.
(See the example with the data sleepstudy). I'll try to understand what's happening and I'll report here when (if) I understand what's happening. | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
Remember that the difference between significant and non-significant is not (always) statistically significant
Now, more to the point of your question, model 1 is called pooled regression, and model 2 |
30,405 | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | Before any moderator intervention, you could look at
library(car)
crPlots(lm.2,terms=~Site)
These are Component+Residual (Partial Residual) Plots | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | Before any moderator intervention, you could look at
library(car)
crPlots(lm.2,terms=~Site)
These are Component+Residual (Partial Residual) Plots | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
Before any moderator intervention, you could look at
library(car)
crPlots(lm.2,terms=~Site)
These are Component+Residual (Partial Residual) Plots | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
Before any moderator intervention, you could look at
library(car)
crPlots(lm.2,terms=~Site)
These are Component+Residual (Partial Residual) Plots |
30,406 | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | I think, among other things, that you're computing the confidence intervals wrong. Here are two ways to look at it:
(1) differences of each site from the baseline (ANZ) site [you could also compute differences from the overall mean by changing to sum-to-zero-contrasts
library(coefplot2) ## on r-forge
coefplot2(lm.2)
or (2) all pairwise comparisons (I'm not fond of this approach, but it's common):
library(multcomp)
ci <- confint(glht(lm.2, linfct = mcp(Site = "Tukey")))
ggplot(fortify(ci),aes(lhs,estimate,ymin=lwr,ymax=upr))+
geom_pointrange()+theme_bw()+geom_hline(yintercept=0,col="red") | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | I think, among other things, that you're computing the confidence intervals wrong. Here are two ways to look at it:
(1) differences of each site from the baseline (ANZ) site [you could also compute d | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
I think, among other things, that you're computing the confidence intervals wrong. Here are two ways to look at it:
(1) differences of each site from the baseline (ANZ) site [you could also compute differences from the overall mean by changing to sum-to-zero-contrasts
library(coefplot2) ## on r-forge
coefplot2(lm.2)
or (2) all pairwise comparisons (I'm not fond of this approach, but it's common):
library(multcomp)
ci <- confint(glht(lm.2, linfct = mcp(Site = "Tukey")))
ggplot(fortify(ci),aes(lhs,estimate,ymin=lwr,ymax=upr))+
geom_pointrange()+theme_bw()+geom_hline(yintercept=0,col="red") | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
I think, among other things, that you're computing the confidence intervals wrong. Here are two ways to look at it:
(1) differences of each site from the baseline (ANZ) site [you could also compute d |
30,407 | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | In addition to the other answers, here are some links from the Cornell Statistical Consulting Unit that are relevant to overlapping confidence intervals and serve as a good, short reminder of what they do and don't mean
http://www.cscu.cornell.edu/news/statnews/stnews73.pdf
http://www.cscu.cornell.edu/news/statnews/Stnews73insert.pdf
Here's the main point:
If two statistics have non-overlapping confidence intervals, they are necessarily significantly different but if they have overlapping confidence intervals, it is not necessarily true that they are not significantly different.
Here's the relevant text from the first link:
We can illustrate this with a simple example. Suppose we are
interested in comparing means from two independent samples. The mean
of the first sample is 9 and the mean of the second sample is 17.
Let’s assume that the two group means have the same standard errors,
equal to 2.5. The 95 percent confidence interval for the first group
mean can be calculated as: ± × 5.296.19 where 1.96 is the critical
t-value. The confidence interval for the first group mean is thus
(4.1, 13.9). Similarly for the second group, the confidence interval
for the mean is (12.1, 21.9). Notice that the two intervals overlap.
However, the t-statistic for comparing two means is:
t = (17-9)/√(2.5² + 2.5²) = 2.26
which reflects that the null hypothesis, that the means of the two
groups are the same, should be rejected at the α =
0.05 level. To verify the above conclusion, consider the 95 percent confidence interval for the difference between the two group means:
(17-9)±1.96 x √(2.5² + 2.5²) which yields (1.09, 14.91). The interval
does not contain zero, hence we reject the null hypothesis that the
group means are the same.
Generally, when comparing two parameter estimates, it is always true
that if the confidence intervals do not overlap, then the statistics
will be statistically significantly different. However, the converse
is not true. That is, it is erroneous to determine the statistical
significance of the difference between two statistics based on
overlapping confidence intervals. For an explanation of why this is
true for the case of two-sample comparison of means, see the following
link: http://www.cscu.cornell.edu/news/statnews/Stnews73insert.pdf
Here's the info from the other link: | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | In addition to the other answers, here are some links from the Cornell Statistical Consulting Unit that are relevant to overlapping confidence intervals and serve as a good, short reminder of what the | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
In addition to the other answers, here are some links from the Cornell Statistical Consulting Unit that are relevant to overlapping confidence intervals and serve as a good, short reminder of what they do and don't mean
http://www.cscu.cornell.edu/news/statnews/stnews73.pdf
http://www.cscu.cornell.edu/news/statnews/Stnews73insert.pdf
Here's the main point:
If two statistics have non-overlapping confidence intervals, they are necessarily significantly different but if they have overlapping confidence intervals, it is not necessarily true that they are not significantly different.
Here's the relevant text from the first link:
We can illustrate this with a simple example. Suppose we are
interested in comparing means from two independent samples. The mean
of the first sample is 9 and the mean of the second sample is 17.
Let’s assume that the two group means have the same standard errors,
equal to 2.5. The 95 percent confidence interval for the first group
mean can be calculated as: ± × 5.296.19 where 1.96 is the critical
t-value. The confidence interval for the first group mean is thus
(4.1, 13.9). Similarly for the second group, the confidence interval
for the mean is (12.1, 21.9). Notice that the two intervals overlap.
However, the t-statistic for comparing two means is:
t = (17-9)/√(2.5² + 2.5²) = 2.26
which reflects that the null hypothesis, that the means of the two
groups are the same, should be rejected at the α =
0.05 level. To verify the above conclusion, consider the 95 percent confidence interval for the difference between the two group means:
(17-9)±1.96 x √(2.5² + 2.5²) which yields (1.09, 14.91). The interval
does not contain zero, hence we reject the null hypothesis that the
group means are the same.
Generally, when comparing two parameter estimates, it is always true
that if the confidence intervals do not overlap, then the statistics
will be statistically significantly different. However, the converse
is not true. That is, it is erroneous to determine the statistical
significance of the difference between two statistics based on
overlapping confidence intervals. For an explanation of why this is
true for the case of two-sample comparison of means, see the following
link: http://www.cscu.cornell.edu/news/statnews/Stnews73insert.pdf
Here's the info from the other link: | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
In addition to the other answers, here are some links from the Cornell Statistical Consulting Unit that are relevant to overlapping confidence intervals and serve as a good, short reminder of what the |
30,408 | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | Note that all your Head values are in the 1.7 - 2.4 range, while the intercepts are trying to estimate the Leg value at Head=0. This is a major extrapolation, so there is lots of uncertainty. If you were to center the Head values, and repeat this analysis, the confidence intervals would get much tighter.
Additionally, overlapping 95% confidence intervals do not imply lack of statistically significant difference. In fact, for two groups, non-overlapping 84% confidence intervals approximate having differences significant at the 5% level. Of course, because of multiple testing, this does not quite work with multiple groups. | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible? | Note that all your Head values are in the 1.7 - 2.4 range, while the intercepts are trying to estimate the Leg value at Head=0. This is a major extrapolation, so there is lots of uncertainty. If you w | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
Note that all your Head values are in the 1.7 - 2.4 range, while the intercepts are trying to estimate the Leg value at Head=0. This is a major extrapolation, so there is lots of uncertainty. If you were to center the Head values, and repeat this analysis, the confidence intervals would get much tighter.
Additionally, overlapping 95% confidence intervals do not imply lack of statistically significant difference. In fact, for two groups, non-overlapping 84% confidence intervals approximate having differences significant at the 5% level. Of course, because of multiple testing, this does not quite work with multiple groups. | ANCOVA in R suggests different intercepts, but the 95% CIs overlap... how is this possible?
Note that all your Head values are in the 1.7 - 2.4 range, while the intercepts are trying to estimate the Leg value at Head=0. This is a major extrapolation, so there is lots of uncertainty. If you w |
30,409 | What is French data analysis? | French style data analysis is usually identified as work based on Correspondence Analysis and other spectrally-oriented work, but is actually more deeply grounded. Tim's reference to the Holmes piece is particularly helpful here.
A slightly broad picture would be to say that French style takes an axiomatic, geometrical, and mathematical approach to data matrices rather than a statistical modelling one. The term must be a little ironic because although CA was popularised by Benzecri, LeBart etc. (French) it has precursors in Hirschfeld (German) and successors in de Leeuw / Gifi (Dutch) and popularisers in Greenacre (South African). Greenacre also noted an important connection to generalised SVD and generated for me the only easily readable book on the topic. Discussions can get caustic -- see de Leeuw's review of Murtagh.
A useful example for seeing the comparing consequences of the style is in the analysis of crosstabulations. With a simple crosstab one might compare the 'French' style of simple Correspondence Analysis based on spectral decomposition of a suitably transformed table, with Association modeling (e.g. by Goodman, Clogg, or Haberman) based on structured interaction terms in an underlying log linear model. In fact these two approaches generate very similar parameterisations (and parameters!), but the focus is quite different. Agresti (1990) has a excellent discussion. | What is French data analysis? | French style data analysis is usually identified as work based on Correspondence Analysis and other spectrally-oriented work, but is actually more deeply grounded. Tim's reference to the Holmes piece | What is French data analysis?
French style data analysis is usually identified as work based on Correspondence Analysis and other spectrally-oriented work, but is actually more deeply grounded. Tim's reference to the Holmes piece is particularly helpful here.
A slightly broad picture would be to say that French style takes an axiomatic, geometrical, and mathematical approach to data matrices rather than a statistical modelling one. The term must be a little ironic because although CA was popularised by Benzecri, LeBart etc. (French) it has precursors in Hirschfeld (German) and successors in de Leeuw / Gifi (Dutch) and popularisers in Greenacre (South African). Greenacre also noted an important connection to generalised SVD and generated for me the only easily readable book on the topic. Discussions can get caustic -- see de Leeuw's review of Murtagh.
A useful example for seeing the comparing consequences of the style is in the analysis of crosstabulations. With a simple crosstab one might compare the 'French' style of simple Correspondence Analysis based on spectral decomposition of a suitably transformed table, with Association modeling (e.g. by Goodman, Clogg, or Haberman) based on structured interaction terms in an underlying log linear model. In fact these two approaches generate very similar parameterisations (and parameters!), but the focus is quite different. Agresti (1990) has a excellent discussion. | What is French data analysis?
French style data analysis is usually identified as work based on Correspondence Analysis and other spectrally-oriented work, but is actually more deeply grounded. Tim's reference to the Holmes piece |
30,410 | What is French data analysis? | Maybe "correspondence analysis"? : http://en.wikipedia.org/wiki/Correspondence_analysis
because it was primarily developed by a French researcher Jean-Paul Benzecri ? | What is French data analysis? | Maybe "correspondence analysis"? : http://en.wikipedia.org/wiki/Correspondence_analysis
because it was primarily developed by a French researcher Jean-Paul Benzecri ? | What is French data analysis?
Maybe "correspondence analysis"? : http://en.wikipedia.org/wiki/Correspondence_analysis
because it was primarily developed by a French researcher Jean-Paul Benzecri ? | What is French data analysis?
Maybe "correspondence analysis"? : http://en.wikipedia.org/wiki/Correspondence_analysis
because it was primarily developed by a French researcher Jean-Paul Benzecri ? |
30,411 | Looking for 2D artificial data to demonstrate properties of clustering algorithms | R comes with a lot of datasets, and it looks like it would not be a big deal to reproduce most of the examples you cited with few lines of code. You may also find the mlbench package useful, in particular synthetic datasets starting with mlbench.*. Some illustrations are given below.
You will find additional examples by looking at the Cluster Task View on CRAN. For example, the fpc package has a built-in generator for "face-shaped" clustered benchmark datasets (rFace).
Similar considerations apply to Python, where you will find interesting benchmark tests and datasets for clustering with the scikit-learn.
The UCI Machine Learning Repository hosts a lot of datasets as well, but you're better off simulating data yourself with the language of your choice. | Looking for 2D artificial data to demonstrate properties of clustering algorithms | R comes with a lot of datasets, and it looks like it would not be a big deal to reproduce most of the examples you cited with few lines of code. You may also find the mlbench package useful, in partic | Looking for 2D artificial data to demonstrate properties of clustering algorithms
R comes with a lot of datasets, and it looks like it would not be a big deal to reproduce most of the examples you cited with few lines of code. You may also find the mlbench package useful, in particular synthetic datasets starting with mlbench.*. Some illustrations are given below.
You will find additional examples by looking at the Cluster Task View on CRAN. For example, the fpc package has a built-in generator for "face-shaped" clustered benchmark datasets (rFace).
Similar considerations apply to Python, where you will find interesting benchmark tests and datasets for clustering with the scikit-learn.
The UCI Machine Learning Repository hosts a lot of datasets as well, but you're better off simulating data yourself with the language of your choice. | Looking for 2D artificial data to demonstrate properties of clustering algorithms
R comes with a lot of datasets, and it looks like it would not be a big deal to reproduce most of the examples you cited with few lines of code. You may also find the mlbench package useful, in partic |
30,412 | Looking for 2D artificial data to demonstrate properties of clustering algorithms | Here are some datasets designed exactly for this task:
The Fundamental Clustering Problem Suite by Ultsch | Looking for 2D artificial data to demonstrate properties of clustering algorithms | Here are some datasets designed exactly for this task:
The Fundamental Clustering Problem Suite by Ultsch | Looking for 2D artificial data to demonstrate properties of clustering algorithms
Here are some datasets designed exactly for this task:
The Fundamental Clustering Problem Suite by Ultsch | Looking for 2D artificial data to demonstrate properties of clustering algorithms
Here are some datasets designed exactly for this task:
The Fundamental Clustering Problem Suite by Ultsch |
30,413 | Looking for 2D artificial data to demonstrate properties of clustering algorithms | This toy clustering benchmark contains various data sets in ARFF format (could be easily converted to CSV), mostly with ground truth labels. The benchmark should validate basic desired properties of clustering algorithms. Most of the data sets comes from the clustering papers like:
BIRCH - Zhang, Tian, Raghu Ramakrishnan, and Miron Livny. "BIRCH: an efficient data clustering method for very large databases." ACM SIGMOD Record. Vol. 25. No. 2. ACM, 1996.
CURE - Guha, Sudipto, Rajeev Rastogi, and Kyuseok Shim. "CURE: an efficient clustering algorithm for large databases." ACM SIGMOD Record. Vol. 27. No. 2. ACM, 1998.
Chameleon - Karypis, George, Eui-Hong Han, and Vipin Kumar. "Chameleon: Hierarchical clustering using dynamic modeling." Computer 32.8 (1999): 68-75.
The Fundamental Clustering Problem Suite - Ultsch, A.: Clustering with SOM: U*C, In Proc. Workshop on Self-Organizing Maps, Paris, France, (2005) , pp. 75-82
MOCK - Handl, Julia, and Joshua Knowles. "An evolutionary approach to multiobjective clustering." Evolutionary Computation, IEEE Transactions on 11.1 (2007): 56-76.
Robust path-based spectral clustering - Chang, Hong, and Dit-Yan Yeung. "Robust path-based spectral clustering." Pattern Recognition 41.1 (2008): 191-203. | Looking for 2D artificial data to demonstrate properties of clustering algorithms | This toy clustering benchmark contains various data sets in ARFF format (could be easily converted to CSV), mostly with ground truth labels. The benchmark should validate basic desired properties of c | Looking for 2D artificial data to demonstrate properties of clustering algorithms
This toy clustering benchmark contains various data sets in ARFF format (could be easily converted to CSV), mostly with ground truth labels. The benchmark should validate basic desired properties of clustering algorithms. Most of the data sets comes from the clustering papers like:
BIRCH - Zhang, Tian, Raghu Ramakrishnan, and Miron Livny. "BIRCH: an efficient data clustering method for very large databases." ACM SIGMOD Record. Vol. 25. No. 2. ACM, 1996.
CURE - Guha, Sudipto, Rajeev Rastogi, and Kyuseok Shim. "CURE: an efficient clustering algorithm for large databases." ACM SIGMOD Record. Vol. 27. No. 2. ACM, 1998.
Chameleon - Karypis, George, Eui-Hong Han, and Vipin Kumar. "Chameleon: Hierarchical clustering using dynamic modeling." Computer 32.8 (1999): 68-75.
The Fundamental Clustering Problem Suite - Ultsch, A.: Clustering with SOM: U*C, In Proc. Workshop on Self-Organizing Maps, Paris, France, (2005) , pp. 75-82
MOCK - Handl, Julia, and Joshua Knowles. "An evolutionary approach to multiobjective clustering." Evolutionary Computation, IEEE Transactions on 11.1 (2007): 56-76.
Robust path-based spectral clustering - Chang, Hong, and Dit-Yan Yeung. "Robust path-based spectral clustering." Pattern Recognition 41.1 (2008): 191-203. | Looking for 2D artificial data to demonstrate properties of clustering algorithms
This toy clustering benchmark contains various data sets in ARFF format (could be easily converted to CSV), mostly with ground truth labels. The benchmark should validate basic desired properties of c |
30,414 | Looking for 2D artificial data to demonstrate properties of clustering algorithms | ELKI comes with a couple of data sets (check also the unit tests, they contain many more than those on the web site, along with parameter settings).
It also includes a fairly flexible data generator. | Looking for 2D artificial data to demonstrate properties of clustering algorithms | ELKI comes with a couple of data sets (check also the unit tests, they contain many more than those on the web site, along with parameter settings).
It also includes a fairly flexible data generator. | Looking for 2D artificial data to demonstrate properties of clustering algorithms
ELKI comes with a couple of data sets (check also the unit tests, they contain many more than those on the web site, along with parameter settings).
It also includes a fairly flexible data generator. | Looking for 2D artificial data to demonstrate properties of clustering algorithms
ELKI comes with a couple of data sets (check also the unit tests, they contain many more than those on the web site, along with parameter settings).
It also includes a fairly flexible data generator. |
30,415 | Looking for 2D artificial data to demonstrate properties of clustering algorithms | Here is a customizable cluster generator. It only addresses a certain class of data sets, but it can surely be used for cluster algorithm investigations.
Here is an example of the kind of clusters it can create:
Cluster affiliation is saved in a text file. The code is open source under MIT license. | Looking for 2D artificial data to demonstrate properties of clustering algorithms | Here is a customizable cluster generator. It only addresses a certain class of data sets, but it can surely be used for cluster algorithm investigations.
Here is an example of the kind of clusters it | Looking for 2D artificial data to demonstrate properties of clustering algorithms
Here is a customizable cluster generator. It only addresses a certain class of data sets, but it can surely be used for cluster algorithm investigations.
Here is an example of the kind of clusters it can create:
Cluster affiliation is saved in a text file. The code is open source under MIT license. | Looking for 2D artificial data to demonstrate properties of clustering algorithms
Here is a customizable cluster generator. It only addresses a certain class of data sets, but it can surely be used for cluster algorithm investigations.
Here is an example of the kind of clusters it |
30,416 | Looking for 2D artificial data to demonstrate properties of clustering algorithms | This Matlab script generates 2D data for clustering. It accepts several parameters so that the generated data is within user requirements. | Looking for 2D artificial data to demonstrate properties of clustering algorithms | This Matlab script generates 2D data for clustering. It accepts several parameters so that the generated data is within user requirements. | Looking for 2D artificial data to demonstrate properties of clustering algorithms
This Matlab script generates 2D data for clustering. It accepts several parameters so that the generated data is within user requirements. | Looking for 2D artificial data to demonstrate properties of clustering algorithms
This Matlab script generates 2D data for clustering. It accepts several parameters so that the generated data is within user requirements. |
30,417 | Looking for 2D artificial data to demonstrate properties of clustering algorithms | I can't believe that nobody has mentioned Fisher's Iris data.
I don't think I've seen a clustering technique that doesn't use the iris data as an example.
In r, just type "iris" to access the data.
Here's an example of a nice (and typical) iris plot:
http://ygc.name/2011/12/24/ml-class-7-kmeans-clustering/ | Looking for 2D artificial data to demonstrate properties of clustering algorithms | I can't believe that nobody has mentioned Fisher's Iris data.
I don't think I've seen a clustering technique that doesn't use the iris data as an example.
In r, just type "iris" to access the data.
| Looking for 2D artificial data to demonstrate properties of clustering algorithms
I can't believe that nobody has mentioned Fisher's Iris data.
I don't think I've seen a clustering technique that doesn't use the iris data as an example.
In r, just type "iris" to access the data.
Here's an example of a nice (and typical) iris plot:
http://ygc.name/2011/12/24/ml-class-7-kmeans-clustering/ | Looking for 2D artificial data to demonstrate properties of clustering algorithms
I can't believe that nobody has mentioned Fisher's Iris data.
I don't think I've seen a clustering technique that doesn't use the iris data as an example.
In r, just type "iris" to access the data.
|
30,418 | What are the mean and variance of the ratio of two lognormal variables? | Note that $\log(X/Y) = \log(X) - \log(Y)$. Since $X$ and $Y$ are lognormally distributed, $\log(X)$ and $\log(Y)$ are Normally distributed.
I'll assume that $\log(X)$ and $\log(Y)$ have means $\mu_X$ and $\mu_Y$, variances $\sigma^2_X$ and $\sigma^2_Y$, and covariance $\sigma_{XY}$ (equal to zero if $X$ and $Y$ are independent) and are jointly normally distributed. The difference $Z$ is then normally distributed with mean $\mu_Z = \mu_X - \mu_Y$ and variance $\sigma^2_Z = \sigma^2_X + \sigma^2_Y - 2\sigma_{XY}$.
To get back to $X/Y$, note that $X/Y = \exp Z$, showing that $X/Y$ is itself lognormally distributed with parameters $\mu_Z$ and $\sigma^2_Z$. The relationship between the mean and variance of a lognormal variate and the mean and variance of the corresponding normal variate is:
$\mathbb E(X/Y) = \mathbb E e^Z = \exp \{\mu_Z + \frac{1}{2}\sigma^2_Z \}$
$\mathrm{Var}(X/Y) = \mathrm{Var}(e^Z) = \exp \{2\mu_Z + 2\sigma^2_Z\} - \exp \{2\mu_Z + \sigma^2_Z\} \>.$
This can be rather easily derived by considering the moment-generating function of the normal distribution with mean $\mu_Z$ and variance $\sigma^2_Z$. | What are the mean and variance of the ratio of two lognormal variables? | Note that $\log(X/Y) = \log(X) - \log(Y)$. Since $X$ and $Y$ are lognormally distributed, $\log(X)$ and $\log(Y)$ are Normally distributed.
I'll assume that $\log(X)$ and $\log(Y)$ have means $\mu | What are the mean and variance of the ratio of two lognormal variables?
Note that $\log(X/Y) = \log(X) - \log(Y)$. Since $X$ and $Y$ are lognormally distributed, $\log(X)$ and $\log(Y)$ are Normally distributed.
I'll assume that $\log(X)$ and $\log(Y)$ have means $\mu_X$ and $\mu_Y$, variances $\sigma^2_X$ and $\sigma^2_Y$, and covariance $\sigma_{XY}$ (equal to zero if $X$ and $Y$ are independent) and are jointly normally distributed. The difference $Z$ is then normally distributed with mean $\mu_Z = \mu_X - \mu_Y$ and variance $\sigma^2_Z = \sigma^2_X + \sigma^2_Y - 2\sigma_{XY}$.
To get back to $X/Y$, note that $X/Y = \exp Z$, showing that $X/Y$ is itself lognormally distributed with parameters $\mu_Z$ and $\sigma^2_Z$. The relationship between the mean and variance of a lognormal variate and the mean and variance of the corresponding normal variate is:
$\mathbb E(X/Y) = \mathbb E e^Z = \exp \{\mu_Z + \frac{1}{2}\sigma^2_Z \}$
$\mathrm{Var}(X/Y) = \mathrm{Var}(e^Z) = \exp \{2\mu_Z + 2\sigma^2_Z\} - \exp \{2\mu_Z + \sigma^2_Z\} \>.$
This can be rather easily derived by considering the moment-generating function of the normal distribution with mean $\mu_Z$ and variance $\sigma^2_Z$. | What are the mean and variance of the ratio of two lognormal variables?
Note that $\log(X/Y) = \log(X) - \log(Y)$. Since $X$ and $Y$ are lognormally distributed, $\log(X)$ and $\log(Y)$ are Normally distributed.
I'll assume that $\log(X)$ and $\log(Y)$ have means $\mu |
30,419 | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution? | To get error bars, you can construct a confidence interval around the entire empirical cumulative distribution function (ECDF). This can be done using the Dvoretzky-Kiefer-Wolfowitz inequality. If you want the ECDF to be within $\epsilon$ of the true CDF with confidence $1- \alpha,$ then choose the sample size $n$ using $$n \ge \left( {{1} \over {2 \epsilon^2}} \right) \mathrm{ln} \left({{2} \over {\alpha}} \right)$$
So, for example, if you want the ECDF to be within $0.01$ of the CDF with 95% confidence, we find by plugging in that $$n \ge 18444.4$$ so we select $n=18445.$ | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut | To get error bars, you can construct a confidence interval around the entire empirical cumulative distribution function (ECDF). This can be done using the Dvoretzky-Kiefer-Wolfowitz inequality. If you | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution?
To get error bars, you can construct a confidence interval around the entire empirical cumulative distribution function (ECDF). This can be done using the Dvoretzky-Kiefer-Wolfowitz inequality. If you want the ECDF to be within $\epsilon$ of the true CDF with confidence $1- \alpha,$ then choose the sample size $n$ using $$n \ge \left( {{1} \over {2 \epsilon^2}} \right) \mathrm{ln} \left({{2} \over {\alpha}} \right)$$
So, for example, if you want the ECDF to be within $0.01$ of the CDF with 95% confidence, we find by plugging in that $$n \ge 18444.4$$ so we select $n=18445.$ | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut
To get error bars, you can construct a confidence interval around the entire empirical cumulative distribution function (ECDF). This can be done using the Dvoretzky-Kiefer-Wolfowitz inequality. If you |
30,420 | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution? | In statistics there really is no concept of a 'right' estimate, it's just if the estimate you construct has the properties that you are looking for.
Typically if you are trying to estimate a CDF, you will use the ECDF (Empirical CDF) which is just $ Pr(X < x) = \Sigma_{i=1}^n \mathbb{I}_{x_{(i)} \le x}(x) n^{-1}$. Where $X_{(i)}$ is the $i$th order statistic.
The ECDF has many nice properties such as being strongly consistent (pointwise even) to the CDF.
Since you have a discrete approximation of a continuous distribution you can generate quantiles that can be used for confidence intervals in the usual discrete way.
$inf_x( x : Pr(X <x) \ge \pi) $
Of course there is no reason why a confidence interval should be symmetric so I'm confused by your last statement that I think should be clarified. | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut | In statistics there really is no concept of a 'right' estimate, it's just if the estimate you construct has the properties that you are looking for.
Typically if you are trying to estimate a CDF, you | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution?
In statistics there really is no concept of a 'right' estimate, it's just if the estimate you construct has the properties that you are looking for.
Typically if you are trying to estimate a CDF, you will use the ECDF (Empirical CDF) which is just $ Pr(X < x) = \Sigma_{i=1}^n \mathbb{I}_{x_{(i)} \le x}(x) n^{-1}$. Where $X_{(i)}$ is the $i$th order statistic.
The ECDF has many nice properties such as being strongly consistent (pointwise even) to the CDF.
Since you have a discrete approximation of a continuous distribution you can generate quantiles that can be used for confidence intervals in the usual discrete way.
$inf_x( x : Pr(X <x) \ge \pi) $
Of course there is no reason why a confidence interval should be symmetric so I'm confused by your last statement that I think should be clarified. | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut
In statistics there really is no concept of a 'right' estimate, it's just if the estimate you construct has the properties that you are looking for.
Typically if you are trying to estimate a CDF, you |
30,421 | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution? | You could always use a kernel density estimator (which would also give the c.d.f. as the weighted sum of the component c.d.f.s). You could then get error bars by bootstrapping the available data. This would be pretty simple to implement and would give nice, well-behaved smooth c.d.f.s with error bars. | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut | You could always use a kernel density estimator (which would also give the c.d.f. as the weighted sum of the component c.d.f.s). You could then get error bars by bootstrapping the available data. Th | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution?
You could always use a kernel density estimator (which would also give the c.d.f. as the weighted sum of the component c.d.f.s). You could then get error bars by bootstrapping the available data. This would be pretty simple to implement and would give nice, well-behaved smooth c.d.f.s with error bars. | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut
You could always use a kernel density estimator (which would also give the c.d.f. as the weighted sum of the component c.d.f.s). You could then get error bars by bootstrapping the available data. Th |
30,422 | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution? | In a bayesian approach, you could use a Dirichlet Process (DP) to estimate the PDF and then integrate it. What you are trying to do is to estimate the function based on samples at certain values. The DP approach allows you to incorporate a smoothness assumption, which is useful because you will often prefer a solution that is differentiable than one that looks like a staircase. The outcome of your analysis is then a distribution over functions, which in particular gives you a mean function, and some error bars on it.
The following book has a nice chapter on Dirichlet processes:
O'Hagan, A. and Forster, J. J. (2004). Bayesian Inference, 2nd edition, volume 2B of "Kendall's Advanced Theory of Statistics". Arnold, London. | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut | In a bayesian approach, you could use a Dirichlet Process (DP) to estimate the PDF and then integrate it. What you are trying to do is to estimate the function based on samples at certain values. The | What is the proper way to estimate the CDF for a distribution from samples taken from that distribution?
In a bayesian approach, you could use a Dirichlet Process (DP) to estimate the PDF and then integrate it. What you are trying to do is to estimate the function based on samples at certain values. The DP approach allows you to incorporate a smoothness assumption, which is useful because you will often prefer a solution that is differentiable than one that looks like a staircase. The outcome of your analysis is then a distribution over functions, which in particular gives you a mean function, and some error bars on it.
The following book has a nice chapter on Dirichlet processes:
O'Hagan, A. and Forster, J. J. (2004). Bayesian Inference, 2nd edition, volume 2B of "Kendall's Advanced Theory of Statistics". Arnold, London. | What is the proper way to estimate the CDF for a distribution from samples taken from that distribut
In a bayesian approach, you could use a Dirichlet Process (DP) to estimate the PDF and then integrate it. What you are trying to do is to estimate the function based on samples at certain values. The |
30,423 | Questions about variable selection for classification, and different classification techniques | Feature selection does not necessarily improve the performance of modern classifier systems, and quite frequently makes performance worse. Unless finding out which features are the most important is an objective of the analysis, it is often better not even to try and to use regularisation to avoid over-fitting (select regularisation parameters by e.g. cross-validation).
The reason that feature selection is difficult is that it involves an optimisation problem with many degrees of freedom (essentially one per feature) where the criterion depends on a finite sample of data. This means you can over-fit the feature selection criterion and end up with a set of features that works well for that particular sample of data, but not for any other (i.e. it generalises poorly). Regularisation on the other hand, while also optimising a criterion based on a finite sample of data, involves fewer degrees of freedom (typically one), which means that over-fitting the criterion is more difficult.
It seems to me that the "feature selection gives better performance" idea has rather passed its sell by date. For simple linear unregularised classifiers (e.g. logistic regression), the complexity of the model (VC dimension) grows with the number of features. Once you bring in regularisation, the complexity of the model depends on the value of the regularisation parameter rather than the number of parameters. That means that regularised classifiers are resistant to over-fitting (provided you tune the regularisation parameter properly) even in very high dimensional spaces. In fact that is the basis of why the support vector machine works, use a kernel to tranform the data into a high (possibly infinite) dimensional space, and then use regularisation to control the complexity of the model and hence avoid over-fitting.
Having said which, there are no free lunches; your problem may be one where feature selection works well, and the only way to find out is to try it. However, whatever you do, make sure you use something like nested cross-validation to get an unbiased estimate of performance. The outer cross-validation is used for performance evaluation, but in each fold repeat every step in fitting the model (including feature selection) again independently. A common error is to perform feature selection using all of the data and then cross-validate to estimate performance using the features identified. IT should be obvious why that is not the right thing to do, but many have done it as the correct approach is computationally expensive.
My suggestion is to try SVMs or kernel logistic regression or LS-SVM etc. with various kernels, but no feature selection. If nothing else it will give you a meaningfull baseline. | Questions about variable selection for classification, and different classification techniques | Feature selection does not necessarily improve the performance of modern classifier systems, and quite frequently makes performance worse. Unless finding out which features are the most important is | Questions about variable selection for classification, and different classification techniques
Feature selection does not necessarily improve the performance of modern classifier systems, and quite frequently makes performance worse. Unless finding out which features are the most important is an objective of the analysis, it is often better not even to try and to use regularisation to avoid over-fitting (select regularisation parameters by e.g. cross-validation).
The reason that feature selection is difficult is that it involves an optimisation problem with many degrees of freedom (essentially one per feature) where the criterion depends on a finite sample of data. This means you can over-fit the feature selection criterion and end up with a set of features that works well for that particular sample of data, but not for any other (i.e. it generalises poorly). Regularisation on the other hand, while also optimising a criterion based on a finite sample of data, involves fewer degrees of freedom (typically one), which means that over-fitting the criterion is more difficult.
It seems to me that the "feature selection gives better performance" idea has rather passed its sell by date. For simple linear unregularised classifiers (e.g. logistic regression), the complexity of the model (VC dimension) grows with the number of features. Once you bring in regularisation, the complexity of the model depends on the value of the regularisation parameter rather than the number of parameters. That means that regularised classifiers are resistant to over-fitting (provided you tune the regularisation parameter properly) even in very high dimensional spaces. In fact that is the basis of why the support vector machine works, use a kernel to tranform the data into a high (possibly infinite) dimensional space, and then use regularisation to control the complexity of the model and hence avoid over-fitting.
Having said which, there are no free lunches; your problem may be one where feature selection works well, and the only way to find out is to try it. However, whatever you do, make sure you use something like nested cross-validation to get an unbiased estimate of performance. The outer cross-validation is used for performance evaluation, but in each fold repeat every step in fitting the model (including feature selection) again independently. A common error is to perform feature selection using all of the data and then cross-validate to estimate performance using the features identified. IT should be obvious why that is not the right thing to do, but many have done it as the correct approach is computationally expensive.
My suggestion is to try SVMs or kernel logistic regression or LS-SVM etc. with various kernels, but no feature selection. If nothing else it will give you a meaningfull baseline. | Questions about variable selection for classification, and different classification techniques
Feature selection does not necessarily improve the performance of modern classifier systems, and quite frequently makes performance worse. Unless finding out which features are the most important is |
30,424 | Questions about variable selection for classification, and different classification techniques | On dimensionality reduction, a good first choice might be principal components analysis.
Apart from that, i don't have too much to add, except that if you have any interest in data mining, I strongly recommend you read the elements of statistical learning. Its both rigorous and clear, and although I haven't finished it, it would probably give you much insight into the right way to approach your problem. Chapter 4, linear classifiers would almost certainly enough to get you started. | Questions about variable selection for classification, and different classification techniques | On dimensionality reduction, a good first choice might be principal components analysis.
Apart from that, i don't have too much to add, except that if you have any interest in data mining, I strongly | Questions about variable selection for classification, and different classification techniques
On dimensionality reduction, a good first choice might be principal components analysis.
Apart from that, i don't have too much to add, except that if you have any interest in data mining, I strongly recommend you read the elements of statistical learning. Its both rigorous and clear, and although I haven't finished it, it would probably give you much insight into the right way to approach your problem. Chapter 4, linear classifiers would almost certainly enough to get you started. | Questions about variable selection for classification, and different classification techniques
On dimensionality reduction, a good first choice might be principal components analysis.
Apart from that, i don't have too much to add, except that if you have any interest in data mining, I strongly |
30,425 | The positive stable distribution in R | The short answer is that your $\delta$ is fine, but your $\gamma$ is wrong. In order to get the positive stable distribution given by your formula in R, you need to set
$$
\gamma = |1 - i \tan \left(\pi \alpha / 2\right)|^{-1/\alpha}.
$$
The earliest example I could find of the formula you gave was in (Feller, 1971), but I've only found that book in physical form. However (Hougaard, 1986) gives the same formula, along with the Laplace transform
$$
\mathrm{L}(s) = \mathrm{E}\left[\exp(-sX)\right] = \exp\left(-s^\alpha\right).
$$
From the stabledist manual (stabledist is used in fBasics), the pm=1 parameterization is from (Samorodnitsky and Taqqu, 1994), another resource whose online reproduction has eluded me. However (Weron, 2001) gives the characteristic function in Samorodnitsky and Taqqu's parameterization for $\alpha \neq 1$ to be
$$
\varphi(t) = \mathrm{E}\left[\exp(i t X) \right] = \exp\left[i \delta t - \gamma^\alpha |t|^\alpha \left(1 - i \beta \mathrm{sign}(t) \tan{\frac{\pi \alpha}{2}} \right) \right].
$$
I've renamed some parameters from Weron's paper to coinside with the notation we're using. He uses $\mu$ for $\delta$ and $\sigma$ for $\gamma$. In any case, plugging in $\beta=1$ and $\delta=0$, we get
$$
\varphi(t) = \exp\left[-\gamma^\alpha |t|^\alpha \left(1 - i \mathrm{sign}(t) \tan \frac{\pi \alpha}{2} \right) \right].
$$
Note that $(1 - i \tan (\pi \alpha / 2)) / |1 - i \tan(\pi \alpha / 2)| = \exp(-i \pi \alpha / 2)$ for $\alpha \in (0, 1)$ and that $i^\alpha = \exp(i \pi \alpha / 2)$. Formally, $\mathrm{L}(s)=\varphi(is)$, so by setting $\gamma = |1 - i \tan \left(\pi \alpha / 2\right)|^{-1/\alpha}$ in $\varphi(t)$ we get
$$
\varphi(is) = \exp\left(-s^\alpha\right) = \mathrm{L}(s).
$$
One interesting point to note is that the $\gamma$ that corresponds to $\alpha=1/2$ is also $1/2$, so if you were to try $\gamma=\alpha$ or $\gamma=1-\alpha$, which is actually not a bad approximation, you end up exactly correct for $\alpha=1/2$.
Here's an example in R to check correctness:
library(stabledist)
# Series representation of the density
PSf <- function(x, alpha, K) {
k <- 1:K
return(
-1 / (pi * x) * sum(
gamma(k * alpha + 1) / factorial(k) *
(-x ^ (-alpha)) ^ k * sin(alpha * k * pi)
)
)
}
# Derived expression for gamma
g <- function(a) {
iu <- complex(real=0, imaginary=1)
return(abs(1 - iu * tan(pi * a / 2)) ^ (-1 / a))
}
x=(1:100)/100
plot(0, xlim=c(0, 1), ylim=c(0, 2), pch='',
xlab='x', ylab='f(x)', main="Density Comparison")
legend('topright', legend=c('Series', 'gamma=g(alpha)'),
lty=c(1, 2), col=c('gray', 'black'),
lwd=c(5, 2))
text(x=c(0.1, 0.25, 0.7), y=c(1.4, 1.1, 0.7),
labels=c(expression(paste(alpha, " = 0.4")),
expression(paste(alpha, " = 0.5")),
expression(paste(alpha, " = 0.6"))))
for(a in seq(0.4, 0.6, by=0.1)) {
y <- vapply(x, PSf, FUN.VALUE=1, alpha=a, K=100)
lines(x, y, col="gray", lwd=5, lty=1)
lines(x, dstable(x, alpha=a, beta=1, gamma=g(a), delta=0, pm=1),
col="black", lwd=2, lty=2)
}
$\hskip1in$
Feller, W. (1971). An Introduction to Probability Theory and Its Applications, 2, 2nd ed. New York: Wiley.
Hougaard, P. (1986). Survival Models for Heterogeneous Populations Derived from Stable Distributions, Biometrika 73, 387-396.
Samorodnitsky, G., Taqqu, M.S. (1994). Stable Non-Gaussian Random Processes, Chapman & Hall, New York, 1994.
Weron, R. (2001). Levy-stable distributions revisited: tail index > 2 does not exclude the Levy-stable regime, International Journal of Modern Physics C, 2001, 12(2), 209-223. | The positive stable distribution in R | The short answer is that your $\delta$ is fine, but your $\gamma$ is wrong. In order to get the positive stable distribution given by your formula in R, you need to set
$$
\gamma = |1 - i \tan \left(\ | The positive stable distribution in R
The short answer is that your $\delta$ is fine, but your $\gamma$ is wrong. In order to get the positive stable distribution given by your formula in R, you need to set
$$
\gamma = |1 - i \tan \left(\pi \alpha / 2\right)|^{-1/\alpha}.
$$
The earliest example I could find of the formula you gave was in (Feller, 1971), but I've only found that book in physical form. However (Hougaard, 1986) gives the same formula, along with the Laplace transform
$$
\mathrm{L}(s) = \mathrm{E}\left[\exp(-sX)\right] = \exp\left(-s^\alpha\right).
$$
From the stabledist manual (stabledist is used in fBasics), the pm=1 parameterization is from (Samorodnitsky and Taqqu, 1994), another resource whose online reproduction has eluded me. However (Weron, 2001) gives the characteristic function in Samorodnitsky and Taqqu's parameterization for $\alpha \neq 1$ to be
$$
\varphi(t) = \mathrm{E}\left[\exp(i t X) \right] = \exp\left[i \delta t - \gamma^\alpha |t|^\alpha \left(1 - i \beta \mathrm{sign}(t) \tan{\frac{\pi \alpha}{2}} \right) \right].
$$
I've renamed some parameters from Weron's paper to coinside with the notation we're using. He uses $\mu$ for $\delta$ and $\sigma$ for $\gamma$. In any case, plugging in $\beta=1$ and $\delta=0$, we get
$$
\varphi(t) = \exp\left[-\gamma^\alpha |t|^\alpha \left(1 - i \mathrm{sign}(t) \tan \frac{\pi \alpha}{2} \right) \right].
$$
Note that $(1 - i \tan (\pi \alpha / 2)) / |1 - i \tan(\pi \alpha / 2)| = \exp(-i \pi \alpha / 2)$ for $\alpha \in (0, 1)$ and that $i^\alpha = \exp(i \pi \alpha / 2)$. Formally, $\mathrm{L}(s)=\varphi(is)$, so by setting $\gamma = |1 - i \tan \left(\pi \alpha / 2\right)|^{-1/\alpha}$ in $\varphi(t)$ we get
$$
\varphi(is) = \exp\left(-s^\alpha\right) = \mathrm{L}(s).
$$
One interesting point to note is that the $\gamma$ that corresponds to $\alpha=1/2$ is also $1/2$, so if you were to try $\gamma=\alpha$ or $\gamma=1-\alpha$, which is actually not a bad approximation, you end up exactly correct for $\alpha=1/2$.
Here's an example in R to check correctness:
library(stabledist)
# Series representation of the density
PSf <- function(x, alpha, K) {
k <- 1:K
return(
-1 / (pi * x) * sum(
gamma(k * alpha + 1) / factorial(k) *
(-x ^ (-alpha)) ^ k * sin(alpha * k * pi)
)
)
}
# Derived expression for gamma
g <- function(a) {
iu <- complex(real=0, imaginary=1)
return(abs(1 - iu * tan(pi * a / 2)) ^ (-1 / a))
}
x=(1:100)/100
plot(0, xlim=c(0, 1), ylim=c(0, 2), pch='',
xlab='x', ylab='f(x)', main="Density Comparison")
legend('topright', legend=c('Series', 'gamma=g(alpha)'),
lty=c(1, 2), col=c('gray', 'black'),
lwd=c(5, 2))
text(x=c(0.1, 0.25, 0.7), y=c(1.4, 1.1, 0.7),
labels=c(expression(paste(alpha, " = 0.4")),
expression(paste(alpha, " = 0.5")),
expression(paste(alpha, " = 0.6"))))
for(a in seq(0.4, 0.6, by=0.1)) {
y <- vapply(x, PSf, FUN.VALUE=1, alpha=a, K=100)
lines(x, y, col="gray", lwd=5, lty=1)
lines(x, dstable(x, alpha=a, beta=1, gamma=g(a), delta=0, pm=1),
col="black", lwd=2, lty=2)
}
$\hskip1in$
Feller, W. (1971). An Introduction to Probability Theory and Its Applications, 2, 2nd ed. New York: Wiley.
Hougaard, P. (1986). Survival Models for Heterogeneous Populations Derived from Stable Distributions, Biometrika 73, 387-396.
Samorodnitsky, G., Taqqu, M.S. (1994). Stable Non-Gaussian Random Processes, Chapman & Hall, New York, 1994.
Weron, R. (2001). Levy-stable distributions revisited: tail index > 2 does not exclude the Levy-stable regime, International Journal of Modern Physics C, 2001, 12(2), 209-223. | The positive stable distribution in R
The short answer is that your $\delta$ is fine, but your $\gamma$ is wrong. In order to get the positive stable distribution given by your formula in R, you need to set
$$
\gamma = |1 - i \tan \left(\ |
30,426 | The positive stable distribution in R | What I think is happening is that in the output delta may be reporting an internal location value, while in the input delta is describing the shift. [There seems to be a similar issue with gamma when pm=2.] So if you try increasing the shift to 2
> dstable(4, alpha=0.4, beta=1, gamma=0.4, delta=2, pm=1)
[1] 0.06569375
attr(,"control")
dist alpha beta gamma delta pm
stable 0.4 1 0.4 2.290617 1
then you add 2 to the location value.
With beta=1 and pm=1 you have a positive random variable with a distribution lower bound at 0.
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=0, pm=1))
[1] 0.002666507
Shift by 2 and the lower bound rises by the same amount
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=2, pm=1))
[1] 2.003286
But if you want the delta input to be the internal location value rather than the shift or lower bound, then you need to use a different specification for the parameters. For example if you try the following (with pm=3 and trying delta=0 and the delta=0.290617 you found earlier), you seem to get the same delta in and out. With pm=3 and delta=0.290617 you get the same density of 0.02700602 you found earlier and a lower bound at 0. With pm=3 and delta=0 you get a negative lower bound (in fact -0.290617).
> dstable(4, alpha=0.4, beta=1, gamma=0.4, delta=0, pm=3)
[1] 0.02464434
attr(,"control")
dist alpha beta gamma delta pm
stable 0.4 1 0.4 0 3
> dstable(4, alpha=0.4, beta=1, gamma=0.4, delta=0.290617, pm=3)
[1] 0.02700602
attr(,"control")
dist alpha beta gamma delta pm
stable 0.4 1 0.4 0.290617 3
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=0, pm=3))
[1] -0.2876658
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=0.290617, pm=3))
[1] 0.004303485
You may find it easier simply to ignore delta in the output, and so long as you keep beta=1 then using pm=1 means delta in the input is the distribution lower bound, which it seems you want to be 0. | The positive stable distribution in R | What I think is happening is that in the output delta may be reporting an internal location value, while in the input delta is describing the shift. [There seems to be a similar issue with gamma when | The positive stable distribution in R
What I think is happening is that in the output delta may be reporting an internal location value, while in the input delta is describing the shift. [There seems to be a similar issue with gamma when pm=2.] So if you try increasing the shift to 2
> dstable(4, alpha=0.4, beta=1, gamma=0.4, delta=2, pm=1)
[1] 0.06569375
attr(,"control")
dist alpha beta gamma delta pm
stable 0.4 1 0.4 2.290617 1
then you add 2 to the location value.
With beta=1 and pm=1 you have a positive random variable with a distribution lower bound at 0.
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=0, pm=1))
[1] 0.002666507
Shift by 2 and the lower bound rises by the same amount
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=2, pm=1))
[1] 2.003286
But if you want the delta input to be the internal location value rather than the shift or lower bound, then you need to use a different specification for the parameters. For example if you try the following (with pm=3 and trying delta=0 and the delta=0.290617 you found earlier), you seem to get the same delta in and out. With pm=3 and delta=0.290617 you get the same density of 0.02700602 you found earlier and a lower bound at 0. With pm=3 and delta=0 you get a negative lower bound (in fact -0.290617).
> dstable(4, alpha=0.4, beta=1, gamma=0.4, delta=0, pm=3)
[1] 0.02464434
attr(,"control")
dist alpha beta gamma delta pm
stable 0.4 1 0.4 0 3
> dstable(4, alpha=0.4, beta=1, gamma=0.4, delta=0.290617, pm=3)
[1] 0.02700602
attr(,"control")
dist alpha beta gamma delta pm
stable 0.4 1 0.4 0.290617 3
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=0, pm=3))
[1] -0.2876658
> min(rstable(100000, alpha=0.4, beta=1, gamma=0.4, delta=0.290617, pm=3))
[1] 0.004303485
You may find it easier simply to ignore delta in the output, and so long as you keep beta=1 then using pm=1 means delta in the input is the distribution lower bound, which it seems you want to be 0. | The positive stable distribution in R
What I think is happening is that in the output delta may be reporting an internal location value, while in the input delta is describing the shift. [There seems to be a similar issue with gamma when |
30,427 | The positive stable distribution in R | Also of note: Martin Maechler just refactored the code for the stable distributed and added some improvements.
His new package stabledist will be used by fBasics as well, so you may want to give this a look as well. | The positive stable distribution in R | Also of note: Martin Maechler just refactored the code for the stable distributed and added some improvements.
His new package stabledist will be used by fBasics as well, so you may want to give this | The positive stable distribution in R
Also of note: Martin Maechler just refactored the code for the stable distributed and added some improvements.
His new package stabledist will be used by fBasics as well, so you may want to give this a look as well. | The positive stable distribution in R
Also of note: Martin Maechler just refactored the code for the stable distributed and added some improvements.
His new package stabledist will be used by fBasics as well, so you may want to give this |
30,428 | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | To shamelessly quote the Stata manual entry for kdensity:
The optimal width is the width that would minimize the mean integrated squared error if the data were Gaussian and a Gaussian kernel were used, so it is not optimal in any global sense. In fact, for multimodal and highly skewed densities, this width is usually too wide and oversmooths the density (Silverman 1992).
Silverman, B. W. 1992. Density Estimation for Statistics and Data Analysis. London: Chapman & Hall. ISBN 9780412246203
The formula Stata give for the optimal bandwidth $h$ is:
$$h = \frac{0.9m}{n^{1/5}} \quad \mbox{with } m = \min\left(\sqrt{\operatorname{Var}(X)},\frac{\operatorname{IQR}(X)}{1.349}\right),$$
where $n$ is the number of observations on $X$, $\operatorname{Var}(X)$ is its variance and $\operatorname{IQR}(X)$ its interquartile range. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | To shamelessly quote the Stata manual entry for kdensity:
The optimal width is the width that would minimize the mean integrated squared error if the data were Gaussian and a Gaussian kernel were use | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
To shamelessly quote the Stata manual entry for kdensity:
The optimal width is the width that would minimize the mean integrated squared error if the data were Gaussian and a Gaussian kernel were used, so it is not optimal in any global sense. In fact, for multimodal and highly skewed densities, this width is usually too wide and oversmooths the density (Silverman 1992).
Silverman, B. W. 1992. Density Estimation for Statistics and Data Analysis. London: Chapman & Hall. ISBN 9780412246203
The formula Stata give for the optimal bandwidth $h$ is:
$$h = \frac{0.9m}{n^{1/5}} \quad \mbox{with } m = \min\left(\sqrt{\operatorname{Var}(X)},\frac{\operatorname{IQR}(X)}{1.349}\right),$$
where $n$ is the number of observations on $X$, $\operatorname{Var}(X)$ is its variance and $\operatorname{IQR}(X)$ its interquartile range. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
To shamelessly quote the Stata manual entry for kdensity:
The optimal width is the width that would minimize the mean integrated squared error if the data were Gaussian and a Gaussian kernel were use |
30,429 | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | I asked a similar question a few months ago. Rob Hyndman provided an excellent answer that recommends the Sheather-Jones method.
One addition point. In R, for the density function, you set the bandwidth explicitly via the bw argument. However, I often find that the adjust argument is more helpful. The adjust argument scales the value of the bandwidth. So adjust=2 means double the bandwidth. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | I asked a similar question a few months ago. Rob Hyndman provided an excellent answer that recommends the Sheather-Jones method.
One addition point. In R, for the density function, you set the bandwid | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
I asked a similar question a few months ago. Rob Hyndman provided an excellent answer that recommends the Sheather-Jones method.
One addition point. In R, for the density function, you set the bandwidth explicitly via the bw argument. However, I often find that the adjust argument is more helpful. The adjust argument scales the value of the bandwidth. So adjust=2 means double the bandwidth. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
I asked a similar question a few months ago. Rob Hyndman provided an excellent answer that recommends the Sheather-Jones method.
One addition point. In R, for the density function, you set the bandwid |
30,430 | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | I second @onestop, but quote Wilcox, 'Introduction to Robust Estimation and Hypothesis Testing', 2nd edition, page 50:
$$
h = 1.06\frac{A}{n^{1/5}}, \qquad A = \min{\left(s,\frac{IQR(x)}{1.34}\right)},
$$
where $s$ is the sample standard deviation. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | I second @onestop, but quote Wilcox, 'Introduction to Robust Estimation and Hypothesis Testing', 2nd edition, page 50:
$$
h = 1.06\frac{A}{n^{1/5}}, \qquad A = \min{\left(s,\frac{IQR(x)}{1.34}\right) | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
I second @onestop, but quote Wilcox, 'Introduction to Robust Estimation and Hypothesis Testing', 2nd edition, page 50:
$$
h = 1.06\frac{A}{n^{1/5}}, \qquad A = \min{\left(s,\frac{IQR(x)}{1.34}\right)},
$$
where $s$ is the sample standard deviation. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
I second @onestop, but quote Wilcox, 'Introduction to Robust Estimation and Hypothesis Testing', 2nd edition, page 50:
$$
h = 1.06\frac{A}{n^{1/5}}, \qquad A = \min{\left(s,\frac{IQR(x)}{1.34}\right) |
30,431 | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | What I usually do is to calculate the plugin bandwidth using Silverman's formula (h_p) and then crossvalidate in the range of [h_p/5, 5h_p] to find the optimal bandwidth. This crossvalidation can be done either by using leave-one-out least squares crossvalidation or by leave-one-out-likelihood crossvalidation. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? | What I usually do is to calculate the plugin bandwidth using Silverman's formula (h_p) and then crossvalidate in the range of [h_p/5, 5h_p] to find the optimal bandwidth. This crossvalidation can be d | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
What I usually do is to calculate the plugin bandwidth using Silverman's formula (h_p) and then crossvalidate in the range of [h_p/5, 5h_p] to find the optimal bandwidth. This crossvalidation can be done either by using leave-one-out least squares crossvalidation or by leave-one-out-likelihood crossvalidation. | Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation?
What I usually do is to calculate the plugin bandwidth using Silverman's formula (h_p) and then crossvalidate in the range of [h_p/5, 5h_p] to find the optimal bandwidth. This crossvalidation can be d |
30,432 | How can I make inferences about individuals from aggregated data? | It sounds like this problem is an example of ecological inference.
Gary King provides this definition in lecture slides: "Advanced Quantitative Research Methodology Lecture
Notes: Ecological Inference" January 28, 2012
Ecological Inference is the process of using aggregate (i.e.,
“ecological”) data to infer discrete individual-level relationships of
interest when individual-level data are not available.
Gary King cautions that, if you can avoid making ecological inference, you'll be much better off! The reason ecological inference is risky is as Utobi states: the problem is under-specified.
That said, some problems are intractable without attempting ecological inference. For instance, ballots are secret, so estimating how voting totals (an aggregate in a geographic area) break down along demographic attributes (a quality of an individual) is a problem for ecological inference. Gary King is a proponent of the tomography method for ecological inference.
Gary King. A Solution to the Ecological Inference Problem: Reconstructing Individual Behavior from Aggregate Data.
Princeton University Press, 1997. | How can I make inferences about individuals from aggregated data? | It sounds like this problem is an example of ecological inference.
Gary King provides this definition in lecture slides: "Advanced Quantitative Research Methodology Lecture
Notes: Ecological Inference | How can I make inferences about individuals from aggregated data?
It sounds like this problem is an example of ecological inference.
Gary King provides this definition in lecture slides: "Advanced Quantitative Research Methodology Lecture
Notes: Ecological Inference" January 28, 2012
Ecological Inference is the process of using aggregate (i.e.,
“ecological”) data to infer discrete individual-level relationships of
interest when individual-level data are not available.
Gary King cautions that, if you can avoid making ecological inference, you'll be much better off! The reason ecological inference is risky is as Utobi states: the problem is under-specified.
That said, some problems are intractable without attempting ecological inference. For instance, ballots are secret, so estimating how voting totals (an aggregate in a geographic area) break down along demographic attributes (a quality of an individual) is a problem for ecological inference. Gary King is a proponent of the tomography method for ecological inference.
Gary King. A Solution to the Ecological Inference Problem: Reconstructing Individual Behavior from Aggregate Data.
Princeton University Press, 1997. | How can I make inferences about individuals from aggregated data?
It sounds like this problem is an example of ecological inference.
Gary King provides this definition in lecture slides: "Advanced Quantitative Research Methodology Lecture
Notes: Ecological Inference |
30,433 | How can I make inferences about individuals from aggregated data? | This is mostly an expanded version of my comment. It's not possible to go backwards from aggregated to individual data. Indeed, suppose variable $\bar x$ for country $i$, takes on value $4$. Assume there are three individuals $x_1,x_2$ and $x_3$. Then for the three individuals, we could either choose $x_1=2, x_2= 6, x_3 = 4$ or $x_1=6, x_2=2, x_3=4$ or any other conforming partition. So we would end up with a dataset that doesn't necessarily coincide with the original one. | How can I make inferences about individuals from aggregated data? | This is mostly an expanded version of my comment. It's not possible to go backwards from aggregated to individual data. Indeed, suppose variable $\bar x$ for country $i$, takes on value $4$. Assume th | How can I make inferences about individuals from aggregated data?
This is mostly an expanded version of my comment. It's not possible to go backwards from aggregated to individual data. Indeed, suppose variable $\bar x$ for country $i$, takes on value $4$. Assume there are three individuals $x_1,x_2$ and $x_3$. Then for the three individuals, we could either choose $x_1=2, x_2= 6, x_3 = 4$ or $x_1=6, x_2=2, x_3=4$ or any other conforming partition. So we would end up with a dataset that doesn't necessarily coincide with the original one. | How can I make inferences about individuals from aggregated data?
This is mostly an expanded version of my comment. It's not possible to go backwards from aggregated to individual data. Indeed, suppose variable $\bar x$ for country $i$, takes on value $4$. Assume th |
30,434 | Linear regression vs. average of slopes | DIFFERENT
We just need one example of these two being different to show that the two need not give the same result, so let's simulate an example.
x <- c(1, 2, -3)
y <- c(1, 6, 3)
# Fit a linear model to calculate the OLS slope coefficient
#
L <- lm(y ~ x)
# Find the pairwise slopes
#
slopes <- rep(NA, 3)
slopes[1] <- (y[2] - y[1])/(x[2] - x[1])
slopes[2] <- (y[3] - y[1])/(x[3] - x[1])
slopes[3] <- (y[3] - y[2])/(x[3] - x[2])
# Compare the OLS estimate with the mean of the pairwise slopes
#
summary(L)$coef[2, 1]
mean(slopes)
The OLS slope estimate is $0.2857143$, while the mean pairwise slope is $1.7$, so the two methods do not have to agree.
For a really interesting example, as is pointed out in the comments, consider what happens when two distinct $y$-values correspond to the same $x$-value. Will that code even run for x <- c(1, 2, 1)? Should it run?
A similar regression method that might be of interest is the Theil–Sen estimator (median pairwise slope instead of mean). In the above example, the Theil-Sen slope estimate is $0.6$, different from both the OLS estimate and the mean of the pairwise slopes. | Linear regression vs. average of slopes | DIFFERENT
We just need one example of these two being different to show that the two need not give the same result, so let's simulate an example.
x <- c(1, 2, -3)
y <- c(1, 6, 3)
# Fit a linear model | Linear regression vs. average of slopes
DIFFERENT
We just need one example of these two being different to show that the two need not give the same result, so let's simulate an example.
x <- c(1, 2, -3)
y <- c(1, 6, 3)
# Fit a linear model to calculate the OLS slope coefficient
#
L <- lm(y ~ x)
# Find the pairwise slopes
#
slopes <- rep(NA, 3)
slopes[1] <- (y[2] - y[1])/(x[2] - x[1])
slopes[2] <- (y[3] - y[1])/(x[3] - x[1])
slopes[3] <- (y[3] - y[2])/(x[3] - x[2])
# Compare the OLS estimate with the mean of the pairwise slopes
#
summary(L)$coef[2, 1]
mean(slopes)
The OLS slope estimate is $0.2857143$, while the mean pairwise slope is $1.7$, so the two methods do not have to agree.
For a really interesting example, as is pointed out in the comments, consider what happens when two distinct $y$-values correspond to the same $x$-value. Will that code even run for x <- c(1, 2, 1)? Should it run?
A similar regression method that might be of interest is the Theil–Sen estimator (median pairwise slope instead of mean). In the above example, the Theil-Sen slope estimate is $0.6$, different from both the OLS estimate and the mean of the pairwise slopes. | Linear regression vs. average of slopes
DIFFERENT
We just need one example of these two being different to show that the two need not give the same result, so let's simulate an example.
x <- c(1, 2, -3)
y <- c(1, 6, 3)
# Fit a linear model |
30,435 | Linear regression vs. average of slopes | What is equivalent to OLS is a weighted mean pairwise slope. Suppose you want to fit $Y=\alpha+\beta X$ and you have $n(n-1)$ pairs $(x_i,y_i,x_j,y_j)$ with slopes $\beta_{ij}$. The information about $\beta$ in a pair is proportional to $(x_i-x_j)^2$, and if you write $w_{ij}=(x_i-x_j)^2$, the OLS estimator is
$$\hat\beta_{OLS}= \frac{\sum_{i\neq j} w_{ij}\beta_{ij}}{\sum_{i\neq j} w_{ij}}$$
(where you use the convention $w_{ij}\beta_{ij}=0$ if $x_i=x_j$)
The proof involves relating the numerator to the U-statistic estimator of covariance
$$\mathrm{cov}[X,Y]=\frac{1}{n(n-1)}\sum_{i\neq j} (x_i-x_j)(y_i-y_j)$$ and
the denominator to the U-statistic estimator of the variance
$$\mathrm{var}[X]=\frac{1}{n(n-1)}\sum_{i\neq j} (x_i-x_j)(x_i-x_j).$$
(To generalise to two predictors you take triples of points and so on. The algebra becomes more tedious and you need to know some formulas for determinants.) | Linear regression vs. average of slopes | What is equivalent to OLS is a weighted mean pairwise slope. Suppose you want to fit $Y=\alpha+\beta X$ and you have $n(n-1)$ pairs $(x_i,y_i,x_j,y_j)$ with slopes $\beta_{ij}$. The information about | Linear regression vs. average of slopes
What is equivalent to OLS is a weighted mean pairwise slope. Suppose you want to fit $Y=\alpha+\beta X$ and you have $n(n-1)$ pairs $(x_i,y_i,x_j,y_j)$ with slopes $\beta_{ij}$. The information about $\beta$ in a pair is proportional to $(x_i-x_j)^2$, and if you write $w_{ij}=(x_i-x_j)^2$, the OLS estimator is
$$\hat\beta_{OLS}= \frac{\sum_{i\neq j} w_{ij}\beta_{ij}}{\sum_{i\neq j} w_{ij}}$$
(where you use the convention $w_{ij}\beta_{ij}=0$ if $x_i=x_j$)
The proof involves relating the numerator to the U-statistic estimator of covariance
$$\mathrm{cov}[X,Y]=\frac{1}{n(n-1)}\sum_{i\neq j} (x_i-x_j)(y_i-y_j)$$ and
the denominator to the U-statistic estimator of the variance
$$\mathrm{var}[X]=\frac{1}{n(n-1)}\sum_{i\neq j} (x_i-x_j)(x_i-x_j).$$
(To generalise to two predictors you take triples of points and so on. The algebra becomes more tedious and you need to know some formulas for determinants.) | Linear regression vs. average of slopes
What is equivalent to OLS is a weighted mean pairwise slope. Suppose you want to fit $Y=\alpha+\beta X$ and you have $n(n-1)$ pairs $(x_i,y_i,x_j,y_j)$ with slopes $\beta_{ij}$. The information about |
30,436 | How can I simulate the frequency of each face for N die rolls? [duplicate] | The frequencies for the different faces aren't independent, since they have to sum to $N$. However, instead of iterating over the dice, you can iterate over the number of faces, which doesn't increase with $N$:
Simulate occurrences of 1, $n_1$, as Binomial, with $N$ trials and success probability $1/6$.
Simulate occurrences of 2, $n_2$, as Binomial, with $N - n_1$ trials and success probability $1/5$.
Simulate occurrences of 3, $n_3$, as Binomial, with $N - n_1 - n_2$ trials and success probability $1/4$.
And so on, until you simulate the occurrences of 6 with a success probability of $1$, using up all the remaining rolls. | How can I simulate the frequency of each face for N die rolls? [duplicate] | The frequencies for the different faces aren't independent, since they have to sum to $N$. However, instead of iterating over the dice, you can iterate over the number of faces, which doesn't increase | How can I simulate the frequency of each face for N die rolls? [duplicate]
The frequencies for the different faces aren't independent, since they have to sum to $N$. However, instead of iterating over the dice, you can iterate over the number of faces, which doesn't increase with $N$:
Simulate occurrences of 1, $n_1$, as Binomial, with $N$ trials and success probability $1/6$.
Simulate occurrences of 2, $n_2$, as Binomial, with $N - n_1$ trials and success probability $1/5$.
Simulate occurrences of 3, $n_3$, as Binomial, with $N - n_1 - n_2$ trials and success probability $1/4$.
And so on, until you simulate the occurrences of 6 with a success probability of $1$, using up all the remaining rolls. | How can I simulate the frequency of each face for N die rolls? [duplicate]
The frequencies for the different faces aren't independent, since they have to sum to $N$. However, instead of iterating over the dice, you can iterate over the number of faces, which doesn't increase |
30,437 | How can I simulate the frequency of each face for N die rolls? [duplicate] | I feel the simplest approach for a die of $D$ sides (your question assumes $D=6$), with an arbitrary set of values (your question assumes a die roll is one of $\in {1,2,3,4,5,6}$) is to use a shuffle algorithm-based sampling function on the set of values of your die:
Python
Assume you have an array of die values (any number of values, any set of values), named MyDie, the basis for "rolling" MyDie N times is:
import random
values, counts = np.unique(random.choices(MyDie,k=10), return_counts=True)
For example, for $N=10$:
>>> import random
>>> import numpy as np
>>> values, counts = np.unique(random.choices(MyDie,k=10),return_counts=True)
>>> print(values,"\n",counts,sep="")
[1 2 3 4 5 6]
[1 4 1 1 1 2]
R
Assume you have an array of die values (any number of values, any set of values), named MyDie, the basis for "rolling" MyDie N times is:
sample(MyDie,size=N,replace=TRUE)
For example, for $N=10$:
> MyDie <- 1:6
> table(sample(MyDie,size=10,replace=TRUE))
1 2 3 5 6
4 1 2 1 2 | How can I simulate the frequency of each face for N die rolls? [duplicate] | I feel the simplest approach for a die of $D$ sides (your question assumes $D=6$), with an arbitrary set of values (your question assumes a die roll is one of $\in {1,2,3,4,5,6}$) is to use a shuffle | How can I simulate the frequency of each face for N die rolls? [duplicate]
I feel the simplest approach for a die of $D$ sides (your question assumes $D=6$), with an arbitrary set of values (your question assumes a die roll is one of $\in {1,2,3,4,5,6}$) is to use a shuffle algorithm-based sampling function on the set of values of your die:
Python
Assume you have an array of die values (any number of values, any set of values), named MyDie, the basis for "rolling" MyDie N times is:
import random
values, counts = np.unique(random.choices(MyDie,k=10), return_counts=True)
For example, for $N=10$:
>>> import random
>>> import numpy as np
>>> values, counts = np.unique(random.choices(MyDie,k=10),return_counts=True)
>>> print(values,"\n",counts,sep="")
[1 2 3 4 5 6]
[1 4 1 1 1 2]
R
Assume you have an array of die values (any number of values, any set of values), named MyDie, the basis for "rolling" MyDie N times is:
sample(MyDie,size=N,replace=TRUE)
For example, for $N=10$:
> MyDie <- 1:6
> table(sample(MyDie,size=10,replace=TRUE))
1 2 3 5 6
4 1 2 1 2 | How can I simulate the frequency of each face for N die rolls? [duplicate]
I feel the simplest approach for a die of $D$ sides (your question assumes $D=6$), with an arbitrary set of values (your question assumes a die roll is one of $\in {1,2,3,4,5,6}$) is to use a shuffle |
30,438 | Regular conditional distribution vs conditional distribution | Why do we need these two different concepts?
Regular conditional distributions are useful because they allow us to generalize the elementary notions of conditional distribution where we consider ratios of the form $\frac{\Pr[A\cap B]}{\Pr[A]}$. This formalization is in contrast with the Kolmogorov abstract conditional expectation which is up to a.s. equivalence. There are also some useful applications such as allowing us to evaluate conditional expectations as ordinary expectations.
Under which circumstances do they coincide?
Let $(\Omega, \mathcal{F}, \Pr)$ be a probability space.
Recall, the elementary definition,
$$\Pr[A|X=x]=\frac{\Pr[\{X=x\} \cap A]}{\Pr[X=x]}$$
This definition gives us a probability measure on the space that concentrates on the event $\{X=x\}$. Since $\{X\neq x\}\cap\{X=x\}=\emptyset$. And for any $A\in\mathcal{F}$ we have,
$$\Pr[A]=\sum_{x\in\mathbb{R}}\Pr[X=x]\Pr[A|X=x]$$
Equivalently,
$$\mathbb{E}[A]=\sum_{x\in\mathbb{R}}\mathbb{E}[A|X=x]\Pr[X=x]$$
The issue that we run into here is that Kolmogorov's abstract conditional expectation is arbitrary on any event with measure zero and it could happen that stringing together uncountably many events of measure zero yields an event with positive probability. This serves as motivation for introducing regular conditional distributions. The regular conditional distribution is a disintegration that allows us to avoid problems with uncountably many measure-zero sets. The other benefit is the disintegration formula which allows us to think of conditional expectations as just regular expectations taken with respect to a conditional measure. That is, let $\mu_\omega(dx)$ be a regular conditional distribution for $X$ and given a sub-$\sigma$-algebra $\mathcal{G}\subset\mathcal{F}$ with r.v. $Y$ that is $\mathcal{G}$-measurable, and a jointly measurable and integrable $f(X,Y)$ we have,
$$\mathbb{E}[f(X,Y)|\mathcal{G}]=\int f(x,Y(\omega))\mu_\omega(dx)$$
holds almost surely. This is very useful as it allows us to pass to a regular expectation. A classic example is the proof of the conditional Jensen inequality (see Dudley, Real Analysis and Probability, 2004 Section 10.2)
The downside to using regular conditional distributions is that we need slightly stronger assumptions than those used by the Kolmogorov abstract conditional expectation for existence. The proof is more technical also and requires that we have a Hausdorff topological space (Theorem 10.2.2 in Dudley). In particular, for the most general existence theorem, we need that our random variable maps into a Polish space.
Is it true that the regular conditional distribution is in general not a probability measure?
In fact, a regular conditional distribution is by definition a probability measure on the range of the random variable. Let $X$ be a random variable from our probability space into $(T, \mathcal{T})$. Let $\mathcal{G}$ be a sub-$\sigma$-algebra as above.
Recall the definition of a regular conditional probability is a function $P(\cdot|\mathcal{G})(\cdot)$ on $\mathcal{F}\times\Omega$ so that,
For $B\in\mathcal{F}$,
$$P(B|\mathcal{G})(\cdot)=\Pr[X\in B|\mathcal{G}](\cdot)$$
almost surely where $P(B|\mathcal{G})(\cdot)$ is a $\mathcal{G}$-measurable.
$P(\cdot|\mathcal{G})(\omega)$ is a probability measure on $\mathcal{F}$.
The regular conditional distribution of $X$ given $\mathcal{G}$ is the function $\mu_\omega(\cdot):\Omega\times\mathcal{T}\to[0,1]$ such that,
$\mu_\omega(\cdot)$ is a probability measure on $\mathcal{T}$ for almost all $\omega$.
For $A\in\mathcal{T}$ we have,
$$\mu_\cdot(A)=\Pr[X^{-1}(A)|\mathcal{G}](\cdot)$$
where $\mu_\cdot(A)$ is $\mathcal{G}$-measurable.
Both objects can be thought of as Markov kernels (i.e. they are regular) and there is a very clear correspondence between the two concepts here because if we set $(T,\mathcal{T})=(\Omega,\mathcal{F})$ and let $X$ be the identity map then the regular conditional distribution is just the regular conditional probability. Since we just get that,
$$\mu_\omega(B)=\Pr[X^{-1}(B)|\mathcal{G}](\omega)=\Pr[B|\mathcal{G}](\omega)=P(B|\mathcal{G})(\omega)$$
Now defining a probability measure on our original space further underscoring the point. Essentially, what we are seeing is rather intuitive. The regular conditional probability acts as a conditional analog for the typical probability measure assigning probabilities to events in our sample space while the regular conditional distribution acts as the conditional analog to the distribution of our random variable i.e. a pushforward measure.
Finally, if we wanted to ignore regularity we might just try to define the conditional probability in terms of Kolmogorov's conditional expectation. That is,
$$\Pr[A|\mathcal{G}]=\mathbb{E}[1_A|\mathcal{G}]$$
In fact, this is a vector measure as it will assign the null set measure zero and it is countably additive ($\Pr[\cup_{n\in\mathbb{N}} A_n|\mathcal{G}]=\sum_{n\in\mathbb{N}}\Pr[A_n|\mathcal{G}]$ a.s.). But, it is not a probability measure because this definition is only up to a.s. equivalence and as we discussed earlier this means that when we consider uncountable families of measure-zero sets we may run into trouble. However, regularity will let us take care of this although as we have seen we need stronger assumptions.
Useful References:
Chang and Pollard, 1997 This is a highly recommended read as it is quite short and easy to read but contains many examples of why we should care about this concept given the abstract conditional expectation. The only downside is the notation is a bit unusual.
Pollard, 2001, Chapter 5
Dudley, 2004, Chapter 10
Addendum:
For completeness let us define Kolmogorov's abstract conditional expectation. It is enough to give the conditional expectation of $X$ given a sub-$\sigma$-algebra $\mathcal{G}\subset\mathcal{F}$. Then, for any $X\in L^1(\Omega, \mathcal{F},\Pr)$ the conditional expectation, $\mathbb{E}[X|\mathcal{G}]$, is the unique random variable $Z\in L^1(\Omega, \mathcal{F},\Pr)$ such that for all $G\in\mathcal{G}$,
$$\int_A Z d\Pr = \int_A X d\Pr$$
It suffices to consider this definition because we can always consider the case where this $\mathcal{G}$ is generated by a random variable to retrieve the elementary definition of conditional expectation. Also, take note that this definition only holds up to a.s. equality defined by an equivalence class of integrable functions. Thus, the conditional expectation can be defined by any member of that equivalence class. Thus, whenever we use this conditional expectation we have to understand that our reasoning only holds up to a.s. equality.
Typically, this definition is first stated for random variables $X\in L^2(\Omega,\mathcal{F},\Pr)$ where it coincides with the minimizer of $E[(Z-X)^2]$ and then generalize to $X\in L^1(\Omega, \mathcal{F},\Pr)$ so that we may account for non-square integrable random variables. It turns out this condition is also sufficient for the existence of the conditional expectation. The proof is a rather straightforward application of the Radon-Nikodym theorem (see Dudley Theorem 10.1.1). That probably explains part of why this is the preferred approach. | Regular conditional distribution vs conditional distribution | Why do we need these two different concepts?
Regular conditional distributions are useful because they allow us to generalize the elementary notions of conditional distribution where we consider rati | Regular conditional distribution vs conditional distribution
Why do we need these two different concepts?
Regular conditional distributions are useful because they allow us to generalize the elementary notions of conditional distribution where we consider ratios of the form $\frac{\Pr[A\cap B]}{\Pr[A]}$. This formalization is in contrast with the Kolmogorov abstract conditional expectation which is up to a.s. equivalence. There are also some useful applications such as allowing us to evaluate conditional expectations as ordinary expectations.
Under which circumstances do they coincide?
Let $(\Omega, \mathcal{F}, \Pr)$ be a probability space.
Recall, the elementary definition,
$$\Pr[A|X=x]=\frac{\Pr[\{X=x\} \cap A]}{\Pr[X=x]}$$
This definition gives us a probability measure on the space that concentrates on the event $\{X=x\}$. Since $\{X\neq x\}\cap\{X=x\}=\emptyset$. And for any $A\in\mathcal{F}$ we have,
$$\Pr[A]=\sum_{x\in\mathbb{R}}\Pr[X=x]\Pr[A|X=x]$$
Equivalently,
$$\mathbb{E}[A]=\sum_{x\in\mathbb{R}}\mathbb{E}[A|X=x]\Pr[X=x]$$
The issue that we run into here is that Kolmogorov's abstract conditional expectation is arbitrary on any event with measure zero and it could happen that stringing together uncountably many events of measure zero yields an event with positive probability. This serves as motivation for introducing regular conditional distributions. The regular conditional distribution is a disintegration that allows us to avoid problems with uncountably many measure-zero sets. The other benefit is the disintegration formula which allows us to think of conditional expectations as just regular expectations taken with respect to a conditional measure. That is, let $\mu_\omega(dx)$ be a regular conditional distribution for $X$ and given a sub-$\sigma$-algebra $\mathcal{G}\subset\mathcal{F}$ with r.v. $Y$ that is $\mathcal{G}$-measurable, and a jointly measurable and integrable $f(X,Y)$ we have,
$$\mathbb{E}[f(X,Y)|\mathcal{G}]=\int f(x,Y(\omega))\mu_\omega(dx)$$
holds almost surely. This is very useful as it allows us to pass to a regular expectation. A classic example is the proof of the conditional Jensen inequality (see Dudley, Real Analysis and Probability, 2004 Section 10.2)
The downside to using regular conditional distributions is that we need slightly stronger assumptions than those used by the Kolmogorov abstract conditional expectation for existence. The proof is more technical also and requires that we have a Hausdorff topological space (Theorem 10.2.2 in Dudley). In particular, for the most general existence theorem, we need that our random variable maps into a Polish space.
Is it true that the regular conditional distribution is in general not a probability measure?
In fact, a regular conditional distribution is by definition a probability measure on the range of the random variable. Let $X$ be a random variable from our probability space into $(T, \mathcal{T})$. Let $\mathcal{G}$ be a sub-$\sigma$-algebra as above.
Recall the definition of a regular conditional probability is a function $P(\cdot|\mathcal{G})(\cdot)$ on $\mathcal{F}\times\Omega$ so that,
For $B\in\mathcal{F}$,
$$P(B|\mathcal{G})(\cdot)=\Pr[X\in B|\mathcal{G}](\cdot)$$
almost surely where $P(B|\mathcal{G})(\cdot)$ is a $\mathcal{G}$-measurable.
$P(\cdot|\mathcal{G})(\omega)$ is a probability measure on $\mathcal{F}$.
The regular conditional distribution of $X$ given $\mathcal{G}$ is the function $\mu_\omega(\cdot):\Omega\times\mathcal{T}\to[0,1]$ such that,
$\mu_\omega(\cdot)$ is a probability measure on $\mathcal{T}$ for almost all $\omega$.
For $A\in\mathcal{T}$ we have,
$$\mu_\cdot(A)=\Pr[X^{-1}(A)|\mathcal{G}](\cdot)$$
where $\mu_\cdot(A)$ is $\mathcal{G}$-measurable.
Both objects can be thought of as Markov kernels (i.e. they are regular) and there is a very clear correspondence between the two concepts here because if we set $(T,\mathcal{T})=(\Omega,\mathcal{F})$ and let $X$ be the identity map then the regular conditional distribution is just the regular conditional probability. Since we just get that,
$$\mu_\omega(B)=\Pr[X^{-1}(B)|\mathcal{G}](\omega)=\Pr[B|\mathcal{G}](\omega)=P(B|\mathcal{G})(\omega)$$
Now defining a probability measure on our original space further underscoring the point. Essentially, what we are seeing is rather intuitive. The regular conditional probability acts as a conditional analog for the typical probability measure assigning probabilities to events in our sample space while the regular conditional distribution acts as the conditional analog to the distribution of our random variable i.e. a pushforward measure.
Finally, if we wanted to ignore regularity we might just try to define the conditional probability in terms of Kolmogorov's conditional expectation. That is,
$$\Pr[A|\mathcal{G}]=\mathbb{E}[1_A|\mathcal{G}]$$
In fact, this is a vector measure as it will assign the null set measure zero and it is countably additive ($\Pr[\cup_{n\in\mathbb{N}} A_n|\mathcal{G}]=\sum_{n\in\mathbb{N}}\Pr[A_n|\mathcal{G}]$ a.s.). But, it is not a probability measure because this definition is only up to a.s. equivalence and as we discussed earlier this means that when we consider uncountable families of measure-zero sets we may run into trouble. However, regularity will let us take care of this although as we have seen we need stronger assumptions.
Useful References:
Chang and Pollard, 1997 This is a highly recommended read as it is quite short and easy to read but contains many examples of why we should care about this concept given the abstract conditional expectation. The only downside is the notation is a bit unusual.
Pollard, 2001, Chapter 5
Dudley, 2004, Chapter 10
Addendum:
For completeness let us define Kolmogorov's abstract conditional expectation. It is enough to give the conditional expectation of $X$ given a sub-$\sigma$-algebra $\mathcal{G}\subset\mathcal{F}$. Then, for any $X\in L^1(\Omega, \mathcal{F},\Pr)$ the conditional expectation, $\mathbb{E}[X|\mathcal{G}]$, is the unique random variable $Z\in L^1(\Omega, \mathcal{F},\Pr)$ such that for all $G\in\mathcal{G}$,
$$\int_A Z d\Pr = \int_A X d\Pr$$
It suffices to consider this definition because we can always consider the case where this $\mathcal{G}$ is generated by a random variable to retrieve the elementary definition of conditional expectation. Also, take note that this definition only holds up to a.s. equality defined by an equivalence class of integrable functions. Thus, the conditional expectation can be defined by any member of that equivalence class. Thus, whenever we use this conditional expectation we have to understand that our reasoning only holds up to a.s. equality.
Typically, this definition is first stated for random variables $X\in L^2(\Omega,\mathcal{F},\Pr)$ where it coincides with the minimizer of $E[(Z-X)^2]$ and then generalize to $X\in L^1(\Omega, \mathcal{F},\Pr)$ so that we may account for non-square integrable random variables. It turns out this condition is also sufficient for the existence of the conditional expectation. The proof is a rather straightforward application of the Radon-Nikodym theorem (see Dudley Theorem 10.1.1). That probably explains part of why this is the preferred approach. | Regular conditional distribution vs conditional distribution
Why do we need these two different concepts?
Regular conditional distributions are useful because they allow us to generalize the elementary notions of conditional distribution where we consider rati |
30,439 | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references? | Observation of "spurious correlation" for time-series over the same time period is something that has been recognised in the statistical community for over a century. Yule (1926) has observed that comparison of time-series vectors breaches the usual independent sampling assumptions in statistical problems, and that some simple deterministic series lead to correlation values with non-zero magnitute --- in some cases giving perfect positive or negative correlation. Wald argues that when time-series have systematic serial correlation (i.e., auto-correlation) then they will tend to be correlated with one another when taken over the same or similar time periods, even if there is no causal connection between the series.
Below I give some simple examples that illustrate the phenomenon of interst here. For an affine time-series with non-zero slope, any time vector is perfectly correlated with its corresponding time-series vector. For out-of-phase sinousoidal time-series, the time-series vectors are strongly negatively correlated, and can be perfectly negatively correlated for particular time vectors. Of particular interest here is the first case, which shows the statistical relationship between a time vector and its corresponding time-series vector under a simple trend. The case in your question is similar, insofar as it looks at the correlation between time values and pollen concentrations at those times. The low positive correlation simply means that there is a slight increasing trend in pollen concentration (relative to its variance) over the period in which the time values of interest occur. As you correctly point out, this does not really mean much --- just that pollen concentration was trending upward (very weakly) over a particular time period that coincided with the onset of Covid phases.
All of this really just reflects the fact that contemporaneous trends in time-series vectors lead to correlation between those vectors. If two time-series trend in the same direction over the same time period then they will tend to be positively correlated over that period. Likewise, if two time-series trend in opposite directions over the same time period then they will tend to be negatively correlated over that period. Several examples can be seen in the book Spurious Correlations, where contemporaneous temporal trends lead to high correlation.
The fallacy that encapsulates your concern here is cum hoc ergo propter hoc ("with this, therefore because of this"). Inferring a causal connection from the mere fact that two things have contemporaneous trends can lead to error, and usually we require more than this for a good causal inference. (And certainly we would at least want to know if the authors here were testing a pre-registered hypothesis, or just making a post hoc observation of correlation. It is almost certainly the latter.) The take-home here is that when you observe that two time-series are correlated (even highly correlated) that does not really mean much, especially as evidence for an underlying causal connection. As you observe in your question, the correlation observed in the paper occurs because there was increasing pollen count during March, and that conincided temporally with more frequent onset of Covid "phases". That is really not saying much, and if you just said that plainly then it would be an unremarkable statement that would not suggest any causal link between the two things.
Perfect positive correlation: As a simple illustration of high positive correlation, consider an affine time-series of the form:
$$X_t = \alpha + \beta t
\quad \quad \quad \beta \neq 0.$$
Suppose we take some time vector $\mathbf{t} = (t_1,...,t_n)$ and form the corresponding vector $\mathbf{x} = (x_1,...,x_n)$ composed of values of the series at those time points. Since $x_i = \alpha + \beta t_i$ for all $i = 1,...,n$ it is easy to show that these vectors are perfectly correlated ---i.e., they have Pearson correlation equal to one.
Strong/perfect negative correlation: As a simple example of high negative correlation, consider the two time-series of the form:
$$X_t = \sin (2 \pi \beta t)
\quad \quad \quad
Y_t = \cos (2 \pi \beta t)
\quad \quad \quad \beta \neq 0.$$
Suppose we take some time vector $\mathbf{t} = (t_1,...,t_n)$ and form the corresponding vectors $\mathbf{x} = (x_1,...,x_n)$ and $\mathbf{y} = (y_1,...,y_n)$ composed of values of the series at those time points. Through the use of discrete Fourier transformation, it is easy to show that these vectors will tend to have high negative correlation, and in some cases they can have perfect negative correlation. | The fallacy of correlating some time series values with specific time points: is there a specific na | Observation of "spurious correlation" for time-series over the same time period is something that has been recognised in the statistical community for over a century. Yule (1926) has observed that co | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references?
Observation of "spurious correlation" for time-series over the same time period is something that has been recognised in the statistical community for over a century. Yule (1926) has observed that comparison of time-series vectors breaches the usual independent sampling assumptions in statistical problems, and that some simple deterministic series lead to correlation values with non-zero magnitute --- in some cases giving perfect positive or negative correlation. Wald argues that when time-series have systematic serial correlation (i.e., auto-correlation) then they will tend to be correlated with one another when taken over the same or similar time periods, even if there is no causal connection between the series.
Below I give some simple examples that illustrate the phenomenon of interst here. For an affine time-series with non-zero slope, any time vector is perfectly correlated with its corresponding time-series vector. For out-of-phase sinousoidal time-series, the time-series vectors are strongly negatively correlated, and can be perfectly negatively correlated for particular time vectors. Of particular interest here is the first case, which shows the statistical relationship between a time vector and its corresponding time-series vector under a simple trend. The case in your question is similar, insofar as it looks at the correlation between time values and pollen concentrations at those times. The low positive correlation simply means that there is a slight increasing trend in pollen concentration (relative to its variance) over the period in which the time values of interest occur. As you correctly point out, this does not really mean much --- just that pollen concentration was trending upward (very weakly) over a particular time period that coincided with the onset of Covid phases.
All of this really just reflects the fact that contemporaneous trends in time-series vectors lead to correlation between those vectors. If two time-series trend in the same direction over the same time period then they will tend to be positively correlated over that period. Likewise, if two time-series trend in opposite directions over the same time period then they will tend to be negatively correlated over that period. Several examples can be seen in the book Spurious Correlations, where contemporaneous temporal trends lead to high correlation.
The fallacy that encapsulates your concern here is cum hoc ergo propter hoc ("with this, therefore because of this"). Inferring a causal connection from the mere fact that two things have contemporaneous trends can lead to error, and usually we require more than this for a good causal inference. (And certainly we would at least want to know if the authors here were testing a pre-registered hypothesis, or just making a post hoc observation of correlation. It is almost certainly the latter.) The take-home here is that when you observe that two time-series are correlated (even highly correlated) that does not really mean much, especially as evidence for an underlying causal connection. As you observe in your question, the correlation observed in the paper occurs because there was increasing pollen count during March, and that conincided temporally with more frequent onset of Covid "phases". That is really not saying much, and if you just said that plainly then it would be an unremarkable statement that would not suggest any causal link between the two things.
Perfect positive correlation: As a simple illustration of high positive correlation, consider an affine time-series of the form:
$$X_t = \alpha + \beta t
\quad \quad \quad \beta \neq 0.$$
Suppose we take some time vector $\mathbf{t} = (t_1,...,t_n)$ and form the corresponding vector $\mathbf{x} = (x_1,...,x_n)$ composed of values of the series at those time points. Since $x_i = \alpha + \beta t_i$ for all $i = 1,...,n$ it is easy to show that these vectors are perfectly correlated ---i.e., they have Pearson correlation equal to one.
Strong/perfect negative correlation: As a simple example of high negative correlation, consider the two time-series of the form:
$$X_t = \sin (2 \pi \beta t)
\quad \quad \quad
Y_t = \cos (2 \pi \beta t)
\quad \quad \quad \beta \neq 0.$$
Suppose we take some time vector $\mathbf{t} = (t_1,...,t_n)$ and form the corresponding vectors $\mathbf{x} = (x_1,...,x_n)$ and $\mathbf{y} = (y_1,...,y_n)$ composed of values of the series at those time points. Through the use of discrete Fourier transformation, it is easy to show that these vectors will tend to have high negative correlation, and in some cases they can have perfect negative correlation. | The fallacy of correlating some time series values with specific time points: is there a specific na
Observation of "spurious correlation" for time-series over the same time period is something that has been recognised in the statistical community for over a century. Yule (1926) has observed that co |
30,440 | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references? | in addition to my article resource of different fallacies in academic research:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.579.5429&rep=rep1&type=pdf
I screened one/two articles and a blog and a few other things, this is the main summary:
Most of the research I found always use the term spurious or non-sense, as i mentioned in my comments.
The first resource I found dealt exactly with the danger behind these in terms of time series: The conclusion to the dangers is, that researchers seem to "not prewhitening" or in other words flatten the noise in a time series, to be sure the remaining parts could offer a small glance of a real relationship:
On prewhitening:
http://hosting.astro.cornell.edu/~cordes/A6523/Prewhitening.pdf
The article that deals with the dangers:
https://link.springer.com/content/pdf/10.3758/s13428-015-0611-2.pdf
Some excerpt:
We have shown clearly that cross-correlations between pairs of time
series, or even pairs of series derived as averages of sets of series,
can be misleadding. The key means of avoiding such spurious
cross correlations is to prewhiten the series being cross-correlated.
But even then, some spurious correlations may remain, and the results
need to be treated with caution. Not only is critical interpretation
necessary, but also an awareness that certain kinds of time series may
not be appropriate for the prewhitening approach—for example, when
data are binomial or the series show only sparse change
The article also deals with different methods to engage the danger, perhaps this is useful for you.
In addition I looked into the terms of causality, as the researchers you mention clearly draw some causal objectives from their observations.
I found this blog which is ourstanding in the term that it highlights, i dunno over 100!? papers and sources on causality and time series granger causality and so on:
https://towardsdatascience.com/inferring-causality-in-time-series-data-b8b75fe52c46#4da2. Although i not completely read through all of it, as you can imagine. Perhaps you found something enlightening if my previous research is not sufficient, so taht you got at least another hint.
To summarize my findings a sentence like they make the error/fallacy of not checking for spurious correlations, or the error of not prewhitening or something like that, could be feasible, as long as you have a source that highlights the danger of not checking the data in depth behind two time series. Because it is not significant because it is in a certain area. We have to look at the series at a whole. I do not believe if it correlates on one or two time points you can make the inductive check that the whole series is like that or there is a causality. That should be also summed up under spurious.
However my insight does not deal completely with the fact, that the researchers left out some information from the beginning at the end of march (the pollen density), I believe this is the error of purely fraud or dunno. But if you believe the researchers made mistake. I would tend to look into the material I provided. Hope it helps in some way.
https://en.wikipedia.org/wiki/Oil_drop_experiment#Fraud_allegations | The fallacy of correlating some time series values with specific time points: is there a specific na | in addition to my article resource of different fallacies in academic research:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.579.5429&rep=rep1&type=pdf
I screened one/two articles and a bl | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references?
in addition to my article resource of different fallacies in academic research:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.579.5429&rep=rep1&type=pdf
I screened one/two articles and a blog and a few other things, this is the main summary:
Most of the research I found always use the term spurious or non-sense, as i mentioned in my comments.
The first resource I found dealt exactly with the danger behind these in terms of time series: The conclusion to the dangers is, that researchers seem to "not prewhitening" or in other words flatten the noise in a time series, to be sure the remaining parts could offer a small glance of a real relationship:
On prewhitening:
http://hosting.astro.cornell.edu/~cordes/A6523/Prewhitening.pdf
The article that deals with the dangers:
https://link.springer.com/content/pdf/10.3758/s13428-015-0611-2.pdf
Some excerpt:
We have shown clearly that cross-correlations between pairs of time
series, or even pairs of series derived as averages of sets of series,
can be misleadding. The key means of avoiding such spurious
cross correlations is to prewhiten the series being cross-correlated.
But even then, some spurious correlations may remain, and the results
need to be treated with caution. Not only is critical interpretation
necessary, but also an awareness that certain kinds of time series may
not be appropriate for the prewhitening approach—for example, when
data are binomial or the series show only sparse change
The article also deals with different methods to engage the danger, perhaps this is useful for you.
In addition I looked into the terms of causality, as the researchers you mention clearly draw some causal objectives from their observations.
I found this blog which is ourstanding in the term that it highlights, i dunno over 100!? papers and sources on causality and time series granger causality and so on:
https://towardsdatascience.com/inferring-causality-in-time-series-data-b8b75fe52c46#4da2. Although i not completely read through all of it, as you can imagine. Perhaps you found something enlightening if my previous research is not sufficient, so taht you got at least another hint.
To summarize my findings a sentence like they make the error/fallacy of not checking for spurious correlations, or the error of not prewhitening or something like that, could be feasible, as long as you have a source that highlights the danger of not checking the data in depth behind two time series. Because it is not significant because it is in a certain area. We have to look at the series at a whole. I do not believe if it correlates on one or two time points you can make the inductive check that the whole series is like that or there is a causality. That should be also summed up under spurious.
However my insight does not deal completely with the fact, that the researchers left out some information from the beginning at the end of march (the pollen density), I believe this is the error of purely fraud or dunno. But if you believe the researchers made mistake. I would tend to look into the material I provided. Hope it helps in some way.
https://en.wikipedia.org/wiki/Oil_drop_experiment#Fraud_allegations | The fallacy of correlating some time series values with specific time points: is there a specific na
in addition to my article resource of different fallacies in academic research:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.579.5429&rep=rep1&type=pdf
I screened one/two articles and a bl |
30,441 | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references? | There are different concepts and some of them overlap. Also I think the main once are already been mention : ). I think these are also interesting in terms of time series and analysis.
'spurious regression' high R2 values and high t-ratios yielding results with no economic meaning. This could happed ussually in a) just silly correlations as in https://www.tylervigen.com/spurious-correlations, or see https://en.wikipedia.org/wiki/Spurious_relationship, or b) very common in time series that are not stationary, see Unit Roots here: https://en.wikipedia.org/wiki/Unit_root
Correlation does not imply causation – Refutation of a logical fallacy. See https://en.wikipedia.org/wiki/Correlation_does_not_imply_causation. In many cases we not to better understand the situation, some useful tools could be Grander Causality (see https://en.wikipedia.org/wiki/Granger_causality) or the creation of experimental set up https://en.wikipedia.org/wiki/Design_of_experiments.
Cum hoc ergo propter hoc ("with this, therefore because of this"). See https://en.wikipedia.org/wiki/Post_hoc_ergo_propter_hoc.
Lucas Critique: https://en.wikipedia.org/wiki/Lucas_critique
It is naive to try to predict the effects of a change in economic policy entirely on the basis of relationships observed in historical data, especially highly aggregated historical data. Kind of saying that it is impossible to predict the future in human systems, for instance when including policies.
A self-fulfilling prophecy is the sociopsychological phenomenon of someone "predicting" or expecting something, and this "prediction" or expectation coming true simply because the person believes it will and the person's resulting behaviors align to fulfill the belief. See https://en.wikipedia.org/wiki/Self-fulfilling_prophecy. I think this is curious with the toilet paper during the beginning of Covid 19. Similar pattern can be observe in the stock market during economics crisis and bubbles. | The fallacy of correlating some time series values with specific time points: is there a specific na | There are different concepts and some of them overlap. Also I think the main once are already been mention : ). I think these are also interesting in terms of time series and analysis.
'spurious regr | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references?
There are different concepts and some of them overlap. Also I think the main once are already been mention : ). I think these are also interesting in terms of time series and analysis.
'spurious regression' high R2 values and high t-ratios yielding results with no economic meaning. This could happed ussually in a) just silly correlations as in https://www.tylervigen.com/spurious-correlations, or see https://en.wikipedia.org/wiki/Spurious_relationship, or b) very common in time series that are not stationary, see Unit Roots here: https://en.wikipedia.org/wiki/Unit_root
Correlation does not imply causation – Refutation of a logical fallacy. See https://en.wikipedia.org/wiki/Correlation_does_not_imply_causation. In many cases we not to better understand the situation, some useful tools could be Grander Causality (see https://en.wikipedia.org/wiki/Granger_causality) or the creation of experimental set up https://en.wikipedia.org/wiki/Design_of_experiments.
Cum hoc ergo propter hoc ("with this, therefore because of this"). See https://en.wikipedia.org/wiki/Post_hoc_ergo_propter_hoc.
Lucas Critique: https://en.wikipedia.org/wiki/Lucas_critique
It is naive to try to predict the effects of a change in economic policy entirely on the basis of relationships observed in historical data, especially highly aggregated historical data. Kind of saying that it is impossible to predict the future in human systems, for instance when including policies.
A self-fulfilling prophecy is the sociopsychological phenomenon of someone "predicting" or expecting something, and this "prediction" or expectation coming true simply because the person believes it will and the person's resulting behaviors align to fulfill the belief. See https://en.wikipedia.org/wiki/Self-fulfilling_prophecy. I think this is curious with the toilet paper during the beginning of Covid 19. Similar pattern can be observe in the stock market during economics crisis and bubbles. | The fallacy of correlating some time series values with specific time points: is there a specific na
There are different concepts and some of them overlap. Also I think the main once are already been mention : ). I think these are also interesting in terms of time series and analysis.
'spurious regr |
30,442 | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references? | This is not an answer providing a canonical example. However, this answer provides another occurrence of the same type of fallacy mistake in a slightly different context.
This makes it interesting to be placed as an answer. (I do not want to add it to the question which would make it too much cluttered)
It also shows that this type of fallacy is more widespread then just the single occurrence in the article about the correlation between pollen and covid in PNAS. A specific term for this specific fallacy might be desirable.
The following argument occurs in
Walrand, S. Autumn COVID-19 surge dates in Europe correlated to latitudes, not to temperature-humidity, pointing to vitamin D as contributing factor. Sci Rep 11, 1981 (2021). https://doi.org/10.1038/s41598-021-81419-w
COVID-19 surge date as a function of country mean temperature (A) and humidity (B) during the 2 preceding weeks and as a function of country PWC latitude (C), pointing to vitamin D as one of the primary factors (flags link countries between graphs).
The argument is that temperature and humidity do not correlate with the date and therefore are excluded as cause for the surge in COVID-19 cases. With temperature and humidity excluded this points to vitamin D (sunlight) as remaining factor.
However when we take the data from table 2 and plot sunlight then we get just as well a lack of correlation. This is illustrated in the graph below. In the first row, we see three graphs from the article. In the second row we see a fourth graph that could have been plotted (and would have shown that UV is similar to temperature and humidity) but has not been added in the article.
The fallacy is that they wrongly assume that there should be a correlation between temperature, humidity and/or UV-light and the onset date of the surge, if these factors play a role. However, the opposite is true. If temperature, humidity and/or UV-light play a role then you will expect that these factors are more or less similar on/before the day of onset in different countries.
By stating that the argument is a fallacy, I do not want to say that all the conclusions are wrong. There might still be a relationship with vitamin D. However, what we can say is that these data are not conclusive about vitamin D. In addition the data are no support for an argument that temperature and humidity do not play a role. | The fallacy of correlating some time series values with specific time points: is there a specific na | This is not an answer providing a canonical example. However, this answer provides another occurrence of the same type of fallacy mistake in a slightly different context.
This makes it interesting to | The fallacy of correlating some time series values with specific time points: is there a specific name for it or are there references?
This is not an answer providing a canonical example. However, this answer provides another occurrence of the same type of fallacy mistake in a slightly different context.
This makes it interesting to be placed as an answer. (I do not want to add it to the question which would make it too much cluttered)
It also shows that this type of fallacy is more widespread then just the single occurrence in the article about the correlation between pollen and covid in PNAS. A specific term for this specific fallacy might be desirable.
The following argument occurs in
Walrand, S. Autumn COVID-19 surge dates in Europe correlated to latitudes, not to temperature-humidity, pointing to vitamin D as contributing factor. Sci Rep 11, 1981 (2021). https://doi.org/10.1038/s41598-021-81419-w
COVID-19 surge date as a function of country mean temperature (A) and humidity (B) during the 2 preceding weeks and as a function of country PWC latitude (C), pointing to vitamin D as one of the primary factors (flags link countries between graphs).
The argument is that temperature and humidity do not correlate with the date and therefore are excluded as cause for the surge in COVID-19 cases. With temperature and humidity excluded this points to vitamin D (sunlight) as remaining factor.
However when we take the data from table 2 and plot sunlight then we get just as well a lack of correlation. This is illustrated in the graph below. In the first row, we see three graphs from the article. In the second row we see a fourth graph that could have been plotted (and would have shown that UV is similar to temperature and humidity) but has not been added in the article.
The fallacy is that they wrongly assume that there should be a correlation between temperature, humidity and/or UV-light and the onset date of the surge, if these factors play a role. However, the opposite is true. If temperature, humidity and/or UV-light play a role then you will expect that these factors are more or less similar on/before the day of onset in different countries.
By stating that the argument is a fallacy, I do not want to say that all the conclusions are wrong. There might still be a relationship with vitamin D. However, what we can say is that these data are not conclusive about vitamin D. In addition the data are no support for an argument that temperature and humidity do not play a role. | The fallacy of correlating some time series values with specific time points: is there a specific na
This is not an answer providing a canonical example. However, this answer provides another occurrence of the same type of fallacy mistake in a slightly different context.
This makes it interesting to |
30,443 | What useful properties does the canonical link function have? | I know this question is quite naive and simple, but I do not exactly know why the link canonical function is so useful
Is it really so useful? A link function being canonical is mostly a mathematical property. It simplifies the mathematics somewhat, but in modeling you should anyhow use the link function that is scientifically meaningful.
So what extra properties does a canonical link function have?
It leads to existence of sufficient statistics. That could imply somewhat more efficient estimation, maybe, but modern software (such as glm in R) do not seem to treat canonical links differently from other links.
It simplifies some formulas, so theoretical developments are eased. Many nice mathematical properties, see What is the difference between a "link function" and a "canonical link function" for GLM.
So advantages seem to be mostly mathematical and algorithmical, not really statistical.
Some more details: Let $Y_1, \dotsc, Y_n$ be independent observations from the exponential dispersion family model
$$
f_Y(y;\theta,\phi)=\exp\left\{(y\theta-b(\theta))/a(\phi) + c(y,\phi)\right\}
$$ with expectation $\DeclareMathOperator{\E}{\mathbb{E}} \E Y_i=\mu_i$ and linear predictor $\eta_i = x_i^T \beta$ with covariate vector $x_i$. The link function is canonical if $\eta_i=\theta_i$. In this case the likelihood function can be written as
$$
\mathcal{L}(\beta; \phi)=\exp\left\{ \sum_i \frac{y_i x_i^T \beta -b(x_i^T \beta)}{a(\phi)}+\sum_i c(y_i,\phi)\right\}
$$ and by the factorization theorem we can conclude that $\sum_i x_i y_i$ is sufficient for $\beta$.
Without going into details, the equations needed for IRLS will be simplified. Likewise, this google search mostly seems to find canonical links mentioned in the context of simplifications, and not any more statistical reasons. | What useful properties does the canonical link function have? | I know this question is quite naive and simple, but I do not exactly know why the link canonical function is so useful
Is it really so useful? A link function being canonical is mostly a mathematical | What useful properties does the canonical link function have?
I know this question is quite naive and simple, but I do not exactly know why the link canonical function is so useful
Is it really so useful? A link function being canonical is mostly a mathematical property. It simplifies the mathematics somewhat, but in modeling you should anyhow use the link function that is scientifically meaningful.
So what extra properties does a canonical link function have?
It leads to existence of sufficient statistics. That could imply somewhat more efficient estimation, maybe, but modern software (such as glm in R) do not seem to treat canonical links differently from other links.
It simplifies some formulas, so theoretical developments are eased. Many nice mathematical properties, see What is the difference between a "link function" and a "canonical link function" for GLM.
So advantages seem to be mostly mathematical and algorithmical, not really statistical.
Some more details: Let $Y_1, \dotsc, Y_n$ be independent observations from the exponential dispersion family model
$$
f_Y(y;\theta,\phi)=\exp\left\{(y\theta-b(\theta))/a(\phi) + c(y,\phi)\right\}
$$ with expectation $\DeclareMathOperator{\E}{\mathbb{E}} \E Y_i=\mu_i$ and linear predictor $\eta_i = x_i^T \beta$ with covariate vector $x_i$. The link function is canonical if $\eta_i=\theta_i$. In this case the likelihood function can be written as
$$
\mathcal{L}(\beta; \phi)=\exp\left\{ \sum_i \frac{y_i x_i^T \beta -b(x_i^T \beta)}{a(\phi)}+\sum_i c(y_i,\phi)\right\}
$$ and by the factorization theorem we can conclude that $\sum_i x_i y_i$ is sufficient for $\beta$.
Without going into details, the equations needed for IRLS will be simplified. Likewise, this google search mostly seems to find canonical links mentioned in the context of simplifications, and not any more statistical reasons. | What useful properties does the canonical link function have?
I know this question is quite naive and simple, but I do not exactly know why the link canonical function is so useful
Is it really so useful? A link function being canonical is mostly a mathematical |
30,444 | What useful properties does the canonical link function have? | The canonical link function describes the mean-variance relationship in a GLM. For instance, a binomial random variable has link function $\mu = \exp( \nu) /(1-\exp(\nu))$ where $\nu$ is a linear predictor $\mathbf{X}^T\beta$. Note that $\frac{\partial }{\partial \nu} \mu = \mu(1-\mu)$ which is the appropriate mean-variance relationship for a Bernoulli random variable. The same is true of Poisson random variables, where the inverse link function is $\mu = \exp(\nu)$ and $\frac{\partial }{\partial \nu} \mu = \mu$ where in a Poisson random variable, the variance is the mean.
The generalized linear model solves an estimating equation of the form:
$$ U(\beta) = D V^{-1} (Y - g(\mathbf{X}^T\beta))$$
where $D = \frac{\partial}{\partial \beta} g(\mathbf{X}^T\beta)$ and $V=\text{var}(Y)$. When the link is canonical, therefore, $D = V$ and the estimating function is the score function, i.e. the derivative of the log likelihood:
$$ S(\beta) = \mathbf{X}^{T}(Y - g(\mathbf{X}^T\beta))$$
As was noted in Wedderburn's 1976 paper on quasilikelihood, the canonical link has the advantage that expected and observed information are the same and that iteratively reweighted least squares is equivalent to Newton-Raphson, so this simplifies estimating procedures and variance estimation. | What useful properties does the canonical link function have? | The canonical link function describes the mean-variance relationship in a GLM. For instance, a binomial random variable has link function $\mu = \exp( \nu) /(1-\exp(\nu))$ where $\nu$ is a linear pred | What useful properties does the canonical link function have?
The canonical link function describes the mean-variance relationship in a GLM. For instance, a binomial random variable has link function $\mu = \exp( \nu) /(1-\exp(\nu))$ where $\nu$ is a linear predictor $\mathbf{X}^T\beta$. Note that $\frac{\partial }{\partial \nu} \mu = \mu(1-\mu)$ which is the appropriate mean-variance relationship for a Bernoulli random variable. The same is true of Poisson random variables, where the inverse link function is $\mu = \exp(\nu)$ and $\frac{\partial }{\partial \nu} \mu = \mu$ where in a Poisson random variable, the variance is the mean.
The generalized linear model solves an estimating equation of the form:
$$ U(\beta) = D V^{-1} (Y - g(\mathbf{X}^T\beta))$$
where $D = \frac{\partial}{\partial \beta} g(\mathbf{X}^T\beta)$ and $V=\text{var}(Y)$. When the link is canonical, therefore, $D = V$ and the estimating function is the score function, i.e. the derivative of the log likelihood:
$$ S(\beta) = \mathbf{X}^{T}(Y - g(\mathbf{X}^T\beta))$$
As was noted in Wedderburn's 1976 paper on quasilikelihood, the canonical link has the advantage that expected and observed information are the same and that iteratively reweighted least squares is equivalent to Newton-Raphson, so this simplifies estimating procedures and variance estimation. | What useful properties does the canonical link function have?
The canonical link function describes the mean-variance relationship in a GLM. For instance, a binomial random variable has link function $\mu = \exp( \nu) /(1-\exp(\nu))$ where $\nu$ is a linear pred |
30,445 | Probability of $X_1 \geq X_2$ | It can't be $50\%$ because $P(X_1=X_2)>0$
One approach:
Consider the three events $P(X_1>X_2), P(X_2>X_1)$ and $P(X_1=X_2)$, which partition the sample space.
There's an obvious connection between the first two. Write an expression for the third and simplify. Hence solve the question. | Probability of $X_1 \geq X_2$ | It can't be $50\%$ because $P(X_1=X_2)>0$
One approach:
Consider the three events $P(X_1>X_2), P(X_2>X_1)$ and $P(X_1=X_2)$, which partition the sample space.
There's an obvious connection between the | Probability of $X_1 \geq X_2$
It can't be $50\%$ because $P(X_1=X_2)>0$
One approach:
Consider the three events $P(X_1>X_2), P(X_2>X_1)$ and $P(X_1=X_2)$, which partition the sample space.
There's an obvious connection between the first two. Write an expression for the third and simplify. Hence solve the question. | Probability of $X_1 \geq X_2$
It can't be $50\%$ because $P(X_1=X_2)>0$
One approach:
Consider the three events $P(X_1>X_2), P(X_2>X_1)$ and $P(X_1=X_2)$, which partition the sample space.
There's an obvious connection between the |
30,446 | Probability of $X_1 \geq X_2$ | Your answer, following Glen's suggestion, is correct. Another, less elegant, way is just to condition:
\begin{align}
\Pr\{X_1\geq X_2\} &= \sum_{k=0}^\infty \Pr\{X_1\geq X_2\mid X_2=k\} \Pr\{X_2=k\} \\ &= \sum_{k=0}^\infty \sum_{\ell=k}^\infty \Pr\{X_1=\ell\}\Pr\{X_2=k\}.
\end{align}
This will give you the same $1/(2-p)$, after handling the two geometric series. Glen's way is better. | Probability of $X_1 \geq X_2$ | Your answer, following Glen's suggestion, is correct. Another, less elegant, way is just to condition:
\begin{align}
\Pr\{X_1\geq X_2\} &= \sum_{k=0}^\infty \Pr\{X_1\geq X_2\mid X_2=k\} \Pr\{X_2=k\} | Probability of $X_1 \geq X_2$
Your answer, following Glen's suggestion, is correct. Another, less elegant, way is just to condition:
\begin{align}
\Pr\{X_1\geq X_2\} &= \sum_{k=0}^\infty \Pr\{X_1\geq X_2\mid X_2=k\} \Pr\{X_2=k\} \\ &= \sum_{k=0}^\infty \sum_{\ell=k}^\infty \Pr\{X_1=\ell\}\Pr\{X_2=k\}.
\end{align}
This will give you the same $1/(2-p)$, after handling the two geometric series. Glen's way is better. | Probability of $X_1 \geq X_2$
Your answer, following Glen's suggestion, is correct. Another, less elegant, way is just to condition:
\begin{align}
\Pr\{X_1\geq X_2\} &= \sum_{k=0}^\infty \Pr\{X_1\geq X_2\mid X_2=k\} \Pr\{X_2=k\} |
30,447 | Wilcoxon Signed Rank Symmetry Assumption | Although on the surface the two statements above may appear contradictory, they aren't. The Wilcoxon Signed Rank test does require that the paired differences come from a continuous symmetric distribution (under the null hypothesis, as Michael Chernick points out in comments.) In the special case when the two sub-populations $A$ and $B$ from which the paired samples will be drawn (one each from $A$ and $B$) have the same (continuous) distribution, it is guaranteed that the pairwise differences between the samples $a_i,b_i$ will come from a continuous symmetric distribution.
You can see this by observing that if the two samples come from the same distribution, $p(a_i = x, b_i = y) = p(a_i = y, b_i = x)$. In the former case, the paired difference $\delta_{i,1} = x-y$, and in the latter case the paired difference $\delta_{i,2} = y-x = -\delta_{i,1}$. Since the probabilities of the two cases are equal, it follows that $p(\delta_i) = p(-\delta_i)$, i.e., that the distribution is symmetric around 0.
Therefore, if you can make the assumption that the two sub-populations have the same continuous distribution under the null hypothesis, you've satisfied the Wilcoxon Signed Rank assumption requirements. Often it is easier to see why this assumption might be true than to see why the more general "pairwise differences come from a continuous symmetric distribution" might be true, hence its occasional use. | Wilcoxon Signed Rank Symmetry Assumption | Although on the surface the two statements above may appear contradictory, they aren't. The Wilcoxon Signed Rank test does require that the paired differences come from a continuous symmetric distrib | Wilcoxon Signed Rank Symmetry Assumption
Although on the surface the two statements above may appear contradictory, they aren't. The Wilcoxon Signed Rank test does require that the paired differences come from a continuous symmetric distribution (under the null hypothesis, as Michael Chernick points out in comments.) In the special case when the two sub-populations $A$ and $B$ from which the paired samples will be drawn (one each from $A$ and $B$) have the same (continuous) distribution, it is guaranteed that the pairwise differences between the samples $a_i,b_i$ will come from a continuous symmetric distribution.
You can see this by observing that if the two samples come from the same distribution, $p(a_i = x, b_i = y) = p(a_i = y, b_i = x)$. In the former case, the paired difference $\delta_{i,1} = x-y$, and in the latter case the paired difference $\delta_{i,2} = y-x = -\delta_{i,1}$. Since the probabilities of the two cases are equal, it follows that $p(\delta_i) = p(-\delta_i)$, i.e., that the distribution is symmetric around 0.
Therefore, if you can make the assumption that the two sub-populations have the same continuous distribution under the null hypothesis, you've satisfied the Wilcoxon Signed Rank assumption requirements. Often it is easier to see why this assumption might be true than to see why the more general "pairwise differences come from a continuous symmetric distribution" might be true, hence its occasional use. | Wilcoxon Signed Rank Symmetry Assumption
Although on the surface the two statements above may appear contradictory, they aren't. The Wilcoxon Signed Rank test does require that the paired differences come from a continuous symmetric distrib |
30,448 | Wilcoxon Signed Rank Symmetry Assumption | Note that the samples may tell you nothing about the suitability of the assumption that is required for the null. If the null is false, you don't necessarily require symmetry (and it's easy to demonstrate examples where everything works as desired without needing symmetry under the alternative).
People seem to spend a deal of effort worrying about testing an assumption using data that may not be relevant to the question of whether the assumption is reasonable. The assumption might better be dealt with by considering its plausibility before even seeing the data (jbowman's excellent answer covers this in some detail; under the assumption that the treatment doesn't change the distribution at all, it should follow immediately).
[This doesn't mean that the situation under the alternative is arbitrary (it's a test sensitive to particular kinds of deviations from symmetry about zero in pair-differences and it's insensitive to other kinds of deviations) - you are still looking for a tendency for differences to be typically larger than 0 or typically smaller than 0]
Additionally, testing the assumption (and then choosing what you do based on whether or not you reject the null on that prior test) will impact the properties of the subsequent procedures you're considering (p-values will no longer be uniform under the null, for example).
In some cases it may be convenient to assume a location shift alternative (certainly it's possible to estimate its size and even give a confidence interval for it). It would for example, make it simpler to discuss the treatment effect. However, that doesn't make it an assumption of the test itself, it makes it an additional assumption we've made for other reasons. In this situation, the data may be relevant to assessing whether that assumption was suitable, but we still have the problem that if we choose a test on the basis of the data, we no longer have our desired significance level (there are also impacts on power). | Wilcoxon Signed Rank Symmetry Assumption | Note that the samples may tell you nothing about the suitability of the assumption that is required for the null. If the null is false, you don't necessarily require symmetry (and it's easy to demonst | Wilcoxon Signed Rank Symmetry Assumption
Note that the samples may tell you nothing about the suitability of the assumption that is required for the null. If the null is false, you don't necessarily require symmetry (and it's easy to demonstrate examples where everything works as desired without needing symmetry under the alternative).
People seem to spend a deal of effort worrying about testing an assumption using data that may not be relevant to the question of whether the assumption is reasonable. The assumption might better be dealt with by considering its plausibility before even seeing the data (jbowman's excellent answer covers this in some detail; under the assumption that the treatment doesn't change the distribution at all, it should follow immediately).
[This doesn't mean that the situation under the alternative is arbitrary (it's a test sensitive to particular kinds of deviations from symmetry about zero in pair-differences and it's insensitive to other kinds of deviations) - you are still looking for a tendency for differences to be typically larger than 0 or typically smaller than 0]
Additionally, testing the assumption (and then choosing what you do based on whether or not you reject the null on that prior test) will impact the properties of the subsequent procedures you're considering (p-values will no longer be uniform under the null, for example).
In some cases it may be convenient to assume a location shift alternative (certainly it's possible to estimate its size and even give a confidence interval for it). It would for example, make it simpler to discuss the treatment effect. However, that doesn't make it an assumption of the test itself, it makes it an additional assumption we've made for other reasons. In this situation, the data may be relevant to assessing whether that assumption was suitable, but we still have the problem that if we choose a test on the basis of the data, we no longer have our desired significance level (there are also impacts on power). | Wilcoxon Signed Rank Symmetry Assumption
Note that the samples may tell you nothing about the suitability of the assumption that is required for the null. If the null is false, you don't necessarily require symmetry (and it's easy to demonst |
30,449 | Wilcoxon Signed Rank Symmetry Assumption | This is less an answer and more a request for further clarification from respondents, and maybe a clarification itself.
Here are a couple of examples from textbooks showing how the symmetry assumption for the signed-rank test is sometimes handled. On my bookshelf I couldn't find anything more clear or more explanatory.
There are also numerous examples from the internet and from Cross Validated where the symmetry assumption is stated simply and without further explication.
The Wilcoxon [signed-rank] test assumes that the sampled population is
symmetric (in which case the median and mean are identical and this
procedure becomes a hypothesis test about the mean as well as about
the median, but the one-sample t test is typically a more powerful
test about the mean).
-- Zar, Biostatitics, 5th, 2010, § 7.9
.
The important difference between the sign test and this [Wilcoxon
signed-rank] test is an additional assumption of symmetry of the
distribution of the differences.
...
Assumptions:
The distribution of each Di [difference in paired observations] is symmetric.
The Dis are mutually independent.
The Dis all have the same mean.
The measurement scale of the Dis is at least interval.
-- Conover, Practical Nonparametric Statistics, 3rd, 1999, § 5.7
However, I think the responses by @jbowman and @Glen_b explain this assumption in a different light.
If the null is false, you don't necessarily require symmetry.
...
In some cases it may be convenient to assume a location shift alternative... However, that doesn't make it an assumption of the test, it makes it an additional assumption we've made for other reasons.
-- @Glen_b
.
The Wilcoxon Signed Rank test does require that the paired differences come from a continuous symmetric distribution (under the null hypothesis, as Michael Chernick points out in comments.)
-- @jbowman
One way I might be able to sum up my understanding is as follows. The null hypothesis for the signed-rank test is that the differences are symmetrically distributed about a value. There are two ways this hypothesis could be wrong. 1) The differences could be symmetrical about a different value. 2) The differences could be not symmetrical. If #1 is the case, then the differences have a different location than in the null hypothesis, which is a useful result, and easy to interpret. If #2 is the case, then the data are skewed in a way that is a useful result. This may be a little less easy to interpret that in #1, but an examination of a histogram of the differences should reveal useful information about the distribution.
With this understanding, I think there is no assumption about the distribution of the original data, the differences, or the ranks of the differences.
How does this sound? | Wilcoxon Signed Rank Symmetry Assumption | This is less an answer and more a request for further clarification from respondents, and maybe a clarification itself.
Here are a couple of examples from textbooks showing how the symmetry assumpti | Wilcoxon Signed Rank Symmetry Assumption
This is less an answer and more a request for further clarification from respondents, and maybe a clarification itself.
Here are a couple of examples from textbooks showing how the symmetry assumption for the signed-rank test is sometimes handled. On my bookshelf I couldn't find anything more clear or more explanatory.
There are also numerous examples from the internet and from Cross Validated where the symmetry assumption is stated simply and without further explication.
The Wilcoxon [signed-rank] test assumes that the sampled population is
symmetric (in which case the median and mean are identical and this
procedure becomes a hypothesis test about the mean as well as about
the median, but the one-sample t test is typically a more powerful
test about the mean).
-- Zar, Biostatitics, 5th, 2010, § 7.9
.
The important difference between the sign test and this [Wilcoxon
signed-rank] test is an additional assumption of symmetry of the
distribution of the differences.
...
Assumptions:
The distribution of each Di [difference in paired observations] is symmetric.
The Dis are mutually independent.
The Dis all have the same mean.
The measurement scale of the Dis is at least interval.
-- Conover, Practical Nonparametric Statistics, 3rd, 1999, § 5.7
However, I think the responses by @jbowman and @Glen_b explain this assumption in a different light.
If the null is false, you don't necessarily require symmetry.
...
In some cases it may be convenient to assume a location shift alternative... However, that doesn't make it an assumption of the test, it makes it an additional assumption we've made for other reasons.
-- @Glen_b
.
The Wilcoxon Signed Rank test does require that the paired differences come from a continuous symmetric distribution (under the null hypothesis, as Michael Chernick points out in comments.)
-- @jbowman
One way I might be able to sum up my understanding is as follows. The null hypothesis for the signed-rank test is that the differences are symmetrically distributed about a value. There are two ways this hypothesis could be wrong. 1) The differences could be symmetrical about a different value. 2) The differences could be not symmetrical. If #1 is the case, then the differences have a different location than in the null hypothesis, which is a useful result, and easy to interpret. If #2 is the case, then the data are skewed in a way that is a useful result. This may be a little less easy to interpret that in #1, but an examination of a histogram of the differences should reveal useful information about the distribution.
With this understanding, I think there is no assumption about the distribution of the original data, the differences, or the ranks of the differences.
How does this sound? | Wilcoxon Signed Rank Symmetry Assumption
This is less an answer and more a request for further clarification from respondents, and maybe a clarification itself.
Here are a couple of examples from textbooks showing how the symmetry assumpti |
30,450 | Wilcoxon Signed Rank Symmetry Assumption | I'm late to the party here, but I was looking into this question and wanted to add something (hopefully) helpful.
In Nonparametric Statistical Inference fifth edition by Gibbons and Chakraborti I found this:
The Wilcoxon signed-rank statistics can also be used as tests for symmetry if the only assumption made is that the random sample is drawn from a continuous distribution...If the null hypothesis is accepted, we can conclude that the population is symmetric and has median M0. But if the null hypothesis is rejected, we cannot tell which portion (or all) of the composite statement [null and alternative] is not consistent with the sample outcome. With the two-sided alternative, for example, we must conclude that either the population is symmetric with median not equal to M0, or the population is asymmetric with median equal to M0, or the population is asymmetric with median not equal to M0. Such a broad conclusion is generally not satisfactory, and this is why in most cases the assumptions that justify a test procedure are separated from the statement of the null hypothesis.
I think this helps reinforce the other answers here to explain why the symmetry assumption is considered as plausible by researchers using this method, but not necessarily desiring a formal test of it based on the sample data. | Wilcoxon Signed Rank Symmetry Assumption | I'm late to the party here, but I was looking into this question and wanted to add something (hopefully) helpful.
In Nonparametric Statistical Inference fifth edition by Gibbons and Chakraborti I foun | Wilcoxon Signed Rank Symmetry Assumption
I'm late to the party here, but I was looking into this question and wanted to add something (hopefully) helpful.
In Nonparametric Statistical Inference fifth edition by Gibbons and Chakraborti I found this:
The Wilcoxon signed-rank statistics can also be used as tests for symmetry if the only assumption made is that the random sample is drawn from a continuous distribution...If the null hypothesis is accepted, we can conclude that the population is symmetric and has median M0. But if the null hypothesis is rejected, we cannot tell which portion (or all) of the composite statement [null and alternative] is not consistent with the sample outcome. With the two-sided alternative, for example, we must conclude that either the population is symmetric with median not equal to M0, or the population is asymmetric with median equal to M0, or the population is asymmetric with median not equal to M0. Such a broad conclusion is generally not satisfactory, and this is why in most cases the assumptions that justify a test procedure are separated from the statement of the null hypothesis.
I think this helps reinforce the other answers here to explain why the symmetry assumption is considered as plausible by researchers using this method, but not necessarily desiring a formal test of it based on the sample data. | Wilcoxon Signed Rank Symmetry Assumption
I'm late to the party here, but I was looking into this question and wanted to add something (hopefully) helpful.
In Nonparametric Statistical Inference fifth edition by Gibbons and Chakraborti I foun |
30,451 | Wilcoxon Signed Rank Symmetry Assumption | Just look at a boxplot of the differences, and make sure it's symmetrical.
Watch this video, at 5:53 : https://www.youtube.com/watch?v=Y4-wAT4SNM4 | Wilcoxon Signed Rank Symmetry Assumption | Just look at a boxplot of the differences, and make sure it's symmetrical.
Watch this video, at 5:53 : https://www.youtube.com/watch?v=Y4-wAT4SNM4 | Wilcoxon Signed Rank Symmetry Assumption
Just look at a boxplot of the differences, and make sure it's symmetrical.
Watch this video, at 5:53 : https://www.youtube.com/watch?v=Y4-wAT4SNM4 | Wilcoxon Signed Rank Symmetry Assumption
Just look at a boxplot of the differences, and make sure it's symmetrical.
Watch this video, at 5:53 : https://www.youtube.com/watch?v=Y4-wAT4SNM4 |
30,452 | Difference between a Student-T vs Cauchy distribution | Student's t-distribution becomes the Cauchy distribution when the degrees of freedom is equal to one and converges to the normal distribution as the degrees of freedom go to infinity. The primary distinction is that for either one or two degrees of freedom, then there is no defined variance for Student's distribution. This allows you to model the existence of a variance or not by choosing the number of degrees of freedom. With the Cauchy distribution, the scale parameter is not identical to the variance nor does it have a defined variance. The variance is infinite.
For small degrees of freedom and a very large sample size, the difference between a Student's t prior distribution and a Cauchy prior distribution may not be different enough for computational differences to arise. | Difference between a Student-T vs Cauchy distribution | Student's t-distribution becomes the Cauchy distribution when the degrees of freedom is equal to one and converges to the normal distribution as the degrees of freedom go to infinity. The primary dis | Difference between a Student-T vs Cauchy distribution
Student's t-distribution becomes the Cauchy distribution when the degrees of freedom is equal to one and converges to the normal distribution as the degrees of freedom go to infinity. The primary distinction is that for either one or two degrees of freedom, then there is no defined variance for Student's distribution. This allows you to model the existence of a variance or not by choosing the number of degrees of freedom. With the Cauchy distribution, the scale parameter is not identical to the variance nor does it have a defined variance. The variance is infinite.
For small degrees of freedom and a very large sample size, the difference between a Student's t prior distribution and a Cauchy prior distribution may not be different enough for computational differences to arise. | Difference between a Student-T vs Cauchy distribution
Student's t-distribution becomes the Cauchy distribution when the degrees of freedom is equal to one and converges to the normal distribution as the degrees of freedom go to infinity. The primary dis |
30,453 | How to interpret the Delta Method? | Some intuition behind the delta method:
The Delta method can be seen as combining two ideas:
Continuous, differentiable functions can be approximated locally by an affine transformation.
An affine transformation of a multivariate normal random variable is multivariate normal.
The 1st idea is from calculus, the 2nd is from probability. The loose intuition / argument goes:
The input random variable $\tilde{\boldsymbol{\theta}}_n$ is asymptotically normal (by assumption or by application of a central limit theorem in the case where $\tilde{\boldsymbol{\theta}}_n$ is a sample mean).
The smaller the neighborhood, the more $\mathbf{g}(\mathbf{x})$ looks like an affine transformation, that is, the more the function looks like a hyperplane (or a line in the 1 variable case).
Where that linear approximation applies (and some regularity conditions hold), the multivariate normality of $\tilde{\boldsymbol{\theta}}_n$ is preserved when function $\mathbf{g}$ is applied to $\tilde{\boldsymbol{\theta}}_n$.
Note that function $\mathbf{g}$ has to satisfy certain conditions for this to be true. Normality isn't preserved in the neighborhood around $x=0$ for $g(x) = x^2$ because you'll basically get both halves of the bell curve mapped to the same side: both $x=-2$ and $x=2$ get mapped to $y=4$. You need $g$ strictly increasing or decreasing in the neighborhood so that this doesn't happen.
Idea 1: Locally, any continuous, differentiable function looks affine
An idea of calculus is if you zoom in enough on a continuous, differentiable function, it will look like a line (or hyperplane in the multivariate case). If we have some vector valued function $\mathbf{g}(\mathbf{x})$, in a small enough neighborhood around $\mathbf{c}$ you can approximate $\mathbf{g}(\mathbf{c} + \boldsymbol{\epsilon}) $ with the below affine function of $\boldsymbol{\epsilon}$:
$$ \mathbf{g}(\mathbf{c} + \boldsymbol{\epsilon}) \approx \mathbf{g}(\mathbf{c}) + \frac{\partial \mathbf{g}(\mathbf{c})}{\partial \mathbf{x}'} \;\boldsymbol{\epsilon} $$
Idea 2: An affine transformation of a multivariate normal random variable is multivariate normal
Let's say we have $\tilde{\boldsymbol{\theta}}$ distributed multivariate normal with mean $\boldsymbol{\mu}$ and variance $V$. That is:
$$\tilde{\boldsymbol{\theta}} \sim \mathcal{N}\left( \boldsymbol{\mu}, V\right)$$
Consider a linear transformation $A$ and consider the multivariate normal random variable defined by the linear transformation $A\tilde{\boldsymbol{\theta}}$. It's easy to show:
$$A\tilde{\boldsymbol{\theta}} - A\boldsymbol{\mu} \sim \mathcal{N}\left(\mathbf{0}, AVA'\right)$$
Putting it together:
If we know that $\tilde{\boldsymbol{\theta}} \sim \mathcal{N}\left( \boldsymbol{\mu}, V\right)$ and that function $\mathbf{g}(\mathbf{x})$ can be approximated around $\boldsymbol{\mu}$ by $\mathbf{g}(\boldsymbol{\mu}) + \frac{\partial \mathbf{g}(\boldsymbol{\mu})}{\partial \mathbf{x}'} \;\boldsymbol{\epsilon}$ then putting ideas (1) and (2) together:
$$ \mathbf{g}\left( \tilde{\boldsymbol{\theta}} \right) - \mathbf{g}(\boldsymbol{\mu}) \sim \mathcal{N} \left( \mathbf{0}, \frac{\partial \mathbf{g}(\boldsymbol{\mu})}{\partial \mathbf{x}'} V \frac{\partial \mathbf{g}(\boldsymbol{\mu})}{\partial \mathbf{x}'} '\right) $$
What can go wrong?
We have a problem doing this if any component of $\frac{\partial \mathbf{g}(\mathbf{c})}{\partial \mathbf{x}'}$ is zero. (eg. $g(x) = x^2$ at $x=0$.) We need $g$ strictly increasing or decreasing in the region where $\tilde{\boldsymbol{\theta}}_n$ has probability mass.
This is also going to be a bad approximation if $g$ doesn't look like an affine function in the region where $\tilde{\boldsymbol{\theta}}_n$ has probability mass.
It may also be a bad approximation if $\tilde{\boldsymbol{\theta}}_n$ isn't normal.
This problem:
$$g(x) = x^2 \quad \quad g'(x) = 2 x $$
If $\sqrt{n}\left( \tilde{\theta} - \mu \right) \xrightarrow{d} \mathcal{N}(0, 1)$
Applying the delta method you get... | How to interpret the Delta Method? | Some intuition behind the delta method:
The Delta method can be seen as combining two ideas:
Continuous, differentiable functions can be approximated locally by an affine transformation.
An affine tr | How to interpret the Delta Method?
Some intuition behind the delta method:
The Delta method can be seen as combining two ideas:
Continuous, differentiable functions can be approximated locally by an affine transformation.
An affine transformation of a multivariate normal random variable is multivariate normal.
The 1st idea is from calculus, the 2nd is from probability. The loose intuition / argument goes:
The input random variable $\tilde{\boldsymbol{\theta}}_n$ is asymptotically normal (by assumption or by application of a central limit theorem in the case where $\tilde{\boldsymbol{\theta}}_n$ is a sample mean).
The smaller the neighborhood, the more $\mathbf{g}(\mathbf{x})$ looks like an affine transformation, that is, the more the function looks like a hyperplane (or a line in the 1 variable case).
Where that linear approximation applies (and some regularity conditions hold), the multivariate normality of $\tilde{\boldsymbol{\theta}}_n$ is preserved when function $\mathbf{g}$ is applied to $\tilde{\boldsymbol{\theta}}_n$.
Note that function $\mathbf{g}$ has to satisfy certain conditions for this to be true. Normality isn't preserved in the neighborhood around $x=0$ for $g(x) = x^2$ because you'll basically get both halves of the bell curve mapped to the same side: both $x=-2$ and $x=2$ get mapped to $y=4$. You need $g$ strictly increasing or decreasing in the neighborhood so that this doesn't happen.
Idea 1: Locally, any continuous, differentiable function looks affine
An idea of calculus is if you zoom in enough on a continuous, differentiable function, it will look like a line (or hyperplane in the multivariate case). If we have some vector valued function $\mathbf{g}(\mathbf{x})$, in a small enough neighborhood around $\mathbf{c}$ you can approximate $\mathbf{g}(\mathbf{c} + \boldsymbol{\epsilon}) $ with the below affine function of $\boldsymbol{\epsilon}$:
$$ \mathbf{g}(\mathbf{c} + \boldsymbol{\epsilon}) \approx \mathbf{g}(\mathbf{c}) + \frac{\partial \mathbf{g}(\mathbf{c})}{\partial \mathbf{x}'} \;\boldsymbol{\epsilon} $$
Idea 2: An affine transformation of a multivariate normal random variable is multivariate normal
Let's say we have $\tilde{\boldsymbol{\theta}}$ distributed multivariate normal with mean $\boldsymbol{\mu}$ and variance $V$. That is:
$$\tilde{\boldsymbol{\theta}} \sim \mathcal{N}\left( \boldsymbol{\mu}, V\right)$$
Consider a linear transformation $A$ and consider the multivariate normal random variable defined by the linear transformation $A\tilde{\boldsymbol{\theta}}$. It's easy to show:
$$A\tilde{\boldsymbol{\theta}} - A\boldsymbol{\mu} \sim \mathcal{N}\left(\mathbf{0}, AVA'\right)$$
Putting it together:
If we know that $\tilde{\boldsymbol{\theta}} \sim \mathcal{N}\left( \boldsymbol{\mu}, V\right)$ and that function $\mathbf{g}(\mathbf{x})$ can be approximated around $\boldsymbol{\mu}$ by $\mathbf{g}(\boldsymbol{\mu}) + \frac{\partial \mathbf{g}(\boldsymbol{\mu})}{\partial \mathbf{x}'} \;\boldsymbol{\epsilon}$ then putting ideas (1) and (2) together:
$$ \mathbf{g}\left( \tilde{\boldsymbol{\theta}} \right) - \mathbf{g}(\boldsymbol{\mu}) \sim \mathcal{N} \left( \mathbf{0}, \frac{\partial \mathbf{g}(\boldsymbol{\mu})}{\partial \mathbf{x}'} V \frac{\partial \mathbf{g}(\boldsymbol{\mu})}{\partial \mathbf{x}'} '\right) $$
What can go wrong?
We have a problem doing this if any component of $\frac{\partial \mathbf{g}(\mathbf{c})}{\partial \mathbf{x}'}$ is zero. (eg. $g(x) = x^2$ at $x=0$.) We need $g$ strictly increasing or decreasing in the region where $\tilde{\boldsymbol{\theta}}_n$ has probability mass.
This is also going to be a bad approximation if $g$ doesn't look like an affine function in the region where $\tilde{\boldsymbol{\theta}}_n$ has probability mass.
It may also be a bad approximation if $\tilde{\boldsymbol{\theta}}_n$ isn't normal.
This problem:
$$g(x) = x^2 \quad \quad g'(x) = 2 x $$
If $\sqrt{n}\left( \tilde{\theta} - \mu \right) \xrightarrow{d} \mathcal{N}(0, 1)$
Applying the delta method you get... | How to interpret the Delta Method?
Some intuition behind the delta method:
The Delta method can be seen as combining two ideas:
Continuous, differentiable functions can be approximated locally by an affine transformation.
An affine tr |
30,454 | Explain what is meant by a deterministic and stochastic trend in relation to the following time series process? [closed] | The deterministic trend is one that you can determine from the equation directly, for example for the time series process $y_t = ct + \varepsilon$ has a deterministic trend with an expected value of $E[y_t] = ct$ and a constant variance of $Var(y_t) = \sigma^2$ (with $\varepsilon - iid(0,\sigma^2)$. This will produce basically a straight line in time, with some tiny fluctuations at each point.
The stochastic trend is one that can change in each run due to the random component of the process, as is the case in $y_t = c + y_{t-1} + \varepsilon_t$; this produces the same expected value of $y_t$ but has a non-constant variance of $Var(y_t) = t\sigma^2$, since the random component generated by $\varepsilon _t$ becomes accumulated in time by summation of the $y_{t-1}$ terms. This can produce wildly different runs in each iteration, which is done in random walks. The 'average' run over many iterations will still follow the general trend but with a lot more noise, and the trend for any given iteration is stochastic in nature.
For further clarification I recommend watching these videos in order, they clear things up rather nicely (he does a better job explaining than I do).
https://www.youtube.com/watch?v=ouahL4HbwBE
https://www.youtube.com/watch?v=yCM6N8sRtPY | Explain what is meant by a deterministic and stochastic trend in relation to the following time seri | The deterministic trend is one that you can determine from the equation directly, for example for the time series process $y_t = ct + \varepsilon$ has a deterministic trend with an expected value of $ | Explain what is meant by a deterministic and stochastic trend in relation to the following time series process? [closed]
The deterministic trend is one that you can determine from the equation directly, for example for the time series process $y_t = ct + \varepsilon$ has a deterministic trend with an expected value of $E[y_t] = ct$ and a constant variance of $Var(y_t) = \sigma^2$ (with $\varepsilon - iid(0,\sigma^2)$. This will produce basically a straight line in time, with some tiny fluctuations at each point.
The stochastic trend is one that can change in each run due to the random component of the process, as is the case in $y_t = c + y_{t-1} + \varepsilon_t$; this produces the same expected value of $y_t$ but has a non-constant variance of $Var(y_t) = t\sigma^2$, since the random component generated by $\varepsilon _t$ becomes accumulated in time by summation of the $y_{t-1}$ terms. This can produce wildly different runs in each iteration, which is done in random walks. The 'average' run over many iterations will still follow the general trend but with a lot more noise, and the trend for any given iteration is stochastic in nature.
For further clarification I recommend watching these videos in order, they clear things up rather nicely (he does a better job explaining than I do).
https://www.youtube.com/watch?v=ouahL4HbwBE
https://www.youtube.com/watch?v=yCM6N8sRtPY | Explain what is meant by a deterministic and stochastic trend in relation to the following time seri
The deterministic trend is one that you can determine from the equation directly, for example for the time series process $y_t = ct + \varepsilon$ has a deterministic trend with an expected value of $ |
30,455 | What is "mixture" in a gaussian mixture model | A mixture distribution combines different component distributions with weights that typically sum to one (or can be renormalized). A gaussian-mixture is the special case where the components are Gaussians.
For instance, here is a mixture of 25% $N(-2,1)$ and 75% $N(2,1)$, which you could call "one part $N(-2,1)$ and three parts $N(2,1)$":
xx <- seq(-5,5,by=.01)
plot(xx,0.25*dnorm(xx,-2,1)+0.75*dnorm(xx,2,1),type="l",xlab="",ylab="")
Essentially, it's like a recipe. Play around a little with the weights, the means and the variances to see what happens, or look at the two tags on CV. | What is "mixture" in a gaussian mixture model | A mixture distribution combines different component distributions with weights that typically sum to one (or can be renormalized). A gaussian-mixture is the special case where the components are Gauss | What is "mixture" in a gaussian mixture model
A mixture distribution combines different component distributions with weights that typically sum to one (or can be renormalized). A gaussian-mixture is the special case where the components are Gaussians.
For instance, here is a mixture of 25% $N(-2,1)$ and 75% $N(2,1)$, which you could call "one part $N(-2,1)$ and three parts $N(2,1)$":
xx <- seq(-5,5,by=.01)
plot(xx,0.25*dnorm(xx,-2,1)+0.75*dnorm(xx,2,1),type="l",xlab="",ylab="")
Essentially, it's like a recipe. Play around a little with the weights, the means and the variances to see what happens, or look at the two tags on CV. | What is "mixture" in a gaussian mixture model
A mixture distribution combines different component distributions with weights that typically sum to one (or can be renormalized). A gaussian-mixture is the special case where the components are Gauss |
30,456 | What is "mixture" in a gaussian mixture model | Yes a Gaussian Mixture is called this way because it is assumed that the observed data come from a Gaussian mixture distribution which consists of $K$ Gaussians with their own means and variances. However, the $K$ classes are latent and so is the indicator telling you which class an observations belongs to.
The goal of mixture modeling is now to estimate the most likely class for each observation. Therefore, Gaussian mixture modeling can be viewed as a missing data problem. Estimation is usually done using the EM algorithm. | What is "mixture" in a gaussian mixture model | Yes a Gaussian Mixture is called this way because it is assumed that the observed data come from a Gaussian mixture distribution which consists of $K$ Gaussians with their own means and variances. How | What is "mixture" in a gaussian mixture model
Yes a Gaussian Mixture is called this way because it is assumed that the observed data come from a Gaussian mixture distribution which consists of $K$ Gaussians with their own means and variances. However, the $K$ classes are latent and so is the indicator telling you which class an observations belongs to.
The goal of mixture modeling is now to estimate the most likely class for each observation. Therefore, Gaussian mixture modeling can be viewed as a missing data problem. Estimation is usually done using the EM algorithm. | What is "mixture" in a gaussian mixture model
Yes a Gaussian Mixture is called this way because it is assumed that the observed data come from a Gaussian mixture distribution which consists of $K$ Gaussians with their own means and variances. How |
30,457 | What is "mixture" in a gaussian mixture model | Suppose a factory makes widgets, initially of one particular size. Its output might be described by a Gaussian distribution, where the mean represents the desired size of the item and the variance comes from well...variance in the manufacturing process (differences in operators' skill, impurities, etc).
During the next shift, the factory starts producing widgets of a different size. These products could also be described by a Gaussian with a new mean, the new size, and potentially a different variance (maybe smaller items are harder to make).
A Gaussian Mixture Model describes the combined output from all shifts, as if they were literally mixed together. It consists of a set of Gaussians, each with their own mean and variance, as well as weights denoting the contribution of each and a normalization constant that ensure the whole things sums to one. The "generative story" is that each item is produced by choosing a first choosing a Gaussian according to its weight, then drawing a sample from that particular Gaussian.
In practice, we often want to run this process in reverse. We assume that the samples were generated by a finite, fixed number of Gaussians, and via the E-M algorithm, recover the parameters of those Gaussians and the "mixing" weights. Armed with that, we can then find the most likely "generator" for each example. For example, we might know that the factory two sizes of items. Fitting a mixture model could tell us that the small size is 1L (with a variance of 0.1) vs the large's 3 ± 0.3L. Moreover, we could determine whether a particular item, measured at 2L is more likely to have come from the "small" or "large" batches. | What is "mixture" in a gaussian mixture model | Suppose a factory makes widgets, initially of one particular size. Its output might be described by a Gaussian distribution, where the mean represents the desired size of the item and the variance com | What is "mixture" in a gaussian mixture model
Suppose a factory makes widgets, initially of one particular size. Its output might be described by a Gaussian distribution, where the mean represents the desired size of the item and the variance comes from well...variance in the manufacturing process (differences in operators' skill, impurities, etc).
During the next shift, the factory starts producing widgets of a different size. These products could also be described by a Gaussian with a new mean, the new size, and potentially a different variance (maybe smaller items are harder to make).
A Gaussian Mixture Model describes the combined output from all shifts, as if they were literally mixed together. It consists of a set of Gaussians, each with their own mean and variance, as well as weights denoting the contribution of each and a normalization constant that ensure the whole things sums to one. The "generative story" is that each item is produced by choosing a first choosing a Gaussian according to its weight, then drawing a sample from that particular Gaussian.
In practice, we often want to run this process in reverse. We assume that the samples were generated by a finite, fixed number of Gaussians, and via the E-M algorithm, recover the parameters of those Gaussians and the "mixing" weights. Armed with that, we can then find the most likely "generator" for each example. For example, we might know that the factory two sizes of items. Fitting a mixture model could tell us that the small size is 1L (with a variance of 0.1) vs the large's 3 ± 0.3L. Moreover, we could determine whether a particular item, measured at 2L is more likely to have come from the "small" or "large" batches. | What is "mixture" in a gaussian mixture model
Suppose a factory makes widgets, initially of one particular size. Its output might be described by a Gaussian distribution, where the mean represents the desired size of the item and the variance com |
30,458 | Is it realistic for all variables to be highly significant in a multiple regression model? | A scatterplot matrix with loess curves and correlation values (absolute values) can be a good starting point:
We can notice here the possibly quadratic relationship of fuelEconomy plotted against both lineDisplacement and hp, which is also reflected in a Nike swoosh appearance in of the residual plot. It would be interesting to investigate the presence of an interaction between these term.
This lack of linearity is also apparent if we run a linear regression of fuelEconomy against linearDisplacement (similar results can be obtained with hp). Notice the red line...
This effect can be partially rectified making the model more complex, and introducing a quadratic model:
The new model has an adjusted R-squared value higher ($0.8205$) than the first ($0.7798$).
The dichotomous nature of fuelStd and wheeldriveStd simply move the mean of the predicted values down, and in effect are dummy-coded variables or factor. This is also apparent on the initial scatter plot, but can be further visualized with box plots:
One final point in the diagnostics is the presence of high leverage points, worth looking into:
What to conclude? Nothing categorical. Perhaps just to emphasize the importance of plotting in understanding the data set and any model imposed on it. | Is it realistic for all variables to be highly significant in a multiple regression model? | A scatterplot matrix with loess curves and correlation values (absolute values) can be a good starting point:
We can notice here the possibly quadratic relationship of fuelEconomy plotted against bot | Is it realistic for all variables to be highly significant in a multiple regression model?
A scatterplot matrix with loess curves and correlation values (absolute values) can be a good starting point:
We can notice here the possibly quadratic relationship of fuelEconomy plotted against both lineDisplacement and hp, which is also reflected in a Nike swoosh appearance in of the residual plot. It would be interesting to investigate the presence of an interaction between these term.
This lack of linearity is also apparent if we run a linear regression of fuelEconomy against linearDisplacement (similar results can be obtained with hp). Notice the red line...
This effect can be partially rectified making the model more complex, and introducing a quadratic model:
The new model has an adjusted R-squared value higher ($0.8205$) than the first ($0.7798$).
The dichotomous nature of fuelStd and wheeldriveStd simply move the mean of the predicted values down, and in effect are dummy-coded variables or factor. This is also apparent on the initial scatter plot, but can be further visualized with box plots:
One final point in the diagnostics is the presence of high leverage points, worth looking into:
What to conclude? Nothing categorical. Perhaps just to emphasize the importance of plotting in understanding the data set and any model imposed on it. | Is it realistic for all variables to be highly significant in a multiple regression model?
A scatterplot matrix with loess curves and correlation values (absolute values) can be a good starting point:
We can notice here the possibly quadratic relationship of fuelEconomy plotted against bot |
30,459 | Is it realistic for all variables to be highly significant in a multiple regression model? | @AntoniParelleada has done a good job demonstrating some of the standard model diagnostic techniques that you can use to evaluate your model. I gather your primary concern is that "most of the variables are highly statistically significant".
I don't see that you need to be concerned about that, per se. From your output I see that the model has an F-statistic: 1566 on 6 and 2648 DF. That means that you are fitting $6$ parameters for $6$ variables and have $2655$ data. This gives you an enormous amount of statistical power. Under the assumption that there is any relationship between your variables and the response, that isn't completely trivial, you should get a significant result. I'm more surprised that anything (namely transSpeed) is not significant.
Perhaps your question is motivated by the belief that, from theoretical perspective, some variable should be unrelated to fuelEconomy and you are thus surprised that it is significant. (If that were true, however, it would have been unusual to have included it in the model.) But a significant result doesn't necessarily mean that a covariate has an effect on the response, so this needn't be a type I error. Because your data are almost certainly observational, you are only detecting marginal associations. That is, cars that have front wheel drive, for example, may also typically differ from rear wheel drive cars in ways other than which wheels transmit power and other than the other variables included in the model. Thus, the coefficient for wheelDriveStd would measure the association between it and all the unincluded variables correlated with it and fuelEconomy. So it can be reasonable for it to be significant even if we knew from the physics / engineering that which wheels transmit power is unrelated to fuel efficiency. | Is it realistic for all variables to be highly significant in a multiple regression model? | @AntoniParelleada has done a good job demonstrating some of the standard model diagnostic techniques that you can use to evaluate your model. I gather your primary concern is that "most of the variab | Is it realistic for all variables to be highly significant in a multiple regression model?
@AntoniParelleada has done a good job demonstrating some of the standard model diagnostic techniques that you can use to evaluate your model. I gather your primary concern is that "most of the variables are highly statistically significant".
I don't see that you need to be concerned about that, per se. From your output I see that the model has an F-statistic: 1566 on 6 and 2648 DF. That means that you are fitting $6$ parameters for $6$ variables and have $2655$ data. This gives you an enormous amount of statistical power. Under the assumption that there is any relationship between your variables and the response, that isn't completely trivial, you should get a significant result. I'm more surprised that anything (namely transSpeed) is not significant.
Perhaps your question is motivated by the belief that, from theoretical perspective, some variable should be unrelated to fuelEconomy and you are thus surprised that it is significant. (If that were true, however, it would have been unusual to have included it in the model.) But a significant result doesn't necessarily mean that a covariate has an effect on the response, so this needn't be a type I error. Because your data are almost certainly observational, you are only detecting marginal associations. That is, cars that have front wheel drive, for example, may also typically differ from rear wheel drive cars in ways other than which wheels transmit power and other than the other variables included in the model. Thus, the coefficient for wheelDriveStd would measure the association between it and all the unincluded variables correlated with it and fuelEconomy. So it can be reasonable for it to be significant even if we knew from the physics / engineering that which wheels transmit power is unrelated to fuel efficiency. | Is it realistic for all variables to be highly significant in a multiple regression model?
@AntoniParelleada has done a good job demonstrating some of the standard model diagnostic techniques that you can use to evaluate your model. I gather your primary concern is that "most of the variab |
30,460 | Is it realistic for all variables to be highly significant in a multiple regression model? | I know very little about the mechanics and physics involved, but the first thing I would look at is the regression diagnostics, in particular, the plots of residuals vs fitted values, for which we would like there to be no overall pattern.
You have fitted a linear model so that each covariate has a linear association with fuelEconomy . Is this supported by the underlying mechanical and physical theory ? Could there be any nonlinear association(s) ? If so then you could consider models with nonlinear terms, transforming certain variables, or you could consider using an additive model. Even if the associations are plausibly linear within your actual dataset, be very wary of extrapolating the results beyond your data limits. | Is it realistic for all variables to be highly significant in a multiple regression model? | I know very little about the mechanics and physics involved, but the first thing I would look at is the regression diagnostics, in particular, the plots of residuals vs fitted values, for which we wou | Is it realistic for all variables to be highly significant in a multiple regression model?
I know very little about the mechanics and physics involved, but the first thing I would look at is the regression diagnostics, in particular, the plots of residuals vs fitted values, for which we would like there to be no overall pattern.
You have fitted a linear model so that each covariate has a linear association with fuelEconomy . Is this supported by the underlying mechanical and physical theory ? Could there be any nonlinear association(s) ? If so then you could consider models with nonlinear terms, transforming certain variables, or you could consider using an additive model. Even if the associations are plausibly linear within your actual dataset, be very wary of extrapolating the results beyond your data limits. | Is it realistic for all variables to be highly significant in a multiple regression model?
I know very little about the mechanics and physics involved, but the first thing I would look at is the regression diagnostics, in particular, the plots of residuals vs fitted values, for which we wou |
30,461 | Is it realistic for all variables to be highly significant in a multiple regression model? | The answer to your first question depends on your theoretical framework, how you state the hypotheses about the relationship between dependent and independent variables, and how you interpret the results. On its own, obtaining statistically significant relationship for most of the variables might not say anything about how realistic your results are.
So, if these results look suspicious to you (based on your prior knowledge), you can run some diagnostics tests for regression. There might be a violation of model assumptions and other problems (for instance, outliers). In fact, it is always helpful to run these tests to evaluate your regression model. Since you are using R, you can check car package which provides a number functions for diagnostics tests. Here you can find the course slides on regression diagnostics by one of the authors (and the creator) of car package, John Fox. You can check his book on the topic (1991) as well. Kabacoff (2011) also discussed regression diagnostics and how to use R functions (including those from car package) and interpret results (p.188-200). I think after these diagnostics tests, it is better to evaluate the results and how usable they are.
Fox, J. (1991). Regression Diagnostics. Newbury Park, London, New Delhi: Sage Publications.
Kabacoff, R. I. (2011). R in Action: Data analysis and graphics with R. Shelter Island: Manning.
Also:
Fox, J., & Weisberg, S. (2011). Diagnosing Problems in Linear and Generalized Linear Models. In An R Companion to Applied Regression (2nd ed., pp. 285–328). Los Angeles: Sage Publications. | Is it realistic for all variables to be highly significant in a multiple regression model? | The answer to your first question depends on your theoretical framework, how you state the hypotheses about the relationship between dependent and independent variables, and how you interpret the resu | Is it realistic for all variables to be highly significant in a multiple regression model?
The answer to your first question depends on your theoretical framework, how you state the hypotheses about the relationship between dependent and independent variables, and how you interpret the results. On its own, obtaining statistically significant relationship for most of the variables might not say anything about how realistic your results are.
So, if these results look suspicious to you (based on your prior knowledge), you can run some diagnostics tests for regression. There might be a violation of model assumptions and other problems (for instance, outliers). In fact, it is always helpful to run these tests to evaluate your regression model. Since you are using R, you can check car package which provides a number functions for diagnostics tests. Here you can find the course slides on regression diagnostics by one of the authors (and the creator) of car package, John Fox. You can check his book on the topic (1991) as well. Kabacoff (2011) also discussed regression diagnostics and how to use R functions (including those from car package) and interpret results (p.188-200). I think after these diagnostics tests, it is better to evaluate the results and how usable they are.
Fox, J. (1991). Regression Diagnostics. Newbury Park, London, New Delhi: Sage Publications.
Kabacoff, R. I. (2011). R in Action: Data analysis and graphics with R. Shelter Island: Manning.
Also:
Fox, J., & Weisberg, S. (2011). Diagnosing Problems in Linear and Generalized Linear Models. In An R Companion to Applied Regression (2nd ed., pp. 285–328). Los Angeles: Sage Publications. | Is it realistic for all variables to be highly significant in a multiple regression model?
The answer to your first question depends on your theoretical framework, how you state the hypotheses about the relationship between dependent and independent variables, and how you interpret the resu |
30,462 | Using HAC standard errors although there might be no autocorrelation | Loosely, when estimating standard errors:
If you assume something is true and it isn't true, you generally lose consistency. (This is bad. As the number of observations rises, your estimate need not converge in probability to the true value.) Eg. when you assume observations are independent and they aren't, you can massively understate standard errors.
If you don't assume something is true and it is true, you generally lose some efficiency (i.e. your estimator is more noisy than necessary.) This often isn't a huge deal. Defending your work in seminar tends to be easier if you've been on the conservative side in your assumptions.
If you have enough data, you should be entirely safe since the estimator is consistent!
As Woolridge points out though in his book Introductory Econometrics (p.247 6th edition) a big drawback can come from small sample issues, that you may be effectively dropping one assumption (i.e. no serial correlation of errors) but adding another assumption that you have enough data for the Central Limit Theorem to kick in! HAC etc... rely on asymptotic arguments.
If you have too little data to rely on asymptotic results:
The "t-stats" you compute may not follow the t-distribution for small samples. Consequently, the p-values may be quite wrong.
But if the errors truly are normal, homoskedastic, IID errors then the t-stats you compute, under the classic small sample assumptions, will follow the t-distribution precisely.
See this answer here to a related question: https://stats.stackexchange.com/a/5626/97925 | Using HAC standard errors although there might be no autocorrelation | Loosely, when estimating standard errors:
If you assume something is true and it isn't true, you generally lose consistency. (This is bad. As the number of observations rises, your estimate need not | Using HAC standard errors although there might be no autocorrelation
Loosely, when estimating standard errors:
If you assume something is true and it isn't true, you generally lose consistency. (This is bad. As the number of observations rises, your estimate need not converge in probability to the true value.) Eg. when you assume observations are independent and they aren't, you can massively understate standard errors.
If you don't assume something is true and it is true, you generally lose some efficiency (i.e. your estimator is more noisy than necessary.) This often isn't a huge deal. Defending your work in seminar tends to be easier if you've been on the conservative side in your assumptions.
If you have enough data, you should be entirely safe since the estimator is consistent!
As Woolridge points out though in his book Introductory Econometrics (p.247 6th edition) a big drawback can come from small sample issues, that you may be effectively dropping one assumption (i.e. no serial correlation of errors) but adding another assumption that you have enough data for the Central Limit Theorem to kick in! HAC etc... rely on asymptotic arguments.
If you have too little data to rely on asymptotic results:
The "t-stats" you compute may not follow the t-distribution for small samples. Consequently, the p-values may be quite wrong.
But if the errors truly are normal, homoskedastic, IID errors then the t-stats you compute, under the classic small sample assumptions, will follow the t-distribution precisely.
See this answer here to a related question: https://stats.stackexchange.com/a/5626/97925 | Using HAC standard errors although there might be no autocorrelation
Loosely, when estimating standard errors:
If you assume something is true and it isn't true, you generally lose consistency. (This is bad. As the number of observations rises, your estimate need not |
30,463 | Using HAC standard errors although there might be no autocorrelation | Indeed, there should be some loss in efficiency in finite samples but asymptotically, you are on the safe side. To see this, consider the simple case of estimating a sample mean (which is a special case of a regression in which you only regress on a constant):
HAC estimators estimate the standard error of the sample mean. Suppose $Y_t$ is covariance stationary with $E(Y_t)=\mu$ and $Cov(Y_t,Y_{t-j})=\gamma_j$ such that $\sum_{j=0}^\infty|\gamma_j|<\infty$.
Then, what HAC standard errors estimate is the square root of the "long run variance", given by:
$$\lim_{T\to\infty}\{Var[\sqrt{T}(\bar{Y}_T- \mu)]\}=\lim_{T\to\infty}\{TE(\bar{Y}_T- \mu)^2\}=\gamma_0+2\sum_{j=1}^\infty\gamma_j.$$
Now, if the series actually has no serial correlation, then $\gamma_j=0$ for $j>0$, which the HAC estimator will also "discover" as $T\to\infty$, so that it will boil down to an estimator of the square root of the standard variance $\gamma_0$. | Using HAC standard errors although there might be no autocorrelation | Indeed, there should be some loss in efficiency in finite samples but asymptotically, you are on the safe side. To see this, consider the simple case of estimating a sample mean (which is a special ca | Using HAC standard errors although there might be no autocorrelation
Indeed, there should be some loss in efficiency in finite samples but asymptotically, you are on the safe side. To see this, consider the simple case of estimating a sample mean (which is a special case of a regression in which you only regress on a constant):
HAC estimators estimate the standard error of the sample mean. Suppose $Y_t$ is covariance stationary with $E(Y_t)=\mu$ and $Cov(Y_t,Y_{t-j})=\gamma_j$ such that $\sum_{j=0}^\infty|\gamma_j|<\infty$.
Then, what HAC standard errors estimate is the square root of the "long run variance", given by:
$$\lim_{T\to\infty}\{Var[\sqrt{T}(\bar{Y}_T- \mu)]\}=\lim_{T\to\infty}\{TE(\bar{Y}_T- \mu)^2\}=\gamma_0+2\sum_{j=1}^\infty\gamma_j.$$
Now, if the series actually has no serial correlation, then $\gamma_j=0$ for $j>0$, which the HAC estimator will also "discover" as $T\to\infty$, so that it will boil down to an estimator of the square root of the standard variance $\gamma_0$. | Using HAC standard errors although there might be no autocorrelation
Indeed, there should be some loss in efficiency in finite samples but asymptotically, you are on the safe side. To see this, consider the simple case of estimating a sample mean (which is a special ca |
30,464 | Relationship between eigenvectors of $\frac{1}{N}XX^\top$ and $\frac{1}{N}X^\top X$ in the context of PCA | This refers to the short section 12.1.4 PCA for high-dimensional data in Bishop's book. I can see that this section can be a bit confusing, because Bishop is going back and forth between $\newcommand{\X}{\mathbf X}\newcommand{\v}{\mathbf v}\newcommand{\u}{\mathbf u}\v_i$ and $\u_i$ using a slightly inconsistent notation.
The section is about the relationship between the eigenvectors of covariance matrix $\frac{1}{N}\X^\top \X$ and the eigenvectors of the Gram matrix $\frac{1}{N}\X \X^\top$ (in the context of PCA). Let $\v_i$ be a unit-length eigenvector of $\frac{1}{N}\X \X^\top$:
$$\frac{1}{N}\X \X^\top \v_i = \lambda_i \v_i.$$
If we multiply this equation by $\X^\top$ from the left:
$$\frac{1}{N}\X^\top \X (\X^\top \v_i) = \lambda_i (\X^\top \v_i),$$
we see that $\X^\top \v_i$ is an eigenvector of $\frac{1}{N}\X^\top \X$.
However, it will not have unit length! Indeed, let us compute its length: $$\|\X^\top \v_i\|^2=(\X^\top \v_i)^\top \X^\top \v_i = \v_i^\top \X\X^\top \v_i=\v_i(N\lambda v_i)=N\lambda\|\v_i\|^2=N\lambda_i.$$
So the squared length of $\X^\top \v_i$ is equal to $N\lambda_i$. Therefore, if we want to transform $\v_i$ into a unit-length covariance matrix eigenvector $\u_i$, we need to normalize it have unit length: $$\u_i = \frac{1}{(N\lambda_i)^{1/2}}\X^\top \v_i.$$
(Please note that the above was not using $\v_i=\X\u_i$ definition that you quoted. Instead, we started directly with a unit-length $\v_i$. I believe this might have been the source of your confusion. Bishop uses $\v_i=\X\u_i$ definition earlier in the section, but it is not relevant anymore for this particular argument.) | Relationship between eigenvectors of $\frac{1}{N}XX^\top$ and $\frac{1}{N}X^\top X$ in the context o | This refers to the short section 12.1.4 PCA for high-dimensional data in Bishop's book. I can see that this section can be a bit confusing, because Bishop is going back and forth between $\newcommand{ | Relationship between eigenvectors of $\frac{1}{N}XX^\top$ and $\frac{1}{N}X^\top X$ in the context of PCA
This refers to the short section 12.1.4 PCA for high-dimensional data in Bishop's book. I can see that this section can be a bit confusing, because Bishop is going back and forth between $\newcommand{\X}{\mathbf X}\newcommand{\v}{\mathbf v}\newcommand{\u}{\mathbf u}\v_i$ and $\u_i$ using a slightly inconsistent notation.
The section is about the relationship between the eigenvectors of covariance matrix $\frac{1}{N}\X^\top \X$ and the eigenvectors of the Gram matrix $\frac{1}{N}\X \X^\top$ (in the context of PCA). Let $\v_i$ be a unit-length eigenvector of $\frac{1}{N}\X \X^\top$:
$$\frac{1}{N}\X \X^\top \v_i = \lambda_i \v_i.$$
If we multiply this equation by $\X^\top$ from the left:
$$\frac{1}{N}\X^\top \X (\X^\top \v_i) = \lambda_i (\X^\top \v_i),$$
we see that $\X^\top \v_i$ is an eigenvector of $\frac{1}{N}\X^\top \X$.
However, it will not have unit length! Indeed, let us compute its length: $$\|\X^\top \v_i\|^2=(\X^\top \v_i)^\top \X^\top \v_i = \v_i^\top \X\X^\top \v_i=\v_i(N\lambda v_i)=N\lambda\|\v_i\|^2=N\lambda_i.$$
So the squared length of $\X^\top \v_i$ is equal to $N\lambda_i$. Therefore, if we want to transform $\v_i$ into a unit-length covariance matrix eigenvector $\u_i$, we need to normalize it have unit length: $$\u_i = \frac{1}{(N\lambda_i)^{1/2}}\X^\top \v_i.$$
(Please note that the above was not using $\v_i=\X\u_i$ definition that you quoted. Instead, we started directly with a unit-length $\v_i$. I believe this might have been the source of your confusion. Bishop uses $\v_i=\X\u_i$ definition earlier in the section, but it is not relevant anymore for this particular argument.) | Relationship between eigenvectors of $\frac{1}{N}XX^\top$ and $\frac{1}{N}X^\top X$ in the context o
This refers to the short section 12.1.4 PCA for high-dimensional data in Bishop's book. I can see that this section can be a bit confusing, because Bishop is going back and forth between $\newcommand{ |
30,465 | two samples z test in Python [closed] | Statsmodels has a ztest function that allows you to compare two means, assuming they are independent and have the same standard deviation. See the documentation here
If you need to compare means from distributions with different standard deviation, you should use CompareMeans.ztest_ind. See documentation here.
There might be other functions I'm missing so search through the documentation! | two samples z test in Python [closed] | Statsmodels has a ztest function that allows you to compare two means, assuming they are independent and have the same standard deviation. See the documentation here
If you need to compare means from | two samples z test in Python [closed]
Statsmodels has a ztest function that allows you to compare two means, assuming they are independent and have the same standard deviation. See the documentation here
If you need to compare means from distributions with different standard deviation, you should use CompareMeans.ztest_ind. See documentation here.
There might be other functions I'm missing so search through the documentation! | two samples z test in Python [closed]
Statsmodels has a ztest function that allows you to compare two means, assuming they are independent and have the same standard deviation. See the documentation here
If you need to compare means from |
30,466 | two samples z test in Python [closed] | No, but this wouldn't be that hard to write a function for:
def twoSampZ(X1, X2, mudiff, sd1, sd2, n1, n2):
from numpy import sqrt, abs, round
from scipy.stats import norm
pooledSE = sqrt(sd1**2/n1 + sd2**2/n2)
z = ((X1 - X2) - mudiff)/pooledSE
pval = 2*(norm.sf(abs(z)))
return round(z, 3), round(pval, 4)
where X1 = $\bar{X1}$, X2 = $\bar{X2}$, mudiff = null = $\mu_1 - \mu_2$, sd1 = $\sigma_1$, sd2 = $\sigma_2$, n1 = $n_1$ and n2 = $n_2$. So, going off of this example:
z, p = twoSampZ(28, 33, 0, 14.1, 9.5, 75, 50)
print z, p | two samples z test in Python [closed] | No, but this wouldn't be that hard to write a function for:
def twoSampZ(X1, X2, mudiff, sd1, sd2, n1, n2):
from numpy import sqrt, abs, round
from scipy.stats import norm
pooledSE = sqrt( | two samples z test in Python [closed]
No, but this wouldn't be that hard to write a function for:
def twoSampZ(X1, X2, mudiff, sd1, sd2, n1, n2):
from numpy import sqrt, abs, round
from scipy.stats import norm
pooledSE = sqrt(sd1**2/n1 + sd2**2/n2)
z = ((X1 - X2) - mudiff)/pooledSE
pval = 2*(norm.sf(abs(z)))
return round(z, 3), round(pval, 4)
where X1 = $\bar{X1}$, X2 = $\bar{X2}$, mudiff = null = $\mu_1 - \mu_2$, sd1 = $\sigma_1$, sd2 = $\sigma_2$, n1 = $n_1$ and n2 = $n_2$. So, going off of this example:
z, p = twoSampZ(28, 33, 0, 14.1, 9.5, 75, 50)
print z, p | two samples z test in Python [closed]
No, but this wouldn't be that hard to write a function for:
def twoSampZ(X1, X2, mudiff, sd1, sd2, n1, n2):
from numpy import sqrt, abs, round
from scipy.stats import norm
pooledSE = sqrt( |
30,467 | What is meant by the term 'exponential family'? Why it is named so? | They're called "exponential family" because they can all be written in the simple form
$$f_X(x|\theta) = \exp \left (\eta(\theta) \cdot T(x) - A(\theta) + B(x) \right )$$
There are some other, equivalent forms that are perhaps more often used, but I think that form makes the "exponential" part clearest.
See, for example, this section of the Wikipedia page on the Exponential family.
In particular, in the mid 1930s a number of authors discussed what conditions would be required for a distribution to have a sufficient statistic; Koopman$^{[1]}$ stated it would have to be "of the very special exponential type of formula (4) below" (emphasis mine), where equation (4) was equivalent to the above form.
So that form succinctly expresses what they all have in common. But the consequence of that form is that this particular class of distributions has some very nice properties; for example, $T$ is a sufficient statistic - it carries all of the information in the data about $\theta$.
A number of additional properties they all share are summarized here.
Commonly used members include the Gaussian, Poisson, binomial, and gamma (including exponential and chi-squared), but I've also had occasion to use other members (such as Tweedie with specified $p$, and inverse Gaussian).
The shared properties make some standardization of the treatment of them possible, leading to the wide use of generalized linear models (GLMs).
[1] Koopman, B.O., (1936),
"On Distributions Admitting a Sufficient Statistic",
Transactions of the American Mathematical Society, 39:3, 399-409. | What is meant by the term 'exponential family'? Why it is named so? | They're called "exponential family" because they can all be written in the simple form
$$f_X(x|\theta) = \exp \left (\eta(\theta) \cdot T(x) - A(\theta) + B(x) \right )$$
There are some other, equival | What is meant by the term 'exponential family'? Why it is named so?
They're called "exponential family" because they can all be written in the simple form
$$f_X(x|\theta) = \exp \left (\eta(\theta) \cdot T(x) - A(\theta) + B(x) \right )$$
There are some other, equivalent forms that are perhaps more often used, but I think that form makes the "exponential" part clearest.
See, for example, this section of the Wikipedia page on the Exponential family.
In particular, in the mid 1930s a number of authors discussed what conditions would be required for a distribution to have a sufficient statistic; Koopman$^{[1]}$ stated it would have to be "of the very special exponential type of formula (4) below" (emphasis mine), where equation (4) was equivalent to the above form.
So that form succinctly expresses what they all have in common. But the consequence of that form is that this particular class of distributions has some very nice properties; for example, $T$ is a sufficient statistic - it carries all of the information in the data about $\theta$.
A number of additional properties they all share are summarized here.
Commonly used members include the Gaussian, Poisson, binomial, and gamma (including exponential and chi-squared), but I've also had occasion to use other members (such as Tweedie with specified $p$, and inverse Gaussian).
The shared properties make some standardization of the treatment of them possible, leading to the wide use of generalized linear models (GLMs).
[1] Koopman, B.O., (1936),
"On Distributions Admitting a Sufficient Statistic",
Transactions of the American Mathematical Society, 39:3, 399-409. | What is meant by the term 'exponential family'? Why it is named so?
They're called "exponential family" because they can all be written in the simple form
$$f_X(x|\theta) = \exp \left (\eta(\theta) \cdot T(x) - A(\theta) + B(x) \right )$$
There are some other, equival |
30,468 | What to do when CFA fit for multi-item scale is bad? | 1. Go back to Exploratory Factor Analysis
If you're getting very bad CFA fits, then it's often a sign that you have jumped too quickly to CFA. You should go back to exploratory factor analysis to learn about the structure of your test. If you have a large sample (in your case you don't), then you can split your sample to have an exploratory and a confirmatory sample.
Apply exploratory factor analysis procedures to check whether the theorised number of factors seems reasonable. I'd check the scree plot to see what it suggests. I'd then check the rotated factor loading matrix with the theorised number of factors as well as with one or two more and one or two less factors. You can often see signs of under or over extraction of factors by looking at such factor loading matrices.
Use exploratory factor analysis to identify problematic items. In particular, items loading most on a non-theorised factor, items with large cross-loadings, items that don't load highly on any factor.
The benefits of EFA is that it gives a lot of freedom, so you'll learn a lot more about the structure of the test than you will from only looking at CFA modification indices.
Anyway, hopefully from this process you may have identified a few issues and solutions. For example, you might drop a few items; you might update your theoretical model of how many factors there are and so on.
2. Improve the Confirmatory Factor Analysis Fit
There are many points that could be made here:
CFA on scales with many items per scale often perform poorly by traditional standards. This often leads people (and note I think this response is often unfortunate) to form item parcels or only use three or four items per scale. The problem is that typically proposed CFA structures fail to capture the small nuances in the data (e.g., small cross loadings, items within a test that correlate a little more than others, minor nuisance factors). These are amplified with many items per scale.
Here are a few responses to the above situation:
Do exploratory SEM that allows for various small cross-loadings and related terms
Examine modification indices and incorporate some of the largest reasonable modifications; e.g., a few within scale correlated residuals; a few cross-loadings. see modificationindices(fit) in lavaan.
Use item parcelling to reduce the number of observed variables
General comments
So in general, if you're CFA model is really bad, return to EFA to learn more about your scale. Alternatively if your EFA is good, and your CFA just looks a little bad due to well known problems of having many items per scale, then standard CFA approaches as mentioned above are appropriate. | What to do when CFA fit for multi-item scale is bad? | 1. Go back to Exploratory Factor Analysis
If you're getting very bad CFA fits, then it's often a sign that you have jumped too quickly to CFA. You should go back to exploratory factor analysis to lear | What to do when CFA fit for multi-item scale is bad?
1. Go back to Exploratory Factor Analysis
If you're getting very bad CFA fits, then it's often a sign that you have jumped too quickly to CFA. You should go back to exploratory factor analysis to learn about the structure of your test. If you have a large sample (in your case you don't), then you can split your sample to have an exploratory and a confirmatory sample.
Apply exploratory factor analysis procedures to check whether the theorised number of factors seems reasonable. I'd check the scree plot to see what it suggests. I'd then check the rotated factor loading matrix with the theorised number of factors as well as with one or two more and one or two less factors. You can often see signs of under or over extraction of factors by looking at such factor loading matrices.
Use exploratory factor analysis to identify problematic items. In particular, items loading most on a non-theorised factor, items with large cross-loadings, items that don't load highly on any factor.
The benefits of EFA is that it gives a lot of freedom, so you'll learn a lot more about the structure of the test than you will from only looking at CFA modification indices.
Anyway, hopefully from this process you may have identified a few issues and solutions. For example, you might drop a few items; you might update your theoretical model of how many factors there are and so on.
2. Improve the Confirmatory Factor Analysis Fit
There are many points that could be made here:
CFA on scales with many items per scale often perform poorly by traditional standards. This often leads people (and note I think this response is often unfortunate) to form item parcels or only use three or four items per scale. The problem is that typically proposed CFA structures fail to capture the small nuances in the data (e.g., small cross loadings, items within a test that correlate a little more than others, minor nuisance factors). These are amplified with many items per scale.
Here are a few responses to the above situation:
Do exploratory SEM that allows for various small cross-loadings and related terms
Examine modification indices and incorporate some of the largest reasonable modifications; e.g., a few within scale correlated residuals; a few cross-loadings. see modificationindices(fit) in lavaan.
Use item parcelling to reduce the number of observed variables
General comments
So in general, if you're CFA model is really bad, return to EFA to learn more about your scale. Alternatively if your EFA is good, and your CFA just looks a little bad due to well known problems of having many items per scale, then standard CFA approaches as mentioned above are appropriate. | What to do when CFA fit for multi-item scale is bad?
1. Go back to Exploratory Factor Analysis
If you're getting very bad CFA fits, then it's often a sign that you have jumped too quickly to CFA. You should go back to exploratory factor analysis to lear |
30,469 | What to do when CFA fit for multi-item scale is bad? | I would work on trying to get the bifactor model to converge. Try adjusting the starting values...this may be a fishy approach though, so bear that in mind and interpret with caution. Read up on the dangers of interpreting models that resist convergence if you want to be truly cautious – I admit I haven't done this much yet myself in my study of SEM, so I suggest doing what you need to do to get the model to converge mostly for your benefit. I don't know that it will be any more suitable for publication, but if it clearly isn't because the bifactor model doesn't fit well either, that might be good for you to know.
Otherwise, it seems like you've done about as much as you can with the data you have. AFAIK (I've been looking deeply into this lately for a methodological project of my own, so please correct me if I'm wrong!!), WLSMV estimation in lavaan uses thresholds from polychoric correlations, which is the best way to get good fit indices out of a CFA of ordinal data. Assuming you've specified your model correctly (or at least optimally), that's about all you can do. Removing items with low loadings and freely estimating inter-item covariances is even going a bit far, but you tried that too.
Your model does not fit well by conventional standards, as you're probably aware. Of course you should not say it fits well when it doesn't. This applies to all sets of fit statistics you report here, unfortunately (I assume you were hoping it would fit). Some of your fit statistics are only fairly poor, not outright bad (the RMSEA = .05 is acceptable), but overall, none of it is good news, and you have a responsibility to be honest about that if you're going to publish these results. I hope you can, FWIW.
Either way, you might consider collecting more data if you can; that could help, depending on what you're after. If your objective is a confirmatory hypothesis test, well, you've "peeked" at your data, and will inflate your error rate if you reuse it in an expanded sample, so unless you can just set this dataset aside and replicate a whole, fresh, larger one, you've got a tough scenario to handle. If you're mostly interested in estimating parameters and narrowing confidence intervals though, I think it might be reasonable to just pool as much data as you can gather, including any you've already used here. If you can get more data, you may get better fit indices, which would make your parameter estimates more reliable. Hopefully that's good enough. | What to do when CFA fit for multi-item scale is bad? | I would work on trying to get the bifactor model to converge. Try adjusting the starting values...this may be a fishy approach though, so bear that in mind and interpret with caution. Read up on the d | What to do when CFA fit for multi-item scale is bad?
I would work on trying to get the bifactor model to converge. Try adjusting the starting values...this may be a fishy approach though, so bear that in mind and interpret with caution. Read up on the dangers of interpreting models that resist convergence if you want to be truly cautious – I admit I haven't done this much yet myself in my study of SEM, so I suggest doing what you need to do to get the model to converge mostly for your benefit. I don't know that it will be any more suitable for publication, but if it clearly isn't because the bifactor model doesn't fit well either, that might be good for you to know.
Otherwise, it seems like you've done about as much as you can with the data you have. AFAIK (I've been looking deeply into this lately for a methodological project of my own, so please correct me if I'm wrong!!), WLSMV estimation in lavaan uses thresholds from polychoric correlations, which is the best way to get good fit indices out of a CFA of ordinal data. Assuming you've specified your model correctly (or at least optimally), that's about all you can do. Removing items with low loadings and freely estimating inter-item covariances is even going a bit far, but you tried that too.
Your model does not fit well by conventional standards, as you're probably aware. Of course you should not say it fits well when it doesn't. This applies to all sets of fit statistics you report here, unfortunately (I assume you were hoping it would fit). Some of your fit statistics are only fairly poor, not outright bad (the RMSEA = .05 is acceptable), but overall, none of it is good news, and you have a responsibility to be honest about that if you're going to publish these results. I hope you can, FWIW.
Either way, you might consider collecting more data if you can; that could help, depending on what you're after. If your objective is a confirmatory hypothesis test, well, you've "peeked" at your data, and will inflate your error rate if you reuse it in an expanded sample, so unless you can just set this dataset aside and replicate a whole, fresh, larger one, you've got a tough scenario to handle. If you're mostly interested in estimating parameters and narrowing confidence intervals though, I think it might be reasonable to just pool as much data as you can gather, including any you've already used here. If you can get more data, you may get better fit indices, which would make your parameter estimates more reliable. Hopefully that's good enough. | What to do when CFA fit for multi-item scale is bad?
I would work on trying to get the bifactor model to converge. Try adjusting the starting values...this may be a fishy approach though, so bear that in mind and interpret with caution. Read up on the d |
30,470 | Help creating a chart to show categorical data over time | Three variables need to be visualized: time, zone, and side. We should capitalize on the two Cartesian coordinates of the plot to map two of these. Then some graphical quality--symbol, color, lightness, or orientation--will be needed to symbolize the third.
To help the eye follow the temporal sequence it can help to connect the symbols with faint line segments. We can obtain a little more information by erasing any segments that seem to correspond to breaks in the series.
The first solution uses symbol type and color to distinguish the sides, vertical position to identify zones, and horizontal position for time. It is designed to display the progress of zone and side over time to help visualize the transitions. To clarify overlaps, the symbol for side 2 is positioned above its nominal location and the symbol for side 1 is positioned below its nominal location.
This figure makes it immediately apparent that Guard 2 prefers the blue side (side 1) over the red (side 2) and that she moves around the zones more and in a more regular fashion.
The use of identically scaled and oriented time axes in these parallel plots enables visual comparison of the guard's patrol patterns during any time interval. With many guards, this construction lends itself well to a "small multiple" display showing all data simultaneously.
The second solution uses symbol color to distinguish times, vertical position to identify sides, and horizontal position for zone. It is a map-like display (which would generalize to a more complex spatial layout). This could be used to study the frequencies with which each space are entered by each guard and, in a more limited way, to visualize the movements among the spaces.
The different frequencies with which the zones and sides were visited are clearly displayed in this figure. The failure of Guard 2 to visit side 2 of zone 10 is immediately apparent, whereas it was not evident in the first figure.
These figures were produced in R. The input data structure is a list of parallel vectors for the times, zones, and sides: one per guard. The following code begins by generating some sample data randomly. Two functions to make the plot for a given guard are provided, corresponding to the figures.
#
# Side transition matrices
#
transition.side <- function(left=1/2, right=1/2) {
rbind(c(left, 1-left), c(1-right, right))
}
#
# Zone transition matrices
#
transition.zone <- function(n, up=1/2, stay=0, down=(1-up-stay)) {
x <- rep(c(down, stay, up, rep(0, n-2)), n)
q <- matrix(x[-c(1, 2:n+n^2)], n)
q <- q / apply(q, 1, sum)
return (q)
}
n.zones <- 10
guards <- list(list(side=transition.side(1/2,1/2),
zone=transition.zone(n.zones,1/2,0)),
list(side=transition.side(3/4,1/4),
zone=transition.zone(n.zones,1/8,3/4)))
#
# Create Markov chain walks for all guards.
#
n.steps <- 500
walks <- list()
for (g in guards) {
zone <- integer(n.steps)
side <- integer(n.steps)
# Random starting location
zone[1] <- sample.int(n.zones, 1)
side[1] <- sample.int(2, 1)
for (i in 2:n.steps) {
zone[i] <- sample.int(n.zones, 1, prob=g$zone[zone[i-1],])
side[i] <- sample.int(2, 1, prob=g$side[side[i-1],])
}
s <- cumsum(sample(c(rexp(n.steps-3), rexp(3, 10/n.steps))))
walks <- c(walks, list(list(zone=zone, side=side, time=s/max(s))))
}
#
# Display a walk.
#
plot.walk <- function(walk, ...) {
n <- length(walk$zone)
#
# Find outlying time differences.
#
d <- diff(walk$time)
q <- quantile(d, c(1/4, 1/2, 3/4))
threshold <- q[2] + 5 * (q[3]-q[1])
breaks <- unique(c(which(d > threshold), n))
#
# Plot the data.
#
sym <- c(0, 19)
col <- c("#2020d080", "#d0202080")
plot(walk$time, walk$zone, type="n", xlab="Time", ylab="Zone", ...)
j <- 1
for (i in breaks) {
lines(walk$time[j:(i-1)], walk$zone[j:(i-1)], col="#00000040")
j <- i+1
}
points(walk$time, walk$zone+0.2*(walk$side-3/2), pch=sym[walk$side], col=col[walk$side],
cex=min(1,sqrt(200/n)))
}
plot.walk2 <- function(walk, n.zones=10, n.sides=2, ...) {
n <- length(walk$zone)
#
# Find outlying time differences.
#
d <- diff(walk$time)
q <- quantile(d, c(1/4, 1/2, 3/4))
threshold <- q[2] + 5 * (q[3]-q[1])
breaks <- unique(c(which(d > threshold), n))
#
# Plot the reference map
#
col <- "#3050b0"
plot(c(1/2, n.zones+1/2), c(1/2, n.sides+1/2), type="n", bty="n", tck=0,
fg="White",
xaxp=c(1,n.zones,n.zones-1), yaxp=c(1,n.sides,n.sides-1),
xlab="Zone", ylab="Side", ...)
polygon(c(1/2,n.zones+1/2,n.zones+1/2,1/2,1/2), c(1/2,1/2,n.sides+1/2,n.sides+1/2,1/2),
border=col, col="#fafafa", lwd=2)
for (i in 2:n.zones) lines(rep(i-1/2,2), c(1/2, n.sides+1/2), col=col)
for (i in 2:n.sides) lines(c(1/2, n.zones+1/2), rep(i-1/2,2), col=col)
#
# Plot the data.
#
col <- terrain.colors(n, alpha=1/2)
x <- walk$zone + runif(n, -1/3, 1/3)
y <- walk$side + runif(n, -1/3, 1/3)
j <- 1
for (i in breaks) {
lines(x[j:(i-1)], y[j:(i-1)], col="#00000020")
j <- i+1
}
points(x, y, pch=19, cex=min(1,sqrt(200/n)), col=col)
}
par(mfcol=c(length(guards), 1))
i <- 1
for (g in walks) {
plot.walk(g, main=paste("Guard", i))
i <- i+1
}
i <- 1
for (g in walks) {
plot.walk2(g, main=paste("Guard", i))
i <- i+1
} | Help creating a chart to show categorical data over time | Three variables need to be visualized: time, zone, and side. We should capitalize on the two Cartesian coordinates of the plot to map two of these. Then some graphical quality--symbol, color, lightn | Help creating a chart to show categorical data over time
Three variables need to be visualized: time, zone, and side. We should capitalize on the two Cartesian coordinates of the plot to map two of these. Then some graphical quality--symbol, color, lightness, or orientation--will be needed to symbolize the third.
To help the eye follow the temporal sequence it can help to connect the symbols with faint line segments. We can obtain a little more information by erasing any segments that seem to correspond to breaks in the series.
The first solution uses symbol type and color to distinguish the sides, vertical position to identify zones, and horizontal position for time. It is designed to display the progress of zone and side over time to help visualize the transitions. To clarify overlaps, the symbol for side 2 is positioned above its nominal location and the symbol for side 1 is positioned below its nominal location.
This figure makes it immediately apparent that Guard 2 prefers the blue side (side 1) over the red (side 2) and that she moves around the zones more and in a more regular fashion.
The use of identically scaled and oriented time axes in these parallel plots enables visual comparison of the guard's patrol patterns during any time interval. With many guards, this construction lends itself well to a "small multiple" display showing all data simultaneously.
The second solution uses symbol color to distinguish times, vertical position to identify sides, and horizontal position for zone. It is a map-like display (which would generalize to a more complex spatial layout). This could be used to study the frequencies with which each space are entered by each guard and, in a more limited way, to visualize the movements among the spaces.
The different frequencies with which the zones and sides were visited are clearly displayed in this figure. The failure of Guard 2 to visit side 2 of zone 10 is immediately apparent, whereas it was not evident in the first figure.
These figures were produced in R. The input data structure is a list of parallel vectors for the times, zones, and sides: one per guard. The following code begins by generating some sample data randomly. Two functions to make the plot for a given guard are provided, corresponding to the figures.
#
# Side transition matrices
#
transition.side <- function(left=1/2, right=1/2) {
rbind(c(left, 1-left), c(1-right, right))
}
#
# Zone transition matrices
#
transition.zone <- function(n, up=1/2, stay=0, down=(1-up-stay)) {
x <- rep(c(down, stay, up, rep(0, n-2)), n)
q <- matrix(x[-c(1, 2:n+n^2)], n)
q <- q / apply(q, 1, sum)
return (q)
}
n.zones <- 10
guards <- list(list(side=transition.side(1/2,1/2),
zone=transition.zone(n.zones,1/2,0)),
list(side=transition.side(3/4,1/4),
zone=transition.zone(n.zones,1/8,3/4)))
#
# Create Markov chain walks for all guards.
#
n.steps <- 500
walks <- list()
for (g in guards) {
zone <- integer(n.steps)
side <- integer(n.steps)
# Random starting location
zone[1] <- sample.int(n.zones, 1)
side[1] <- sample.int(2, 1)
for (i in 2:n.steps) {
zone[i] <- sample.int(n.zones, 1, prob=g$zone[zone[i-1],])
side[i] <- sample.int(2, 1, prob=g$side[side[i-1],])
}
s <- cumsum(sample(c(rexp(n.steps-3), rexp(3, 10/n.steps))))
walks <- c(walks, list(list(zone=zone, side=side, time=s/max(s))))
}
#
# Display a walk.
#
plot.walk <- function(walk, ...) {
n <- length(walk$zone)
#
# Find outlying time differences.
#
d <- diff(walk$time)
q <- quantile(d, c(1/4, 1/2, 3/4))
threshold <- q[2] + 5 * (q[3]-q[1])
breaks <- unique(c(which(d > threshold), n))
#
# Plot the data.
#
sym <- c(0, 19)
col <- c("#2020d080", "#d0202080")
plot(walk$time, walk$zone, type="n", xlab="Time", ylab="Zone", ...)
j <- 1
for (i in breaks) {
lines(walk$time[j:(i-1)], walk$zone[j:(i-1)], col="#00000040")
j <- i+1
}
points(walk$time, walk$zone+0.2*(walk$side-3/2), pch=sym[walk$side], col=col[walk$side],
cex=min(1,sqrt(200/n)))
}
plot.walk2 <- function(walk, n.zones=10, n.sides=2, ...) {
n <- length(walk$zone)
#
# Find outlying time differences.
#
d <- diff(walk$time)
q <- quantile(d, c(1/4, 1/2, 3/4))
threshold <- q[2] + 5 * (q[3]-q[1])
breaks <- unique(c(which(d > threshold), n))
#
# Plot the reference map
#
col <- "#3050b0"
plot(c(1/2, n.zones+1/2), c(1/2, n.sides+1/2), type="n", bty="n", tck=0,
fg="White",
xaxp=c(1,n.zones,n.zones-1), yaxp=c(1,n.sides,n.sides-1),
xlab="Zone", ylab="Side", ...)
polygon(c(1/2,n.zones+1/2,n.zones+1/2,1/2,1/2), c(1/2,1/2,n.sides+1/2,n.sides+1/2,1/2),
border=col, col="#fafafa", lwd=2)
for (i in 2:n.zones) lines(rep(i-1/2,2), c(1/2, n.sides+1/2), col=col)
for (i in 2:n.sides) lines(c(1/2, n.zones+1/2), rep(i-1/2,2), col=col)
#
# Plot the data.
#
col <- terrain.colors(n, alpha=1/2)
x <- walk$zone + runif(n, -1/3, 1/3)
y <- walk$side + runif(n, -1/3, 1/3)
j <- 1
for (i in breaks) {
lines(x[j:(i-1)], y[j:(i-1)], col="#00000020")
j <- i+1
}
points(x, y, pch=19, cex=min(1,sqrt(200/n)), col=col)
}
par(mfcol=c(length(guards), 1))
i <- 1
for (g in walks) {
plot.walk(g, main=paste("Guard", i))
i <- i+1
}
i <- 1
for (g in walks) {
plot.walk2(g, main=paste("Guard", i))
i <- i+1
} | Help creating a chart to show categorical data over time
Three variables need to be visualized: time, zone, and side. We should capitalize on the two Cartesian coordinates of the plot to map two of these. Then some graphical quality--symbol, color, lightn |
30,471 | Help creating a chart to show categorical data over time | As a way of displaying the information, perhaps I'd try to do something like this, with zone on the y-axis and time on the x-axis:
... but what kind of display is best depends on what you're trying to get out of it. | Help creating a chart to show categorical data over time | As a way of displaying the information, perhaps I'd try to do something like this, with zone on the y-axis and time on the x-axis:
... but what kind of display is best depends on what you're trying | Help creating a chart to show categorical data over time
As a way of displaying the information, perhaps I'd try to do something like this, with zone on the y-axis and time on the x-axis:
... but what kind of display is best depends on what you're trying to get out of it. | Help creating a chart to show categorical data over time
As a way of displaying the information, perhaps I'd try to do something like this, with zone on the y-axis and time on the x-axis:
... but what kind of display is best depends on what you're trying |
30,472 | Help creating a chart to show categorical data over time | As always, the best visual(s) depends on what question(s) you want to answer. Possible questions that would lead to different visuals:
Is a guard's pattern is predictable?
Is a guard stationary too often?
Are both guards are in the same zone too often?
Are there zones that are never or rarely visited?
How are the guards different?
What's the average time spent in each zone?
What's the average/maximum time between visits for each zone?
Since you did ask for a visual over time, here's a heat map time view showing the time between visits to each zone over time. That is, for each time/zone combination the cell color indicates how long it's been since the zone was visited. If there is a special cut-off for acceptable time between visits, you can adjust the color scale to indicate it.
I'm using whuber's simulated random walk data which has time as a continuous measure, which causes some artifacts as a heat map (some cells have no data (white stripes) and some have multiple data). The original question suggests discrete time data which will work better in a heat map. | Help creating a chart to show categorical data over time | As always, the best visual(s) depends on what question(s) you want to answer. Possible questions that would lead to different visuals:
Is a guard's pattern is predictable?
Is a guard stationary too o | Help creating a chart to show categorical data over time
As always, the best visual(s) depends on what question(s) you want to answer. Possible questions that would lead to different visuals:
Is a guard's pattern is predictable?
Is a guard stationary too often?
Are both guards are in the same zone too often?
Are there zones that are never or rarely visited?
How are the guards different?
What's the average time spent in each zone?
What's the average/maximum time between visits for each zone?
Since you did ask for a visual over time, here's a heat map time view showing the time between visits to each zone over time. That is, for each time/zone combination the cell color indicates how long it's been since the zone was visited. If there is a special cut-off for acceptable time between visits, you can adjust the color scale to indicate it.
I'm using whuber's simulated random walk data which has time as a continuous measure, which causes some artifacts as a heat map (some cells have no data (white stripes) and some have multiple data). The original question suggests discrete time data which will work better in a heat map. | Help creating a chart to show categorical data over time
As always, the best visual(s) depends on what question(s) you want to answer. Possible questions that would lead to different visuals:
Is a guard's pattern is predictable?
Is a guard stationary too o |
30,473 | Help creating a chart to show categorical data over time | Depends on the goals of the trends, are you trying to ensure they are covering the area?
However I would abstract time and do something like this- | Help creating a chart to show categorical data over time | Depends on the goals of the trends, are you trying to ensure they are covering the area?
However I would abstract time and do something like this- | Help creating a chart to show categorical data over time
Depends on the goals of the trends, are you trying to ensure they are covering the area?
However I would abstract time and do something like this- | Help creating a chart to show categorical data over time
Depends on the goals of the trends, are you trying to ensure they are covering the area?
However I would abstract time and do something like this- |
30,474 | How can I find a Z score from a p-value? | Typically the tables for $p$-values for the $Z$ distribution are arranged with values of $Z$ defining the row and column headers, and the body of the table consists of $p$-values.
If you are given a $Z$ value, you go to the corresponding row and column to look in the table. However, you can do the reverse of this, right? Given $p$ (or $\alpha$), you can find this value in the table and then look at the row and column headers to get $Z$.
Ta da! | How can I find a Z score from a p-value? | Typically the tables for $p$-values for the $Z$ distribution are arranged with values of $Z$ defining the row and column headers, and the body of the table consists of $p$-values.
If you are given a $ | How can I find a Z score from a p-value?
Typically the tables for $p$-values for the $Z$ distribution are arranged with values of $Z$ defining the row and column headers, and the body of the table consists of $p$-values.
If you are given a $Z$ value, you go to the corresponding row and column to look in the table. However, you can do the reverse of this, right? Given $p$ (or $\alpha$), you can find this value in the table and then look at the row and column headers to get $Z$.
Ta da! | How can I find a Z score from a p-value?
Typically the tables for $p$-values for the $Z$ distribution are arranged with values of $Z$ defining the row and column headers, and the body of the table consists of $p$-values.
If you are given a $ |
30,475 | How can I find a Z score from a p-value? | Actually, $z_{.95}=1.6\underline{\mathbf{4}}$; your handout is LIES! (I'm being facetiously hyperbolic because the author seems to have rounded up somewhat improperly. It's not really a big deal.)
In r, the qnorm function converts probabilities (akin to distribution quantiles) to z-scores. Thus:
> qnorm(.95)
[1] 1.644854
The documation for qnorm lists the following reference for the algorithm, in case you want it. If you prefer not to use R, John Walker's calculator works through JavaScript-enabled web browsers. He also offers some equations that could be rearranged to do this by hand. You may also wish to check "How to deal with Z-score greater than 3?"
Reference
Wichura, M. J. (1988) Algorithm AS 241: The percentage points of the normal distribution. Applied Statistics, 37, 477–484. | How can I find a Z score from a p-value? | Actually, $z_{.95}=1.6\underline{\mathbf{4}}$; your handout is LIES! (I'm being facetiously hyperbolic because the author seems to have rounded up somewhat improperly. It's not really a big deal.)
In | How can I find a Z score from a p-value?
Actually, $z_{.95}=1.6\underline{\mathbf{4}}$; your handout is LIES! (I'm being facetiously hyperbolic because the author seems to have rounded up somewhat improperly. It's not really a big deal.)
In r, the qnorm function converts probabilities (akin to distribution quantiles) to z-scores. Thus:
> qnorm(.95)
[1] 1.644854
The documation for qnorm lists the following reference for the algorithm, in case you want it. If you prefer not to use R, John Walker's calculator works through JavaScript-enabled web browsers. He also offers some equations that could be rearranged to do this by hand. You may also wish to check "How to deal with Z-score greater than 3?"
Reference
Wichura, M. J. (1988) Algorithm AS 241: The percentage points of the normal distribution. Applied Statistics, 37, 477–484. | How can I find a Z score from a p-value?
Actually, $z_{.95}=1.6\underline{\mathbf{4}}$; your handout is LIES! (I'm being facetiously hyperbolic because the author seems to have rounded up somewhat improperly. It's not really a big deal.)
In |
30,476 | How to estimate confidence level for SVM or Random Forest? | For random forests you can look at the vote counts instead of just the winning class. Ie did 92% or 52% of the trees in the ensemble vote for class 1. How you do this will depend on the implementation. | How to estimate confidence level for SVM or Random Forest? | For random forests you can look at the vote counts instead of just the winning class. Ie did 92% or 52% of the trees in the ensemble vote for class 1. How you do this will depend on the implementation | How to estimate confidence level for SVM or Random Forest?
For random forests you can look at the vote counts instead of just the winning class. Ie did 92% or 52% of the trees in the ensemble vote for class 1. How you do this will depend on the implementation. | How to estimate confidence level for SVM or Random Forest?
For random forests you can look at the vote counts instead of just the winning class. Ie did 92% or 52% of the trees in the ensemble vote for class 1. How you do this will depend on the implementation |
30,477 | How to estimate confidence level for SVM or Random Forest? | Confidence intervals for SVMs are often obtained via bootstrapping or by taking a Bayesian approach.
For classification, bootstrapping may be a good approach to take.
This slide deck illustrates some concepts of how to estimate confidence intervals to a test error of a certain
classifier based on continuous functionals.
Another approach given here:
Estimating the Confidence Interval for Prediction Errors of Support Vector Machine Classifiers Bo Jiang, Xuegong Zhang, Tianxi Cai; 9(Mar):521--540, 2008.
is to use perturbation-resampling (similar to bootstrapping) to obtain the desired confidence intervals.
This paper is a bit more interpretable than the slide deck. To summarize, first, it proposes that the classifier be estimated using cross-validation, and that as an output one will have $\hat{D}$ the estimated prediction error (Equation (5)). They go on to point out that it is desirable to know something about the distribution of this estimated prediction error (for instance if we know something about its distribution we can try to obtain confidence intervals for it). In order to do so for a general class of distributions (a problem confronted in the slide deck as well), they detail their resampling approach in Section 3.2. This is consolidated in an algorithm that they provide in this section.
You may also have luck attempting to learn something from the LS-SVM toolbox posted by this work group. They implement confidence intervals for Least Squares SVMs for regression using a Baysian confidence interval. This is not for classification, but it may be possible that you can adapt it to your problem. | How to estimate confidence level for SVM or Random Forest? | Confidence intervals for SVMs are often obtained via bootstrapping or by taking a Bayesian approach.
For classification, bootstrapping may be a good approach to take.
This slide deck illustrates some | How to estimate confidence level for SVM or Random Forest?
Confidence intervals for SVMs are often obtained via bootstrapping or by taking a Bayesian approach.
For classification, bootstrapping may be a good approach to take.
This slide deck illustrates some concepts of how to estimate confidence intervals to a test error of a certain
classifier based on continuous functionals.
Another approach given here:
Estimating the Confidence Interval for Prediction Errors of Support Vector Machine Classifiers Bo Jiang, Xuegong Zhang, Tianxi Cai; 9(Mar):521--540, 2008.
is to use perturbation-resampling (similar to bootstrapping) to obtain the desired confidence intervals.
This paper is a bit more interpretable than the slide deck. To summarize, first, it proposes that the classifier be estimated using cross-validation, and that as an output one will have $\hat{D}$ the estimated prediction error (Equation (5)). They go on to point out that it is desirable to know something about the distribution of this estimated prediction error (for instance if we know something about its distribution we can try to obtain confidence intervals for it). In order to do so for a general class of distributions (a problem confronted in the slide deck as well), they detail their resampling approach in Section 3.2. This is consolidated in an algorithm that they provide in this section.
You may also have luck attempting to learn something from the LS-SVM toolbox posted by this work group. They implement confidence intervals for Least Squares SVMs for regression using a Baysian confidence interval. This is not for classification, but it may be possible that you can adapt it to your problem. | How to estimate confidence level for SVM or Random Forest?
Confidence intervals for SVMs are often obtained via bootstrapping or by taking a Bayesian approach.
For classification, bootstrapping may be a good approach to take.
This slide deck illustrates some |
30,478 | How to replicate Stata's robust binomial GLM for proportion data in R? | Using the R package sandwich and lmtest, you can replicate the results like that (I assume that you've already downloaded the dataset or access it over the internet):
#-----------------------------------------------------------------------------
# Load the required packages
#-----------------------------------------------------------------------------
require(foreign)
require(sandwich)
#-----------------------------------------------------------------------------
# Load the data
#-----------------------------------------------------------------------------
dat <- read.dta("MyPath/proportion.dta")
#-----------------------------------------------------------------------------
# Inspect dataset
#-----------------------------------------------------------------------------
str(dat)
#-----------------------------------------------------------------------------
# Fit the glm
#-----------------------------------------------------------------------------
fitglm <- glm(meals ~ yr_rnd + parented + api99, family = binomial(logit), data = dat)
#-----------------------------------------------------------------------------
# Output of the model
#-----------------------------------------------------------------------------
summary(fitglm)
#-----------------------------------------------------------------------------
# Calculate robust standard errors by hand
#-----------------------------------------------------------------------------
cov.m1 <- vcovHC(fitglm, type = "HC1")
std.err <- sqrt(diag(cov.m1))
q.val <- qnorm(0.975)
r.est <- cbind(
Estimate = coef(fitglm)
, "Robust SE" = std.err
, z = (coef(fitglm)/std.err)
, "Pr(>|z|) "= 2 * pnorm(abs(coef(fitglm)/std.err), lower.tail = FALSE)
, LL = coef(fitglm) - q.val * std.err
, UL = coef(fitglm) + q.val * std.err
)
r.est
The model output using robust standard errors is:
Estimate Robust SE z Pr(>|z|) LL UL
(Intercept) 6.801682703 0.0724029936 93.942009 0.000000e+00 6.659775443 6.943589963
yr_rndYes 0.048252657 0.0321827112 1.499335 1.337868e-01 -0.014824298 0.111329612
parented -0.766259824 0.0390852844 -19.604816 1.406590e-85 -0.842865573 -0.689654074
api99 -0.007304603 0.0002156354 -33.874790 1.566480e-251 -0.007727241 -0.006881966
A much more convenient way is using the coeftest and coefci functions from the lmtest package (output not shown but is identical to output above):
coeftest(fitglm, vcov. = vcovHC(fitglm, type = "HC1"))
coefci(fitglm, vcov. = vcovHC(fitglm, type = "HC1"))
The estimates and standard errors are fairly similar to those calculated using Stata but not exactly. The reason is that Stata uses a finite-sample adjustment (see this post). The Stata-output is (caution: I enter the variable yr_rnd as categorical variable to replicate R's behaviour, unlike the UCLA page):
------------------------------------------------------------------------------
| Robust
meals | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
yr_rnd |
Yes | .0482527 .0321714 1.50 0.134 -.0148021 .1113074
parented | -.7662598 .0390715 -19.61 0.000 -.8428386 -.6896811
api99 | -.0073046 .0002156 -33.89 0.000 -.0077271 -.0068821
_cons | 6.801683 .0723775 93.98 0.000 6.659825 6.94354
------------------------------------------------------------------------------
To exactly replicate Stata's standard errors, we have to use @AchimZeileis' function (found here):
sandwich1 <- function(object, ...) sandwich(object) * nobs(object) / (nobs(object) - 1)
coeftest(fitglm, vcov. = sandwich1)
Estimate Std. Error z value Pr(>|z|)
(Intercept) 6.80168270 0.07237747 93.9751 <2e-16 ***
yr_rndYes 0.04825266 0.03217137 1.4999 0.1336
parented -0.76625982 0.03907151 -19.6117 <2e-16 ***
api99 -0.00730460 0.00021556 -33.8867 <2e-16 ***
There are several methods available for the function vcovHC. Consult the help file of vcovHC for the details.
Note that if you use the option family = quasibinomial(logit), there will be no error message (see here). | How to replicate Stata's robust binomial GLM for proportion data in R? | Using the R package sandwich and lmtest, you can replicate the results like that (I assume that you've already downloaded the dataset or access it over the internet):
#-------------------------------- | How to replicate Stata's robust binomial GLM for proportion data in R?
Using the R package sandwich and lmtest, you can replicate the results like that (I assume that you've already downloaded the dataset or access it over the internet):
#-----------------------------------------------------------------------------
# Load the required packages
#-----------------------------------------------------------------------------
require(foreign)
require(sandwich)
#-----------------------------------------------------------------------------
# Load the data
#-----------------------------------------------------------------------------
dat <- read.dta("MyPath/proportion.dta")
#-----------------------------------------------------------------------------
# Inspect dataset
#-----------------------------------------------------------------------------
str(dat)
#-----------------------------------------------------------------------------
# Fit the glm
#-----------------------------------------------------------------------------
fitglm <- glm(meals ~ yr_rnd + parented + api99, family = binomial(logit), data = dat)
#-----------------------------------------------------------------------------
# Output of the model
#-----------------------------------------------------------------------------
summary(fitglm)
#-----------------------------------------------------------------------------
# Calculate robust standard errors by hand
#-----------------------------------------------------------------------------
cov.m1 <- vcovHC(fitglm, type = "HC1")
std.err <- sqrt(diag(cov.m1))
q.val <- qnorm(0.975)
r.est <- cbind(
Estimate = coef(fitglm)
, "Robust SE" = std.err
, z = (coef(fitglm)/std.err)
, "Pr(>|z|) "= 2 * pnorm(abs(coef(fitglm)/std.err), lower.tail = FALSE)
, LL = coef(fitglm) - q.val * std.err
, UL = coef(fitglm) + q.val * std.err
)
r.est
The model output using robust standard errors is:
Estimate Robust SE z Pr(>|z|) LL UL
(Intercept) 6.801682703 0.0724029936 93.942009 0.000000e+00 6.659775443 6.943589963
yr_rndYes 0.048252657 0.0321827112 1.499335 1.337868e-01 -0.014824298 0.111329612
parented -0.766259824 0.0390852844 -19.604816 1.406590e-85 -0.842865573 -0.689654074
api99 -0.007304603 0.0002156354 -33.874790 1.566480e-251 -0.007727241 -0.006881966
A much more convenient way is using the coeftest and coefci functions from the lmtest package (output not shown but is identical to output above):
coeftest(fitglm, vcov. = vcovHC(fitglm, type = "HC1"))
coefci(fitglm, vcov. = vcovHC(fitglm, type = "HC1"))
The estimates and standard errors are fairly similar to those calculated using Stata but not exactly. The reason is that Stata uses a finite-sample adjustment (see this post). The Stata-output is (caution: I enter the variable yr_rnd as categorical variable to replicate R's behaviour, unlike the UCLA page):
------------------------------------------------------------------------------
| Robust
meals | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
yr_rnd |
Yes | .0482527 .0321714 1.50 0.134 -.0148021 .1113074
parented | -.7662598 .0390715 -19.61 0.000 -.8428386 -.6896811
api99 | -.0073046 .0002156 -33.89 0.000 -.0077271 -.0068821
_cons | 6.801683 .0723775 93.98 0.000 6.659825 6.94354
------------------------------------------------------------------------------
To exactly replicate Stata's standard errors, we have to use @AchimZeileis' function (found here):
sandwich1 <- function(object, ...) sandwich(object) * nobs(object) / (nobs(object) - 1)
coeftest(fitglm, vcov. = sandwich1)
Estimate Std. Error z value Pr(>|z|)
(Intercept) 6.80168270 0.07237747 93.9751 <2e-16 ***
yr_rndYes 0.04825266 0.03217137 1.4999 0.1336
parented -0.76625982 0.03907151 -19.6117 <2e-16 ***
api99 -0.00730460 0.00021556 -33.8867 <2e-16 ***
There are several methods available for the function vcovHC. Consult the help file of vcovHC for the details.
Note that if you use the option family = quasibinomial(logit), there will be no error message (see here). | How to replicate Stata's robust binomial GLM for proportion data in R?
Using the R package sandwich and lmtest, you can replicate the results like that (I assume that you've already downloaded the dataset or access it over the internet):
#-------------------------------- |
30,479 | How to replicate Stata's robust binomial GLM for proportion data in R? | You can replicate the UCLA FAQ on proportions (with a percentage as a dependent variable) as follows:
require(foreign);require(lmtest);require(sandwich)
meals <- read.dta("http://www.ats.ucla.edu/stat/stata/faq/proportion.dta")
fitperc <- glm(meals ~ yr_rnd + parented + api99, family = binomial, data=meals)
## Warning message:
## In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
I don't know if the warning above is an issue here or not. For some reason the intercept don't match in R and Stata, but since we don't interpret it usually in logit/probit anyway it shouldn't matter much.
summary(fitperc)
##
## Call:
## glm(formula = meals ~ yr_rnd + parented + api99, family = binomial,
## data = meals, na.action = na.exclude)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.77722 -0.18995 -0.01649 0.18692 1.60959
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.801683 0.231914 29.329 <2e-16 ***
## yr_rndYes 0.048253 0.104210 0.463 0.643
## parented -0.766260 0.090733 -8.445 <2e-16 ***
## api99 -0.007305 0.000506 -14.435 <2e-16 ***
## ---
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 1953.94 on 4256 degrees of freedom
## Residual deviance: 395.81 on 4253 degrees of freedom
## (164 observations deleted due to missingness)
## AIC: 2936.7
##
## Number of Fisher Scoring iterations: 5
In R the small-sample corrections used are different than those in Stata, but the robust SEs are fairly similar:
coeftest(fitperc, function(x) vcovHC(x, type = "HC1"))
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.80168270 0.07240299 93.9420 <2e-16 ***
## yr_rndYes 0.04825266 0.03218271 1.4993 0.1338
## parented -0.76625982 0.03908528 -19.6048 <2e-16 ***
## api99 -0.00730460 0.00021564 -33.8748 <2e-16 ***
## ---
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
To use the exact same small-sample correction you need to follow this post:
sandwich1 <- function(object, ...) sandwich(object) * nobs(object) / (nobs(object) - 1)
coeftest(fitperc, vcov = sandwich1)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.80168270 0.07237747 93.9751 <2e-16 ***
## yr_rndYes 0.04825266 0.03217137 1.4999 0.1336
## parented -0.76625982 0.03907151 -19.6117 <2e-16 ***
## api99 -0.00730460 0.00021556 -33.8867 <2e-16 ***
## ---
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The log likelihood and the confidence intervals (slightly different as the estimation procedure seems to be different):
logLik(fitperc)
## 'log Lik.' -1464.363 (df=4)
confint(fitperc)
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) 6.352788748 7.262067304
## yr_rndYes -0.155529338 0.253123151
## parented -0.944775733 -0.588903012
## api99 -0.008303668 -0.006319185
To obtain the predictions:
meals_pred <- data.frame(api99=rep(c(500,600,700), 2),
yr_rnd=rep(c("No", "Yes"), times=1, each=3),
parented=rep(2.5, 6))
cbind(meals_pred, pred=predict(fitperc, meals_pred, "response"))
## api99 yr_rnd parented pred
## 1 500 No 2.5 0.7744710
## 2 600 No 2.5 0.6232278
## 3 700 No 2.5 0.4434458
## 4 500 Yes 2.5 0.7827873
## 5 600 Yes 2.5 0.6344891
## 6 700 Yes 2.5 0.4553849
See this question for a related discussion:
Estimating percentages as the dependent variable in regression | How to replicate Stata's robust binomial GLM for proportion data in R? | You can replicate the UCLA FAQ on proportions (with a percentage as a dependent variable) as follows:
require(foreign);require(lmtest);require(sandwich)
meals <- read.dta("http://www.ats.ucla.edu/sta | How to replicate Stata's robust binomial GLM for proportion data in R?
You can replicate the UCLA FAQ on proportions (with a percentage as a dependent variable) as follows:
require(foreign);require(lmtest);require(sandwich)
meals <- read.dta("http://www.ats.ucla.edu/stat/stata/faq/proportion.dta")
fitperc <- glm(meals ~ yr_rnd + parented + api99, family = binomial, data=meals)
## Warning message:
## In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
I don't know if the warning above is an issue here or not. For some reason the intercept don't match in R and Stata, but since we don't interpret it usually in logit/probit anyway it shouldn't matter much.
summary(fitperc)
##
## Call:
## glm(formula = meals ~ yr_rnd + parented + api99, family = binomial,
## data = meals, na.action = na.exclude)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.77722 -0.18995 -0.01649 0.18692 1.60959
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.801683 0.231914 29.329 <2e-16 ***
## yr_rndYes 0.048253 0.104210 0.463 0.643
## parented -0.766260 0.090733 -8.445 <2e-16 ***
## api99 -0.007305 0.000506 -14.435 <2e-16 ***
## ---
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 1953.94 on 4256 degrees of freedom
## Residual deviance: 395.81 on 4253 degrees of freedom
## (164 observations deleted due to missingness)
## AIC: 2936.7
##
## Number of Fisher Scoring iterations: 5
In R the small-sample corrections used are different than those in Stata, but the robust SEs are fairly similar:
coeftest(fitperc, function(x) vcovHC(x, type = "HC1"))
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.80168270 0.07240299 93.9420 <2e-16 ***
## yr_rndYes 0.04825266 0.03218271 1.4993 0.1338
## parented -0.76625982 0.03908528 -19.6048 <2e-16 ***
## api99 -0.00730460 0.00021564 -33.8748 <2e-16 ***
## ---
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
To use the exact same small-sample correction you need to follow this post:
sandwich1 <- function(object, ...) sandwich(object) * nobs(object) / (nobs(object) - 1)
coeftest(fitperc, vcov = sandwich1)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.80168270 0.07237747 93.9751 <2e-16 ***
## yr_rndYes 0.04825266 0.03217137 1.4999 0.1336
## parented -0.76625982 0.03907151 -19.6117 <2e-16 ***
## api99 -0.00730460 0.00021556 -33.8867 <2e-16 ***
## ---
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The log likelihood and the confidence intervals (slightly different as the estimation procedure seems to be different):
logLik(fitperc)
## 'log Lik.' -1464.363 (df=4)
confint(fitperc)
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) 6.352788748 7.262067304
## yr_rndYes -0.155529338 0.253123151
## parented -0.944775733 -0.588903012
## api99 -0.008303668 -0.006319185
To obtain the predictions:
meals_pred <- data.frame(api99=rep(c(500,600,700), 2),
yr_rnd=rep(c("No", "Yes"), times=1, each=3),
parented=rep(2.5, 6))
cbind(meals_pred, pred=predict(fitperc, meals_pred, "response"))
## api99 yr_rnd parented pred
## 1 500 No 2.5 0.7744710
## 2 600 No 2.5 0.6232278
## 3 700 No 2.5 0.4434458
## 4 500 Yes 2.5 0.7827873
## 5 600 Yes 2.5 0.6344891
## 6 700 Yes 2.5 0.4553849
See this question for a related discussion:
Estimating percentages as the dependent variable in regression | How to replicate Stata's robust binomial GLM for proportion data in R?
You can replicate the UCLA FAQ on proportions (with a percentage as a dependent variable) as follows:
require(foreign);require(lmtest);require(sandwich)
meals <- read.dta("http://www.ats.ucla.edu/sta |
30,480 | Calculating pointwise mutual information between two strings | Let's start by taking a look at where your expression for PMI comes from. According to this article, for a pair of outcomes $x$ and $y$, $$PMI(x,y) = \log\left[\frac{p(x,y)}{p(x)p(y)}\right]$$ This says that, in order to calculate PMI properly, you need to somehow define a rule for associating the observation of your $n$-grams with a probability.
In the context of your particular data set, which can be cleanly divided into 5000 sentences, a very natural thing to define would be the probabilities for various $n$-grams to appear in a single sentence. To calculate the PMI, we can start by defining two different outcomes:
Outcome 1: the 3-gram $\vec{x} = (x_{1}, x_{2}, x_{3})$ appears in a given sentence
Outcome 2: the 5-gram $\vec{y} = (y_{1}, y_{2}, y_{3}, y_{4}, y_{5})$ appears in a given sentence
In general, the 3-gram and 5-gram need not contain any words in common in order to calculate a valid PMI, however if you wish to set $x_{1} = y_{2}$, $x_{2} = y_{3}$, etc., you may certainly do so and still calculate a mathematically well-defined result.
To obtain $p\left(\vec{x}, \vec{y}\right)$, the joint probability that both the 3-gram and the 5-gram appear simultaneously in the same sentence, we would simply count the number of sentences $n\left(\vec{x},\vec{y}\right)$ in your data set which contain both $\vec{x}$ and $\vec{y}$ together, and divide by the total number of sentences $N=5000$; i.e., $$p\left(\vec{x}, \vec{y}\right) = \frac{n\left(\vec{x},\vec{y}\right)}{N}$$ Similarly, $p\left(\vec{x}\right)$ and $p\left(\vec{y}\right)$ are defined by the number of times that $\vec{x}$ and $\vec{y}$ are observed individually in each of the 5 sentences. Thus, the PMI is defined by $$PMI\left(\vec{x},\vec{y}\right) = \log\left\{\frac{\left[\frac{n\left(\vec{x},\vec{y}\right)}{N}\right]}{\left[\frac{n\left(\vec{x}\right)}{N}\right]\left[\frac{n\left(\vec{y}\right)}{N}\right]}\right\} = \log\left[\frac{n\left(\vec{x},\vec{y}\right)N}{n\left(\vec{x}\right)n\left(\vec{y}\right)}\right]$$ which looks superficially similar to your result, with a few key differences (e.g., you forgot the include the $\log$ function, etc.). This formula is valid regardless of whether or not the 3-gram $\vec{x}$ and the 5-gram $\vec{y}$ have any words in common, and it is defined with the understanding that:
$N$ is the number of sentences in the data set (5000, in this case)
The values $n\left(\vec{x}, \vec{y}\right)$, $n\left(\vec{x}\right)$, and $n\left(\vec{y}\right)$ count the number of times that $\vec{x}$ and $\vec{y}$ appear with all words simultaneously together in the same sentence (i.e., if 2 of the words in a 5-gram appear in one sentence and 3 of the words appear in the next, it doesn't actually count as a valid 5-gram because the words aren't found all together within the same sentence)
In the question as you originally stated it, you considered a very special and unusual case: one where every word in the 3-gram was identical to a word in the 5-gram; i.e., $x_{1}=y_{2}$, $x_{2}=y_{3}$, $x_{3}=y_{4}$. In this unique circumstance, as you correctly observed, $n\left(\vec{x},\vec{y}\right) = n\left(\vec{y}\right)$, i.e., the number of sentences in which the 3-gram and 5-gram appear jointly is the same as the number of in which the 5-gram appears in total. Thus, in this special case, those two terms cancel, and we are left with $$PMI\left(\vec{x},\vec{y}\right) = \log\left[\frac{N}{n\left(\vec{x}\right)}\right]$$ This is a perfectly valid result, assuming that you are trying to calculate the PMI for this special case. However, it's not a very general result; usually, you'd be considering cases where the words of the 3-gram and 5-gram don't overlap, and thus those count values would not cancel. | Calculating pointwise mutual information between two strings | Let's start by taking a look at where your expression for PMI comes from. According to this article, for a pair of outcomes $x$ and $y$, $$PMI(x,y) = \log\left[\frac{p(x,y)}{p(x)p(y)}\right]$$ This s | Calculating pointwise mutual information between two strings
Let's start by taking a look at where your expression for PMI comes from. According to this article, for a pair of outcomes $x$ and $y$, $$PMI(x,y) = \log\left[\frac{p(x,y)}{p(x)p(y)}\right]$$ This says that, in order to calculate PMI properly, you need to somehow define a rule for associating the observation of your $n$-grams with a probability.
In the context of your particular data set, which can be cleanly divided into 5000 sentences, a very natural thing to define would be the probabilities for various $n$-grams to appear in a single sentence. To calculate the PMI, we can start by defining two different outcomes:
Outcome 1: the 3-gram $\vec{x} = (x_{1}, x_{2}, x_{3})$ appears in a given sentence
Outcome 2: the 5-gram $\vec{y} = (y_{1}, y_{2}, y_{3}, y_{4}, y_{5})$ appears in a given sentence
In general, the 3-gram and 5-gram need not contain any words in common in order to calculate a valid PMI, however if you wish to set $x_{1} = y_{2}$, $x_{2} = y_{3}$, etc., you may certainly do so and still calculate a mathematically well-defined result.
To obtain $p\left(\vec{x}, \vec{y}\right)$, the joint probability that both the 3-gram and the 5-gram appear simultaneously in the same sentence, we would simply count the number of sentences $n\left(\vec{x},\vec{y}\right)$ in your data set which contain both $\vec{x}$ and $\vec{y}$ together, and divide by the total number of sentences $N=5000$; i.e., $$p\left(\vec{x}, \vec{y}\right) = \frac{n\left(\vec{x},\vec{y}\right)}{N}$$ Similarly, $p\left(\vec{x}\right)$ and $p\left(\vec{y}\right)$ are defined by the number of times that $\vec{x}$ and $\vec{y}$ are observed individually in each of the 5 sentences. Thus, the PMI is defined by $$PMI\left(\vec{x},\vec{y}\right) = \log\left\{\frac{\left[\frac{n\left(\vec{x},\vec{y}\right)}{N}\right]}{\left[\frac{n\left(\vec{x}\right)}{N}\right]\left[\frac{n\left(\vec{y}\right)}{N}\right]}\right\} = \log\left[\frac{n\left(\vec{x},\vec{y}\right)N}{n\left(\vec{x}\right)n\left(\vec{y}\right)}\right]$$ which looks superficially similar to your result, with a few key differences (e.g., you forgot the include the $\log$ function, etc.). This formula is valid regardless of whether or not the 3-gram $\vec{x}$ and the 5-gram $\vec{y}$ have any words in common, and it is defined with the understanding that:
$N$ is the number of sentences in the data set (5000, in this case)
The values $n\left(\vec{x}, \vec{y}\right)$, $n\left(\vec{x}\right)$, and $n\left(\vec{y}\right)$ count the number of times that $\vec{x}$ and $\vec{y}$ appear with all words simultaneously together in the same sentence (i.e., if 2 of the words in a 5-gram appear in one sentence and 3 of the words appear in the next, it doesn't actually count as a valid 5-gram because the words aren't found all together within the same sentence)
In the question as you originally stated it, you considered a very special and unusual case: one where every word in the 3-gram was identical to a word in the 5-gram; i.e., $x_{1}=y_{2}$, $x_{2}=y_{3}$, $x_{3}=y_{4}$. In this unique circumstance, as you correctly observed, $n\left(\vec{x},\vec{y}\right) = n\left(\vec{y}\right)$, i.e., the number of sentences in which the 3-gram and 5-gram appear jointly is the same as the number of in which the 5-gram appears in total. Thus, in this special case, those two terms cancel, and we are left with $$PMI\left(\vec{x},\vec{y}\right) = \log\left[\frac{N}{n\left(\vec{x}\right)}\right]$$ This is a perfectly valid result, assuming that you are trying to calculate the PMI for this special case. However, it's not a very general result; usually, you'd be considering cases where the words of the 3-gram and 5-gram don't overlap, and thus those count values would not cancel. | Calculating pointwise mutual information between two strings
Let's start by taking a look at where your expression for PMI comes from. According to this article, for a pair of outcomes $x$ and $y$, $$PMI(x,y) = \log\left[\frac{p(x,y)}{p(x)p(y)}\right]$$ This s |
30,481 | Calculating pointwise mutual information between two strings | The problem you are coming across is due to the fact that your 3-grams are a deterministic function of your 5-grams (e.g. just a marginalization). In such cases $I[X:f(X)] = H[f(X)]$ and so your $I[x_2x_3x_4 : x_1x_2x_3x_4x_5] = H[x_2x_3x_4]$ and translating back to pointwise, $pmi(x_2x_3x_4 : x_1x_2x_3x_4x_5) = h(x_2x_3x_4) = -log(p(x_2x_3x_4))$. | Calculating pointwise mutual information between two strings | The problem you are coming across is due to the fact that your 3-grams are a deterministic function of your 5-grams (e.g. just a marginalization). In such cases $I[X:f(X)] = H[f(X)]$ and so your $I[x_ | Calculating pointwise mutual information between two strings
The problem you are coming across is due to the fact that your 3-grams are a deterministic function of your 5-grams (e.g. just a marginalization). In such cases $I[X:f(X)] = H[f(X)]$ and so your $I[x_2x_3x_4 : x_1x_2x_3x_4x_5] = H[x_2x_3x_4]$ and translating back to pointwise, $pmi(x_2x_3x_4 : x_1x_2x_3x_4x_5) = h(x_2x_3x_4) = -log(p(x_2x_3x_4))$. | Calculating pointwise mutual information between two strings
The problem you are coming across is due to the fact that your 3-grams are a deterministic function of your 5-grams (e.g. just a marginalization). In such cases $I[X:f(X)] = H[f(X)]$ and so your $I[x_ |
30,482 | Ideas for outputting a prediction equation for Random Forests | Here there are some thoughts:
All black-box models might be inspected in some way. You can compute the variable importance for each feature for example or you can also plot the predicted response and the actual one for each feature (link);
You might think about some pruning of the ensemble. Not all the trees in the forest are necessary and you might use just a few. Paper: [Search for the Smallest Random Forest, Zhang]. Otherwise just Google "ensemble pruning", and have a look at "Ensemble Methods: Foundations and Algorithms
" Chapter 6;
You can build a single model by feature selection as you said. Otherwise you can also try to use Domingos' method in [Knowledge acquisition from examples via multiple models] that consists in building a new dataset with black-box predictions and build a decision tree on top of it.
As mentioned in this Stack Exchange's answer, a tree model might seem interpretable but it is prone to high changes just because of small perturbations of the training data. Thus, it is better to use a black-box model. The final aim of an end user is to understand why a new record is classified as a particular class. You might think about some feature importances just for that particular record.
I would go for 1. or 2. | Ideas for outputting a prediction equation for Random Forests | Here there are some thoughts:
All black-box models might be inspected in some way. You can compute the variable importance for each feature for example or you can also plot the predicted response and | Ideas for outputting a prediction equation for Random Forests
Here there are some thoughts:
All black-box models might be inspected in some way. You can compute the variable importance for each feature for example or you can also plot the predicted response and the actual one for each feature (link);
You might think about some pruning of the ensemble. Not all the trees in the forest are necessary and you might use just a few. Paper: [Search for the Smallest Random Forest, Zhang]. Otherwise just Google "ensemble pruning", and have a look at "Ensemble Methods: Foundations and Algorithms
" Chapter 6;
You can build a single model by feature selection as you said. Otherwise you can also try to use Domingos' method in [Knowledge acquisition from examples via multiple models] that consists in building a new dataset with black-box predictions and build a decision tree on top of it.
As mentioned in this Stack Exchange's answer, a tree model might seem interpretable but it is prone to high changes just because of small perturbations of the training data. Thus, it is better to use a black-box model. The final aim of an end user is to understand why a new record is classified as a particular class. You might think about some feature importances just for that particular record.
I would go for 1. or 2. | Ideas for outputting a prediction equation for Random Forests
Here there are some thoughts:
All black-box models might be inspected in some way. You can compute the variable importance for each feature for example or you can also plot the predicted response and |
30,483 | Ideas for outputting a prediction equation for Random Forests | I've had to deal with the same situation of using RF in a diagnostic setting, with stakeholders who are used to algorithms that boil down to a single, readable equation. I've found that if you start by explaining a simple decision tree (here you can use equations), then a very complicated one, and then explain the drawbacks of over-fitting, you start to get some head nods. Once you explain that many small trees can mitigate inaccuracy by being grown differently ("random"), and that they can be taken as an ensemble vote or average to avoid over-fitting but still account for edge cases, you get understanding. Here are some example slides I've used with good reception:
You can't get away from trees in a forest, and they are what give the algorithm so much predictive power and robustness, so there is rarely a better solution if RF is working very well for you. Ones that will compare, like SVM (depending on your data), will be just as complex. You have to make them understand that any good solution is going to be a black box of sorts (to the user). Your best move is to create a consumable implementation that doesn't require any more effort than a single equation would. I've had success with building an RF model in Python (via sklearn), and creating a simple web server REST API that loads that model into memory and accepts the variables in a POST to output the prediction. You can also do this in Java or R very easily, or skip the API and just create an executable binary/jar that takes the data as arguments. | Ideas for outputting a prediction equation for Random Forests | I've had to deal with the same situation of using RF in a diagnostic setting, with stakeholders who are used to algorithms that boil down to a single, readable equation. I've found that if you start | Ideas for outputting a prediction equation for Random Forests
I've had to deal with the same situation of using RF in a diagnostic setting, with stakeholders who are used to algorithms that boil down to a single, readable equation. I've found that if you start by explaining a simple decision tree (here you can use equations), then a very complicated one, and then explain the drawbacks of over-fitting, you start to get some head nods. Once you explain that many small trees can mitigate inaccuracy by being grown differently ("random"), and that they can be taken as an ensemble vote or average to avoid over-fitting but still account for edge cases, you get understanding. Here are some example slides I've used with good reception:
You can't get away from trees in a forest, and they are what give the algorithm so much predictive power and robustness, so there is rarely a better solution if RF is working very well for you. Ones that will compare, like SVM (depending on your data), will be just as complex. You have to make them understand that any good solution is going to be a black box of sorts (to the user). Your best move is to create a consumable implementation that doesn't require any more effort than a single equation would. I've had success with building an RF model in Python (via sklearn), and creating a simple web server REST API that loads that model into memory and accepts the variables in a POST to output the prediction. You can also do this in Java or R very easily, or skip the API and just create an executable binary/jar that takes the data as arguments. | Ideas for outputting a prediction equation for Random Forests
I've had to deal with the same situation of using RF in a diagnostic setting, with stakeholders who are used to algorithms that boil down to a single, readable equation. I've found that if you start |
30,484 | Ideas for outputting a prediction equation for Random Forests | I have experience of deploying random forests in a SQL Server environment via User Defined Function. The trick is to convert the IF-THEN ELSE rules that you get from each tree into a CASE-WHEN END or any other Conditional Processing construct (admittedly I've used JMP Pro's Bootstrap Forest implementation - 500k lines of SQL code).
There is absolutely no reason why this cannot be achived using the rattle R package. Have a look at randomForest2Rules & printRandomForests functions in that package. Both take random forest object as input and visit each tree in the forest and output a set of IF-THEN ELSE rules. Taking this as a starting point it should not be difficult converting this logic into your desired language in an automated way, since the output from the above mentioned function is structured text.
The above, also makes it important to decide the smallest no. of trees you need in the forest to make predictions at a desired level of accuracy (hint: plot(rf.object) shows you at what point the forest predictions do not improve despite adding more trees.) in order to keep the no. of lines to represent the forest down. | Ideas for outputting a prediction equation for Random Forests | I have experience of deploying random forests in a SQL Server environment via User Defined Function. The trick is to convert the IF-THEN ELSE rules that you get from each tree into a CASE-WHEN END or | Ideas for outputting a prediction equation for Random Forests
I have experience of deploying random forests in a SQL Server environment via User Defined Function. The trick is to convert the IF-THEN ELSE rules that you get from each tree into a CASE-WHEN END or any other Conditional Processing construct (admittedly I've used JMP Pro's Bootstrap Forest implementation - 500k lines of SQL code).
There is absolutely no reason why this cannot be achived using the rattle R package. Have a look at randomForest2Rules & printRandomForests functions in that package. Both take random forest object as input and visit each tree in the forest and output a set of IF-THEN ELSE rules. Taking this as a starting point it should not be difficult converting this logic into your desired language in an automated way, since the output from the above mentioned function is structured text.
The above, also makes it important to decide the smallest no. of trees you need in the forest to make predictions at a desired level of accuracy (hint: plot(rf.object) shows you at what point the forest predictions do not improve despite adding more trees.) in order to keep the no. of lines to represent the forest down. | Ideas for outputting a prediction equation for Random Forests
I have experience of deploying random forests in a SQL Server environment via User Defined Function. The trick is to convert the IF-THEN ELSE rules that you get from each tree into a CASE-WHEN END or |
30,485 | What is the test statistic in Fisher's exact test? | (To make our notions a little more precise, let's call the 'test statistic' the distribution of the thing we look up to actually compute the p-value. This means that for a two-tailed t-test, our test statistic would be $|T|$ rather than $T$.)
What a test statistic does is induce an ordering on the sample space (or more strictly, a partial ordering), so that you can identify the extreme cases (the ones most consistent with the alternative).
In the case of Fisher's exact test, there's already an ordering in a sense - which are the probabilities of the various 2x2 tables themselves. As it happens, they correspond to the ordering on $X_{1,1}$ in the sense that either the largest or smallest values of $X_{1,1}$ are 'extreme' and they are also the ones with smallest probability. So rather than look at the values of $X_{1,1}$ in the way you suggest, one can simply work in from the large and small ends, at each step just adding whichever value (the largest or smallest $X_{1,1}$-value not already in there) has the smallest probability associated with it, continuing until you reach your observed table; on its inclusion, the total probability of all those extreme tables is the p-value.
Here's an example:
> data.frame(x=x,prob=dhyper(x,9,12,10),rank=rank(dhyper(x,9,12,10)))
x prob rank
1 0 1.871194e-04 2
2 1 5.613581e-03 4
3 2 5.052223e-02 6
4 3 1.886163e-01 8
5 4 3.300786e-01 10
6 5 2.829245e-01 9
7 6 1.178852e-01 7
8 7 2.245433e-02 5
9 8 1.684074e-03 3
10 9 3.402171e-05 1
The first column are $X_{1,1}$ values, the second column are the probabilities and the third column is the induced ordering.
So in the particular case of the Fisher exact test, the probability of each table (equivalently, of each $X_{1,1}$ value) can be considered the actual test statistic.
If you compare your suggested test statistic $|X_{1,1}-\mu|$, it induces the same ordering in this case (and I believe it does so in general but I have not checked), in that larger values of that statistic are the smaller values of the probability, so it could equally be considered 'the statistic' - but so could many other quantities -- indeed any that preserve this ordering of the $X_{1,1}$s in all cases are equivalent test statistics, because they always produce identical p-values.
Also note that with the more precise notion of 'test statistic' introduced at the start, none of the possible test statistics for this problem actually has a hypergeometric distribution; $X_{1,1}$ does, but it's not actually a suitable test statistic for the two tailed test (if we did a one-sided test where only more association in the main diagonal and not in the second diagonal was regarded as consistent with the alternative, then it would be a test statistic). This is just the same one-tailed/two-tailed issue I began with.
[Edit: some programs do present a test statistic for the Fisher test; I'd presume this would be a -2logL type calculation that would be asymptotically comparable with a chi-square. Some may also present the odds-ratio or its log but that's not quite equivalent.] | What is the test statistic in Fisher's exact test? | (To make our notions a little more precise, let's call the 'test statistic' the distribution of the thing we look up to actually compute the p-value. This means that for a two-tailed t-test, our test | What is the test statistic in Fisher's exact test?
(To make our notions a little more precise, let's call the 'test statistic' the distribution of the thing we look up to actually compute the p-value. This means that for a two-tailed t-test, our test statistic would be $|T|$ rather than $T$.)
What a test statistic does is induce an ordering on the sample space (or more strictly, a partial ordering), so that you can identify the extreme cases (the ones most consistent with the alternative).
In the case of Fisher's exact test, there's already an ordering in a sense - which are the probabilities of the various 2x2 tables themselves. As it happens, they correspond to the ordering on $X_{1,1}$ in the sense that either the largest or smallest values of $X_{1,1}$ are 'extreme' and they are also the ones with smallest probability. So rather than look at the values of $X_{1,1}$ in the way you suggest, one can simply work in from the large and small ends, at each step just adding whichever value (the largest or smallest $X_{1,1}$-value not already in there) has the smallest probability associated with it, continuing until you reach your observed table; on its inclusion, the total probability of all those extreme tables is the p-value.
Here's an example:
> data.frame(x=x,prob=dhyper(x,9,12,10),rank=rank(dhyper(x,9,12,10)))
x prob rank
1 0 1.871194e-04 2
2 1 5.613581e-03 4
3 2 5.052223e-02 6
4 3 1.886163e-01 8
5 4 3.300786e-01 10
6 5 2.829245e-01 9
7 6 1.178852e-01 7
8 7 2.245433e-02 5
9 8 1.684074e-03 3
10 9 3.402171e-05 1
The first column are $X_{1,1}$ values, the second column are the probabilities and the third column is the induced ordering.
So in the particular case of the Fisher exact test, the probability of each table (equivalently, of each $X_{1,1}$ value) can be considered the actual test statistic.
If you compare your suggested test statistic $|X_{1,1}-\mu|$, it induces the same ordering in this case (and I believe it does so in general but I have not checked), in that larger values of that statistic are the smaller values of the probability, so it could equally be considered 'the statistic' - but so could many other quantities -- indeed any that preserve this ordering of the $X_{1,1}$s in all cases are equivalent test statistics, because they always produce identical p-values.
Also note that with the more precise notion of 'test statistic' introduced at the start, none of the possible test statistics for this problem actually has a hypergeometric distribution; $X_{1,1}$ does, but it's not actually a suitable test statistic for the two tailed test (if we did a one-sided test where only more association in the main diagonal and not in the second diagonal was regarded as consistent with the alternative, then it would be a test statistic). This is just the same one-tailed/two-tailed issue I began with.
[Edit: some programs do present a test statistic for the Fisher test; I'd presume this would be a -2logL type calculation that would be asymptotically comparable with a chi-square. Some may also present the odds-ratio or its log but that's not quite equivalent.] | What is the test statistic in Fisher's exact test?
(To make our notions a little more precise, let's call the 'test statistic' the distribution of the thing we look up to actually compute the p-value. This means that for a two-tailed t-test, our test |
30,486 | What is the test statistic in Fisher's exact test? | $|X_{1,1} - \mu|$ cannot have a hypergeometric distribution in general because $\mu$ does not need to be an integer value and then $|X_{1,1} - \mu|$ would not be an integer. But conditionally on the margins, $X_{1,1}$ will have a hypergeometric distribution.
If you do it properly and fix the margins to known values, you can consider $X_{1,1}$ (or any other cell) to be your statistic. With the analogy of drawing $k$ balls from an urn containing $W$ white balls and $B$ black balls without replacement, $X_{1,1}$ can be interpreted as the number of white balls drawn, where $B$ is the sum of the first row, $W$ is the sum of the second row, $k$ is the sum of the first column. | What is the test statistic in Fisher's exact test? | $|X_{1,1} - \mu|$ cannot have a hypergeometric distribution in general because $\mu$ does not need to be an integer value and then $|X_{1,1} - \mu|$ would not be an integer. But conditionally on the m | What is the test statistic in Fisher's exact test?
$|X_{1,1} - \mu|$ cannot have a hypergeometric distribution in general because $\mu$ does not need to be an integer value and then $|X_{1,1} - \mu|$ would not be an integer. But conditionally on the margins, $X_{1,1}$ will have a hypergeometric distribution.
If you do it properly and fix the margins to known values, you can consider $X_{1,1}$ (or any other cell) to be your statistic. With the analogy of drawing $k$ balls from an urn containing $W$ white balls and $B$ black balls without replacement, $X_{1,1}$ can be interpreted as the number of white balls drawn, where $B$ is the sum of the first row, $W$ is the sum of the second row, $k$ is the sum of the first column. | What is the test statistic in Fisher's exact test?
$|X_{1,1} - \mu|$ cannot have a hypergeometric distribution in general because $\mu$ does not need to be an integer value and then $|X_{1,1} - \mu|$ would not be an integer. But conditionally on the m |
30,487 | What is the test statistic in Fisher's exact test? | It doesn't really have one. Test statistics are a historical anomaly - the only reason we have a test statistic is to get to a p-value. Fisher's exact test jumps past a test statistic and goes straight to a p-value. | What is the test statistic in Fisher's exact test? | It doesn't really have one. Test statistics are a historical anomaly - the only reason we have a test statistic is to get to a p-value. Fisher's exact test jumps past a test statistic and goes straigh | What is the test statistic in Fisher's exact test?
It doesn't really have one. Test statistics are a historical anomaly - the only reason we have a test statistic is to get to a p-value. Fisher's exact test jumps past a test statistic and goes straight to a p-value. | What is the test statistic in Fisher's exact test?
It doesn't really have one. Test statistics are a historical anomaly - the only reason we have a test statistic is to get to a p-value. Fisher's exact test jumps past a test statistic and goes straigh |
30,488 | Doubly robust estimation of causal effects implementation | Doubly robust estimation is not actually particularly hard to implement in the language of your choice. All you are actually doing is controlling for variables in two ways, rather than one- the idea being that as long as one of the two models used for control is correct, you've successfully controlled for confounding.
The easiest way to do it, in my mind, is to use Inverse-Probability-of-Treatment (IPTW) weights to weight the data set, then also include variables in a normal regression model. This is how the authors approach the problem in the paper linked above. There are other options as well, usually built off propensity scores used for either matching or as a covariate in the model.
There are lots of introductions to IPTW in whatever statistical language you prefer. I'd provide code snippets, but all of mine are in SAS, and would likely read very much like the authors.
Briefly, what you do is model the probability of exposure based on your covariates using something like logistic regression and estimate the predicted probability of exposure based on that model. This gives you a propensity score. The Inverse Probability of Treatment Weight is, as the name suggests, 1/Propensity Score. This sometimes produces extreme values, so some people stabilize the weight by substituting the marginal probability of exposure (obtained by a logistic regression model of the outcome and no covariates) for 1 in the equation above.
Instead of treating each subject in your analysis as 1 subject, you now treat them as n copies of a subject, where n is their weight. If you run your regression model using those weights and including covariates, out comes a doubly robust estimate.
A word of caution however: While doubly (or triply, etc.) robust estimation gives you more chances to specify the correct covariate model, it does not guarantee you will do so. And more importantly, cannot save you from unmeasured confounding. | Doubly robust estimation of causal effects implementation | Doubly robust estimation is not actually particularly hard to implement in the language of your choice. All you are actually doing is controlling for variables in two ways, rather than one- the idea b | Doubly robust estimation of causal effects implementation
Doubly robust estimation is not actually particularly hard to implement in the language of your choice. All you are actually doing is controlling for variables in two ways, rather than one- the idea being that as long as one of the two models used for control is correct, you've successfully controlled for confounding.
The easiest way to do it, in my mind, is to use Inverse-Probability-of-Treatment (IPTW) weights to weight the data set, then also include variables in a normal regression model. This is how the authors approach the problem in the paper linked above. There are other options as well, usually built off propensity scores used for either matching or as a covariate in the model.
There are lots of introductions to IPTW in whatever statistical language you prefer. I'd provide code snippets, but all of mine are in SAS, and would likely read very much like the authors.
Briefly, what you do is model the probability of exposure based on your covariates using something like logistic regression and estimate the predicted probability of exposure based on that model. This gives you a propensity score. The Inverse Probability of Treatment Weight is, as the name suggests, 1/Propensity Score. This sometimes produces extreme values, so some people stabilize the weight by substituting the marginal probability of exposure (obtained by a logistic regression model of the outcome and no covariates) for 1 in the equation above.
Instead of treating each subject in your analysis as 1 subject, you now treat them as n copies of a subject, where n is their weight. If you run your regression model using those weights and including covariates, out comes a doubly robust estimate.
A word of caution however: While doubly (or triply, etc.) robust estimation gives you more chances to specify the correct covariate model, it does not guarantee you will do so. And more importantly, cannot save you from unmeasured confounding. | Doubly robust estimation of causal effects implementation
Doubly robust estimation is not actually particularly hard to implement in the language of your choice. All you are actually doing is controlling for variables in two ways, rather than one- the idea b |
30,489 | Doubly robust estimation of causal effects implementation | It looks like there was an implementation in Stata even before the article you cited was published: http://www.stata-journal.com/article.html?article=st0149. | Doubly robust estimation of causal effects implementation | It looks like there was an implementation in Stata even before the article you cited was published: http://www.stata-journal.com/article.html?article=st0149. | Doubly robust estimation of causal effects implementation
It looks like there was an implementation in Stata even before the article you cited was published: http://www.stata-journal.com/article.html?article=st0149. | Doubly robust estimation of causal effects implementation
It looks like there was an implementation in Stata even before the article you cited was published: http://www.stata-journal.com/article.html?article=st0149. |
30,490 | Doubly robust estimation of causal effects implementation | The tmle R package implemented the Targeted Minimum Loss Based Estimator, which is double robust and efficient under conditions. It has the additional advantage that it is a substitution estimator, as opposed to the Augmented IPTW (which is the one I assume you are referring to). | Doubly robust estimation of causal effects implementation | The tmle R package implemented the Targeted Minimum Loss Based Estimator, which is double robust and efficient under conditions. It has the additional advantage that it is a substitution estimator, as | Doubly robust estimation of causal effects implementation
The tmle R package implemented the Targeted Minimum Loss Based Estimator, which is double robust and efficient under conditions. It has the additional advantage that it is a substitution estimator, as opposed to the Augmented IPTW (which is the one I assume you are referring to). | Doubly robust estimation of causal effects implementation
The tmle R package implemented the Targeted Minimum Loss Based Estimator, which is double robust and efficient under conditions. It has the additional advantage that it is a substitution estimator, as |
30,491 | Doubly robust estimation of causal effects implementation | I have the estimator described in Funk et al. 2011 (augmented inverse probability weights), implemented in the zEpid Python 3 library within the AIPTW class. Details and syntax are HERE. The library also includes TMLE, in case you wanted to use both approaches | Doubly robust estimation of causal effects implementation | I have the estimator described in Funk et al. 2011 (augmented inverse probability weights), implemented in the zEpid Python 3 library within the AIPTW class. Details and syntax are HERE. The library a | Doubly robust estimation of causal effects implementation
I have the estimator described in Funk et al. 2011 (augmented inverse probability weights), implemented in the zEpid Python 3 library within the AIPTW class. Details and syntax are HERE. The library also includes TMLE, in case you wanted to use both approaches | Doubly robust estimation of causal effects implementation
I have the estimator described in Funk et al. 2011 (augmented inverse probability weights), implemented in the zEpid Python 3 library within the AIPTW class. Details and syntax are HERE. The library a |
30,492 | Doubly robust estimation of causal effects implementation | There is an R package which implements this DR estimator of the ATE (as well as some other things), the npcausal package: https://github.com/ehkennedy/npcausal
The function that fits a DR estimator is ate() | Doubly robust estimation of causal effects implementation | There is an R package which implements this DR estimator of the ATE (as well as some other things), the npcausal package: https://github.com/ehkennedy/npcausal
The function that fits a DR estimator is | Doubly robust estimation of causal effects implementation
There is an R package which implements this DR estimator of the ATE (as well as some other things), the npcausal package: https://github.com/ehkennedy/npcausal
The function that fits a DR estimator is ate() | Doubly robust estimation of causal effects implementation
There is an R package which implements this DR estimator of the ATE (as well as some other things), the npcausal package: https://github.com/ehkennedy/npcausal
The function that fits a DR estimator is |
30,493 | Robust estimation of Poisson distribution | @cardinal has telegraphed an answer in comments. Let's flesh it out. His point is that although general linear models (such as implemented by lm and, in this case, glmRob) appear intended to evaluate relationships among variables, they can be powerful tools for studying a single variable, too. The trick relies on the fact that regressing data against a constant is just another way of estimating its average value ("location").
As an example, generate some Poisson-distributed data:
set.seed(17)
x <- rpois(10, lambda=2)
In this case, R will produce the vector $(1,5,2,3,2,2,1,1,3,1)$ of values for x from a Poisson distribution of mean $2$. Estimate its location with glmRob:
library(robust)
glmrob(x ~ 1, family=poisson())
The response tells us the intercept is estimated at $0.7268$. Of course, anyone using a statistical method needs to know how it works: when you use generalized linear models with the Poisson family, the standard "link" function is the logarithm. This means the intercept is the logarithm of the estimated location. So we compute
exp(0.7268)
The result, $2.0685$, is comfortably close to $2$: the procedure seems to work. To see what it is doing, plot the data:
plot(x, ylim=c(0, max(x)))
abline(exp(0.7268), 0, col="red")
The fitted line is purely horizontal and therefore estimates the middle of the vertical values: our data. That's all that's going on.
To check robustness, let's create a bad outlier by tacking a few zeros onto the first value of x:
x[1] <- 100
This time, for greater flexibility in post-processing, we will save the output of glmRob:
m <- glmrob(x ~ 1, family=poisson())
To obtain the estimated average we can request
exp(m$coefficients)
The value this time equals $2.496$: a little off, but not too far off, given that the average value of x (obtained as mean(x)) is $12$. That is the sense in which this procedure is "robust." More information can be obtained via
summary(m)
Its output shows us, among other things, that the weight associated with the outlying value of $100$ in x[1] is just $0.02179$, almost $0$, pinpointing the suspected outlier. | Robust estimation of Poisson distribution | @cardinal has telegraphed an answer in comments. Let's flesh it out. His point is that although general linear models (such as implemented by lm and, in this case, glmRob) appear intended to evaluat | Robust estimation of Poisson distribution
@cardinal has telegraphed an answer in comments. Let's flesh it out. His point is that although general linear models (such as implemented by lm and, in this case, glmRob) appear intended to evaluate relationships among variables, they can be powerful tools for studying a single variable, too. The trick relies on the fact that regressing data against a constant is just another way of estimating its average value ("location").
As an example, generate some Poisson-distributed data:
set.seed(17)
x <- rpois(10, lambda=2)
In this case, R will produce the vector $(1,5,2,3,2,2,1,1,3,1)$ of values for x from a Poisson distribution of mean $2$. Estimate its location with glmRob:
library(robust)
glmrob(x ~ 1, family=poisson())
The response tells us the intercept is estimated at $0.7268$. Of course, anyone using a statistical method needs to know how it works: when you use generalized linear models with the Poisson family, the standard "link" function is the logarithm. This means the intercept is the logarithm of the estimated location. So we compute
exp(0.7268)
The result, $2.0685$, is comfortably close to $2$: the procedure seems to work. To see what it is doing, plot the data:
plot(x, ylim=c(0, max(x)))
abline(exp(0.7268), 0, col="red")
The fitted line is purely horizontal and therefore estimates the middle of the vertical values: our data. That's all that's going on.
To check robustness, let's create a bad outlier by tacking a few zeros onto the first value of x:
x[1] <- 100
This time, for greater flexibility in post-processing, we will save the output of glmRob:
m <- glmrob(x ~ 1, family=poisson())
To obtain the estimated average we can request
exp(m$coefficients)
The value this time equals $2.496$: a little off, but not too far off, given that the average value of x (obtained as mean(x)) is $12$. That is the sense in which this procedure is "robust." More information can be obtained via
summary(m)
Its output shows us, among other things, that the weight associated with the outlying value of $100$ in x[1] is just $0.02179$, almost $0$, pinpointing the suspected outlier. | Robust estimation of Poisson distribution
@cardinal has telegraphed an answer in comments. Let's flesh it out. His point is that although general linear models (such as implemented by lm and, in this case, glmRob) appear intended to evaluat |
30,494 | How is $\chi^2$ value converted to p-value? | The $p$-value is the area under the $\chi^2$ density to the right of the observed test statistic. Therefore, to calculate the $p$-value by hand you need to calculate an integral.
In particular, a $\chi^2$ random variable with $k$ degrees of freedom has probability density
$$f(x;\,k) =
\begin{cases}
\frac{x^{(k/2)-1} e^{-x/2}}{2^{k/2} \Gamma\left(\frac{k}{2}\right)}, & x \geq 0; \\ 0, & \text{otherwise}.
\end{cases}$$
Suppose you observe a test statistic $\lambda$. Then, the $p$-value corresponding to $\lambda$ is
$$
p = \int_{\lambda}^{\infty}
\frac{x^{(k/2)-1} e^{-x/2}}{2^{k/2} \Gamma\left(\frac{k}{2}\right)}
dx $$
After trying to evaluate this integral by hand, it may become clear to you why people use tables (and computers) for calculating such things.
Edit: (This was in the comments but seemed important enough to add here) Note that you can write the $p$-value using special functions:
$$ p = 1−\frac{γ(k/2,λ/2)}{Γ(k/2)} $$
where $\gamma(\cdot,\cdot)$ is the lower incomplete gamma function. | How is $\chi^2$ value converted to p-value? | The $p$-value is the area under the $\chi^2$ density to the right of the observed test statistic. Therefore, to calculate the $p$-value by hand you need to calculate an integral.
In particular, a $\c | How is $\chi^2$ value converted to p-value?
The $p$-value is the area under the $\chi^2$ density to the right of the observed test statistic. Therefore, to calculate the $p$-value by hand you need to calculate an integral.
In particular, a $\chi^2$ random variable with $k$ degrees of freedom has probability density
$$f(x;\,k) =
\begin{cases}
\frac{x^{(k/2)-1} e^{-x/2}}{2^{k/2} \Gamma\left(\frac{k}{2}\right)}, & x \geq 0; \\ 0, & \text{otherwise}.
\end{cases}$$
Suppose you observe a test statistic $\lambda$. Then, the $p$-value corresponding to $\lambda$ is
$$
p = \int_{\lambda}^{\infty}
\frac{x^{(k/2)-1} e^{-x/2}}{2^{k/2} \Gamma\left(\frac{k}{2}\right)}
dx $$
After trying to evaluate this integral by hand, it may become clear to you why people use tables (and computers) for calculating such things.
Edit: (This was in the comments but seemed important enough to add here) Note that you can write the $p$-value using special functions:
$$ p = 1−\frac{γ(k/2,λ/2)}{Γ(k/2)} $$
where $\gamma(\cdot,\cdot)$ is the lower incomplete gamma function. | How is $\chi^2$ value converted to p-value?
The $p$-value is the area under the $\chi^2$ density to the right of the observed test statistic. Therefore, to calculate the $p$-value by hand you need to calculate an integral.
In particular, a $\c |
30,495 | Normalizing a 2D-histogram and getting the marginals | Densities can be hard to work with. Whenever you can, calculate with the total probabilities instead.
Usually, histograms begin with point data, such as these 10,000 points:
A general 2D histogram tessellates the domain of the two variables (here, the unit square) by a collection $P$ of non-overlapping polygons (usually rectangles or triangles). To each polygon $p$ it assigns a density (probability or relative frequency per unit area). This is computed as
$$\text{density}(p) = \frac{\text{count within}(p)}{\text{total count}} / \text{area}(p).$$
The $\frac{\text{count within}(p)}{\text{total count}}$ part estimates the probability of $p$; when it is divided by the area of $p$, you get the density.
In this 2D histogram, the unit square has been tessellated by rectangles of width $1/26$ and height $1/11$.
2D histograms represent probability (or relative frequency) by means of volume: for each polygon $p$, the product of height and base, or density * area, returns $\frac{\text{count within}(p)}{\text{total count}}$. As a check, the total probability is obtained by summing the volumes over all polygons:
$$\eqalign{
\text{Total probability} &= \sum_{p \in P}\text{area}(p)\text{density}(p) \\
&= \sum_{p \in P}\frac{\text{count within}(p)}{\text{total count}} \\
&= \frac{1}{{\text{total count}}}\sum_{p \in P}\text{count within}(p) \\
&= \frac{\text{total count}}{\text{total count}},
}$$
which is equal to unity, as it should. (In the previous image, the histogram heights range from $0$ almost up to $3$; the total volume is $1$.)
To get a marginal density--say, along the x-axis--you slice that axis into bins at cutpoints $x_0 \lt x_1 \lt x_2 \lt \cdots \lt x_n$. (These are allowed to have unequal lengths.) Each bin $(x_i, x_{i+1}]$ determines a vertical slice of the 2D region (consisting of all points $(x,y)$ for which $x_i \lt x \le x_{i+1}$). Let's call this strip $S_i$. As with any (1D) histogram, compute (or estimate) the total probability within each bin and divide by the bin width to obtain the histogram value. The total probability is usually estimated as the the sum of probabilities in polygons intersecting that strip:
$$\Pr[x_i\lt x \le x_{i+1}] = \sum_{p \in P}\text{area}(p\cap S_i)\text{density}(p).$$
Dividing this value by $x_{i+1} - x_i$ gives the value for the histogram of the marginal distribution. Repeat for each bin.
The x-marginal histogram is in blue and the y-marginal histogram is in red. Each has a total area of $1$. | Normalizing a 2D-histogram and getting the marginals | Densities can be hard to work with. Whenever you can, calculate with the total probabilities instead.
Usually, histograms begin with point data, such as these 10,000 points:
A general 2D histogram t | Normalizing a 2D-histogram and getting the marginals
Densities can be hard to work with. Whenever you can, calculate with the total probabilities instead.
Usually, histograms begin with point data, such as these 10,000 points:
A general 2D histogram tessellates the domain of the two variables (here, the unit square) by a collection $P$ of non-overlapping polygons (usually rectangles or triangles). To each polygon $p$ it assigns a density (probability or relative frequency per unit area). This is computed as
$$\text{density}(p) = \frac{\text{count within}(p)}{\text{total count}} / \text{area}(p).$$
The $\frac{\text{count within}(p)}{\text{total count}}$ part estimates the probability of $p$; when it is divided by the area of $p$, you get the density.
In this 2D histogram, the unit square has been tessellated by rectangles of width $1/26$ and height $1/11$.
2D histograms represent probability (or relative frequency) by means of volume: for each polygon $p$, the product of height and base, or density * area, returns $\frac{\text{count within}(p)}{\text{total count}}$. As a check, the total probability is obtained by summing the volumes over all polygons:
$$\eqalign{
\text{Total probability} &= \sum_{p \in P}\text{area}(p)\text{density}(p) \\
&= \sum_{p \in P}\frac{\text{count within}(p)}{\text{total count}} \\
&= \frac{1}{{\text{total count}}}\sum_{p \in P}\text{count within}(p) \\
&= \frac{\text{total count}}{\text{total count}},
}$$
which is equal to unity, as it should. (In the previous image, the histogram heights range from $0$ almost up to $3$; the total volume is $1$.)
To get a marginal density--say, along the x-axis--you slice that axis into bins at cutpoints $x_0 \lt x_1 \lt x_2 \lt \cdots \lt x_n$. (These are allowed to have unequal lengths.) Each bin $(x_i, x_{i+1}]$ determines a vertical slice of the 2D region (consisting of all points $(x,y)$ for which $x_i \lt x \le x_{i+1}$). Let's call this strip $S_i$. As with any (1D) histogram, compute (or estimate) the total probability within each bin and divide by the bin width to obtain the histogram value. The total probability is usually estimated as the the sum of probabilities in polygons intersecting that strip:
$$\Pr[x_i\lt x \le x_{i+1}] = \sum_{p \in P}\text{area}(p\cap S_i)\text{density}(p).$$
Dividing this value by $x_{i+1} - x_i$ gives the value for the histogram of the marginal distribution. Repeat for each bin.
The x-marginal histogram is in blue and the y-marginal histogram is in red. Each has a total area of $1$. | Normalizing a 2D-histogram and getting the marginals
Densities can be hard to work with. Whenever you can, calculate with the total probabilities instead.
Usually, histograms begin with point data, such as these 10,000 points:
A general 2D histogram t |
30,496 | Normalizing a 2D-histogram and getting the marginals | If you normalize a histogram, you don't need to take the bin-width into account. You can look at it like this: When estimating a histogram from continuous data, you basically discretize it first (by setting each value to the bin center which is closest to it) and then generate a discrete histogram for the discretized data. This is simply normalized by dividing by the sum over all its elements.
When taking the bin-width into account you are essentially not estimating a histogram anymore, but a piecewise constant approximation to the density. If you do that, then you also have to take the bin-width into account for marginalizing. This means your code for the marginals needs to be
prob1M = sum(prob2D, 2)*L;
Edit: Histogram, discrete probability distribution, density
Since there seems to be some confusion about histograms, I try to make it clearer.
Let's first look at discrete data, e.g. integers from 1 to 10. When you observe $m$ samples from a random variable that takes values between 1 and 10 you can build a histogram. If you normalize that histogram (by dividing it by $m$), you get a discrete probability distribution $p_1,...,p_{10}$. There is no bin width involved, since discrete probability distributions are normalized by summing, i.e. $\sum_{i=1}^{10}p_i = 1$.
When you bin continuous data, what you really do is to (1) discretize it first and (2) bin it. Let's say, we have $m$ samples of a random variable $X$ that takes on values in $[0,10]$. When building a histogram, we first map each value to the nearest bin center, i.e. $1.34$ gets mapped to $1.5$, $0.1$ gets mapped to $0.5$, and so on. Afterwards, we again build a histogram an normalize it. However, now the histogram values have a different meaning. For example, when we look at the first bin for values between $0$ and $1$, then this contains all the probability of the values $X$ that end up in that bin, i.e. if $q$ is the true underlying density, then $p_{1} = \int_0^1 q(x) dx$. Therefore, you the value of the normalized histogram already implicitly contains the bin-width. Furthermore, there is really nothing to integrate, since the histogram runs again over discrete values, i.e. $0.5, 1.5, ..., 9.5$.
Now, if you want to use the histogram to get a continuous density, one that integrates to one, the you need to take into account the bin width. You can do that by defining $$p(x) = \sum_{i=1}^{10} \frac{p_i}{\Delta} \cdot I_i.$$
$I_i$ is a function that is one on the $i$th bin and zero otherwise. $\Delta$ is the bin width which would be $\Delta = 1$ in our example. This function integrates to one. For our example
$$\int_0^{10} p(x) dx = \int_0^{10} \sum_{i=1}^{10} \frac{p_i}{\Delta} \cdot I_i dx
= \sum_{i=1}^{10} \frac{p_i}{\Delta} \cdot \underbrace{\int_0^{10} \sum_{i=1}^{10} I_i dx}_{=\Delta} = \sum_{i=1}^{10} p_i = 1.
$$
What this does is to approximate the true density by a pieceswise constant function.
If you want to estimate mutual information, you can use the histogram values itself, without bin-width. For a continuous density you have $p_i = \int_{ith\:bin} q(x)dx = \Delta \cdot \xi_i$ where $\xi_i$ is a value from the bin such that the equality holds. Since you can write it as a product, the bin-width in the quotient cancels and the sum converges to the Riemann integral for the mutual information. | Normalizing a 2D-histogram and getting the marginals | If you normalize a histogram, you don't need to take the bin-width into account. You can look at it like this: When estimating a histogram from continuous data, you basically discretize it first (by s | Normalizing a 2D-histogram and getting the marginals
If you normalize a histogram, you don't need to take the bin-width into account. You can look at it like this: When estimating a histogram from continuous data, you basically discretize it first (by setting each value to the bin center which is closest to it) and then generate a discrete histogram for the discretized data. This is simply normalized by dividing by the sum over all its elements.
When taking the bin-width into account you are essentially not estimating a histogram anymore, but a piecewise constant approximation to the density. If you do that, then you also have to take the bin-width into account for marginalizing. This means your code for the marginals needs to be
prob1M = sum(prob2D, 2)*L;
Edit: Histogram, discrete probability distribution, density
Since there seems to be some confusion about histograms, I try to make it clearer.
Let's first look at discrete data, e.g. integers from 1 to 10. When you observe $m$ samples from a random variable that takes values between 1 and 10 you can build a histogram. If you normalize that histogram (by dividing it by $m$), you get a discrete probability distribution $p_1,...,p_{10}$. There is no bin width involved, since discrete probability distributions are normalized by summing, i.e. $\sum_{i=1}^{10}p_i = 1$.
When you bin continuous data, what you really do is to (1) discretize it first and (2) bin it. Let's say, we have $m$ samples of a random variable $X$ that takes on values in $[0,10]$. When building a histogram, we first map each value to the nearest bin center, i.e. $1.34$ gets mapped to $1.5$, $0.1$ gets mapped to $0.5$, and so on. Afterwards, we again build a histogram an normalize it. However, now the histogram values have a different meaning. For example, when we look at the first bin for values between $0$ and $1$, then this contains all the probability of the values $X$ that end up in that bin, i.e. if $q$ is the true underlying density, then $p_{1} = \int_0^1 q(x) dx$. Therefore, you the value of the normalized histogram already implicitly contains the bin-width. Furthermore, there is really nothing to integrate, since the histogram runs again over discrete values, i.e. $0.5, 1.5, ..., 9.5$.
Now, if you want to use the histogram to get a continuous density, one that integrates to one, the you need to take into account the bin width. You can do that by defining $$p(x) = \sum_{i=1}^{10} \frac{p_i}{\Delta} \cdot I_i.$$
$I_i$ is a function that is one on the $i$th bin and zero otherwise. $\Delta$ is the bin width which would be $\Delta = 1$ in our example. This function integrates to one. For our example
$$\int_0^{10} p(x) dx = \int_0^{10} \sum_{i=1}^{10} \frac{p_i}{\Delta} \cdot I_i dx
= \sum_{i=1}^{10} \frac{p_i}{\Delta} \cdot \underbrace{\int_0^{10} \sum_{i=1}^{10} I_i dx}_{=\Delta} = \sum_{i=1}^{10} p_i = 1.
$$
What this does is to approximate the true density by a pieceswise constant function.
If you want to estimate mutual information, you can use the histogram values itself, without bin-width. For a continuous density you have $p_i = \int_{ith\:bin} q(x)dx = \Delta \cdot \xi_i$ where $\xi_i$ is a value from the bin such that the equality holds. Since you can write it as a product, the bin-width in the quotient cancels and the sum converges to the Riemann integral for the mutual information. | Normalizing a 2D-histogram and getting the marginals
If you normalize a histogram, you don't need to take the bin-width into account. You can look at it like this: When estimating a histogram from continuous data, you basically discretize it first (by s |
30,497 | Overmatching bias and confounding variables | From Modern Epidemiology 3rd Edition by Rothman, Greenland and Lash:
There are at least three forms of overmatching. The first refers to matching that harms statistical efficiency, such as case-control matching on a variable associated with exposure but not disease. The second refers to matching that harms validity, such as matching on an intermediate between exposure and disease. The third refers to matching that harms cost-efficiency.
The answer from AndyW is about the second form of overmatching. Briefly, here's how they all work:
1: In order to be a confounder, one of the criteria is that the covariate be associated with both the outcome and the exposure. If it's only associated with one of them, its not a confounder, and all you've succeeded in doing is widening your confidence interval.
To explore this type of overmatching further, consider a matched case-control study of a binary exposure, with one control matched to each case on one or more confounders. Each stratum in the analysis will consist of one case and one control unless some strata can be combined. If the case and its matched control are either both exposed or both unexposed, one margin of the 2 x 2 table will be 0 ... such a pair of subjects will not contribute any information to the analysis. If one stratifies on correlates of exposure, one will increase the chance that such tables will occur and thus tend to increase the information lost in stratified analysis.
2: This is partially discussed by AndyW. Matching on an intermediate factor will bias your estimate, as will matching on something affected by both the exposure and outcome. This is essentially controlling on a collider, and any technique that does so will bias your estimate.
If, however, the potential matching factor is affected by exposure and the factor in turn affects disease (i.e., is an intermediate variable), or is affected by both exposure and disease, then matching on the factor will bias both the crude and adjusted effect estimates. In these situations, case-control matching is nothing more than an irreparable form of selection bias.
3: This is more of a study design problem. Extensively matching on variables that you needn't match on for reasons 1 & 2 can cause you to reject easily obtained controls (friends, family, nearby social network, etc.) in favor of far harder to obtain controls that can be matched on the unnecessary set of covariates. That costs money - money that could have been spent on more subjects, better exposure or disease ascertainment, etc., for no appreciable gain in bias or precision, and indeed having threatened both. | Overmatching bias and confounding variables | From Modern Epidemiology 3rd Edition by Rothman, Greenland and Lash:
There are at least three forms of overmatching. The first refers to matching that harms statistical efficiency, such as case-contr | Overmatching bias and confounding variables
From Modern Epidemiology 3rd Edition by Rothman, Greenland and Lash:
There are at least three forms of overmatching. The first refers to matching that harms statistical efficiency, such as case-control matching on a variable associated with exposure but not disease. The second refers to matching that harms validity, such as matching on an intermediate between exposure and disease. The third refers to matching that harms cost-efficiency.
The answer from AndyW is about the second form of overmatching. Briefly, here's how they all work:
1: In order to be a confounder, one of the criteria is that the covariate be associated with both the outcome and the exposure. If it's only associated with one of them, its not a confounder, and all you've succeeded in doing is widening your confidence interval.
To explore this type of overmatching further, consider a matched case-control study of a binary exposure, with one control matched to each case on one or more confounders. Each stratum in the analysis will consist of one case and one control unless some strata can be combined. If the case and its matched control are either both exposed or both unexposed, one margin of the 2 x 2 table will be 0 ... such a pair of subjects will not contribute any information to the analysis. If one stratifies on correlates of exposure, one will increase the chance that such tables will occur and thus tend to increase the information lost in stratified analysis.
2: This is partially discussed by AndyW. Matching on an intermediate factor will bias your estimate, as will matching on something affected by both the exposure and outcome. This is essentially controlling on a collider, and any technique that does so will bias your estimate.
If, however, the potential matching factor is affected by exposure and the factor in turn affects disease (i.e., is an intermediate variable), or is affected by both exposure and disease, then matching on the factor will bias both the crude and adjusted effect estimates. In these situations, case-control matching is nothing more than an irreparable form of selection bias.
3: This is more of a study design problem. Extensively matching on variables that you needn't match on for reasons 1 & 2 can cause you to reject easily obtained controls (friends, family, nearby social network, etc.) in favor of far harder to obtain controls that can be matched on the unnecessary set of covariates. That costs money - money that could have been spent on more subjects, better exposure or disease ascertainment, etc., for no appreciable gain in bias or precision, and indeed having threatened both. | Overmatching bias and confounding variables
From Modern Epidemiology 3rd Edition by Rothman, Greenland and Lash:
There are at least three forms of overmatching. The first refers to matching that harms statistical efficiency, such as case-contr |
30,498 | Overmatching bias and confounding variables | While I was ignorant of the "over-matching" terminology as well, one example of the same idea I have heard in Economic and Statistic lingo could be matching on an "intermediate" outcome. See Andrew Gelman's posts on the subject
Amusing example of the fallacy of controlling for an intermediate outcome, or, the tyranny of statistical methodology and how it can lead even well-intentioned sociobiologists astray.
Does having sons make you more conservative? Maybe, maybe not. A problem with controlling for an intermediate outcome
This is the same problem as described at the beginning of the article you cite (Marsh et al., 2002)
If the exposure itself leads to the confounder, or has equal status
with it, then stratifying by the confounder will also stratify by the
exposure, and the relation of the exposure to the disease will be
obscured. This is called over-matching ...
Gelman gives a conceptually clear example in the "Does making sons make you more conservative" post. In just simple terms (absent of examples) it is just you have your causal directions backwards. | Overmatching bias and confounding variables | While I was ignorant of the "over-matching" terminology as well, one example of the same idea I have heard in Economic and Statistic lingo could be matching on an "intermediate" outcome. See Andrew Ge | Overmatching bias and confounding variables
While I was ignorant of the "over-matching" terminology as well, one example of the same idea I have heard in Economic and Statistic lingo could be matching on an "intermediate" outcome. See Andrew Gelman's posts on the subject
Amusing example of the fallacy of controlling for an intermediate outcome, or, the tyranny of statistical methodology and how it can lead even well-intentioned sociobiologists astray.
Does having sons make you more conservative? Maybe, maybe not. A problem with controlling for an intermediate outcome
This is the same problem as described at the beginning of the article you cite (Marsh et al., 2002)
If the exposure itself leads to the confounder, or has equal status
with it, then stratifying by the confounder will also stratify by the
exposure, and the relation of the exposure to the disease will be
obscured. This is called over-matching ...
Gelman gives a conceptually clear example in the "Does making sons make you more conservative" post. In just simple terms (absent of examples) it is just you have your causal directions backwards. | Overmatching bias and confounding variables
While I was ignorant of the "over-matching" terminology as well, one example of the same idea I have heard in Economic and Statistic lingo could be matching on an "intermediate" outcome. See Andrew Ge |
30,499 | How to group-center / standardize variables in R? | Here is a possible plyr solution. Note that it relies on the base transform() function.
my.df <- data.frame(x=rnorm(100, mean=10),
sex=sample(c("M","F"), 100, rep=T),
group=gl(5, 20, labels=LETTERS[1:5]))
library(plyr)
ddply(my.df, c("sex", "group"), transform, x.std = scale(x))
(We can check whether it works as expected with e.g., with(subset(my.df, sex=="F" & group=="A"), scale(x)))
Basically, the 2nd argument describes how to "split" the data, the 3rd argument what function to apply to each chunk. The above will append a variable x.std to the data.frame. Use x if you want to replace your original variable by the scaled one. | How to group-center / standardize variables in R? | Here is a possible plyr solution. Note that it relies on the base transform() function.
my.df <- data.frame(x=rnorm(100, mean=10),
sex=sample(c("M","F"), 100, rep=T),
| How to group-center / standardize variables in R?
Here is a possible plyr solution. Note that it relies on the base transform() function.
my.df <- data.frame(x=rnorm(100, mean=10),
sex=sample(c("M","F"), 100, rep=T),
group=gl(5, 20, labels=LETTERS[1:5]))
library(plyr)
ddply(my.df, c("sex", "group"), transform, x.std = scale(x))
(We can check whether it works as expected with e.g., with(subset(my.df, sex=="F" & group=="A"), scale(x)))
Basically, the 2nd argument describes how to "split" the data, the 3rd argument what function to apply to each chunk. The above will append a variable x.std to the data.frame. Use x if you want to replace your original variable by the scaled one. | How to group-center / standardize variables in R?
Here is a possible plyr solution. Note that it relies on the base transform() function.
my.df <- data.frame(x=rnorm(100, mean=10),
sex=sample(c("M","F"), 100, rep=T),
|
30,500 | How to group-center / standardize variables in R? | group.center <- function(var,grp) {
return(var-tapply(var,grp,mean,na.rm=T)[grp])
} | How to group-center / standardize variables in R? | group.center <- function(var,grp) {
return(var-tapply(var,grp,mean,na.rm=T)[grp])
} | How to group-center / standardize variables in R?
group.center <- function(var,grp) {
return(var-tapply(var,grp,mean,na.rm=T)[grp])
} | How to group-center / standardize variables in R?
group.center <- function(var,grp) {
return(var-tapply(var,grp,mean,na.rm=T)[grp])
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.