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 |
|---|---|---|---|---|---|---|
26,001 | Why ever use Durbin-Watson instead of testing autocorrelation? | The Durbin-Watson test is how you test for autocorrelation. Plotting an ACF is like making a Q-Q plot to test for normality. Being able to eyeball a Q-Q plot to test for normality is useful, but a Kolmogorov-Smirnov or Levene test supplements what you see in the plot because a hypothesis test for normality is more conclusive.
With regard to multiple lags, you could use a generalized Durbin-Watson statistic, run a few hypothesis tests, and do a Bonferroni correction to correct for multiple testing. You could also run a Breusch-Godfrey test, which tests for the presence of a correlation of any order. | Why ever use Durbin-Watson instead of testing autocorrelation? | The Durbin-Watson test is how you test for autocorrelation. Plotting an ACF is like making a Q-Q plot to test for normality. Being able to eyeball a Q-Q plot to test for normality is useful, but a K | Why ever use Durbin-Watson instead of testing autocorrelation?
The Durbin-Watson test is how you test for autocorrelation. Plotting an ACF is like making a Q-Q plot to test for normality. Being able to eyeball a Q-Q plot to test for normality is useful, but a Kolmogorov-Smirnov or Levene test supplements what you see in the plot because a hypothesis test for normality is more conclusive.
With regard to multiple lags, you could use a generalized Durbin-Watson statistic, run a few hypothesis tests, and do a Bonferroni correction to correct for multiple testing. You could also run a Breusch-Godfrey test, which tests for the presence of a correlation of any order. | Why ever use Durbin-Watson instead of testing autocorrelation?
The Durbin-Watson test is how you test for autocorrelation. Plotting an ACF is like making a Q-Q plot to test for normality. Being able to eyeball a Q-Q plot to test for normality is useful, but a K |
26,002 | Question about normality assumption of t-test | For t-tests, according to most texts there's an assumption that the population data is normally distributed. I don't see why that is. Doesn't a t-test only require that the sampling distribution of sample means is normally distributed, and not the population?
The t-statistic consists of a ratio of two quantities, both random variables. It doesn't just consist of a numerator.
For the t-statistic to have the t-distribution, you need not just that the sample mean have a normal distribution. You also need:
that the $s$ in the denominator be such that $s^2/\sigma^2 \sim \chi^2_d$*
that the numerator and denominator be independent.
*(the value of $d$ depends on which test -- in the one-sample $t$ we have $d=n-1$)
For those three things to be actually true, you need that the original data are normally distributed.
If it is the case that t-test only ultimately requires normality in the sampling distribution, the population can look like any distribution, right?
Let's take iid as given for a moment. For the CLT to hold the population has to fit the conditions... -- the population has to have a distribution to which the CLT applies. So no, since there are population distributions for which the CLT doesn't apply.
So long as there is a reasonable sample size. Is that not what the central limit theorem states?
No, the CLT actually says not one word about "reasonable sample size".
It actually says nothing at all about what happens at any finite sample size.
I'm thinking of a specific distribution right now. It's one to which the CLT certainly does apply. But at $n=10^{15}$, the distribution of the sample mean is plainly non-normal. Yet I doubt that any sample in the history of humanity has ever had that many values in it. So - outside of tautology - what does 'reasonable $n$' mean?
So you have twin problems:
A. The effect that people usually attribute to the CLT -- the increasingly close approach to normality of the distributions of sample means at small/moderate sample sizes -- isn't actually stated in the CLT**.
B. "Something not so far from normal in the numerator" isn't enough to get the statistic having a t-distribution
**(Something like the Berry-Esseen theorem gets you more like what people are seeing when they look at the effect of increasing sample size on distribution of sample means.)
The CLT and Slutsky's theorem together give you (as long as all their assumptions hold) that as $n\to\infty$, the distribution of the t-statistic approaches standard normal. It doesn't say whether any given finite $n$ might be enough for some purpose.
Note however that this doesn't of itself suggest that the t-distribution is particularly likely to be a poor approximation for the distribution of the t-statistic under H0.
The one sample test is sensitive to skewness and somewhat sensitive to heavy tails and the two sample test is somewhat sensitive to heavy tails. but the effect of heavy tails is typically to make the test more conservative. If the loss of power doesn't worry you, you might be less bothered by this than by the possibility of an anti-conservative test. It's much harder to make the two sample test anti-conservative, though possible, and even then, it's hard to make it substantial.
In that sense at least, the two sample t-test is typically pretty level-"robust" (more strictly either close to accurate, or conservatve) even in quite modest sized samples, but this doesn't come from the CLT itself. If you care about power, you may have more to worry about.
I would worry about power, but a lot of people don't seem to give it much attention in these kinds of considerations. | Question about normality assumption of t-test | For t-tests, according to most texts there's an assumption that the population data is normally distributed. I don't see why that is. Doesn't a t-test only require that the sampling distribution of sa | Question about normality assumption of t-test
For t-tests, according to most texts there's an assumption that the population data is normally distributed. I don't see why that is. Doesn't a t-test only require that the sampling distribution of sample means is normally distributed, and not the population?
The t-statistic consists of a ratio of two quantities, both random variables. It doesn't just consist of a numerator.
For the t-statistic to have the t-distribution, you need not just that the sample mean have a normal distribution. You also need:
that the $s$ in the denominator be such that $s^2/\sigma^2 \sim \chi^2_d$*
that the numerator and denominator be independent.
*(the value of $d$ depends on which test -- in the one-sample $t$ we have $d=n-1$)
For those three things to be actually true, you need that the original data are normally distributed.
If it is the case that t-test only ultimately requires normality in the sampling distribution, the population can look like any distribution, right?
Let's take iid as given for a moment. For the CLT to hold the population has to fit the conditions... -- the population has to have a distribution to which the CLT applies. So no, since there are population distributions for which the CLT doesn't apply.
So long as there is a reasonable sample size. Is that not what the central limit theorem states?
No, the CLT actually says not one word about "reasonable sample size".
It actually says nothing at all about what happens at any finite sample size.
I'm thinking of a specific distribution right now. It's one to which the CLT certainly does apply. But at $n=10^{15}$, the distribution of the sample mean is plainly non-normal. Yet I doubt that any sample in the history of humanity has ever had that many values in it. So - outside of tautology - what does 'reasonable $n$' mean?
So you have twin problems:
A. The effect that people usually attribute to the CLT -- the increasingly close approach to normality of the distributions of sample means at small/moderate sample sizes -- isn't actually stated in the CLT**.
B. "Something not so far from normal in the numerator" isn't enough to get the statistic having a t-distribution
**(Something like the Berry-Esseen theorem gets you more like what people are seeing when they look at the effect of increasing sample size on distribution of sample means.)
The CLT and Slutsky's theorem together give you (as long as all their assumptions hold) that as $n\to\infty$, the distribution of the t-statistic approaches standard normal. It doesn't say whether any given finite $n$ might be enough for some purpose.
Note however that this doesn't of itself suggest that the t-distribution is particularly likely to be a poor approximation for the distribution of the t-statistic under H0.
The one sample test is sensitive to skewness and somewhat sensitive to heavy tails and the two sample test is somewhat sensitive to heavy tails. but the effect of heavy tails is typically to make the test more conservative. If the loss of power doesn't worry you, you might be less bothered by this than by the possibility of an anti-conservative test. It's much harder to make the two sample test anti-conservative, though possible, and even then, it's hard to make it substantial.
In that sense at least, the two sample t-test is typically pretty level-"robust" (more strictly either close to accurate, or conservatve) even in quite modest sized samples, but this doesn't come from the CLT itself. If you care about power, you may have more to worry about.
I would worry about power, but a lot of people don't seem to give it much attention in these kinds of considerations. | Question about normality assumption of t-test
For t-tests, according to most texts there's an assumption that the population data is normally distributed. I don't see why that is. Doesn't a t-test only require that the sampling distribution of sa |
26,003 | Question about normality assumption of t-test | Just got an interview question related to this and had the same question in my head (while providing my answers). Did a little bit of reading and found the following explanation (excerpt from here) provides the best intuition for me:
According to the central limit theorem, the distribution of sample mean values tends to follow the normal distribution regardless of the population distribution if the sample size is large enough [2]. For this reason, there are some books which suggest that if the sample size per group is large enough, the t-test can be applied without the normality test. Strictly speaking, this is not true. Although the central limit theorem guarantees the normal distribution of the sample mean values, it does not guarantee the normal distribution of samples in the population. The purpose of the t-test is to compare certain characteristics representing groups, and the mean values become representative when the population has a normal distribution. This is the reason why satisfaction of the normality assumption is essential in the t-test. Therefore, even if the sample size is sufficient, it is recommended that the results of the normality test be checked first. Wellknown methods of normality testing include the Shapiro–Wilks test and the Kolmogorov–Smirnov test. | Question about normality assumption of t-test | Just got an interview question related to this and had the same question in my head (while providing my answers). Did a little bit of reading and found the following explanation (excerpt from here) pr | Question about normality assumption of t-test
Just got an interview question related to this and had the same question in my head (while providing my answers). Did a little bit of reading and found the following explanation (excerpt from here) provides the best intuition for me:
According to the central limit theorem, the distribution of sample mean values tends to follow the normal distribution regardless of the population distribution if the sample size is large enough [2]. For this reason, there are some books which suggest that if the sample size per group is large enough, the t-test can be applied without the normality test. Strictly speaking, this is not true. Although the central limit theorem guarantees the normal distribution of the sample mean values, it does not guarantee the normal distribution of samples in the population. The purpose of the t-test is to compare certain characteristics representing groups, and the mean values become representative when the population has a normal distribution. This is the reason why satisfaction of the normality assumption is essential in the t-test. Therefore, even if the sample size is sufficient, it is recommended that the results of the normality test be checked first. Wellknown methods of normality testing include the Shapiro–Wilks test and the Kolmogorov–Smirnov test. | Question about normality assumption of t-test
Just got an interview question related to this and had the same question in my head (while providing my answers). Did a little bit of reading and found the following explanation (excerpt from here) pr |
26,004 | Is calculating a percentile the same as evaluating a cumulative density function? | You are close but not exactly right. Remember that the area under a probability distribution has to sum to 1. The cumulative density function (CDF) is a function with values in [0,1] since CDF is defined as
$$
F(a) = \int_{-\infty}^{a} f(x) dx
$$
where f(x) is the probability density function. Then 50th percentile is the total probability of 50% of the samples which means the point where CDF reaches 0.5. Or in more general terms, the p'th percentile is the point where the CDF reaches p/100. | Is calculating a percentile the same as evaluating a cumulative density function? | You are close but not exactly right. Remember that the area under a probability distribution has to sum to 1. The cumulative density function (CDF) is a function with values in [0,1] since CDF is defi | Is calculating a percentile the same as evaluating a cumulative density function?
You are close but not exactly right. Remember that the area under a probability distribution has to sum to 1. The cumulative density function (CDF) is a function with values in [0,1] since CDF is defined as
$$
F(a) = \int_{-\infty}^{a} f(x) dx
$$
where f(x) is the probability density function. Then 50th percentile is the total probability of 50% of the samples which means the point where CDF reaches 0.5. Or in more general terms, the p'th percentile is the point where the CDF reaches p/100. | Is calculating a percentile the same as evaluating a cumulative density function?
You are close but not exactly right. Remember that the area under a probability distribution has to sum to 1. The cumulative density function (CDF) is a function with values in [0,1] since CDF is defi |
26,005 | Is calculating a percentile the same as evaluating a cumulative density function? | No. Essentially, calculating a percentile (or a p-quantile) is equivalent to finding the inverse of a CDF.
Note that the inverse, in the usual sense, of a CDF may not exist
and the notion of generalized inverse should be introduced. To make
discussion precise, we clarify all definitions.
Definition: A CDF is a function $F:[-\infty,\infty]\rightarrow[0,1]$
that satisfies the following conditions:
(Increasing) For any $x,y\in[-\infty,\infty]$, if $x<y$, then
$F(x)\leq F(y)$,
(Right-continuity) For any $a\in\mathbb{R}$, we have that $F(a)=\lim_{x\rightarrow a+}F(x)$,
$F(-\infty)=\lim_{x\rightarrow-\infty}F(x)=0$, and
$F(\infty)=\lim_{x\rightarrow\infty}F(x)=1$.
We have at least two versions of generalized inverse of $F$, denoted
by $Inv_{1}F$ and $Inv_{2}F$, which are defined as follows.
$Inv_{1}F:[0,1]\rightarrow[-\infty,\infty]$, defined by $Inv_{1}F(x)=\inf\{y\mid F(y)\geq x\},$
$Inv_{2}F:[0,1]\rightarrow[-\infty,\infty]$, defined by $Inv_{2}F(x)=\inf\{y\mid F(y)>x\}$.
Here, we adopt the convention that $\inf(\emptyset)=\infty$.
If I remember correctly, given $p\in[0,1]$, the $p$-quantile is
simply defined as $Inv_{1}F(p)$.
Of course, if $F$ is strictly increasing and continuous, both versions
of generalized inverse are the same and reduce to the usual inverse
of function$F^{-1}:[0,1]\rightarrow[-\infty,\infty].$
For more information: https://people.math.ethz.ch/~embrecht/ftp/generalized_inverse.pdf | Is calculating a percentile the same as evaluating a cumulative density function? | No. Essentially, calculating a percentile (or a p-quantile) is equivalent to finding the inverse of a CDF.
Note that the inverse, in the usual sense, of a CDF may not exist
and the notion of generali | Is calculating a percentile the same as evaluating a cumulative density function?
No. Essentially, calculating a percentile (or a p-quantile) is equivalent to finding the inverse of a CDF.
Note that the inverse, in the usual sense, of a CDF may not exist
and the notion of generalized inverse should be introduced. To make
discussion precise, we clarify all definitions.
Definition: A CDF is a function $F:[-\infty,\infty]\rightarrow[0,1]$
that satisfies the following conditions:
(Increasing) For any $x,y\in[-\infty,\infty]$, if $x<y$, then
$F(x)\leq F(y)$,
(Right-continuity) For any $a\in\mathbb{R}$, we have that $F(a)=\lim_{x\rightarrow a+}F(x)$,
$F(-\infty)=\lim_{x\rightarrow-\infty}F(x)=0$, and
$F(\infty)=\lim_{x\rightarrow\infty}F(x)=1$.
We have at least two versions of generalized inverse of $F$, denoted
by $Inv_{1}F$ and $Inv_{2}F$, which are defined as follows.
$Inv_{1}F:[0,1]\rightarrow[-\infty,\infty]$, defined by $Inv_{1}F(x)=\inf\{y\mid F(y)\geq x\},$
$Inv_{2}F:[0,1]\rightarrow[-\infty,\infty]$, defined by $Inv_{2}F(x)=\inf\{y\mid F(y)>x\}$.
Here, we adopt the convention that $\inf(\emptyset)=\infty$.
If I remember correctly, given $p\in[0,1]$, the $p$-quantile is
simply defined as $Inv_{1}F(p)$.
Of course, if $F$ is strictly increasing and continuous, both versions
of generalized inverse are the same and reduce to the usual inverse
of function$F^{-1}:[0,1]\rightarrow[-\infty,\infty].$
For more information: https://people.math.ethz.ch/~embrecht/ftp/generalized_inverse.pdf | Is calculating a percentile the same as evaluating a cumulative density function?
No. Essentially, calculating a percentile (or a p-quantile) is equivalent to finding the inverse of a CDF.
Note that the inverse, in the usual sense, of a CDF may not exist
and the notion of generali |
26,006 | adjusted odds ratio vs odds ratio | Unadjusted OR is a simple ratio of probabilities of outcome in two groups $p_1, p_2$ (check here or here):
$$OR = \frac{p_1/(1-p_1)}{p_2/(1-p_2)} $$
and it can be derived from the results of logistic regression (as opposed to counting a simple ratio calculated by hand from a $2 \times 2$ table). However, in logistic regression you can include other, confounding variables so to control their influence on your dependent variable and if you do so, what you can get is OR that is adjusted for the influence of confounders (see also here). So you adjust by controlling additional variables in logistic regression model. | adjusted odds ratio vs odds ratio | Unadjusted OR is a simple ratio of probabilities of outcome in two groups $p_1, p_2$ (check here or here):
$$OR = \frac{p_1/(1-p_1)}{p_2/(1-p_2)} $$
and it can be derived from the results of logistic | adjusted odds ratio vs odds ratio
Unadjusted OR is a simple ratio of probabilities of outcome in two groups $p_1, p_2$ (check here or here):
$$OR = \frac{p_1/(1-p_1)}{p_2/(1-p_2)} $$
and it can be derived from the results of logistic regression (as opposed to counting a simple ratio calculated by hand from a $2 \times 2$ table). However, in logistic regression you can include other, confounding variables so to control their influence on your dependent variable and if you do so, what you can get is OR that is adjusted for the influence of confounders (see also here). So you adjust by controlling additional variables in logistic regression model. | adjusted odds ratio vs odds ratio
Unadjusted OR is a simple ratio of probabilities of outcome in two groups $p_1, p_2$ (check here or here):
$$OR = \frac{p_1/(1-p_1)}{p_2/(1-p_2)} $$
and it can be derived from the results of logistic |
26,007 | Consistency of 2SLS with Binary endogenous variable | There has been a similar question regarding a probit first stage and an OLS second stage. In the answer I have provided a link to notes that contain a formal proof of the inconsistency of this regression which is formally known as "forbidden regression", as it was termed by Jerry Hausman. The main reason for the inconsistency of the probit first stage/OLS second stage approach is that neither the expectations operator nor the linear projections operator pass through a non-linear first stage. Therefore the fitted values from a first stage probit are only uncorrelated with the second stage error term under very restrictive assumptions that almost never hold in practice.
Be aware though that the formal proof of the inconsistency of the forbidden regression is quite elaborate, if I remember correctly.
If you have a model
$$Y_i = \alpha + \beta X_i + \epsilon_i$$
where $Y_i$ is a continuous outcomes and $X_i$ is a binary endogenous variable, you can run the first stage
$$X_i = a + Z'_i\pi + \eta_i$$
via OLS and use the fitted values $\widehat{X}_i$ instead of $X_i$ in the second stage. This is the linear probability model you were referring to. Given that there is no problem for expectations or linear projections for this linear first stage, your 2SLS estimates will be consistent albeit less efficient than they could be if we were to take into account the non-linear nature of $X_i$.
Consistency of this approach stems from the fact that whilst a non-linear model may fit the conditional expectations function more closely for limited dependent variables this does not matter much if you are interested in the marginal effect. In the linear probability model the coefficients themselves are marginal effects evaluated at the mean, so if the marginal effect at the mean is what you are after (and usually people are) then this is what you want given the the linear model gives the best linear approximations to non-linear conditional expectation functions.
The same holds true if $Y_i$ is binary, too.
For a more detailed discussion of this have a look at Kit Baum's excellent lecture notes on this topic. From slide 7 he discusses the use of the linear probability model in the 2SLS context.
Finally, if you really want to use probit because you want more efficient estimates then there is another way which is also mentioned in Wooldridge (2010) "Econometric Analysis of Cross Section and Panel Data". The above linked answer includes it, I repeat it here for completeness. As an applied example see Adams et al. (2009) who use a three-step procedure that goes as follows:
use probit to regress the endogenous variable on the instrument(s) and exogenous variables
use the predicted values from the previous step in an OLS first stage together with the exogenous (but without the instrumental) variables
do the second stage as usual
This procedure does not fall for the forbidden regression problem but potentially delivers more efficient estimates of your parameter of interest. | Consistency of 2SLS with Binary endogenous variable | There has been a similar question regarding a probit first stage and an OLS second stage. In the answer I have provided a link to notes that contain a formal proof of the inconsistency of this regress | Consistency of 2SLS with Binary endogenous variable
There has been a similar question regarding a probit first stage and an OLS second stage. In the answer I have provided a link to notes that contain a formal proof of the inconsistency of this regression which is formally known as "forbidden regression", as it was termed by Jerry Hausman. The main reason for the inconsistency of the probit first stage/OLS second stage approach is that neither the expectations operator nor the linear projections operator pass through a non-linear first stage. Therefore the fitted values from a first stage probit are only uncorrelated with the second stage error term under very restrictive assumptions that almost never hold in practice.
Be aware though that the formal proof of the inconsistency of the forbidden regression is quite elaborate, if I remember correctly.
If you have a model
$$Y_i = \alpha + \beta X_i + \epsilon_i$$
where $Y_i$ is a continuous outcomes and $X_i$ is a binary endogenous variable, you can run the first stage
$$X_i = a + Z'_i\pi + \eta_i$$
via OLS and use the fitted values $\widehat{X}_i$ instead of $X_i$ in the second stage. This is the linear probability model you were referring to. Given that there is no problem for expectations or linear projections for this linear first stage, your 2SLS estimates will be consistent albeit less efficient than they could be if we were to take into account the non-linear nature of $X_i$.
Consistency of this approach stems from the fact that whilst a non-linear model may fit the conditional expectations function more closely for limited dependent variables this does not matter much if you are interested in the marginal effect. In the linear probability model the coefficients themselves are marginal effects evaluated at the mean, so if the marginal effect at the mean is what you are after (and usually people are) then this is what you want given the the linear model gives the best linear approximations to non-linear conditional expectation functions.
The same holds true if $Y_i$ is binary, too.
For a more detailed discussion of this have a look at Kit Baum's excellent lecture notes on this topic. From slide 7 he discusses the use of the linear probability model in the 2SLS context.
Finally, if you really want to use probit because you want more efficient estimates then there is another way which is also mentioned in Wooldridge (2010) "Econometric Analysis of Cross Section and Panel Data". The above linked answer includes it, I repeat it here for completeness. As an applied example see Adams et al. (2009) who use a three-step procedure that goes as follows:
use probit to regress the endogenous variable on the instrument(s) and exogenous variables
use the predicted values from the previous step in an OLS first stage together with the exogenous (but without the instrumental) variables
do the second stage as usual
This procedure does not fall for the forbidden regression problem but potentially delivers more efficient estimates of your parameter of interest. | Consistency of 2SLS with Binary endogenous variable
There has been a similar question regarding a probit first stage and an OLS second stage. In the answer I have provided a link to notes that contain a formal proof of the inconsistency of this regress |
26,008 | How do FDR procedures estimate a False Discovery Rate without a model of base rates? | I think that's a really good question; too many people use the Benjamini-Hochberg procedure (abbreviated BH; possibly the most popular procedure to control the FDR) as a black box. Indeed there is an underlying assumption it makes on the statistics and it is nicely hidden in the definition of the p-values!
For a well-defined p-value $P$ it holds that $P$ is uniformly distributed ($P\sim U[0,1]$) under the null hypothesis. Sometimes it might even be that $\Pr[P\leq t] \leq t$, i.e. that $P$ is stochastically smaller than uniform, but this only makes the procedures more conservative (and therefore still valid). Thus, by calculating your p-values, using a t-test or really any test of your choice, you are providing the information about the distribution under the null hypothesis.
But notice here that I kept talking about the null hypothesis; so what you mentioned about knowledge of the base rate of true positives is not needed, you only need knowledge of the base rate of false positives! Why is this?
Let $R$ denote the number of all the rejected (positive) hypotheses and $V$ the false positives, then:
$$ \text{FDR} = \mathbb E\left[\frac{V}{\max(R,1)}\right] \approx \frac{\mathbb E[V]}{\mathbb E[R]}$$
So to estimate the FDR you need a way of estimating $\mathbb E[R]$, $\mathbb E[V]$. We will now look at decision rules which reject all p-values $\leq t$. To make this clear in the notation I will also write $FDR(t),R(t),V(t)$ for the corresponding quantities/random variables of such a procedure.
Since $\mathbb E[R(t)]$ is just the expectation of the total number of rejections, you can unbiasedly estimate it by the number of rejections you observe, so $\mathbb E[R(t)] \approx R(t)$, i.e. simply by counting how many of your p-values are $\leq t$.
Now what about $\mathbb E[V]$? Well assume $m_0$ of your $m$ total hypotheses are null hypotheses, then by the uniformity (or sub-uniformity) of the p-values under the null you get:
$$\mathbb E[V(t)] = \sum_{i \text{ null}} \Pr[P_i \leq t] \leq m_0 t$$
But we still do not know $m_0$, but we know that $m_0 \leq m$, so a conservative upper bound would just be $\mathbb E[V(t)] \leq m t$. Therefore, since we just need an upper bound on the number of false positives, it is enough that we know their distribution! And this is exactly what the BH procedure does.
So, while Aarong Zeng's comment that "the BH procedure is a way to control the FDR at the given level q. It's not about estimating the FDR" is not false, it is also highly misleading! The BH procedure actually does estimate the FDR for each given threshold $t$. And then it chooses the biggest threshold, such that the estimated FDR is below $\alpha$. Indeed the "adjusted p-value" of hypothesis $i$ is essentially just an estimate of the FDR at the threshold $t=p_i$ (up to isotonization). I think the standard BH algorithm hides this fact a bit, but it is easy to show the equivalence of these two approaches (also called the "equivalence theorem" in the Multiple testing literature).
As a final remark, there do exist methods such as Storey's procedure which even estimate $m_0$ from the data; this can increase power by a tiny bit. Also in principle you are right, one could also model the distribution under the alternative (your true positive base rate) to get more powerful procedures; but so far the multiple testing research has mainly focused on maintaining control of type-I error rather than maximizing power. One difficulty would also be that in many cases each of your true alternatives will have a different alternative distribution (e.g. different power for different hypotheses), while under the null all p-values have the same distribution. This makes the modelling of the true positive rate even more difficult. | How do FDR procedures estimate a False Discovery Rate without a model of base rates? | I think that's a really good question; too many people use the Benjamini-Hochberg procedure (abbreviated BH; possibly the most popular procedure to control the FDR) as a black box. Indeed there is an | How do FDR procedures estimate a False Discovery Rate without a model of base rates?
I think that's a really good question; too many people use the Benjamini-Hochberg procedure (abbreviated BH; possibly the most popular procedure to control the FDR) as a black box. Indeed there is an underlying assumption it makes on the statistics and it is nicely hidden in the definition of the p-values!
For a well-defined p-value $P$ it holds that $P$ is uniformly distributed ($P\sim U[0,1]$) under the null hypothesis. Sometimes it might even be that $\Pr[P\leq t] \leq t$, i.e. that $P$ is stochastically smaller than uniform, but this only makes the procedures more conservative (and therefore still valid). Thus, by calculating your p-values, using a t-test or really any test of your choice, you are providing the information about the distribution under the null hypothesis.
But notice here that I kept talking about the null hypothesis; so what you mentioned about knowledge of the base rate of true positives is not needed, you only need knowledge of the base rate of false positives! Why is this?
Let $R$ denote the number of all the rejected (positive) hypotheses and $V$ the false positives, then:
$$ \text{FDR} = \mathbb E\left[\frac{V}{\max(R,1)}\right] \approx \frac{\mathbb E[V]}{\mathbb E[R]}$$
So to estimate the FDR you need a way of estimating $\mathbb E[R]$, $\mathbb E[V]$. We will now look at decision rules which reject all p-values $\leq t$. To make this clear in the notation I will also write $FDR(t),R(t),V(t)$ for the corresponding quantities/random variables of such a procedure.
Since $\mathbb E[R(t)]$ is just the expectation of the total number of rejections, you can unbiasedly estimate it by the number of rejections you observe, so $\mathbb E[R(t)] \approx R(t)$, i.e. simply by counting how many of your p-values are $\leq t$.
Now what about $\mathbb E[V]$? Well assume $m_0$ of your $m$ total hypotheses are null hypotheses, then by the uniformity (or sub-uniformity) of the p-values under the null you get:
$$\mathbb E[V(t)] = \sum_{i \text{ null}} \Pr[P_i \leq t] \leq m_0 t$$
But we still do not know $m_0$, but we know that $m_0 \leq m$, so a conservative upper bound would just be $\mathbb E[V(t)] \leq m t$. Therefore, since we just need an upper bound on the number of false positives, it is enough that we know their distribution! And this is exactly what the BH procedure does.
So, while Aarong Zeng's comment that "the BH procedure is a way to control the FDR at the given level q. It's not about estimating the FDR" is not false, it is also highly misleading! The BH procedure actually does estimate the FDR for each given threshold $t$. And then it chooses the biggest threshold, such that the estimated FDR is below $\alpha$. Indeed the "adjusted p-value" of hypothesis $i$ is essentially just an estimate of the FDR at the threshold $t=p_i$ (up to isotonization). I think the standard BH algorithm hides this fact a bit, but it is easy to show the equivalence of these two approaches (also called the "equivalence theorem" in the Multiple testing literature).
As a final remark, there do exist methods such as Storey's procedure which even estimate $m_0$ from the data; this can increase power by a tiny bit. Also in principle you are right, one could also model the distribution under the alternative (your true positive base rate) to get more powerful procedures; but so far the multiple testing research has mainly focused on maintaining control of type-I error rather than maximizing power. One difficulty would also be that in many cases each of your true alternatives will have a different alternative distribution (e.g. different power for different hypotheses), while under the null all p-values have the same distribution. This makes the modelling of the true positive rate even more difficult. | How do FDR procedures estimate a False Discovery Rate without a model of base rates?
I think that's a really good question; too many people use the Benjamini-Hochberg procedure (abbreviated BH; possibly the most popular procedure to control the FDR) as a black box. Indeed there is an |
26,009 | How do FDR procedures estimate a False Discovery Rate without a model of base rates? | As suggested by @air, the Benjamini-Hochberg (BH) procedure guarantees FDR control. It does not aim at estimating it. It thus requires a mere weak dependence assumption between test statistics. [1,2]
Methods that aim at estimating the FDR [e.g. 3,4,5] do require some assumptions on the generative process in order to estimate it.
They typically assume test statistics are independent.
They will also assume something on the null distribution of the test statistics. Departures from this null distribution, together with the independence assumption, can thus be attributed to effects, and the FDR may be estimated.
Note that these ideas reappear in the semi-supervised novelty detection literature. [6].
[1] Benjamini, Y., and Y. Hochberg. “Controlling the False Discovery Rate: A Practical and Powerful Approach to Multiple Testing.” JOURNAL-ROYAL STATISTICAL SOCIETY SERIES B 57 (1995): 289–289.
[2] Benjamini, Y., and D. Yekutieli. “The Control of the False Discovery Rate in Multiple Testing under Dependency.” ANNALS OF STATISTICS 29, no. 4 (2001): 1165–88.
[3] Storey, J.D. “A Direct Approach to False Discovery Rates.” Journal Of The Royal Statistical Society Series B 64, no. 3 (2002): 479–98. doi:10.1111/1467-9868.00346.
[4] Efron, B. “Microarrays, Empirical Bayes and the Two-Groups Model.” Statistical Science 23, no. 1 (2008): 1–22.
[5] Jin, Jiashun, and T. Tony Cai. “Estimating the Null and the Proportion of Nonnull Effects in Large-Scale Multiple Comparisons.” Journal of the American Statistical Association 102, no. 478 (June 1, 2007): 495–506. doi:10.1198/016214507000000167.
[6] Claesen, Marc, Jesse Davis, Frank De Smet, and Bart De Moor. “Assessing Binary Classifiers Using Only Positive and Unlabeled Data.” arXiv:1504.06837 [cs, Stat], April 26, 2015. http://arxiv.org/abs/1504.06837. | How do FDR procedures estimate a False Discovery Rate without a model of base rates? | As suggested by @air, the Benjamini-Hochberg (BH) procedure guarantees FDR control. It does not aim at estimating it. It thus requires a mere weak dependence assumption between test statistics. [1,2]
| How do FDR procedures estimate a False Discovery Rate without a model of base rates?
As suggested by @air, the Benjamini-Hochberg (BH) procedure guarantees FDR control. It does not aim at estimating it. It thus requires a mere weak dependence assumption between test statistics. [1,2]
Methods that aim at estimating the FDR [e.g. 3,4,5] do require some assumptions on the generative process in order to estimate it.
They typically assume test statistics are independent.
They will also assume something on the null distribution of the test statistics. Departures from this null distribution, together with the independence assumption, can thus be attributed to effects, and the FDR may be estimated.
Note that these ideas reappear in the semi-supervised novelty detection literature. [6].
[1] Benjamini, Y., and Y. Hochberg. “Controlling the False Discovery Rate: A Practical and Powerful Approach to Multiple Testing.” JOURNAL-ROYAL STATISTICAL SOCIETY SERIES B 57 (1995): 289–289.
[2] Benjamini, Y., and D. Yekutieli. “The Control of the False Discovery Rate in Multiple Testing under Dependency.” ANNALS OF STATISTICS 29, no. 4 (2001): 1165–88.
[3] Storey, J.D. “A Direct Approach to False Discovery Rates.” Journal Of The Royal Statistical Society Series B 64, no. 3 (2002): 479–98. doi:10.1111/1467-9868.00346.
[4] Efron, B. “Microarrays, Empirical Bayes and the Two-Groups Model.” Statistical Science 23, no. 1 (2008): 1–22.
[5] Jin, Jiashun, and T. Tony Cai. “Estimating the Null and the Proportion of Nonnull Effects in Large-Scale Multiple Comparisons.” Journal of the American Statistical Association 102, no. 478 (June 1, 2007): 495–506. doi:10.1198/016214507000000167.
[6] Claesen, Marc, Jesse Davis, Frank De Smet, and Bart De Moor. “Assessing Binary Classifiers Using Only Positive and Unlabeled Data.” arXiv:1504.06837 [cs, Stat], April 26, 2015. http://arxiv.org/abs/1504.06837. | How do FDR procedures estimate a False Discovery Rate without a model of base rates?
As suggested by @air, the Benjamini-Hochberg (BH) procedure guarantees FDR control. It does not aim at estimating it. It thus requires a mere weak dependence assumption between test statistics. [1,2]
|
26,010 | How do FDR procedures estimate a False Discovery Rate without a model of base rates? | When the true underlying model is unknown, we cannot compute the FDR, but can estimate the FDR value by permutation test. Basically the permutation test procedure is just doing the hypothesis test multiple times by change the outcome variable vector with its permutations. It can also be done based on the permutations of the samples, but not as common as the former one.
The paper here reviews the standard permutation procedure for FDR estimation, and also proposed a new FDR estimator. It should be able to address your question. | How do FDR procedures estimate a False Discovery Rate without a model of base rates? | When the true underlying model is unknown, we cannot compute the FDR, but can estimate the FDR value by permutation test. Basically the permutation test procedure is just doing the hypothesis test mul | How do FDR procedures estimate a False Discovery Rate without a model of base rates?
When the true underlying model is unknown, we cannot compute the FDR, but can estimate the FDR value by permutation test. Basically the permutation test procedure is just doing the hypothesis test multiple times by change the outcome variable vector with its permutations. It can also be done based on the permutations of the samples, but not as common as the former one.
The paper here reviews the standard permutation procedure for FDR estimation, and also proposed a new FDR estimator. It should be able to address your question. | How do FDR procedures estimate a False Discovery Rate without a model of base rates?
When the true underlying model is unknown, we cannot compute the FDR, but can estimate the FDR value by permutation test. Basically the permutation test procedure is just doing the hypothesis test mul |
26,011 | How to find a density from a characteristic function? | Density functions are found with the inverse Fourier transform. The density function of the distribution, if such a density exists, will be given by
$$f(t) = \frac{1}{2\pi}\int_{\mathbb{R}}e^{-itx}\phi(x) dx = \frac{1}{2\pi}\int_{\mathbb{R}}e^{-itx}\left((1-x^2/2)e^{-x^2/4}\right) dx .$$
This integral can be split into two, each of which has an integrand of the form
$$\exp(-Q_t(x))x^{2k}$$
where $Q_t$ is a quadratic form with negative leading term and $k$ is a non-negative integer. This makes each integrand a Schwartz (rapidly decreasing) function, assuring its integrability for any $t$. The integrability proves it is continuous; the rapid decrease proves it is absolutely continuous. The integrals are readily performed by completing the square in the exponential, reducing them to multiples of even moments of the Gaussian distribution. The result is
$$f(t) = \frac{2}{\sqrt{\pi}} t^2 e^{-t^2}.$$
The continuity of $f$ confirms the earlier conclusion of absolute continuity of the distribution.
The square of this (symmetric) variable has a Gamma$(3/2, 1)$ distribution.
Alternatively, one might recognize that
$$\phi(t) = -2\left(-\frac{1}{2} + \frac{t^2}{4}\right)e^{-t^2/4} = (-i)^2\frac{d^2}{dt^2}2e^{-t^2/4}$$
is proportional to the second derivative of the Gaussian $e^{-t^2/4}$, implying (since the operator $-id/dt$ on characteristic functions is equivalent to multiplication of distribution functions by the variable) that the density $f(x)$ exists and is proportional to $x^2$ times the density whose c.f. is $2e^{-t^2/4}$. That is immediately recognizable as a Gaussian (Normal) distribution with density proportional to $e^{-x^2}$. At this point all one has to do is work out the normalizing constant of $2/\sqrt{\pi}$ via integration or by computing the variance of a Normal distribution with standard deviation $\sqrt{1/2}$. | How to find a density from a characteristic function? | Density functions are found with the inverse Fourier transform. The density function of the distribution, if such a density exists, will be given by
$$f(t) = \frac{1}{2\pi}\int_{\mathbb{R}}e^{-itx}\p | How to find a density from a characteristic function?
Density functions are found with the inverse Fourier transform. The density function of the distribution, if such a density exists, will be given by
$$f(t) = \frac{1}{2\pi}\int_{\mathbb{R}}e^{-itx}\phi(x) dx = \frac{1}{2\pi}\int_{\mathbb{R}}e^{-itx}\left((1-x^2/2)e^{-x^2/4}\right) dx .$$
This integral can be split into two, each of which has an integrand of the form
$$\exp(-Q_t(x))x^{2k}$$
where $Q_t$ is a quadratic form with negative leading term and $k$ is a non-negative integer. This makes each integrand a Schwartz (rapidly decreasing) function, assuring its integrability for any $t$. The integrability proves it is continuous; the rapid decrease proves it is absolutely continuous. The integrals are readily performed by completing the square in the exponential, reducing them to multiples of even moments of the Gaussian distribution. The result is
$$f(t) = \frac{2}{\sqrt{\pi}} t^2 e^{-t^2}.$$
The continuity of $f$ confirms the earlier conclusion of absolute continuity of the distribution.
The square of this (symmetric) variable has a Gamma$(3/2, 1)$ distribution.
Alternatively, one might recognize that
$$\phi(t) = -2\left(-\frac{1}{2} + \frac{t^2}{4}\right)e^{-t^2/4} = (-i)^2\frac{d^2}{dt^2}2e^{-t^2/4}$$
is proportional to the second derivative of the Gaussian $e^{-t^2/4}$, implying (since the operator $-id/dt$ on characteristic functions is equivalent to multiplication of distribution functions by the variable) that the density $f(x)$ exists and is proportional to $x^2$ times the density whose c.f. is $2e^{-t^2/4}$. That is immediately recognizable as a Gaussian (Normal) distribution with density proportional to $e^{-x^2}$. At this point all one has to do is work out the normalizing constant of $2/\sqrt{\pi}$ via integration or by computing the variance of a Normal distribution with standard deviation $\sqrt{1/2}$. | How to find a density from a characteristic function?
Density functions are found with the inverse Fourier transform. The density function of the distribution, if such a density exists, will be given by
$$f(t) = \frac{1}{2\pi}\int_{\mathbb{R}}e^{-itx}\p |
26,012 | When to terminate the Bayesian A/B test? | I'm glad you mentioned this example, as one project I am working on is writing a whole chapter on Bayesian A/B testing.
We are interested in two quantities: $P( p_A > p_B \;|\; data)$ and some measure of "increase". I'll discuss the $P( p_A > p_B \;|\; data)$ quantity first.
There are no error bounds on $P( p_A > p_B \;|\; \text{data})$, it is a true quantity. This is similar to saying "What is the mean of the posterior?", there is only 1 mean, and we can compute it by taking the average of all the samples (I'm ignoring any Monte Carlo errors, as they can be reduced to insignificance by sampling more). I think you are mixing up unknown quantities, where we can say something like "+- 3%", and posterior-computed quantities.
What I am saying is that $P(p_A > p_B \;|\; \text{data}) = 0.95$ is certain: given your observed data and priors, this is your conclusion.
Note that we will know $p_A > p_B$ quickly: it requires only moderate amounts of observations for different enough $p_A$ and $p_B$. It is much harder, and more interesting, to measure what increase A has over B (and often this is the goal of an A/B test: how much are we increasing conversions). You mentioned that $\frac{p_A - p_B}{p_B} >$ 5% -- how certain are you of this?
Note that while $p_A > p_B$ is a boolean, and hence easy to measure,$\frac{p_A - p_B}{p_B}$ is certainly not a boolean. It is a distribution of possibilities:
As more and more data is acquired, this distribution converges to the actual relative increase, one can say the distribution stabilizes. This is where I suggest thinking about terminating the experiment. Once this distribution seems to "calm down", and we can feel confident about the increase, then terminate the experiment. | When to terminate the Bayesian A/B test? | I'm glad you mentioned this example, as one project I am working on is writing a whole chapter on Bayesian A/B testing.
We are interested in two quantities: $P( p_A > p_B \;|\; data)$ and some measur | When to terminate the Bayesian A/B test?
I'm glad you mentioned this example, as one project I am working on is writing a whole chapter on Bayesian A/B testing.
We are interested in two quantities: $P( p_A > p_B \;|\; data)$ and some measure of "increase". I'll discuss the $P( p_A > p_B \;|\; data)$ quantity first.
There are no error bounds on $P( p_A > p_B \;|\; \text{data})$, it is a true quantity. This is similar to saying "What is the mean of the posterior?", there is only 1 mean, and we can compute it by taking the average of all the samples (I'm ignoring any Monte Carlo errors, as they can be reduced to insignificance by sampling more). I think you are mixing up unknown quantities, where we can say something like "+- 3%", and posterior-computed quantities.
What I am saying is that $P(p_A > p_B \;|\; \text{data}) = 0.95$ is certain: given your observed data and priors, this is your conclusion.
Note that we will know $p_A > p_B$ quickly: it requires only moderate amounts of observations for different enough $p_A$ and $p_B$. It is much harder, and more interesting, to measure what increase A has over B (and often this is the goal of an A/B test: how much are we increasing conversions). You mentioned that $\frac{p_A - p_B}{p_B} >$ 5% -- how certain are you of this?
Note that while $p_A > p_B$ is a boolean, and hence easy to measure,$\frac{p_A - p_B}{p_B}$ is certainly not a boolean. It is a distribution of possibilities:
As more and more data is acquired, this distribution converges to the actual relative increase, one can say the distribution stabilizes. This is where I suggest thinking about terminating the experiment. Once this distribution seems to "calm down", and we can feel confident about the increase, then terminate the experiment. | When to terminate the Bayesian A/B test?
I'm glad you mentioned this example, as one project I am working on is writing a whole chapter on Bayesian A/B testing.
We are interested in two quantities: $P( p_A > p_B \;|\; data)$ and some measur |
26,013 | When to terminate the Bayesian A/B test? | There seem to be two main approaches for decision making in Bayesian A/B testing. The first one is based on a paper by John Kruschke from Indiana University (K. Kruschke, Bayesian Estimation Supersedes the t Test, Journal of Experimental Psychology: General, 142, 573 (2013)). The decision rule used in this paper is based on the concept of Region Of Practical Equivalence (ROPE).
Another possibility is to use the concept of an Expected Loss. It has been proposed by Chris Stucchio (C. Stucchio, Bayesian A/B Testing at VWO). It is another approach that I would consider.
The approach suggested by Cam.Davidson.Pilon of looking at the posterior distribution of $(p_A - p_B) / p_A$ makes a lot of sense and would fit well within the ROPE method. Using the ROPE method has the added advantage of giving also a rule for when the experiment is inconclusive (not just when the "A" or "B" variants can be declared winners).
You can find more in this blog post: Bayesian A/B Testing: a step-by-step guide. It also includes some Python code snippets that are mostly based on a Python project hosted on Github. | When to terminate the Bayesian A/B test? | There seem to be two main approaches for decision making in Bayesian A/B testing. The first one is based on a paper by John Kruschke from Indiana University (K. Kruschke, Bayesian Estimation Supersede | When to terminate the Bayesian A/B test?
There seem to be two main approaches for decision making in Bayesian A/B testing. The first one is based on a paper by John Kruschke from Indiana University (K. Kruschke, Bayesian Estimation Supersedes the t Test, Journal of Experimental Psychology: General, 142, 573 (2013)). The decision rule used in this paper is based on the concept of Region Of Practical Equivalence (ROPE).
Another possibility is to use the concept of an Expected Loss. It has been proposed by Chris Stucchio (C. Stucchio, Bayesian A/B Testing at VWO). It is another approach that I would consider.
The approach suggested by Cam.Davidson.Pilon of looking at the posterior distribution of $(p_A - p_B) / p_A$ makes a lot of sense and would fit well within the ROPE method. Using the ROPE method has the added advantage of giving also a rule for when the experiment is inconclusive (not just when the "A" or "B" variants can be declared winners).
You can find more in this blog post: Bayesian A/B Testing: a step-by-step guide. It also includes some Python code snippets that are mostly based on a Python project hosted on Github. | When to terminate the Bayesian A/B test?
There seem to be two main approaches for decision making in Bayesian A/B testing. The first one is based on a paper by John Kruschke from Indiana University (K. Kruschke, Bayesian Estimation Supersede |
26,014 | When to terminate the Bayesian A/B test? | I've been experimenting with ways to stop a Bayesian A/B test and you're right - there aren't that many obvious ways from googling around. The method I like most is a precision based method, based on this: http://doingbayesiandataanalysis.blogspot.com/2013/11/optional-stopping-in-data-collection-p.html. However, I haven't found much mathematical literature around this, so right now it's just a good heuristic.
I've found that while my tests need to run much longer in order to hit some desired precision, it's more intuitive and you're giving time for the distribution of $P(A > B | data)$ to "calm down" in an objective way, i.e. rather than eye-balling it. | When to terminate the Bayesian A/B test? | I've been experimenting with ways to stop a Bayesian A/B test and you're right - there aren't that many obvious ways from googling around. The method I like most is a precision based method, based on | When to terminate the Bayesian A/B test?
I've been experimenting with ways to stop a Bayesian A/B test and you're right - there aren't that many obvious ways from googling around. The method I like most is a precision based method, based on this: http://doingbayesiandataanalysis.blogspot.com/2013/11/optional-stopping-in-data-collection-p.html. However, I haven't found much mathematical literature around this, so right now it's just a good heuristic.
I've found that while my tests need to run much longer in order to hit some desired precision, it's more intuitive and you're giving time for the distribution of $P(A > B | data)$ to "calm down" in an objective way, i.e. rather than eye-balling it. | When to terminate the Bayesian A/B test?
I've been experimenting with ways to stop a Bayesian A/B test and you're right - there aren't that many obvious ways from googling around. The method I like most is a precision based method, based on |
26,015 | How can I generate uniformly distributed points on a circle? | In the case of a circle, it suffices to generate a uniform angle, $\theta$, on $[0,2\pi)$ and then make the radius, $r$, whatever is desired. If you want Cartesian, rather than polar co-ordinates, $x=r\cos\theta$ and $y=r\sin\theta$.
One really easy way to generate random points from a uniform distribution a d-sphere (a hypersphere in a space of arbitrary dimension $d+1$, with surface of dimension $d$), is to generate multivariate standard normals $X_i\sim N_{d+1}(0,I)$, and then scale by their distance from the origin:
$$Y_i=X_i/||X_i||\,,$$
where $||.||$ is the Euclidean norm.
In R, let's generate on the surface of a (2-)sphere:
x <- matrix(rnorm(300),nc=3)
y <- x/sqrt(rowSums(x^2))
head(y)
[,1] [,2] [,3]
[1,] 0.9989826 -0.03752732 0.02500752
[2,] -0.1740810 0.08668104 0.98090887
[3,] -0.7121632 -0.70011994 0.05153283
[4,] -0.5843537 -0.49940138 0.63963192
[5,] -0.7059208 0.20506946 0.67795451
[6,] -0.6244425 -0.70917197 0.32733262
head(rowSums(y^2))
[1] 1 1 1 1 1 1
Here's those data from two slightly different angles:
You can then scale to whatever other radius you like.
In low dimensions, there are faster ways, but if your normal random number generator is reasonably fast, it's pretty good in higher dimensions.
There are several packages on CRAN for circular statistics, including CircStats and circular. There's probably something on CRAN that generates uniform distributions on n-spheres for n>1, but I don't know of it. | How can I generate uniformly distributed points on a circle? | In the case of a circle, it suffices to generate a uniform angle, $\theta$, on $[0,2\pi)$ and then make the radius, $r$, whatever is desired. If you want Cartesian, rather than polar co-ordinates, $x= | How can I generate uniformly distributed points on a circle?
In the case of a circle, it suffices to generate a uniform angle, $\theta$, on $[0,2\pi)$ and then make the radius, $r$, whatever is desired. If you want Cartesian, rather than polar co-ordinates, $x=r\cos\theta$ and $y=r\sin\theta$.
One really easy way to generate random points from a uniform distribution a d-sphere (a hypersphere in a space of arbitrary dimension $d+1$, with surface of dimension $d$), is to generate multivariate standard normals $X_i\sim N_{d+1}(0,I)$, and then scale by their distance from the origin:
$$Y_i=X_i/||X_i||\,,$$
where $||.||$ is the Euclidean norm.
In R, let's generate on the surface of a (2-)sphere:
x <- matrix(rnorm(300),nc=3)
y <- x/sqrt(rowSums(x^2))
head(y)
[,1] [,2] [,3]
[1,] 0.9989826 -0.03752732 0.02500752
[2,] -0.1740810 0.08668104 0.98090887
[3,] -0.7121632 -0.70011994 0.05153283
[4,] -0.5843537 -0.49940138 0.63963192
[5,] -0.7059208 0.20506946 0.67795451
[6,] -0.6244425 -0.70917197 0.32733262
head(rowSums(y^2))
[1] 1 1 1 1 1 1
Here's those data from two slightly different angles:
You can then scale to whatever other radius you like.
In low dimensions, there are faster ways, but if your normal random number generator is reasonably fast, it's pretty good in higher dimensions.
There are several packages on CRAN for circular statistics, including CircStats and circular. There's probably something on CRAN that generates uniform distributions on n-spheres for n>1, but I don't know of it. | How can I generate uniformly distributed points on a circle?
In the case of a circle, it suffices to generate a uniform angle, $\theta$, on $[0,2\pi)$ and then make the radius, $r$, whatever is desired. If you want Cartesian, rather than polar co-ordinates, $x= |
26,016 | How to calculate Kullback-Leibler divergence/distance? | To answer your question, we should recall the definition of KL divergence:
$$D_{KL}(Y||X) = \sum_{i=1}^N \ln \left( \frac{Y_i}{X_i} \right) Y_i$$
First of all you have to go from what you have to probability distributions. For this you should normalize your data such that it sums up to one:
$X_i := \frac{X_i}{\sum_{i=1}^N X_i}$; $Y_i := \frac{Y_i}{\sum_{i=1}^N Y_i}$; $Z_i := \frac{Z_i}{\sum_{i=1}^N Z_i}$
Then, for discrete values we have one very important assumption that is needed to evaluate KL-divergence and that is often violated:
$X_i = 0$ should imply $Y_i = 0$.
In case when both $X_i$ and $Y_i$ equals to zero, $\ln \left( Y_i / X_i \right) Y_i$ is assumed to be zero (as the limit value).
In your dataset it means that you can find $D_{KL}(X||Y)$, but not for example $D_{KL}(Y||X)$ (because of second entry).
What I could advise from practical point of view is:
either make your events "larger" such that you will have less zeros
or gain more data, such that you will cover even rare events with at least one entry.
If you can use neither of the advices above, then you will probably need to find another metric between the distributions. For example,
Mutual information, defined as $I(X, Y) = \sum_{i=1}^N \sum_{j=1}^N p(X_i, Y_j) \ln \left( \frac{p(X_i, Y_j)}{p(X_i) p(Y_j)} \right)$. Where $p(X_i, Y_i)$ is a joint probability of two events.
Hope it will help. | How to calculate Kullback-Leibler divergence/distance? | To answer your question, we should recall the definition of KL divergence:
$$D_{KL}(Y||X) = \sum_{i=1}^N \ln \left( \frac{Y_i}{X_i} \right) Y_i$$
First of all you have to go from what you have to prob | How to calculate Kullback-Leibler divergence/distance?
To answer your question, we should recall the definition of KL divergence:
$$D_{KL}(Y||X) = \sum_{i=1}^N \ln \left( \frac{Y_i}{X_i} \right) Y_i$$
First of all you have to go from what you have to probability distributions. For this you should normalize your data such that it sums up to one:
$X_i := \frac{X_i}{\sum_{i=1}^N X_i}$; $Y_i := \frac{Y_i}{\sum_{i=1}^N Y_i}$; $Z_i := \frac{Z_i}{\sum_{i=1}^N Z_i}$
Then, for discrete values we have one very important assumption that is needed to evaluate KL-divergence and that is often violated:
$X_i = 0$ should imply $Y_i = 0$.
In case when both $X_i$ and $Y_i$ equals to zero, $\ln \left( Y_i / X_i \right) Y_i$ is assumed to be zero (as the limit value).
In your dataset it means that you can find $D_{KL}(X||Y)$, but not for example $D_{KL}(Y||X)$ (because of second entry).
What I could advise from practical point of view is:
either make your events "larger" such that you will have less zeros
or gain more data, such that you will cover even rare events with at least one entry.
If you can use neither of the advices above, then you will probably need to find another metric between the distributions. For example,
Mutual information, defined as $I(X, Y) = \sum_{i=1}^N \sum_{j=1}^N p(X_i, Y_j) \ln \left( \frac{p(X_i, Y_j)}{p(X_i) p(Y_j)} \right)$. Where $p(X_i, Y_i)$ is a joint probability of two events.
Hope it will help. | How to calculate Kullback-Leibler divergence/distance?
To answer your question, we should recall the definition of KL divergence:
$$D_{KL}(Y||X) = \sum_{i=1}^N \ln \left( \frac{Y_i}{X_i} \right) Y_i$$
First of all you have to go from what you have to prob |
26,017 | How to calculate Kullback-Leibler divergence/distance? | You may want to set \epsilon to some very small value 0.00001 (say) and go ahead with non-zero values for all Probabilities and calculate KL scores.
Please let me know if this works. | How to calculate Kullback-Leibler divergence/distance? | You may want to set \epsilon to some very small value 0.00001 (say) and go ahead with non-zero values for all Probabilities and calculate KL scores.
Please let me know if this works. | How to calculate Kullback-Leibler divergence/distance?
You may want to set \epsilon to some very small value 0.00001 (say) and go ahead with non-zero values for all Probabilities and calculate KL scores.
Please let me know if this works. | How to calculate Kullback-Leibler divergence/distance?
You may want to set \epsilon to some very small value 0.00001 (say) and go ahead with non-zero values for all Probabilities and calculate KL scores.
Please let me know if this works. |
26,018 | Why is the coefficient of variation not valid when using data with positive and negative values? | Think about what CV is: Ratio of standard deviation to mean. But if the variable can have positive and negative values, the mean could be very close to 0; thus, CV no longer does what it is supposed to do: That is, give a sense of how big the sd is, compared to the mean.
EDIT: In a comment, I said that if you could sensibly add a constant to the variable, CV wasn't good. Here is an example:
set.seed(239920)
x <- rnorm(100, 10, 2)
min(x)#To check that none are negative
(CVX <- sd(x)/mean(x))
x2 <- x + 10
(CVX2 <- sd(x2)/mean(x2))
x2 is simply x + 10. I think it's intuitively clear that they are equally variable; but CV is different.
A real life example of this would be if x was temperature in degrees C and x2 was temperature in degrees K (although there one could argue that K is the proper scale, since it has a defined 0). | Why is the coefficient of variation not valid when using data with positive and negative values? | Think about what CV is: Ratio of standard deviation to mean. But if the variable can have positive and negative values, the mean could be very close to 0; thus, CV no longer does what it is supposed t | Why is the coefficient of variation not valid when using data with positive and negative values?
Think about what CV is: Ratio of standard deviation to mean. But if the variable can have positive and negative values, the mean could be very close to 0; thus, CV no longer does what it is supposed to do: That is, give a sense of how big the sd is, compared to the mean.
EDIT: In a comment, I said that if you could sensibly add a constant to the variable, CV wasn't good. Here is an example:
set.seed(239920)
x <- rnorm(100, 10, 2)
min(x)#To check that none are negative
(CVX <- sd(x)/mean(x))
x2 <- x + 10
(CVX2 <- sd(x2)/mean(x2))
x2 is simply x + 10. I think it's intuitively clear that they are equally variable; but CV is different.
A real life example of this would be if x was temperature in degrees C and x2 was temperature in degrees K (although there one could argue that K is the proper scale, since it has a defined 0). | Why is the coefficient of variation not valid when using data with positive and negative values?
Think about what CV is: Ratio of standard deviation to mean. But if the variable can have positive and negative values, the mean could be very close to 0; thus, CV no longer does what it is supposed t |
26,019 | Why is the coefficient of variation not valid when using data with positive and negative values? | I think of these as different models of variation. There are statistical models where the CV is constant. Where those work one may report a CV. There are models where the standard deviation is a power function of the mean. There are models where the standard deviation is constant. As a rule a constant-CV model is a better initial guess than a constant SD model, for ratio scale variables. You can speculate on why that would be true, perhaps based on prevalence of multiplicative rather than additive interactions.
Constant-CV modeling is often associated with logarithmic transformation. (An important exception is a nonnegative response that is sometimes zero.) There are a couple ways to look at that. First, if the CV is constant then logs are the conventional variance-stabilizing transformation. Alternatively, if your error model is lognormal with SD constant in the log scale, then the CV is a simple transformation of that SD. CV is about equal to log-scale SD when both are small.
Two ways of applying stats 101 methods like a standard deviation are to the data the way you got them or (especially if those are ratio scale) to their logs. You make the best first guess you can knowing that nature could be rather more complicated and that further study may be in order. Do take into account what folks have previously found productive with your kind of data.
Here's a case where this stuff is important. Chemical concentrations are sometimes summarized with CV or modeled in a log scale. However, pH is a log concentration. | Why is the coefficient of variation not valid when using data with positive and negative values? | I think of these as different models of variation. There are statistical models where the CV is constant. Where those work one may report a CV. There are models where the standard deviation is a po | Why is the coefficient of variation not valid when using data with positive and negative values?
I think of these as different models of variation. There are statistical models where the CV is constant. Where those work one may report a CV. There are models where the standard deviation is a power function of the mean. There are models where the standard deviation is constant. As a rule a constant-CV model is a better initial guess than a constant SD model, for ratio scale variables. You can speculate on why that would be true, perhaps based on prevalence of multiplicative rather than additive interactions.
Constant-CV modeling is often associated with logarithmic transformation. (An important exception is a nonnegative response that is sometimes zero.) There are a couple ways to look at that. First, if the CV is constant then logs are the conventional variance-stabilizing transformation. Alternatively, if your error model is lognormal with SD constant in the log scale, then the CV is a simple transformation of that SD. CV is about equal to log-scale SD when both are small.
Two ways of applying stats 101 methods like a standard deviation are to the data the way you got them or (especially if those are ratio scale) to their logs. You make the best first guess you can knowing that nature could be rather more complicated and that further study may be in order. Do take into account what folks have previously found productive with your kind of data.
Here's a case where this stuff is important. Chemical concentrations are sometimes summarized with CV or modeled in a log scale. However, pH is a log concentration. | Why is the coefficient of variation not valid when using data with positive and negative values?
I think of these as different models of variation. There are statistical models where the CV is constant. Where those work one may report a CV. There are models where the standard deviation is a po |
26,020 | Small and unbalanced sample sizes for two groups - what to do? | T-tests that assume equal variances of the two populations aren't valid when the two populations have different variances, & it's worse for unequal sample sizes. If the smallest sample size is the one with highest variance the test will have inflated Type I error). The Welch-Satterthwaite version of the t-test, on the other hand, does not assume equal variances. If you're thinking of the Fisher-Pitman permutation test, it too assumes equal variances (if you want to infer unequal means from a low p-value).
There are a number of other things you might want to think about :
(1) If the variances are clearly unequal are you still so interested in a difference between the means?
(2) Might effect estimates be of more use to you than p-values?
(3) Do you want to consider the multivariate nature of your data, rather than just making a series of univariate comparisons? | Small and unbalanced sample sizes for two groups - what to do? | T-tests that assume equal variances of the two populations aren't valid when the two populations have different variances, & it's worse for unequal sample sizes. If the smallest sample size is the on | Small and unbalanced sample sizes for two groups - what to do?
T-tests that assume equal variances of the two populations aren't valid when the two populations have different variances, & it's worse for unequal sample sizes. If the smallest sample size is the one with highest variance the test will have inflated Type I error). The Welch-Satterthwaite version of the t-test, on the other hand, does not assume equal variances. If you're thinking of the Fisher-Pitman permutation test, it too assumes equal variances (if you want to infer unequal means from a low p-value).
There are a number of other things you might want to think about :
(1) If the variances are clearly unequal are you still so interested in a difference between the means?
(2) Might effect estimates be of more use to you than p-values?
(3) Do you want to consider the multivariate nature of your data, rather than just making a series of univariate comparisons? | Small and unbalanced sample sizes for two groups - what to do?
T-tests that assume equal variances of the two populations aren't valid when the two populations have different variances, & it's worse for unequal sample sizes. If the smallest sample size is the on |
26,021 | Small and unbalanced sample sizes for two groups - what to do? | First, as Scortchi already point out, the T-test is not suited that well to your data, because of its assumptions on the distribution of the data.
To your second point, I would propose an alternative to the T-test. If your interest is only about the fact, if the distributions of your two samples are equal or not, you could also try to use the two-sided version of the Wilcoxon rank-sum test. The Wilcoxon rank-sum test is a non-parametric test. This kind of test is especially helpful, if you are not sure about the underlying distribution of your data.
It exists an exact solution of the test for small sample sizes as well as for large cohorts. In addition, there exists also an R package which realizes the Wilcoxon rank-sum test.
Since it is a parameter free test and also handles small sample sizes, the test should suit well for you test case. | Small and unbalanced sample sizes for two groups - what to do? | First, as Scortchi already point out, the T-test is not suited that well to your data, because of its assumptions on the distribution of the data.
To your second point, I would propose an alternative | Small and unbalanced sample sizes for two groups - what to do?
First, as Scortchi already point out, the T-test is not suited that well to your data, because of its assumptions on the distribution of the data.
To your second point, I would propose an alternative to the T-test. If your interest is only about the fact, if the distributions of your two samples are equal or not, you could also try to use the two-sided version of the Wilcoxon rank-sum test. The Wilcoxon rank-sum test is a non-parametric test. This kind of test is especially helpful, if you are not sure about the underlying distribution of your data.
It exists an exact solution of the test for small sample sizes as well as for large cohorts. In addition, there exists also an R package which realizes the Wilcoxon rank-sum test.
Since it is a parameter free test and also handles small sample sizes, the test should suit well for you test case. | Small and unbalanced sample sizes for two groups - what to do?
First, as Scortchi already point out, the T-test is not suited that well to your data, because of its assumptions on the distribution of the data.
To your second point, I would propose an alternative |
26,022 | Evaluation of classifiers: learning curves vs ROC curves | Learning curve is only a diagnosing tool, telling you how fast your model learns and whether your whole analysis is not stuck in a quirky area of too small sets / too small ensemble (if applies). The only part of this plot that is interesting for model assessment is the end of it, i.e. the final performance -- but this does not need a plot to be reported.
Selecting a model based on a learning curve as you sketched in your question is rather a poor idea, because you are likely to select a model that is best at overfitting on a too small sample set.
About ROCs... ROC curve is a method to assess binary models that produce a confidence score that an object belongs to one class; possibly also to find them best thresholds to convert them into an actual classifiers.
What you describe is rather an idea to plot your classifiers' performance as a scatterplot of TPR/FPR in the ROC space and use closest-to-top-left-corner criterion to select this which is best balanced between generating false alarms and misses -- this particular aim can be more elegantly achieved by simply selecting model with a best F-score (harmonic mean of precision and recall). | Evaluation of classifiers: learning curves vs ROC curves | Learning curve is only a diagnosing tool, telling you how fast your model learns and whether your whole analysis is not stuck in a quirky area of too small sets / too small ensemble (if applies). The | Evaluation of classifiers: learning curves vs ROC curves
Learning curve is only a diagnosing tool, telling you how fast your model learns and whether your whole analysis is not stuck in a quirky area of too small sets / too small ensemble (if applies). The only part of this plot that is interesting for model assessment is the end of it, i.e. the final performance -- but this does not need a plot to be reported.
Selecting a model based on a learning curve as you sketched in your question is rather a poor idea, because you are likely to select a model that is best at overfitting on a too small sample set.
About ROCs... ROC curve is a method to assess binary models that produce a confidence score that an object belongs to one class; possibly also to find them best thresholds to convert them into an actual classifiers.
What you describe is rather an idea to plot your classifiers' performance as a scatterplot of TPR/FPR in the ROC space and use closest-to-top-left-corner criterion to select this which is best balanced between generating false alarms and misses -- this particular aim can be more elegantly achieved by simply selecting model with a best F-score (harmonic mean of precision and recall). | Evaluation of classifiers: learning curves vs ROC curves
Learning curve is only a diagnosing tool, telling you how fast your model learns and whether your whole analysis is not stuck in a quirky area of too small sets / too small ensemble (if applies). The |
26,023 | A course in experimental design for data miners | [Noah Smith][1] and [David Smith][2] offered a course sometime ago at JHU with similar motivations.
Outline:
Lecture 1: introduction, review of statistics, hypothesis testing,
sampling
Lecture 2: statistics of interest: means, quantiles,
variance
Lectures 3–4: experiments with runtime and “space”
Lecture 5: exploratory data analysis
Lecture 6: parametric modeling, regression, and classification
Lecture 7: statistical debugging and profiling
Lecture 8: summary and review
For details, see Empirical Research Methods in Computer Science (600.408)
http://www.cs.jhu.edu/~nasmith/erm/ | A course in experimental design for data miners | [Noah Smith][1] and [David Smith][2] offered a course sometime ago at JHU with similar motivations.
Outline:
Lecture 1: introduction, review of statistics, hypothesis testing,
sampling
Lecture 2: | A course in experimental design for data miners
[Noah Smith][1] and [David Smith][2] offered a course sometime ago at JHU with similar motivations.
Outline:
Lecture 1: introduction, review of statistics, hypothesis testing,
sampling
Lecture 2: statistics of interest: means, quantiles,
variance
Lectures 3–4: experiments with runtime and “space”
Lecture 5: exploratory data analysis
Lecture 6: parametric modeling, regression, and classification
Lecture 7: statistical debugging and profiling
Lecture 8: summary and review
For details, see Empirical Research Methods in Computer Science (600.408)
http://www.cs.jhu.edu/~nasmith/erm/ | A course in experimental design for data miners
[Noah Smith][1] and [David Smith][2] offered a course sometime ago at JHU with similar motivations.
Outline:
Lecture 1: introduction, review of statistics, hypothesis testing,
sampling
Lecture 2: |
26,024 | A course in experimental design for data miners | I could sugest you two books instead of courses
Computational Text Analysis For Functional Genomics and Bioinformatics by
Soumya Raychaudhuri.
The Oxford Handbook of Functional Data Analysis by Edited by Frederic Ferraty and Yves Romain.
The first one, as an application to bioinformatics and the second one for any discipline | A course in experimental design for data miners | I could sugest you two books instead of courses
Computational Text Analysis For Functional Genomics and Bioinformatics by
Soumya Raychaudhuri.
The Oxford Handbook of Functional Data Analysis by Edi | A course in experimental design for data miners
I could sugest you two books instead of courses
Computational Text Analysis For Functional Genomics and Bioinformatics by
Soumya Raychaudhuri.
The Oxford Handbook of Functional Data Analysis by Edited by Frederic Ferraty and Yves Romain.
The first one, as an application to bioinformatics and the second one for any discipline | A course in experimental design for data miners
I could sugest you two books instead of courses
Computational Text Analysis For Functional Genomics and Bioinformatics by
Soumya Raychaudhuri.
The Oxford Handbook of Functional Data Analysis by Edi |
26,025 | A course in experimental design for data miners | Good question. I am keen to see the responses.
From a statistical standpoint two issues need addressing: most statistics and statistical designs discuss small sample statistics and most methodologies used by engineers are not "modern" statistics.
I have no immediate suggestion for the first problem beyond good schooling in data mining/exploration and the meaning of statistically different when faced with analysis of population (or large sample) statistics.
However two books of interest for introducing students to statistics would be from Rand Wilcox (a psychologist):
Wilcox, R. R. (2012). Introduction to Robust Estimation and Hypothesis Testing, 3rd Ed. Academic Press.
Wilcox, R. R. (2010). Fundamentals of Modern Statistical Methods: Substantially Improving Power and Accuracy, Springer, 2nd Ed. | A course in experimental design for data miners | Good question. I am keen to see the responses.
From a statistical standpoint two issues need addressing: most statistics and statistical designs discuss small sample statistics and most methodologie | A course in experimental design for data miners
Good question. I am keen to see the responses.
From a statistical standpoint two issues need addressing: most statistics and statistical designs discuss small sample statistics and most methodologies used by engineers are not "modern" statistics.
I have no immediate suggestion for the first problem beyond good schooling in data mining/exploration and the meaning of statistically different when faced with analysis of population (or large sample) statistics.
However two books of interest for introducing students to statistics would be from Rand Wilcox (a psychologist):
Wilcox, R. R. (2012). Introduction to Robust Estimation and Hypothesis Testing, 3rd Ed. Academic Press.
Wilcox, R. R. (2010). Fundamentals of Modern Statistical Methods: Substantially Improving Power and Accuracy, Springer, 2nd Ed. | A course in experimental design for data miners
Good question. I am keen to see the responses.
From a statistical standpoint two issues need addressing: most statistics and statistical designs discuss small sample statistics and most methodologie |
26,026 | Logistic regression: grouped and ungrouped variables (using R) | Table 3.1 is reproduced below:
Agresti considered the following numerical scores for snoring level: {0,2,4,5}.
There are two ways to fit a GLM with R: either your outcome is provided as a vector of 0/1 or a factor with two levels, with the predictors on the rhs of your formula; or you can give a matrix with two columns of counts for success/failure as the lhs of the formula. The latter corresponds to what Agresti call 'grouped' data. A third method, which also applies to grouped settings, would be to use the weights= argument to indicate how many positive and negative outcomes were observed for each category of the classification table.
Data in matrix view would read:
snoring <- matrix(c(24,35,21,30,1355,603,192,224), nc=2)
From this, we can generate a data.frame in long format (2484 rows = sum(snoring) observations) as follows:
snoring.df <- data.frame(snoring=gl(4, 1, labels=c("Never", "Occasional",
"Nearly every night",
"Every night")),
disease=gl(2, 4, labels=c("Yes", "No")),
counts=as.vector(snoring))
snoring.df <- snoring.df[rep(seq_len(nrow(snoring.df)), snoring.df$counts), 1:2]
And the following two models will yield identical results:
levels(snoring.df$snoring) <- c(0, 2, 4, 5)
y <- abs(as.numeric(snoring.df$disease)-2)
x <- as.numeric(as.character(snoring.df$snoring))
fit.glm1 <- glm(y ~ x, family=binomial)
fit.glm2 <- glm(snoring ~ c(0, 2, 4, 5), family=binomial)
That is, $\text{logit}[\hat\pi(x)]=-3.87+0.40x$, using Agresti's notation.
The second notation is frequently used on aggregated table with an instruction like cbind(a, b), where a and b are columns of counts for a binary event (see e.g., Generalized Linear Models). It looks like it would also work when using table instead of matrix (as in your example), e.g.
glm(as.table(snoring) ~ c(0, 2, 4, 5), family=binomial) | Logistic regression: grouped and ungrouped variables (using R) | Table 3.1 is reproduced below:
Agresti considered the following numerical scores for snoring level: {0,2,4,5}.
There are two ways to fit a GLM with R: either your outcome is provided as a vector of 0 | Logistic regression: grouped and ungrouped variables (using R)
Table 3.1 is reproduced below:
Agresti considered the following numerical scores for snoring level: {0,2,4,5}.
There are two ways to fit a GLM with R: either your outcome is provided as a vector of 0/1 or a factor with two levels, with the predictors on the rhs of your formula; or you can give a matrix with two columns of counts for success/failure as the lhs of the formula. The latter corresponds to what Agresti call 'grouped' data. A third method, which also applies to grouped settings, would be to use the weights= argument to indicate how many positive and negative outcomes were observed for each category of the classification table.
Data in matrix view would read:
snoring <- matrix(c(24,35,21,30,1355,603,192,224), nc=2)
From this, we can generate a data.frame in long format (2484 rows = sum(snoring) observations) as follows:
snoring.df <- data.frame(snoring=gl(4, 1, labels=c("Never", "Occasional",
"Nearly every night",
"Every night")),
disease=gl(2, 4, labels=c("Yes", "No")),
counts=as.vector(snoring))
snoring.df <- snoring.df[rep(seq_len(nrow(snoring.df)), snoring.df$counts), 1:2]
And the following two models will yield identical results:
levels(snoring.df$snoring) <- c(0, 2, 4, 5)
y <- abs(as.numeric(snoring.df$disease)-2)
x <- as.numeric(as.character(snoring.df$snoring))
fit.glm1 <- glm(y ~ x, family=binomial)
fit.glm2 <- glm(snoring ~ c(0, 2, 4, 5), family=binomial)
That is, $\text{logit}[\hat\pi(x)]=-3.87+0.40x$, using Agresti's notation.
The second notation is frequently used on aggregated table with an instruction like cbind(a, b), where a and b are columns of counts for a binary event (see e.g., Generalized Linear Models). It looks like it would also work when using table instead of matrix (as in your example), e.g.
glm(as.table(snoring) ~ c(0, 2, 4, 5), family=binomial) | Logistic regression: grouped and ungrouped variables (using R)
Table 3.1 is reproduced below:
Agresti considered the following numerical scores for snoring level: {0,2,4,5}.
There are two ways to fit a GLM with R: either your outcome is provided as a vector of 0 |
26,027 | Multiple imputation for missing count data in a time series from a panel study | You can use the Amelia package to impute the data (full disclosure: I am one of the authors of Amelia). The package vignette has an extended example of how to use it to impute missing data.
It seems as though you have units which are district-gender-ageGroup observed at the monthly level. First you create a factor variable for each type of unit (that is, one level for each district-gender-ageGroup). Let's call this group. Then, you would need a variable for time, which is probably the number of months since January 2003. Thus, this variable would be 13 in January of 2004. Call this variable time. Amelia will allow you to impute based on the time trends with the following commands:
library(Amelia)
a.out <- amelia(my.data, ts = "time", cs = "group", splinetime = 2, intercs = TRUE)
The ts and cs arguments simply denote the time and unit variables. The splinetime argument sets how flexible should time be used to impute the missing data. Here, a 2 means that the imputation will use a quadratic function of time, but higher values will be more flexible. The intercs argument here tells Amelia to use a separate time trend for each district-gender-ageGroup. This adds many parameters to the model, so if you run into trouble, you can set this to FALSE to try to debug.
In any event, this will get you imputations using the time information in your data. Since the missing data is bounded at zero, you can use the bounds argument to force imputations into those logical bounds.
EDIT: How to create group/time variables
The time variable might be the easiest to create, because you just need to count from 2002 (assuming that is the lowest year in your data):
my.data$time <- my.data$Month + 12 * (my.data$Year - 2002)
The group variable is slightly harder but a quick way to do it is using the paste command:
my.data$group <- with(my.data,
as.factor(paste(District, Gender, AgeGroup, sep = ".")))
With these variables created, you want to remove the original variables from the imputation. To do that you can use the idvars argument:
a.out <- amelia(my.data, ts = "time", cs = "group", splinetime = 2, intercs = TRUE,
idvars = c("District", "Gender", "Month", "Year", "AgeGroup")) | Multiple imputation for missing count data in a time series from a panel study | You can use the Amelia package to impute the data (full disclosure: I am one of the authors of Amelia). The package vignette has an extended example of how to use it to impute missing data.
It seems | Multiple imputation for missing count data in a time series from a panel study
You can use the Amelia package to impute the data (full disclosure: I am one of the authors of Amelia). The package vignette has an extended example of how to use it to impute missing data.
It seems as though you have units which are district-gender-ageGroup observed at the monthly level. First you create a factor variable for each type of unit (that is, one level for each district-gender-ageGroup). Let's call this group. Then, you would need a variable for time, which is probably the number of months since January 2003. Thus, this variable would be 13 in January of 2004. Call this variable time. Amelia will allow you to impute based on the time trends with the following commands:
library(Amelia)
a.out <- amelia(my.data, ts = "time", cs = "group", splinetime = 2, intercs = TRUE)
The ts and cs arguments simply denote the time and unit variables. The splinetime argument sets how flexible should time be used to impute the missing data. Here, a 2 means that the imputation will use a quadratic function of time, but higher values will be more flexible. The intercs argument here tells Amelia to use a separate time trend for each district-gender-ageGroup. This adds many parameters to the model, so if you run into trouble, you can set this to FALSE to try to debug.
In any event, this will get you imputations using the time information in your data. Since the missing data is bounded at zero, you can use the bounds argument to force imputations into those logical bounds.
EDIT: How to create group/time variables
The time variable might be the easiest to create, because you just need to count from 2002 (assuming that is the lowest year in your data):
my.data$time <- my.data$Month + 12 * (my.data$Year - 2002)
The group variable is slightly harder but a quick way to do it is using the paste command:
my.data$group <- with(my.data,
as.factor(paste(District, Gender, AgeGroup, sep = ".")))
With these variables created, you want to remove the original variables from the imputation. To do that you can use the idvars argument:
a.out <- amelia(my.data, ts = "time", cs = "group", splinetime = 2, intercs = TRUE,
idvars = c("District", "Gender", "Month", "Year", "AgeGroup")) | Multiple imputation for missing count data in a time series from a panel study
You can use the Amelia package to impute the data (full disclosure: I am one of the authors of Amelia). The package vignette has an extended example of how to use it to impute missing data.
It seems |
26,028 | MANOVA and correlations between dependent variables: how strong is too strong? | There's no clear answer. The idea is that if you have a correlation that approaches 1 then you essentially have one variable and not multiple variables. So you could test against the hypotheses that r=1.00. With that said, the idea of MANOVA is to give you something more than a series of ANOVA tests. It helps you find a relationship with one test because you're able to lower your mean square error when combining dependent variables. It just won't help if you have highly correlated dependent variables. | MANOVA and correlations between dependent variables: how strong is too strong? | There's no clear answer. The idea is that if you have a correlation that approaches 1 then you essentially have one variable and not multiple variables. So you could test against the hypotheses that | MANOVA and correlations between dependent variables: how strong is too strong?
There's no clear answer. The idea is that if you have a correlation that approaches 1 then you essentially have one variable and not multiple variables. So you could test against the hypotheses that r=1.00. With that said, the idea of MANOVA is to give you something more than a series of ANOVA tests. It helps you find a relationship with one test because you're able to lower your mean square error when combining dependent variables. It just won't help if you have highly correlated dependent variables. | MANOVA and correlations between dependent variables: how strong is too strong?
There's no clear answer. The idea is that if you have a correlation that approaches 1 then you essentially have one variable and not multiple variables. So you could test against the hypotheses that |
26,029 | MANOVA and correlations between dependent variables: how strong is too strong? | Why not use Cohen's (1988, 1992) guidelines for effect size values? He defines a "small" $(0.1 \leq r \leq 0.23)$, "medium" $(0.24 \leq r \leq 0.36)$ and "large" $(r \geq 0.37)$ effect. This would suggest to use MANOVA with variables whose $r$ is below $0.37$.
References
Cohen, J. (1988) Statistical Power Analysis for the Behavioral Sciences. 2nd Ed. Routledge Academic, 567 pp.
Cohen, J (1992). A power primer. Psychological Bulletin 112, 155–159. | MANOVA and correlations between dependent variables: how strong is too strong? | Why not use Cohen's (1988, 1992) guidelines for effect size values? He defines a "small" $(0.1 \leq r \leq 0.23)$, "medium" $(0.24 \leq r \leq 0.36)$ and "large" $(r \geq 0.37)$ effect. This would sug | MANOVA and correlations between dependent variables: how strong is too strong?
Why not use Cohen's (1988, 1992) guidelines for effect size values? He defines a "small" $(0.1 \leq r \leq 0.23)$, "medium" $(0.24 \leq r \leq 0.36)$ and "large" $(r \geq 0.37)$ effect. This would suggest to use MANOVA with variables whose $r$ is below $0.37$.
References
Cohen, J. (1988) Statistical Power Analysis for the Behavioral Sciences. 2nd Ed. Routledge Academic, 567 pp.
Cohen, J (1992). A power primer. Psychological Bulletin 112, 155–159. | MANOVA and correlations between dependent variables: how strong is too strong?
Why not use Cohen's (1988, 1992) guidelines for effect size values? He defines a "small" $(0.1 \leq r \leq 0.23)$, "medium" $(0.24 \leq r \leq 0.36)$ and "large" $(r \geq 0.37)$ effect. This would sug |
26,030 | MANOVA and correlations between dependent variables: how strong is too strong? | I would recommend to conduct a MANOVA whenever you are comparing groups on multiple DVs that have been measured on each observation. The data are multivariate, and a MV procedure should be used to model that known data situation. I do not believe in deciding whether to use it on the basis of that correlation. So I would use MANOVA for either of those situations. I would recommend reading the relevant portions of the following conference paper by Bruce Thompson (ERIC ID ED429110).
p.s. I believe the 'conceptually related' quote comes from the Stevens book. | MANOVA and correlations between dependent variables: how strong is too strong? | I would recommend to conduct a MANOVA whenever you are comparing groups on multiple DVs that have been measured on each observation. The data are multivariate, and a MV procedure should be used to mod | MANOVA and correlations between dependent variables: how strong is too strong?
I would recommend to conduct a MANOVA whenever you are comparing groups on multiple DVs that have been measured on each observation. The data are multivariate, and a MV procedure should be used to model that known data situation. I do not believe in deciding whether to use it on the basis of that correlation. So I would use MANOVA for either of those situations. I would recommend reading the relevant portions of the following conference paper by Bruce Thompson (ERIC ID ED429110).
p.s. I believe the 'conceptually related' quote comes from the Stevens book. | MANOVA and correlations between dependent variables: how strong is too strong?
I would recommend to conduct a MANOVA whenever you are comparing groups on multiple DVs that have been measured on each observation. The data are multivariate, and a MV procedure should be used to mod |
26,031 | MANOVA and correlations between dependent variables: how strong is too strong? | Claims about what correlations should or shouldn't be used in MANOVA are basically "myths" (see Frane, 2015, "Power and Type I error control fro univariate comparisons in multivariate two-group designs"). But of course, if your DVs are almost perfectly correlated (i.e., near 1 or -1), you should ask yourself why you're treating them as different variables in the first place. | MANOVA and correlations between dependent variables: how strong is too strong? | Claims about what correlations should or shouldn't be used in MANOVA are basically "myths" (see Frane, 2015, "Power and Type I error control fro univariate comparisons in multivariate two-group design | MANOVA and correlations between dependent variables: how strong is too strong?
Claims about what correlations should or shouldn't be used in MANOVA are basically "myths" (see Frane, 2015, "Power and Type I error control fro univariate comparisons in multivariate two-group designs"). But of course, if your DVs are almost perfectly correlated (i.e., near 1 or -1), you should ask yourself why you're treating them as different variables in the first place. | MANOVA and correlations between dependent variables: how strong is too strong?
Claims about what correlations should or shouldn't be used in MANOVA are basically "myths" (see Frane, 2015, "Power and Type I error control fro univariate comparisons in multivariate two-group design |
26,032 | Good text for resampling? | As for a good reference, I would recommend Philip Good, Resampling Methods: A Practical Guide to Data Analysis (Birkhäuser Boston, 2005, 3rd ed.) for an applied companion textbook. And here is An Annotated Bibliography for Bootstrap Resampling. Resampling methods: Concepts, Applications, and Justification also provides a good start.
There are many R packages that facilitate the use of resampling techniques:
boot, for bootstraping -- but see also P. Burns, The Statistical Bootstrap and Other Resampling Methods, for illustrations
coin, for permutation tests (but see the accompanying vignette which includes extensive help)
(There are many other packages...) | Good text for resampling? | As for a good reference, I would recommend Philip Good, Resampling Methods: A Practical Guide to Data Analysis (Birkhäuser Boston, 2005, 3rd ed.) for an applied companion textbook. And here is An Anno | Good text for resampling?
As for a good reference, I would recommend Philip Good, Resampling Methods: A Practical Guide to Data Analysis (Birkhäuser Boston, 2005, 3rd ed.) for an applied companion textbook. And here is An Annotated Bibliography for Bootstrap Resampling. Resampling methods: Concepts, Applications, and Justification also provides a good start.
There are many R packages that facilitate the use of resampling techniques:
boot, for bootstraping -- but see also P. Burns, The Statistical Bootstrap and Other Resampling Methods, for illustrations
coin, for permutation tests (but see the accompanying vignette which includes extensive help)
(There are many other packages...) | Good text for resampling?
As for a good reference, I would recommend Philip Good, Resampling Methods: A Practical Guide to Data Analysis (Birkhäuser Boston, 2005, 3rd ed.) for an applied companion textbook. And here is An Anno |
26,033 | Good text for resampling? | Phillip Good, Permutation, Parametric, and Bootstrap Tests of Hypotheses (3rd Edition). Springer, 2005.
This book is mathematically easy, accessible, and covers a wide range of applications. | Good text for resampling? | Phillip Good, Permutation, Parametric, and Bootstrap Tests of Hypotheses (3rd Edition). Springer, 2005.
This book is mathematically easy, accessible, and covers a wide range of applications. | Good text for resampling?
Phillip Good, Permutation, Parametric, and Bootstrap Tests of Hypotheses (3rd Edition). Springer, 2005.
This book is mathematically easy, accessible, and covers a wide range of applications. | Good text for resampling?
Phillip Good, Permutation, Parametric, and Bootstrap Tests of Hypotheses (3rd Edition). Springer, 2005.
This book is mathematically easy, accessible, and covers a wide range of applications. |
26,034 | Good text for resampling? | Aside from the excellent and cleverly written Good's book mentioned in the response above, you might find Basso, Pesarin, Salmaso, and Solari "Permutation Tests for Stochastic Ordering and ANOVA Theory and Applications with R", useful.
To be honest, I haven't read it all the way through, but it employs some new models based on likelihood and sufficient statistics (if that makes sense in a nonparametric context). It is simple to read (for someone who knows statistics), but it contains all of the theoretical details as well as some R. | Good text for resampling? | Aside from the excellent and cleverly written Good's book mentioned in the response above, you might find Basso, Pesarin, Salmaso, and Solari "Permutation Tests for Stochastic Ordering and ANOVA Theor | Good text for resampling?
Aside from the excellent and cleverly written Good's book mentioned in the response above, you might find Basso, Pesarin, Salmaso, and Solari "Permutation Tests for Stochastic Ordering and ANOVA Theory and Applications with R", useful.
To be honest, I haven't read it all the way through, but it employs some new models based on likelihood and sufficient statistics (if that makes sense in a nonparametric context). It is simple to read (for someone who knows statistics), but it contains all of the theoretical details as well as some R. | Good text for resampling?
Aside from the excellent and cleverly written Good's book mentioned in the response above, you might find Basso, Pesarin, Salmaso, and Solari "Permutation Tests for Stochastic Ordering and ANOVA Theor |
26,035 | Probability that someone will like image | I believe this is a standard problem of Collaborative Filtering. A google search gives thousands of results. | Probability that someone will like image | I believe this is a standard problem of Collaborative Filtering. A google search gives thousands of results. | Probability that someone will like image
I believe this is a standard problem of Collaborative Filtering. A google search gives thousands of results. | Probability that someone will like image
I believe this is a standard problem of Collaborative Filtering. A google search gives thousands of results. |
26,036 | Probability that someone will like image | This looks like a good problem for machine learning, so I'll concentrate on this group of methods.
First and the most obvious idea is the kNN algorithm. There you first calculate the similarity among viewers and then predict the missing votes with the average vote on this picture cast by similar users. For details see Wikipedia.
Another idea is to grow unsupervised random forest on this data (either way, with attributes in images or people, whatever is better) and impute missing data based on the forest structure; the whole method is implemented and described in R randomForest package, look for rfImpute function.
Finally, you can restructure the problem to a plain classification task, say make an object of each zero in matrix and try to think of some reasonable descriptors (like average viewer vote, average image vote, vote of a most, second most, ... similar viewer, same with image, possibly some external data (average hue of image, age of voter, etc). And then try various classifiers on this data (SVM, RF, NB, ...).
There are also some more complex possibilities; for an overview you can look for Netflix prize challenge (which was a similar problem) solutions. | Probability that someone will like image | This looks like a good problem for machine learning, so I'll concentrate on this group of methods.
First and the most obvious idea is the kNN algorithm. There you first calculate the similarity among | Probability that someone will like image
This looks like a good problem for machine learning, so I'll concentrate on this group of methods.
First and the most obvious idea is the kNN algorithm. There you first calculate the similarity among viewers and then predict the missing votes with the average vote on this picture cast by similar users. For details see Wikipedia.
Another idea is to grow unsupervised random forest on this data (either way, with attributes in images or people, whatever is better) and impute missing data based on the forest structure; the whole method is implemented and described in R randomForest package, look for rfImpute function.
Finally, you can restructure the problem to a plain classification task, say make an object of each zero in matrix and try to think of some reasonable descriptors (like average viewer vote, average image vote, vote of a most, second most, ... similar viewer, same with image, possibly some external data (average hue of image, age of voter, etc). And then try various classifiers on this data (SVM, RF, NB, ...).
There are also some more complex possibilities; for an overview you can look for Netflix prize challenge (which was a similar problem) solutions. | Probability that someone will like image
This looks like a good problem for machine learning, so I'll concentrate on this group of methods.
First and the most obvious idea is the kNN algorithm. There you first calculate the similarity among |
26,037 | Measuring goodness-of-fit in a model that combines two distributions | You can use a metric such as Mean Squared Error between actual vs predicted values to compare the two models. | Measuring goodness-of-fit in a model that combines two distributions | You can use a metric such as Mean Squared Error between actual vs predicted values to compare the two models. | Measuring goodness-of-fit in a model that combines two distributions
You can use a metric such as Mean Squared Error between actual vs predicted values to compare the two models. | Measuring goodness-of-fit in a model that combines two distributions
You can use a metric such as Mean Squared Error between actual vs predicted values to compare the two models. |
26,038 | Measuring goodness-of-fit in a model that combines two distributions | You can't compare them directly since the Negative Binomial has more parameters. Indeed the Poisson is "nested" within the Negative Binomial in the sense that it's a limiting case, so the NegBin will always fit better than the Poisson. However, that makes it possible to consider something like a likelihood ratio test but the fact that the Poisson is at the boundary of the parameter space for the negative binomial may affect the distribution of the test statistic.
In any case, even if the difference in number of parameters wasn't a problem, you can't do K-S tests directly because you have estimated parameters, and K-S is specifically for the case where all parameters are specified. Your idea of using the bootstrap deals with this issue, but not the first one (difference in number of parameters)
I'd also be considering smooth tests of goodness of fit (e.g. see Rayner and Best's book), which, for example, can lead to a partition the chi-square goodness of fit test into components of interest (measuring deviations from the Poisson model in this case) - taken out to say fourth order or sixth order, this should lead to a test with good power for the NegBin alternative.
(Edit: You could compare your poisson and negbin fits via a chi-squared test but it will have low power. Partitioning the chi-square and looking only at say the first 4-6 components, as is done with smooth tests might do better.) | Measuring goodness-of-fit in a model that combines two distributions | You can't compare them directly since the Negative Binomial has more parameters. Indeed the Poisson is "nested" within the Negative Binomial in the sense that it's a limiting case, so the NegBin will | Measuring goodness-of-fit in a model that combines two distributions
You can't compare them directly since the Negative Binomial has more parameters. Indeed the Poisson is "nested" within the Negative Binomial in the sense that it's a limiting case, so the NegBin will always fit better than the Poisson. However, that makes it possible to consider something like a likelihood ratio test but the fact that the Poisson is at the boundary of the parameter space for the negative binomial may affect the distribution of the test statistic.
In any case, even if the difference in number of parameters wasn't a problem, you can't do K-S tests directly because you have estimated parameters, and K-S is specifically for the case where all parameters are specified. Your idea of using the bootstrap deals with this issue, but not the first one (difference in number of parameters)
I'd also be considering smooth tests of goodness of fit (e.g. see Rayner and Best's book), which, for example, can lead to a partition the chi-square goodness of fit test into components of interest (measuring deviations from the Poisson model in this case) - taken out to say fourth order or sixth order, this should lead to a test with good power for the NegBin alternative.
(Edit: You could compare your poisson and negbin fits via a chi-squared test but it will have low power. Partitioning the chi-square and looking only at say the first 4-6 components, as is done with smooth tests might do better.) | Measuring goodness-of-fit in a model that combines two distributions
You can't compare them directly since the Negative Binomial has more parameters. Indeed the Poisson is "nested" within the Negative Binomial in the sense that it's a limiting case, so the NegBin will |
26,039 | Asymptotic distribution of multinomial | The covariance is still non-negative definite (so is a valid multivariate normal distribution), but not positive definite: what this means is that (at least) one element of the random vector is a linear combination of the others.
As a result, any draw from this distribution will always lie on a subspace of $R^d$. As a consequence, this means it is not possible to define a density function (as the distribution is concentrated on the subspace: think of the way a univariate normal will concentrate at the mean if the variance is zero).
However, as suggested by Robby McKilliam, in this case you can drop the last element of the random vector. The covariance matrix of this reduced vector will be the original matrix, with the last column and row dropped, which will now be positive definite, and will have a density (this trick will work in other cases, but you have to be careful which element you drop, and you may need to drop more than one). | Asymptotic distribution of multinomial | The covariance is still non-negative definite (so is a valid multivariate normal distribution), but not positive definite: what this means is that (at least) one element of the random vector is a line | Asymptotic distribution of multinomial
The covariance is still non-negative definite (so is a valid multivariate normal distribution), but not positive definite: what this means is that (at least) one element of the random vector is a linear combination of the others.
As a result, any draw from this distribution will always lie on a subspace of $R^d$. As a consequence, this means it is not possible to define a density function (as the distribution is concentrated on the subspace: think of the way a univariate normal will concentrate at the mean if the variance is zero).
However, as suggested by Robby McKilliam, in this case you can drop the last element of the random vector. The covariance matrix of this reduced vector will be the original matrix, with the last column and row dropped, which will now be positive definite, and will have a density (this trick will work in other cases, but you have to be careful which element you drop, and you may need to drop more than one). | Asymptotic distribution of multinomial
The covariance is still non-negative definite (so is a valid multivariate normal distribution), but not positive definite: what this means is that (at least) one element of the random vector is a line |
26,040 | Asymptotic distribution of multinomial | It looks to me like Wasserman's covariance matrix is singular, to see, multiply it by a vector of $d$ ones, i.e. $[1,1,1,\dots,1]^\prime$ of length $d$.
Wikipedia gives the same covariance matrix anyway. If we restrict ourselves to just a binomial distribution then the standard central limit theorem tells us that the binomial distribution (after appropriate scaling) converges to the normal as $n$ gets big (see wikipedia again). Applying similar ideas you should be able to show that an appropriately scaled mulinomial is going to converge in distribution to the multivariate normal, i.e. each marginal distribution is just a binomial and converges to the normal distribution, and the variance between them is known.
So, I am very confident you will find that the distribution of
$$\frac{X_n - np}{\sqrt{n}}$$
converges to the multivariate normal with zero mean and covariance
$$\frac{C}{n}$$
where $C$ is the covariance matrix of the multinomial in question and $p$ is the vector of probabilities $[p_1,\dots,p_d]$. | Asymptotic distribution of multinomial | It looks to me like Wasserman's covariance matrix is singular, to see, multiply it by a vector of $d$ ones, i.e. $[1,1,1,\dots,1]^\prime$ of length $d$.
Wikipedia gives the same covariance matrix anyw | Asymptotic distribution of multinomial
It looks to me like Wasserman's covariance matrix is singular, to see, multiply it by a vector of $d$ ones, i.e. $[1,1,1,\dots,1]^\prime$ of length $d$.
Wikipedia gives the same covariance matrix anyway. If we restrict ourselves to just a binomial distribution then the standard central limit theorem tells us that the binomial distribution (after appropriate scaling) converges to the normal as $n$ gets big (see wikipedia again). Applying similar ideas you should be able to show that an appropriately scaled mulinomial is going to converge in distribution to the multivariate normal, i.e. each marginal distribution is just a binomial and converges to the normal distribution, and the variance between them is known.
So, I am very confident you will find that the distribution of
$$\frac{X_n - np}{\sqrt{n}}$$
converges to the multivariate normal with zero mean and covariance
$$\frac{C}{n}$$
where $C$ is the covariance matrix of the multinomial in question and $p$ is the vector of probabilities $[p_1,\dots,p_d]$. | Asymptotic distribution of multinomial
It looks to me like Wasserman's covariance matrix is singular, to see, multiply it by a vector of $d$ ones, i.e. $[1,1,1,\dots,1]^\prime$ of length $d$.
Wikipedia gives the same covariance matrix anyw |
26,041 | Asymptotic distribution of multinomial | There no inherent problem with the singular covariance here. Your asymptotic distribution is the singular normal. See http://fedc.wiwi.hu-berlin.de/xplore/tutorials/mvahtmlnode34.html which gives the density of the singular normal. | Asymptotic distribution of multinomial | There no inherent problem with the singular covariance here. Your asymptotic distribution is the singular normal. See http://fedc.wiwi.hu-berlin.de/xplore/tutorials/mvahtmlnode34.html which gives th | Asymptotic distribution of multinomial
There no inherent problem with the singular covariance here. Your asymptotic distribution is the singular normal. See http://fedc.wiwi.hu-berlin.de/xplore/tutorials/mvahtmlnode34.html which gives the density of the singular normal. | Asymptotic distribution of multinomial
There no inherent problem with the singular covariance here. Your asymptotic distribution is the singular normal. See http://fedc.wiwi.hu-berlin.de/xplore/tutorials/mvahtmlnode34.html which gives th |
26,042 | Asymptotic distribution of multinomial | Is it not the case that $|S_{-i}|=|S_{-j}|$ for all $i,j$ where $S_{-i}$ is the Multinomial covariance matrix with the $i$-th row and column removed? Since this is the case, I don't understand what you mean by "freedom of choice" as any "choice" is equivalent. | Asymptotic distribution of multinomial | Is it not the case that $|S_{-i}|=|S_{-j}|$ for all $i,j$ where $S_{-i}$ is the Multinomial covariance matrix with the $i$-th row and column removed? Since this is the case, I don't understand what y | Asymptotic distribution of multinomial
Is it not the case that $|S_{-i}|=|S_{-j}|$ for all $i,j$ where $S_{-i}$ is the Multinomial covariance matrix with the $i$-th row and column removed? Since this is the case, I don't understand what you mean by "freedom of choice" as any "choice" is equivalent. | Asymptotic distribution of multinomial
Is it not the case that $|S_{-i}|=|S_{-j}|$ for all $i,j$ where $S_{-i}$ is the Multinomial covariance matrix with the $i$-th row and column removed? Since this is the case, I don't understand what y |
26,043 | Asymptotic distribution of multinomial | Another way to think of this is your multinomial distribution parameters are embedded in the simplex, so your asymptotic distribution should also be embedded in the simplex. You can get to this by trying to instead characterize the distribution of $y$ given by the transform
$$
y = ilr(p)=V^T\log p
$$
where $ilr(p)$ is the isometric log-ratio transform and $V$ is an orthonormal basis of dimension $D-1\times D$. It doesn't actually matter which basis you use, but you could use the top D-1 eigenvectors from the eigendecomposition of $\log p$ for starters.
It can then be shown that the asympotic distribution can be given by
$$
\hat{y} \sim \mathcal{N}_{D-1}\big(y, \frac{1}{n} V^TD^{-1}V\big)
$$
where $D=diag(p)$
See Ortego et al 2015 for more details, the paper can be found below
https://www.researchgate.net/publication/327646436_The_asymptotic_distribution_of_log-ratio_transformed_proportions_of_multinomial_count_data | Asymptotic distribution of multinomial | Another way to think of this is your multinomial distribution parameters are embedded in the simplex, so your asymptotic distribution should also be embedded in the simplex. You can get to this by try | Asymptotic distribution of multinomial
Another way to think of this is your multinomial distribution parameters are embedded in the simplex, so your asymptotic distribution should also be embedded in the simplex. You can get to this by trying to instead characterize the distribution of $y$ given by the transform
$$
y = ilr(p)=V^T\log p
$$
where $ilr(p)$ is the isometric log-ratio transform and $V$ is an orthonormal basis of dimension $D-1\times D$. It doesn't actually matter which basis you use, but you could use the top D-1 eigenvectors from the eigendecomposition of $\log p$ for starters.
It can then be shown that the asympotic distribution can be given by
$$
\hat{y} \sim \mathcal{N}_{D-1}\big(y, \frac{1}{n} V^TD^{-1}V\big)
$$
where $D=diag(p)$
See Ortego et al 2015 for more details, the paper can be found below
https://www.researchgate.net/publication/327646436_The_asymptotic_distribution_of_log-ratio_transformed_proportions_of_multinomial_count_data | Asymptotic distribution of multinomial
Another way to think of this is your multinomial distribution parameters are embedded in the simplex, so your asymptotic distribution should also be embedded in the simplex. You can get to this by try |
26,044 | Auction problem | To examine the estimator for $\Phi$ we will treat $\mathbf{x}$ as a control variable, meaning that the auction house sets their own prices for each round of auctions. Without loss of generality, let us suppose that the values in this control vector are in non-decreasing order and let $\Phi_i \equiv \Phi(x_i)$ denote the corresponding unknown CDF values at the chosen points, so that we have a set of ordered unknown points $0 < \Phi_1 \leqslant \cdots \leqslant \Phi_n < 1$.$^\dagger$ This gives us the likelihood function for the data is:
$$\begin{align}
L_{\mathbf{x},\mathbf{t}}(\Phi)
&= \prod_{i=1}^n \text{Geom}(t_i| 1-\Phi(x_i)) \\[6pt]
&= \prod_{i=1}^n \Phi(x_i)^{t_i-1}(1-\Phi(x_i)) \\[6pt]
&= \prod_{i=1}^n \Phi_i^{t_i-1} (1-\Phi_i) \\[6pt]
\end{align}$$
As you can see, the likelihood depends on the distribution $\Phi$ only through the specific points used for the control variable, so without any additional structural assumption on the distribution, you can only learn about the distribution through inference about the CDF at these points.
It is possible to find the MLE by solving the multivariate optimisation problem that maximises the above function over the constrained space $0 < \Phi_1 \leqslant \cdots \leqslant \Phi_n < 1$. This is a constrained multivariate optimisation problem, which will typically require some transformation and numerical methods. Below I show how you can construct an algorithm to compute the MLE by writing the CDF points as a transformation of an unconstrained parameter vector, thereby converting the problem to an unconstrained optimisation.
Solving to obtain the MLE gives us an estimator of the form $\hat{\boldsymbol{\Phi}} = (\hat{\Phi}_1,...,\hat{\Phi}_n)$, and with some further work we can obtain the estimated asymptotic variance matrix for this estimator (and therefore obtain the standard errors of each of the elements). To estimate the CDF at points other than those used as control variables you could use interpolation, noting that this entails some implicit assumptions about the structure of the distribution (e.g., if you were to estimate the median using linear interpolation from the MLE then this would involve an implicit assumption that the CDF is linear between the relevant control points used in the interpolation). It is also possible to use alternative modelling methods where you assume a particular parametric distributional form for $\Phi$ and then estimate the parameters of the distribution using the MLE or another estimator.
Computing the MLE: As noted above, the MLE involves a constrained multivariate optimisation problem, and this can be solved by conversion to an unconstrained mutivariate optimisation problem. To facilitate this analysis it is useful to write the parameters $\Phi_1,...,\Phi_n$ as transformations of an unconstrained parameter vector $\boldsymbol{\gamma} = (\gamma_1, ..., \gamma_n) \in \mathbb{R}^n$, given by:$^\dagger$
$$\Phi_i = \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)}.$$
This transformation allows us to write the likelihood function in terms of the parameter $\boldsymbol{\gamma}$ and obtain the MLE through this parameter. If we let $\bar{t}_n \equiv \sum_{i=1}^n t_i$ then we can write the likelihood function as:
$$\begin{align}
L_{\mathbf{x},\mathbf{t}}(\boldsymbol{\gamma})
&= \prod_{i=1}^n \bigg( \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg)^{t_i-1} \bigg( 1 - \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg) \\[6pt]
&= \prod_{i=1}^n \bigg( \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg)^{t_i-1} \bigg( \frac{1+\sum_{r=i+1}^n \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg) \\[6pt]
&= \frac{\prod_{i=1}^n (\sum_{r=1}^i \exp(\gamma_r))^{t_i-1} (1+\sum_{r=i+1}^n \exp(\gamma_r))}{(1+\sum_{r=1}^n \exp(\gamma_r))^{n \bar{t}_n}} \\[6pt]
\end{align}$$
and the corresponding log-likelihood is:
$$\begin{align}
\ell_{\mathbf{x},\mathbf{t}}(\boldsymbol{\gamma})
&= \sum_{i=1}^n (t_i-1) \log \bigg( \sum_{r=1}^i \exp(\gamma_r) \bigg)
+ \sum_{i=1}^n \log \bigg( 1 + \sum_{r=i+1}^n \exp(\gamma_r) \bigg) \\[6pt]
&\quad \quad \quad - n(1+\bar{t}_n) \log \bigg( 1+\sum_{r=1}^n \exp(\gamma_r) \bigg) \\[6pt]
&= \sum_{i=1}^n (t_i-1) \text{LSE}(\gamma_1,...,\gamma_i)
+ \sum_{i=1}^n \text{LSE}(0,\gamma_{i+1},...,\gamma_n) \\[6pt]
&\quad \quad \quad - n \bar{t}_n \text{LSE}(0, \gamma_1,...,\gamma_n). \\[6pt]
\end{align}$$
(The function $\text{LSE}$ here is the logsumexp function.) The partial derivatives of the log-likelihood (which are the elements of the score function) are:
$$\begin{align}
\frac{\partial \ell_{\mathbf{x},\mathbf{t}}}{\partial \gamma_k}(\boldsymbol{\gamma})
&= \sum_{i \geqslant k} \frac{(t_i-1) \exp(\gamma_k)}{\sum_{r=1}^i \exp(\gamma_r)}
+ \sum_{i < k} \frac{\exp(\gamma_k)}{1+\sum_{r=i+1}^n \exp(\gamma_r)}
- \frac{n \bar{t}_n \exp(\gamma_k)}{1+\sum_{r=1}^n \exp(\gamma_r)} \\[12pt]
&= \sum_{i \geqslant k} (t_i-1) \exp(\gamma_k - \text{LSE}(\gamma_1,...,\gamma_i))
+ \sum_{i < k} \exp(\gamma_k - \text{LSE}(0,\gamma_{i+1},...,\gamma_n)) \\[6pt]
&\quad \quad \quad - n \bar{t}_n \exp(\gamma_k - \text{LSE}(0, \gamma_1,...,\gamma_n)) \\[12pt]
&= \exp( \text{LSE}(\log(t_k-1) + \gamma_k - \text{LSE}(\gamma_1, ..., \gamma_k) , ..., \log(t_n-1) + \gamma_k - \text{LSE}(\gamma_1,...,\gamma_n)) ) \\[6pt]
&\quad \quad + \exp( \text{LSE}(\gamma_k - \text{LSE}(0,\gamma_{2},...,\gamma_n), ..., \gamma_k - \text{LSE}(0,\gamma_{k},...,\gamma_n)) ) \\[6pt]
&\quad \quad - n \bar{t}_n \exp(\gamma_k - \text{LSE}(0, \gamma_1,...,\gamma_n)) \\[6pt]
\end{align}$$
Setting all partial derivatives to zero and solving for $\boldsymbol{\gamma}$ gives a critical point of the log-likelhood function, which will give the MLE $\hat{\boldsymbol{\gamma}}$. From the invariance property of the MLE we can then easily obtain the MLE $\hat{\boldsymbol{\Phi}}$. In the code below we create a function MLE.auction which computes the MLE for any input vectors x and t (with some other arguments to control the optimisation). The function produces a list giving the MLE and some associated outputs relating to the optimisation.
MLE.auction <- function(x, t, gradtol = 1e-7, steptol = 1e-7, iterlim = 1000) {
#Check inputs x and t
if (!is.vector(x)) stop('Error: Input x should be a numeric vector')
if (!is.numeric(x)) stop('Error: Input x should be a numeric vector')
if (!is.vector(t)) stop('Error: Input t should be a numeric vector')
if (!is.numeric(t)) stop('Error: Input t should be a numeric vector')
if (any(t != as.integer(t))) stop('Error: Input t should contain only integers')
if (min(t) < 1) stop('Error: Input t should contain only positive integers')
if (length(x) != length(t)) stop('Error: Inputs x and t should have the same length')
#Check input gradtol
if (!is.vector(gradtol)) stop('Error: Input gradtol should be numeric')
if (!is.numeric(gradtol)) stop('Error: Input gradtol should be numeric')
if (length(gradtol) != 1) stop('Error: Input gradtol should be a single numeric value')
if (min(gradtol) <= 0) stop('Error: Input gradtol should be positive')
#Check input steptol
if (!is.vector(steptol)) stop('Error: Input steptol should be numeric')
if (!is.numeric(steptol)) stop('Error: Input steptol should be numeric')
if (length(steptol) != 1) stop('Error: Input steptol should be a single numeric value')
if (min(steptol) <= 0) stop('Error: Input steptol should be positive')
#Check input iterlim
if (!is.vector(iterlim)) stop('Error: Input iterlim should be numeric')
if (!is.numeric(iterlim)) stop('Error: Input iterlim should be numeric')
if (length(iterlim) != 1) stop('Error: Input iterlim should be a single numeric value')
if (iterlim != as.integer(iterlim)) stop('Error: Input iterlim should be an integer')
if (min(iterlim) <= 0) stop('Error: Input iterlim should be positive')
#Set preliminary quantities
ORD <- order(x)
x <- x[ORD]
t <- t[ORD]
n <- length(t)
tbar <- mean(t)
#Set negative log-likelihood function
NEGLOGLIKE <- function(gamma) {
TT <- matrixStats::logSumExp(c(0, gamma[1:n]))
T1 <- rep(0, n)
T2 <- rep(0, n)
for (i in 1:n) {
T1[i] <- matrixStats::logSumExp(gamma[1:i])
if (i < n) { T2[i] <- matrixStats::logSumExp(c(0, gamma[(i+1):n])) } }
NLL <- - sum((t-1)*T1) - sum(T2) + n*tbar*TT
#Set derivative
SS <- n*tbar*exp(gamma - TT)
S1 <- rep(0, n)
S2 <- rep(0, n)
for (k in 1:n) {
S1[k] <- exp(matrixStats::logSumExp(log(t[k:n]-1) + gamma[k] - T1[k:n]))
if (k > 1) { S2[k] <- exp(matrixStats::logSumExp(gamma[k] - T2[1:(k-1)])) } }
DERIV <- - S1 - S2 + SS
attr(NLL, 'gradient') <- DERIV
#Give output
NLL }
#Compute optima
OPT <- nlm(NEGLOGLIKE, p = rep(0, n),
gradtol = gradtol, steptol = steptol, iterlim = iterlim)
#Convert to MLE for phi
GAMMA.MLE <- OPT$estimate
MAXLOGLIKE <- -OPT$minimum
TTT <- matrixStats::logSumExp(c(0, GAMMA.MLE))
TT1 <- rep(0, n)
for (i in 1:n) { TT1[i] <- matrixStats::logSumExp(GAMMA.MLE[1:i]) }
PHI.MLE <- exp(TT1 - TTT)
MLE.OUT <- data.frame(x = x, t = t, MLE = PHI.MLE)
rownames(MLE.OUT) <- sprintf('Phi[%s]', 1:n)
#Give output
list(MLE = MLE.OUT, maxloglike = MAXLOGLIKE, mean.maxloglike = MAXLOGLIKE/n,
code = OPT$code, iterations = OPT$iterations,
gradtol = gradtol, steptol = steptol, iterlim = iterlim) }
We can test this function on the set of input data $\mathbf{x} = (4, 6, 12, 15, 21)$ and $\mathbf{t} = (2, 7, 6, 12, 15)$. As you can see from the output, the computed MLE respects the CDF ordering for the input values and it also tells you the maximised value of the log-likelihood function.
#Set data
x <- c(4, 6, 12, 15, 21)
t <- c(2, 7, 6, 12, 15)
#Compute MLE
MLE.auction(x = x, t = t)
$MLE
x t MLE
Phi[1] 4 2 0.5000001
Phi[2] 6 7 0.8461538
Phi[3] 12 6 0.8461538
Phi[4] 15 12 0.9166667
Phi[5] 21 15 0.9333334
$maxloglike
[1] -14.08348
$mean.maxloglike
[1] -2.816695
...
$^\dagger$ Here we use the simplifying assumption that $\Phi_1 > 0$ and $\Phi_n < 1$. It is simple to proceed without this simplifying assumption by allowing $\boldsymbol{\gamma} \in \bar{\mathbb{R}}^n$, which is the extended Euclidean space. | Auction problem | To examine the estimator for $\Phi$ we will treat $\mathbf{x}$ as a control variable, meaning that the auction house sets their own prices for each round of auctions. Without loss of generality, let | Auction problem
To examine the estimator for $\Phi$ we will treat $\mathbf{x}$ as a control variable, meaning that the auction house sets their own prices for each round of auctions. Without loss of generality, let us suppose that the values in this control vector are in non-decreasing order and let $\Phi_i \equiv \Phi(x_i)$ denote the corresponding unknown CDF values at the chosen points, so that we have a set of ordered unknown points $0 < \Phi_1 \leqslant \cdots \leqslant \Phi_n < 1$.$^\dagger$ This gives us the likelihood function for the data is:
$$\begin{align}
L_{\mathbf{x},\mathbf{t}}(\Phi)
&= \prod_{i=1}^n \text{Geom}(t_i| 1-\Phi(x_i)) \\[6pt]
&= \prod_{i=1}^n \Phi(x_i)^{t_i-1}(1-\Phi(x_i)) \\[6pt]
&= \prod_{i=1}^n \Phi_i^{t_i-1} (1-\Phi_i) \\[6pt]
\end{align}$$
As you can see, the likelihood depends on the distribution $\Phi$ only through the specific points used for the control variable, so without any additional structural assumption on the distribution, you can only learn about the distribution through inference about the CDF at these points.
It is possible to find the MLE by solving the multivariate optimisation problem that maximises the above function over the constrained space $0 < \Phi_1 \leqslant \cdots \leqslant \Phi_n < 1$. This is a constrained multivariate optimisation problem, which will typically require some transformation and numerical methods. Below I show how you can construct an algorithm to compute the MLE by writing the CDF points as a transformation of an unconstrained parameter vector, thereby converting the problem to an unconstrained optimisation.
Solving to obtain the MLE gives us an estimator of the form $\hat{\boldsymbol{\Phi}} = (\hat{\Phi}_1,...,\hat{\Phi}_n)$, and with some further work we can obtain the estimated asymptotic variance matrix for this estimator (and therefore obtain the standard errors of each of the elements). To estimate the CDF at points other than those used as control variables you could use interpolation, noting that this entails some implicit assumptions about the structure of the distribution (e.g., if you were to estimate the median using linear interpolation from the MLE then this would involve an implicit assumption that the CDF is linear between the relevant control points used in the interpolation). It is also possible to use alternative modelling methods where you assume a particular parametric distributional form for $\Phi$ and then estimate the parameters of the distribution using the MLE or another estimator.
Computing the MLE: As noted above, the MLE involves a constrained multivariate optimisation problem, and this can be solved by conversion to an unconstrained mutivariate optimisation problem. To facilitate this analysis it is useful to write the parameters $\Phi_1,...,\Phi_n$ as transformations of an unconstrained parameter vector $\boldsymbol{\gamma} = (\gamma_1, ..., \gamma_n) \in \mathbb{R}^n$, given by:$^\dagger$
$$\Phi_i = \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)}.$$
This transformation allows us to write the likelihood function in terms of the parameter $\boldsymbol{\gamma}$ and obtain the MLE through this parameter. If we let $\bar{t}_n \equiv \sum_{i=1}^n t_i$ then we can write the likelihood function as:
$$\begin{align}
L_{\mathbf{x},\mathbf{t}}(\boldsymbol{\gamma})
&= \prod_{i=1}^n \bigg( \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg)^{t_i-1} \bigg( 1 - \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg) \\[6pt]
&= \prod_{i=1}^n \bigg( \frac{\sum_{r=1}^i \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg)^{t_i-1} \bigg( \frac{1+\sum_{r=i+1}^n \exp(\gamma_r)}{1+\sum_{r=1}^n \exp(\gamma_r)} \bigg) \\[6pt]
&= \frac{\prod_{i=1}^n (\sum_{r=1}^i \exp(\gamma_r))^{t_i-1} (1+\sum_{r=i+1}^n \exp(\gamma_r))}{(1+\sum_{r=1}^n \exp(\gamma_r))^{n \bar{t}_n}} \\[6pt]
\end{align}$$
and the corresponding log-likelihood is:
$$\begin{align}
\ell_{\mathbf{x},\mathbf{t}}(\boldsymbol{\gamma})
&= \sum_{i=1}^n (t_i-1) \log \bigg( \sum_{r=1}^i \exp(\gamma_r) \bigg)
+ \sum_{i=1}^n \log \bigg( 1 + \sum_{r=i+1}^n \exp(\gamma_r) \bigg) \\[6pt]
&\quad \quad \quad - n(1+\bar{t}_n) \log \bigg( 1+\sum_{r=1}^n \exp(\gamma_r) \bigg) \\[6pt]
&= \sum_{i=1}^n (t_i-1) \text{LSE}(\gamma_1,...,\gamma_i)
+ \sum_{i=1}^n \text{LSE}(0,\gamma_{i+1},...,\gamma_n) \\[6pt]
&\quad \quad \quad - n \bar{t}_n \text{LSE}(0, \gamma_1,...,\gamma_n). \\[6pt]
\end{align}$$
(The function $\text{LSE}$ here is the logsumexp function.) The partial derivatives of the log-likelihood (which are the elements of the score function) are:
$$\begin{align}
\frac{\partial \ell_{\mathbf{x},\mathbf{t}}}{\partial \gamma_k}(\boldsymbol{\gamma})
&= \sum_{i \geqslant k} \frac{(t_i-1) \exp(\gamma_k)}{\sum_{r=1}^i \exp(\gamma_r)}
+ \sum_{i < k} \frac{\exp(\gamma_k)}{1+\sum_{r=i+1}^n \exp(\gamma_r)}
- \frac{n \bar{t}_n \exp(\gamma_k)}{1+\sum_{r=1}^n \exp(\gamma_r)} \\[12pt]
&= \sum_{i \geqslant k} (t_i-1) \exp(\gamma_k - \text{LSE}(\gamma_1,...,\gamma_i))
+ \sum_{i < k} \exp(\gamma_k - \text{LSE}(0,\gamma_{i+1},...,\gamma_n)) \\[6pt]
&\quad \quad \quad - n \bar{t}_n \exp(\gamma_k - \text{LSE}(0, \gamma_1,...,\gamma_n)) \\[12pt]
&= \exp( \text{LSE}(\log(t_k-1) + \gamma_k - \text{LSE}(\gamma_1, ..., \gamma_k) , ..., \log(t_n-1) + \gamma_k - \text{LSE}(\gamma_1,...,\gamma_n)) ) \\[6pt]
&\quad \quad + \exp( \text{LSE}(\gamma_k - \text{LSE}(0,\gamma_{2},...,\gamma_n), ..., \gamma_k - \text{LSE}(0,\gamma_{k},...,\gamma_n)) ) \\[6pt]
&\quad \quad - n \bar{t}_n \exp(\gamma_k - \text{LSE}(0, \gamma_1,...,\gamma_n)) \\[6pt]
\end{align}$$
Setting all partial derivatives to zero and solving for $\boldsymbol{\gamma}$ gives a critical point of the log-likelhood function, which will give the MLE $\hat{\boldsymbol{\gamma}}$. From the invariance property of the MLE we can then easily obtain the MLE $\hat{\boldsymbol{\Phi}}$. In the code below we create a function MLE.auction which computes the MLE for any input vectors x and t (with some other arguments to control the optimisation). The function produces a list giving the MLE and some associated outputs relating to the optimisation.
MLE.auction <- function(x, t, gradtol = 1e-7, steptol = 1e-7, iterlim = 1000) {
#Check inputs x and t
if (!is.vector(x)) stop('Error: Input x should be a numeric vector')
if (!is.numeric(x)) stop('Error: Input x should be a numeric vector')
if (!is.vector(t)) stop('Error: Input t should be a numeric vector')
if (!is.numeric(t)) stop('Error: Input t should be a numeric vector')
if (any(t != as.integer(t))) stop('Error: Input t should contain only integers')
if (min(t) < 1) stop('Error: Input t should contain only positive integers')
if (length(x) != length(t)) stop('Error: Inputs x and t should have the same length')
#Check input gradtol
if (!is.vector(gradtol)) stop('Error: Input gradtol should be numeric')
if (!is.numeric(gradtol)) stop('Error: Input gradtol should be numeric')
if (length(gradtol) != 1) stop('Error: Input gradtol should be a single numeric value')
if (min(gradtol) <= 0) stop('Error: Input gradtol should be positive')
#Check input steptol
if (!is.vector(steptol)) stop('Error: Input steptol should be numeric')
if (!is.numeric(steptol)) stop('Error: Input steptol should be numeric')
if (length(steptol) != 1) stop('Error: Input steptol should be a single numeric value')
if (min(steptol) <= 0) stop('Error: Input steptol should be positive')
#Check input iterlim
if (!is.vector(iterlim)) stop('Error: Input iterlim should be numeric')
if (!is.numeric(iterlim)) stop('Error: Input iterlim should be numeric')
if (length(iterlim) != 1) stop('Error: Input iterlim should be a single numeric value')
if (iterlim != as.integer(iterlim)) stop('Error: Input iterlim should be an integer')
if (min(iterlim) <= 0) stop('Error: Input iterlim should be positive')
#Set preliminary quantities
ORD <- order(x)
x <- x[ORD]
t <- t[ORD]
n <- length(t)
tbar <- mean(t)
#Set negative log-likelihood function
NEGLOGLIKE <- function(gamma) {
TT <- matrixStats::logSumExp(c(0, gamma[1:n]))
T1 <- rep(0, n)
T2 <- rep(0, n)
for (i in 1:n) {
T1[i] <- matrixStats::logSumExp(gamma[1:i])
if (i < n) { T2[i] <- matrixStats::logSumExp(c(0, gamma[(i+1):n])) } }
NLL <- - sum((t-1)*T1) - sum(T2) + n*tbar*TT
#Set derivative
SS <- n*tbar*exp(gamma - TT)
S1 <- rep(0, n)
S2 <- rep(0, n)
for (k in 1:n) {
S1[k] <- exp(matrixStats::logSumExp(log(t[k:n]-1) + gamma[k] - T1[k:n]))
if (k > 1) { S2[k] <- exp(matrixStats::logSumExp(gamma[k] - T2[1:(k-1)])) } }
DERIV <- - S1 - S2 + SS
attr(NLL, 'gradient') <- DERIV
#Give output
NLL }
#Compute optima
OPT <- nlm(NEGLOGLIKE, p = rep(0, n),
gradtol = gradtol, steptol = steptol, iterlim = iterlim)
#Convert to MLE for phi
GAMMA.MLE <- OPT$estimate
MAXLOGLIKE <- -OPT$minimum
TTT <- matrixStats::logSumExp(c(0, GAMMA.MLE))
TT1 <- rep(0, n)
for (i in 1:n) { TT1[i] <- matrixStats::logSumExp(GAMMA.MLE[1:i]) }
PHI.MLE <- exp(TT1 - TTT)
MLE.OUT <- data.frame(x = x, t = t, MLE = PHI.MLE)
rownames(MLE.OUT) <- sprintf('Phi[%s]', 1:n)
#Give output
list(MLE = MLE.OUT, maxloglike = MAXLOGLIKE, mean.maxloglike = MAXLOGLIKE/n,
code = OPT$code, iterations = OPT$iterations,
gradtol = gradtol, steptol = steptol, iterlim = iterlim) }
We can test this function on the set of input data $\mathbf{x} = (4, 6, 12, 15, 21)$ and $\mathbf{t} = (2, 7, 6, 12, 15)$. As you can see from the output, the computed MLE respects the CDF ordering for the input values and it also tells you the maximised value of the log-likelihood function.
#Set data
x <- c(4, 6, 12, 15, 21)
t <- c(2, 7, 6, 12, 15)
#Compute MLE
MLE.auction(x = x, t = t)
$MLE
x t MLE
Phi[1] 4 2 0.5000001
Phi[2] 6 7 0.8461538
Phi[3] 12 6 0.8461538
Phi[4] 15 12 0.9166667
Phi[5] 21 15 0.9333334
$maxloglike
[1] -14.08348
$mean.maxloglike
[1] -2.816695
...
$^\dagger$ Here we use the simplifying assumption that $\Phi_1 > 0$ and $\Phi_n < 1$. It is simple to proceed without this simplifying assumption by allowing $\boldsymbol{\gamma} \in \bar{\mathbb{R}}^n$, which is the extended Euclidean space. | Auction problem
To examine the estimator for $\Phi$ we will treat $\mathbf{x}$ as a control variable, meaning that the auction house sets their own prices for each round of auctions. Without loss of generality, let |
26,045 | Auction problem | As you pointed out, each observation $(x_i,t_i)$ gives you information on the value of the cumulative distribution at the point $x_i$, however notice that the probability of this observation is $\Phi(x_i)^{t_i-1}(1-\Phi(x_i))$ (the first $t-1$ offers rejected and the last one accepted).
So, without additional assumption on $\Phi$ (such as smoothness), you can only directly estimate from the data the set of values $\{\Phi(x_i)\}$. Now there are many possible methods of statistical inference, but most are based on the likelihood function, so that's a good place to start. Denote $p_i = \Phi(x_i)$ the set of unknown parameters and assume that the $x_i$'s are sorted such that $0 \le p_1 \le p_2 \le ...\le p_n \le 1$. The likelihood function is then
$$\log \mathcal L(p_1,...,p_n) = \sum_{i=1}^n (t_i-1)\log p_i + \log(1-p_i).$$
The constraint on the $p_i$'s being monotonically increasing makes this a slightly less trivial problem, but we can still find the maximum likelihood estimators (MLE) with a bit of work. The unconstrained MLE's are easily found by setting the respective derivatives of the likelihood to zero:
$$ \frac{\partial \log \mathcal L}{\partial p_i} = \frac{t_i - 1}{p_i} - \frac{1}{1-p_i}=0 $$
which gives
$$ \hat p_i = \frac{t_i-1}{t_i}.$$
If this set of MLE's satisfy the constraint $0 \le \hat p_1 \le \hat p_2 \le ... \le \hat p_n \le 1$ then we are done. Otherwise, since there is only a single local maximum at the interior of the parameter space, the global maximum must be on the boundary, namely there must be some $i$ such that $\hat p_i = \hat p_{i+1}$. One can test all possible $n$ pairs, but it is quite clear the highest value of the likelihood will be achieved by applying this to a pair that is in the "wrong" order. Applying this additional constraint only affects the terms in the likelihood involving $p_i$ and $p_{i+1}$ so the equation for the MLE becomes:
$$ \frac{\partial \log \mathcal L}{\partial p_i} = \frac{t_i + t_{i+1}-2}{p_i} - \frac{2}{1-p_i}=0 $$
Which is, understandably, the same equation we got before just with the average $(t_i+t_{i+1})/2$ replacing $t_i$.
Repeating this procedure for all out of order pairs will give us the constrained MLE's. If there are three or more consecutive estimators that are out of order, the number of possibilities we need to test becomes larger. In general there are $2^n$ ways of choosing which consecutive pair of estimators are equal, so this might become non-feasible if all the estimators are completely out of order, but in that case we probably can't say much about $\Phi(x)$ anyway.
Finding the MLE's is just the tip of the iceberg. You may also want to estimate the uncertainty of the estimators, add assumptions on the shape on the distribution $\Phi$ and so on. Describing all methods of doing it will require a full course in statistics. The particular methods that are best suited to your case will depend on the nature of your assumptions and data, and what purpose you want to use it for.
UPDATE
As a simple example we can apply this to the same input data as given in @Ben's answer: $t=(2,7,6,12,15)$. There is one pair in the wrong order $(7,6)$ so we conclude that $p_2=p_3$, and we proceed by replacing those values with the average $6.5$ and simply calculating $(t-1)/t$ for the set $(2,6.5,6.5,12,15)$: this results in $\hat p = (0.5000, 0.8462, 0.8462, 0.9167, 0.9333)$, In complete agreement with @Ben's numerical calculation. | Auction problem | As you pointed out, each observation $(x_i,t_i)$ gives you information on the value of the cumulative distribution at the point $x_i$, however notice that the probability of this observation is $\Phi( | Auction problem
As you pointed out, each observation $(x_i,t_i)$ gives you information on the value of the cumulative distribution at the point $x_i$, however notice that the probability of this observation is $\Phi(x_i)^{t_i-1}(1-\Phi(x_i))$ (the first $t-1$ offers rejected and the last one accepted).
So, without additional assumption on $\Phi$ (such as smoothness), you can only directly estimate from the data the set of values $\{\Phi(x_i)\}$. Now there are many possible methods of statistical inference, but most are based on the likelihood function, so that's a good place to start. Denote $p_i = \Phi(x_i)$ the set of unknown parameters and assume that the $x_i$'s are sorted such that $0 \le p_1 \le p_2 \le ...\le p_n \le 1$. The likelihood function is then
$$\log \mathcal L(p_1,...,p_n) = \sum_{i=1}^n (t_i-1)\log p_i + \log(1-p_i).$$
The constraint on the $p_i$'s being monotonically increasing makes this a slightly less trivial problem, but we can still find the maximum likelihood estimators (MLE) with a bit of work. The unconstrained MLE's are easily found by setting the respective derivatives of the likelihood to zero:
$$ \frac{\partial \log \mathcal L}{\partial p_i} = \frac{t_i - 1}{p_i} - \frac{1}{1-p_i}=0 $$
which gives
$$ \hat p_i = \frac{t_i-1}{t_i}.$$
If this set of MLE's satisfy the constraint $0 \le \hat p_1 \le \hat p_2 \le ... \le \hat p_n \le 1$ then we are done. Otherwise, since there is only a single local maximum at the interior of the parameter space, the global maximum must be on the boundary, namely there must be some $i$ such that $\hat p_i = \hat p_{i+1}$. One can test all possible $n$ pairs, but it is quite clear the highest value of the likelihood will be achieved by applying this to a pair that is in the "wrong" order. Applying this additional constraint only affects the terms in the likelihood involving $p_i$ and $p_{i+1}$ so the equation for the MLE becomes:
$$ \frac{\partial \log \mathcal L}{\partial p_i} = \frac{t_i + t_{i+1}-2}{p_i} - \frac{2}{1-p_i}=0 $$
Which is, understandably, the same equation we got before just with the average $(t_i+t_{i+1})/2$ replacing $t_i$.
Repeating this procedure for all out of order pairs will give us the constrained MLE's. If there are three or more consecutive estimators that are out of order, the number of possibilities we need to test becomes larger. In general there are $2^n$ ways of choosing which consecutive pair of estimators are equal, so this might become non-feasible if all the estimators are completely out of order, but in that case we probably can't say much about $\Phi(x)$ anyway.
Finding the MLE's is just the tip of the iceberg. You may also want to estimate the uncertainty of the estimators, add assumptions on the shape on the distribution $\Phi$ and so on. Describing all methods of doing it will require a full course in statistics. The particular methods that are best suited to your case will depend on the nature of your assumptions and data, and what purpose you want to use it for.
UPDATE
As a simple example we can apply this to the same input data as given in @Ben's answer: $t=(2,7,6,12,15)$. There is one pair in the wrong order $(7,6)$ so we conclude that $p_2=p_3$, and we proceed by replacing those values with the average $6.5$ and simply calculating $(t-1)/t$ for the set $(2,6.5,6.5,12,15)$: this results in $\hat p = (0.5000, 0.8462, 0.8462, 0.9167, 0.9333)$, In complete agreement with @Ben's numerical calculation. | Auction problem
As you pointed out, each observation $(x_i,t_i)$ gives you information on the value of the cumulative distribution at the point $x_i$, however notice that the probability of this observation is $\Phi( |
26,046 | Auction problem | In general, problems like this can be solved by writing out the likelihood function: the likelihood of seeing a particular set of observations as a function of the parameters of the CDF, which I presume is Gaussian with parameters $\mu$ and $\sigma$.
In R, this would look as follows
likelihood_function = function(parameters, asking_price, number_asked){
mu = parameters[1]
sigma = parameters[2]
# Probability of any one person accepting the asking price
p_accept = pnorm(asking_price, mu, sigma, lower.tail = T)
# Number of people asked BEFORE someone accepts
# follows geometric distribution (pdf = p_accept * (1 - p_accept)^number),
number_of_rejections = number_asked - 1
loglikelihood = dgeom(number_of_rejections, p_accept, log = T)
loglikelihood_adj = loglikelihood + 1e-6 # Add tiny correction to prevent underflow
sum(loglikelihood_adj)
}
You can then use optimisation to find the parameters that maximise this function: the maximum-likelihood parameters.
starting_values = c(mu = 50, sigma = 100)
result = optim(starting_values, likelihood_function,
asking_price = data$asking_price,
number_asked = data$number_asked,
control = list(fnscale = -1)) # Find max, not min
result$par
You can find plenty of information on this site on how to calculate the uncertainty around these estimates, e.g. using Fisher information, or Bayesian methods.
While we're here, the code below simulates data from the model you describe.
library(tidyverse)
true_pars = c(mu = 10, sigma = 10)
simulate_trials = function(n_trials, mu, sigma){
# Distribution of asking prices is uniform [0, 100]
asking_price = round(runif(n_trials, 0, 100))
# Probability of any one person accepting the asking price
p_accept = pnorm(asking_price, mu, sigma, lower.tail = T)
# Number of people asked BEFORE someone accepts
# follows geometric distribution (pdf = p_accept * (1 - p_accept)^number),
number_of_rejections = rgeom(n_trials, prob = p_accept)
# so total number asked is that +1
number_asked = number_of_rejections + 1
data.frame(asking_price, p_accept, number_asked) %>%
arrange(asking_price)
}
data = simulate_trials(1000, true_pars[1], true_pars[2])
# ggplot(data, aes(asking_price, p_accept)) + geom_path()
ggplot(data, aes(asking_price, number_asked)) +
stat_smooth() +
scale_y_log10() | Auction problem | In general, problems like this can be solved by writing out the likelihood function: the likelihood of seeing a particular set of observations as a function of the parameters of the CDF, which I presu | Auction problem
In general, problems like this can be solved by writing out the likelihood function: the likelihood of seeing a particular set of observations as a function of the parameters of the CDF, which I presume is Gaussian with parameters $\mu$ and $\sigma$.
In R, this would look as follows
likelihood_function = function(parameters, asking_price, number_asked){
mu = parameters[1]
sigma = parameters[2]
# Probability of any one person accepting the asking price
p_accept = pnorm(asking_price, mu, sigma, lower.tail = T)
# Number of people asked BEFORE someone accepts
# follows geometric distribution (pdf = p_accept * (1 - p_accept)^number),
number_of_rejections = number_asked - 1
loglikelihood = dgeom(number_of_rejections, p_accept, log = T)
loglikelihood_adj = loglikelihood + 1e-6 # Add tiny correction to prevent underflow
sum(loglikelihood_adj)
}
You can then use optimisation to find the parameters that maximise this function: the maximum-likelihood parameters.
starting_values = c(mu = 50, sigma = 100)
result = optim(starting_values, likelihood_function,
asking_price = data$asking_price,
number_asked = data$number_asked,
control = list(fnscale = -1)) # Find max, not min
result$par
You can find plenty of information on this site on how to calculate the uncertainty around these estimates, e.g. using Fisher information, or Bayesian methods.
While we're here, the code below simulates data from the model you describe.
library(tidyverse)
true_pars = c(mu = 10, sigma = 10)
simulate_trials = function(n_trials, mu, sigma){
# Distribution of asking prices is uniform [0, 100]
asking_price = round(runif(n_trials, 0, 100))
# Probability of any one person accepting the asking price
p_accept = pnorm(asking_price, mu, sigma, lower.tail = T)
# Number of people asked BEFORE someone accepts
# follows geometric distribution (pdf = p_accept * (1 - p_accept)^number),
number_of_rejections = rgeom(n_trials, prob = p_accept)
# so total number asked is that +1
number_asked = number_of_rejections + 1
data.frame(asking_price, p_accept, number_asked) %>%
arrange(asking_price)
}
data = simulate_trials(1000, true_pars[1], true_pars[2])
# ggplot(data, aes(asking_price, p_accept)) + geom_path()
ggplot(data, aes(asking_price, number_asked)) +
stat_smooth() +
scale_y_log10() | Auction problem
In general, problems like this can be solved by writing out the likelihood function: the likelihood of seeing a particular set of observations as a function of the parameters of the CDF, which I presu |
26,047 | Aren't ALL Parameters Eventually "Nuisance Parameters"? | The concept of nuisance parameters is somewhat controversial, and some argue it should not be used (I do not understand that argument). It might be better to focus on the opposite concept of interest parameters (also called focus parameters, see for instance Changing the size of a confidence interval in order to emphasize results)
Start with what is your research question. If that can be formulated as a question about one (or a few parameters), those are the interest parameter(s).
If it can only be formulated as a question about some complicated function of the parameters, consider a reparametrization so your focus/interest parameter is actually a parameter in the model.
Now, for the nuisance parameters, they are just those left after you have selected your interest parameter(s). There are many posts on this site about nuisance parameters, so search! Some:
When do we have nuisance parameters?
Is there a radical difference in how bayesian and frequentist approaches treat nuisance parameters?
For your normal means example, if your research question is only about the mean, then the variance parameter $\sigma^2$ is a nuisance parameter. It does not influence your hypothesis/research question directly, but it determines the precision with which you estimate the mean. But be careful, if the variance is not a constant (for instance, varies between different groups in the data), then variance might well be of interest after all. See Unequal variance in randomized experiments to compare treatment with control? and references therein. | Aren't ALL Parameters Eventually "Nuisance Parameters"? | The concept of nuisance parameters is somewhat controversial, and some argue it should not be used (I do not understand that argument). It might be better to focus on the opposite concept of interest | Aren't ALL Parameters Eventually "Nuisance Parameters"?
The concept of nuisance parameters is somewhat controversial, and some argue it should not be used (I do not understand that argument). It might be better to focus on the opposite concept of interest parameters (also called focus parameters, see for instance Changing the size of a confidence interval in order to emphasize results)
Start with what is your research question. If that can be formulated as a question about one (or a few parameters), those are the interest parameter(s).
If it can only be formulated as a question about some complicated function of the parameters, consider a reparametrization so your focus/interest parameter is actually a parameter in the model.
Now, for the nuisance parameters, they are just those left after you have selected your interest parameter(s). There are many posts on this site about nuisance parameters, so search! Some:
When do we have nuisance parameters?
Is there a radical difference in how bayesian and frequentist approaches treat nuisance parameters?
For your normal means example, if your research question is only about the mean, then the variance parameter $\sigma^2$ is a nuisance parameter. It does not influence your hypothesis/research question directly, but it determines the precision with which you estimate the mean. But be careful, if the variance is not a constant (for instance, varies between different groups in the data), then variance might well be of interest after all. See Unequal variance in randomized experiments to compare treatment with control? and references therein. | Aren't ALL Parameters Eventually "Nuisance Parameters"?
The concept of nuisance parameters is somewhat controversial, and some argue it should not be used (I do not understand that argument). It might be better to focus on the opposite concept of interest |
26,048 | Modern machine learning and the bias-variance trade-off | The main point about Belkin's Double Descent is that, at the interpolation threshold, i.e. the least model capacity where you fit training data exactly, the number of solutions is very constrained.
The model has to "stretch" to reach the interpolation threshold with a limited capacity.
When you increase capacity further than that, the space of interpolating solutions opens-up, actually allowing optimization to reach lower-norm interpolating solutions.
These tend to generalize better, and that's why you get the second descent on test data. | Modern machine learning and the bias-variance trade-off | The main point about Belkin's Double Descent is that, at the interpolation threshold, i.e. the least model capacity where you fit training data exactly, the number of solutions is very constrained.
Th | Modern machine learning and the bias-variance trade-off
The main point about Belkin's Double Descent is that, at the interpolation threshold, i.e. the least model capacity where you fit training data exactly, the number of solutions is very constrained.
The model has to "stretch" to reach the interpolation threshold with a limited capacity.
When you increase capacity further than that, the space of interpolating solutions opens-up, actually allowing optimization to reach lower-norm interpolating solutions.
These tend to generalize better, and that's why you get the second descent on test data. | Modern machine learning and the bias-variance trade-off
The main point about Belkin's Double Descent is that, at the interpolation threshold, i.e. the least model capacity where you fit training data exactly, the number of solutions is very constrained.
Th |
26,049 | Propensity score matching vs non-parametric regression | This is a great question and one for which there is no single answer, so I won't attempt to give one to be comprehensive. I'll mention a few topics that might satisfy some of your curiosity and point you to some interesting studies seeking to address the question you asked.
The method you described of training a random forest and then producing predictions under the treatment and under control is a well-established and somewhat popular method called g-computation. The bootstrap is often used to estimate confidence intervals for effects estimated with g-computation. A recently popular method of g-computation uses Bayesian additive regression trees (BART) as the model; it has proven to be very successful and straightforward to use because it does not require parameter tuning. Inference is straightforward because it produces a Bayesian posterior from which credible intervals can be computed and interpreted as confidence intervals.
There is a class of methods known as "doubly-robust" methods that involve estimating both an outcome model and a propensity score model and combining them. A benefit of these methods is that the estimate is consistent (i.e., unbiased in large samples) if either the propensity score model or outcome model is correct, and often inference is straightforward with these methods. Examples of doubly-robust methods include augmented inverse probability weighting (AIPW), targeted minimum loss-based estimation (TMLE), g-computation in propensity score-matched samples, and BART with the propensity score as an additional covariate. These methods are gaining popularity and are widely discussed in the statistics literature. They combine the best of both outcome modeling and treatment modeling.
That said, many researchers prefer to only use matching and other treatment model-focused methods like weighting. I'll provide a short list of some of the primary motivations I've seen:
Matching methods can be more robust to model misspecification, making their estimates more trustworthy
Matching and weighting involve the assessment and reporting of covariate balance, which provides evidence to the reader that the method has plausibly reduced all the bias due to the measured covariates (this cannot be done with outcome regression)
With matching and weighting, one can try many different methods without estimating a treatment effect to find the one that is going to be the most trustworthy. With outcome modeling, you only get one chance, or else you succumb to capitalization on chance and the potential to try many models until the desired effect is found
Matching methods are easier to understand and explain to lay audiences
Matching and weighting are agnostic to the outcome type, so they can be used in larger models or for outcome types for which g-computation is less straightforward, like survival outcomes
Matching and weighting methods are sometimes found to be less biased than g-computation in simulations
Matching and weighting are more transparent and customizable; it is easier to incorporate substantive expertise into the way certain variables are prioritized
Matching and weighting do not involve extrapolation beyond the region of common support
Hopefully that list gets you started in trying to understand this choice. Unfortunately the question of "should I use matching or g-computation for my data?" is basically equivalent to "what is the correct model for my data?" which is an eternal mystery. The "correct" answer for any given dataset is unknown, and some methods may be better suited for different kinds of datasets based on qualities that are unobservable.
To specifically address your hypotheses:
Yes, sometimes, though combinations of both tend to do best.
Yes-ish; bootstrapping is often used, but not necessarily always valid. For some methods, we can use Bayesian to help. G-computation is not too hard to implement nonparametrically but it often has to be manually programmed.
Same as 2).
Absolutely yes. Just because a method is flexible doesn't mean it will always get the answer right. There is an inherent bias-variance tradeoff that must be managed with all methods. BART tends to do better than other machine learning methods because of how it balances flexibility with precision.
Not really; we know a lot about how to use them, but we know a lot about how they can be improved and using doubly robust methods in many cases dramatically improves their performance. | Propensity score matching vs non-parametric regression | This is a great question and one for which there is no single answer, so I won't attempt to give one to be comprehensive. I'll mention a few topics that might satisfy some of your curiosity and point | Propensity score matching vs non-parametric regression
This is a great question and one for which there is no single answer, so I won't attempt to give one to be comprehensive. I'll mention a few topics that might satisfy some of your curiosity and point you to some interesting studies seeking to address the question you asked.
The method you described of training a random forest and then producing predictions under the treatment and under control is a well-established and somewhat popular method called g-computation. The bootstrap is often used to estimate confidence intervals for effects estimated with g-computation. A recently popular method of g-computation uses Bayesian additive regression trees (BART) as the model; it has proven to be very successful and straightforward to use because it does not require parameter tuning. Inference is straightforward because it produces a Bayesian posterior from which credible intervals can be computed and interpreted as confidence intervals.
There is a class of methods known as "doubly-robust" methods that involve estimating both an outcome model and a propensity score model and combining them. A benefit of these methods is that the estimate is consistent (i.e., unbiased in large samples) if either the propensity score model or outcome model is correct, and often inference is straightforward with these methods. Examples of doubly-robust methods include augmented inverse probability weighting (AIPW), targeted minimum loss-based estimation (TMLE), g-computation in propensity score-matched samples, and BART with the propensity score as an additional covariate. These methods are gaining popularity and are widely discussed in the statistics literature. They combine the best of both outcome modeling and treatment modeling.
That said, many researchers prefer to only use matching and other treatment model-focused methods like weighting. I'll provide a short list of some of the primary motivations I've seen:
Matching methods can be more robust to model misspecification, making their estimates more trustworthy
Matching and weighting involve the assessment and reporting of covariate balance, which provides evidence to the reader that the method has plausibly reduced all the bias due to the measured covariates (this cannot be done with outcome regression)
With matching and weighting, one can try many different methods without estimating a treatment effect to find the one that is going to be the most trustworthy. With outcome modeling, you only get one chance, or else you succumb to capitalization on chance and the potential to try many models until the desired effect is found
Matching methods are easier to understand and explain to lay audiences
Matching and weighting are agnostic to the outcome type, so they can be used in larger models or for outcome types for which g-computation is less straightforward, like survival outcomes
Matching and weighting methods are sometimes found to be less biased than g-computation in simulations
Matching and weighting are more transparent and customizable; it is easier to incorporate substantive expertise into the way certain variables are prioritized
Matching and weighting do not involve extrapolation beyond the region of common support
Hopefully that list gets you started in trying to understand this choice. Unfortunately the question of "should I use matching or g-computation for my data?" is basically equivalent to "what is the correct model for my data?" which is an eternal mystery. The "correct" answer for any given dataset is unknown, and some methods may be better suited for different kinds of datasets based on qualities that are unobservable.
To specifically address your hypotheses:
Yes, sometimes, though combinations of both tend to do best.
Yes-ish; bootstrapping is often used, but not necessarily always valid. For some methods, we can use Bayesian to help. G-computation is not too hard to implement nonparametrically but it often has to be manually programmed.
Same as 2).
Absolutely yes. Just because a method is flexible doesn't mean it will always get the answer right. There is an inherent bias-variance tradeoff that must be managed with all methods. BART tends to do better than other machine learning methods because of how it balances flexibility with precision.
Not really; we know a lot about how to use them, but we know a lot about how they can be improved and using doubly robust methods in many cases dramatically improves their performance. | Propensity score matching vs non-parametric regression
This is a great question and one for which there is no single answer, so I won't attempt to give one to be comprehensive. I'll mention a few topics that might satisfy some of your curiosity and point |
26,050 | Propensity score matching vs non-parametric regression | I found this set of lecture notes to be quite helpful: https://mlhcmit.github.io/slides/lecture15.pdf
There are two common approaches for counterfactual inference, Propensity Scores, and Covariate adjustment.
For Covariate Adjustment you explicitly model the relationship between treatment, confounders, and outcome. Obviously there are lots of options on how to model the relationship, from linear regression, to more advanced techniques, for example random forests and deep learning
To be honest, I'm not sure of why to prefer one approach vs. the other, one thought is perhaps if you're not confident about how to model the causal relationship, or if you've captured all the confounders, but you're able to predict treatment well, then you might favor propsensity score matching? | Propensity score matching vs non-parametric regression | I found this set of lecture notes to be quite helpful: https://mlhcmit.github.io/slides/lecture15.pdf
There are two common approaches for counterfactual inference, Propensity Scores, and Covariate adj | Propensity score matching vs non-parametric regression
I found this set of lecture notes to be quite helpful: https://mlhcmit.github.io/slides/lecture15.pdf
There are two common approaches for counterfactual inference, Propensity Scores, and Covariate adjustment.
For Covariate Adjustment you explicitly model the relationship between treatment, confounders, and outcome. Obviously there are lots of options on how to model the relationship, from linear regression, to more advanced techniques, for example random forests and deep learning
To be honest, I'm not sure of why to prefer one approach vs. the other, one thought is perhaps if you're not confident about how to model the causal relationship, or if you've captured all the confounders, but you're able to predict treatment well, then you might favor propsensity score matching? | Propensity score matching vs non-parametric regression
I found this set of lecture notes to be quite helpful: https://mlhcmit.github.io/slides/lecture15.pdf
There are two common approaches for counterfactual inference, Propensity Scores, and Covariate adj |
26,051 | Abraham Wald survivorship bias intuition | Wald wrote his analysis in a set of eight technical memoranda for the Statistical Research Group (SRG), and these documents have been published by the Centre for Naval Analysis, so you can actually read them and see exactly what he did in his written work. The original memos can be found here and a good summary and analysis of his work on survival of aircraft is set out in Mangel and Samaniego (1984). If you read this paper and the accompanying technical memos you will see that Wald did indeed develop a theoretical model of aircraft survival to make his conclusions.
Wald's analysis covered multiple problems, starting with estimation of the survival probabilities for aircraft based on the number of hits to those aircraft, and then proceeding in more detail to estimation based on the number and location of the hits. His method goes essentially like this. For any plane that leaves on a bombing run, there is a distribution for the number of hits that plane will take. For any given number of hits there is an associated survival probability; a plane with no hits is assumed to survive with probability one, and the conditionl probability of survivial from each hit is some positive probability. Based on this, it is possible to use data on the returning planes to estimate the conditional probabilities of survival for each hit. (Any plane that does not return is assumed to have been hit at least once, and is missing data.)
To deal with different probabilities for hits to different locations, Wald expanded his model to divide the plane into a finite number of locations, and expanded the model so that there is an unknown conditional probability of survival for each hit to each location. Wald assumed that the conditional distribution of hits to specific locations (given the total number of hits) was fixed. He advanced the view that this could be determined experimentally within the military research centres by firing dummy bullets at real aircraft. Given assumed values for these probabilties (based on independent experiments), and some sensible statistical independence assumptions, you can then use the data on the number and locations of hits on returning planes to estimate the conditional probabilities of survival for each hit on a particular location. (Again, any plane that does not return is assumed to have been hit at least once, and is missing data.) If you formulate a model like this, the phenomenon under consideration here will emerge --- i.e., the more hits observed on a particular location, the higher the estimated survival probability for hits on that location will be. Thus, the parts of the aircraft showing the lowest survivial probability for hits will be those that have the lowest number of hits in the returning planes (relative to the probability of being hit in that location).
Wald's technical memoranda on this subject give specific formulae for his models and estimation methods for the unknown conditional probabilities. Nevertheless, it is not necessary to understand the technical details to understand his basic insight that areas of the plane exhibiting low numbers of hits (on the returning planes) are actually the most vulnerable parts. The reason this story is so wonderful is that it illustrates a counter-intuitive problem involving missing data where the intuitive answer for most people is the opposite of the correct answer. I have used this problem as a teaching example in statistics seminars a number of times, and when asked their advice, the audience inevitably advise that more armour should be attached to the parts of the planes that showed the most damage in the data. When they are informed of Wald's opposite advice, and the reasoning for it, they are usually very impressed and realise their error.
Finally, with regard to the actual folk legend that has emerged around this, I am not aware of any evidence showing exactly what conversations Wald had with the military, what he said, or who disagreed with him (or was surprised by his advice). However, in the versions of the story I have heard, it was not other statisticians he was disagreeing with, but military officials who lacked the statistical training needed to have the intuitively correct answer to this missing data problem. In any case, it is a brilliant story about a brilliant man. | Abraham Wald survivorship bias intuition | Wald wrote his analysis in a set of eight technical memoranda for the Statistical Research Group (SRG), and these documents have been published by the Centre for Naval Analysis, so you can actually re | Abraham Wald survivorship bias intuition
Wald wrote his analysis in a set of eight technical memoranda for the Statistical Research Group (SRG), and these documents have been published by the Centre for Naval Analysis, so you can actually read them and see exactly what he did in his written work. The original memos can be found here and a good summary and analysis of his work on survival of aircraft is set out in Mangel and Samaniego (1984). If you read this paper and the accompanying technical memos you will see that Wald did indeed develop a theoretical model of aircraft survival to make his conclusions.
Wald's analysis covered multiple problems, starting with estimation of the survival probabilities for aircraft based on the number of hits to those aircraft, and then proceeding in more detail to estimation based on the number and location of the hits. His method goes essentially like this. For any plane that leaves on a bombing run, there is a distribution for the number of hits that plane will take. For any given number of hits there is an associated survival probability; a plane with no hits is assumed to survive with probability one, and the conditionl probability of survivial from each hit is some positive probability. Based on this, it is possible to use data on the returning planes to estimate the conditional probabilities of survival for each hit. (Any plane that does not return is assumed to have been hit at least once, and is missing data.)
To deal with different probabilities for hits to different locations, Wald expanded his model to divide the plane into a finite number of locations, and expanded the model so that there is an unknown conditional probability of survival for each hit to each location. Wald assumed that the conditional distribution of hits to specific locations (given the total number of hits) was fixed. He advanced the view that this could be determined experimentally within the military research centres by firing dummy bullets at real aircraft. Given assumed values for these probabilties (based on independent experiments), and some sensible statistical independence assumptions, you can then use the data on the number and locations of hits on returning planes to estimate the conditional probabilities of survival for each hit on a particular location. (Again, any plane that does not return is assumed to have been hit at least once, and is missing data.) If you formulate a model like this, the phenomenon under consideration here will emerge --- i.e., the more hits observed on a particular location, the higher the estimated survival probability for hits on that location will be. Thus, the parts of the aircraft showing the lowest survivial probability for hits will be those that have the lowest number of hits in the returning planes (relative to the probability of being hit in that location).
Wald's technical memoranda on this subject give specific formulae for his models and estimation methods for the unknown conditional probabilities. Nevertheless, it is not necessary to understand the technical details to understand his basic insight that areas of the plane exhibiting low numbers of hits (on the returning planes) are actually the most vulnerable parts. The reason this story is so wonderful is that it illustrates a counter-intuitive problem involving missing data where the intuitive answer for most people is the opposite of the correct answer. I have used this problem as a teaching example in statistics seminars a number of times, and when asked their advice, the audience inevitably advise that more armour should be attached to the parts of the planes that showed the most damage in the data. When they are informed of Wald's opposite advice, and the reasoning for it, they are usually very impressed and realise their error.
Finally, with regard to the actual folk legend that has emerged around this, I am not aware of any evidence showing exactly what conversations Wald had with the military, what he said, or who disagreed with him (or was surprised by his advice). However, in the versions of the story I have heard, it was not other statisticians he was disagreeing with, but military officials who lacked the statistical training needed to have the intuitively correct answer to this missing data problem. In any case, it is a brilliant story about a brilliant man. | Abraham Wald survivorship bias intuition
Wald wrote his analysis in a set of eight technical memoranda for the Statistical Research Group (SRG), and these documents have been published by the Centre for Naval Analysis, so you can actually re |
26,052 | Abraham Wald survivorship bias intuition | I thank all those who have had their time bringing an answer.
In the meantime, I have been looking for more on the subject and found his article with the intuitions and mathematical proofs. Follow this link:
https://apps.dtic.mil/dtic/tr/fulltext/u2/a091073.pdf
Really a remarkable statistician! | Abraham Wald survivorship bias intuition | I thank all those who have had their time bringing an answer.
In the meantime, I have been looking for more on the subject and found his article with the intuitions and mathematical proofs. Follow thi | Abraham Wald survivorship bias intuition
I thank all those who have had their time bringing an answer.
In the meantime, I have been looking for more on the subject and found his article with the intuitions and mathematical proofs. Follow this link:
https://apps.dtic.mil/dtic/tr/fulltext/u2/a091073.pdf
Really a remarkable statistician! | Abraham Wald survivorship bias intuition
I thank all those who have had their time bringing an answer.
In the meantime, I have been looking for more on the subject and found his article with the intuitions and mathematical proofs. Follow thi |
26,053 | Abraham Wald survivorship bias intuition | I think it is just that Abraham Wald was a clever man and an acomplished statistician, and saw that aircraft observed were not a random sample, but rather a sample self-selected by survivorship.
I do not think that a "mathematical proof" can be given that certain concrete areas need reinforcing. Rather what Wald did is a sensible descriptive analysis of the data at hand, supplemented with sound statistical judgement. I imagine that when he proposed to reinforce areas with no impacts, subject-matter specialists looked upon those areas and confirmed that they were the critical ones to protect. | Abraham Wald survivorship bias intuition | I think it is just that Abraham Wald was a clever man and an acomplished statistician, and saw that aircraft observed were not a random sample, but rather a sample self-selected by survivorship.
I do | Abraham Wald survivorship bias intuition
I think it is just that Abraham Wald was a clever man and an acomplished statistician, and saw that aircraft observed were not a random sample, but rather a sample self-selected by survivorship.
I do not think that a "mathematical proof" can be given that certain concrete areas need reinforcing. Rather what Wald did is a sensible descriptive analysis of the data at hand, supplemented with sound statistical judgement. I imagine that when he proposed to reinforce areas with no impacts, subject-matter specialists looked upon those areas and confirmed that they were the critical ones to protect. | Abraham Wald survivorship bias intuition
I think it is just that Abraham Wald was a clever man and an acomplished statistician, and saw that aircraft observed were not a random sample, but rather a sample self-selected by survivorship.
I do |
26,054 | What is gained from a scale-location plot? | In the example which you show the two plots, the residuals versus fitted and the scale versus location clearly give the same message. The scale location plot however is superior when the points are rather unevenly distributed along the $x$-axis. In that case it can be hard to distinguish in the residual versus fitted whether the apparent increase in spread is because there are more points in that part of the space or because there is a genuine increase. | What is gained from a scale-location plot? | In the example which you show the two plots, the residuals versus fitted and the scale versus location clearly give the same message. The scale location plot however is superior when the points are ra | What is gained from a scale-location plot?
In the example which you show the two plots, the residuals versus fitted and the scale versus location clearly give the same message. The scale location plot however is superior when the points are rather unevenly distributed along the $x$-axis. In that case it can be hard to distinguish in the residual versus fitted whether the apparent increase in spread is because there are more points in that part of the space or because there is a genuine increase. | What is gained from a scale-location plot?
In the example which you show the two plots, the residuals versus fitted and the scale versus location clearly give the same message. The scale location plot however is superior when the points are ra |
26,055 | What is gained from a scale-location plot? | The scale-location plot makes it easier to diagnose heteroscedasticity. In the present case this is also evident from the residual plot, but the scale-location plot makes it clearer, since it also allows you to fit a smoothed line showing the change in the root-absolute residuals with respect to the fitted values. | What is gained from a scale-location plot? | The scale-location plot makes it easier to diagnose heteroscedasticity. In the present case this is also evident from the residual plot, but the scale-location plot makes it clearer, since it also al | What is gained from a scale-location plot?
The scale-location plot makes it easier to diagnose heteroscedasticity. In the present case this is also evident from the residual plot, but the scale-location plot makes it clearer, since it also allows you to fit a smoothed line showing the change in the root-absolute residuals with respect to the fitted values. | What is gained from a scale-location plot?
The scale-location plot makes it easier to diagnose heteroscedasticity. In the present case this is also evident from the residual plot, but the scale-location plot makes it clearer, since it also al |
26,056 | How to use a cross-validated model for prediction? | tl;dr Yes, you could build a voting classifier using the array of your trained estimators. I don't recommend that, especially as I don't know much about the use case.
My typical workflow
There could be multiple candidates to build a decent estimator in this use case (Let's say RandomForest, xgboost, SVM)
Build an estimator using each of them with their optimal hyper parameters (here is one way to do that)
Evaluate the above estimators for predictive power and how well they generalize across different test sets (I would use Cross-validation here)
Some/all candidate estimators seem to fair well (this would be helpful here)
Build an ensemble of multiple estimators for better predictive and/or generalizing power. (I could use VotingClassifier here)
VotingClassifier is mainly used to vote among different techniques, you could of course also use it as you said though. Following is a quick take on usage of cross validation and also about voting.
Thoughts about your use case
Cross-validation is mainly used as a way to check for over-fit. Assuming you have determined the optimal hyper parameters of your classification technique (Let's assume random forest for now), you would then want to see if the model generalizes well across different test sets.
Cross-validation in your case would build k estimators (assuming k-fold CV) and then you could check the predictive power and variance of the technique on your data as following:
mean of the quality measure. Higher, the better
standard_deviation of the quality measure. Lower, the better
A high mean and low standard deviation of your quality measure would mean the modeling technique is doing well.
Assuming the above measure looks good, you could then conclude that random forest with the hyper parameters used is a decent candidate model. If you think your classification technique does well enough, then you could also build a voting classifier using the k estimators from CV. | How to use a cross-validated model for prediction? | tl;dr Yes, you could build a voting classifier using the array of your trained estimators. I don't recommend that, especially as I don't know much about the use case.
My typical workflow
There could | How to use a cross-validated model for prediction?
tl;dr Yes, you could build a voting classifier using the array of your trained estimators. I don't recommend that, especially as I don't know much about the use case.
My typical workflow
There could be multiple candidates to build a decent estimator in this use case (Let's say RandomForest, xgboost, SVM)
Build an estimator using each of them with their optimal hyper parameters (here is one way to do that)
Evaluate the above estimators for predictive power and how well they generalize across different test sets (I would use Cross-validation here)
Some/all candidate estimators seem to fair well (this would be helpful here)
Build an ensemble of multiple estimators for better predictive and/or generalizing power. (I could use VotingClassifier here)
VotingClassifier is mainly used to vote among different techniques, you could of course also use it as you said though. Following is a quick take on usage of cross validation and also about voting.
Thoughts about your use case
Cross-validation is mainly used as a way to check for over-fit. Assuming you have determined the optimal hyper parameters of your classification technique (Let's assume random forest for now), you would then want to see if the model generalizes well across different test sets.
Cross-validation in your case would build k estimators (assuming k-fold CV) and then you could check the predictive power and variance of the technique on your data as following:
mean of the quality measure. Higher, the better
standard_deviation of the quality measure. Lower, the better
A high mean and low standard deviation of your quality measure would mean the modeling technique is doing well.
Assuming the above measure looks good, you could then conclude that random forest with the hyper parameters used is a decent candidate model. If you think your classification technique does well enough, then you could also build a voting classifier using the k estimators from CV. | How to use a cross-validated model for prediction?
tl;dr Yes, you could build a voting classifier using the array of your trained estimators. I don't recommend that, especially as I don't know much about the use case.
My typical workflow
There could |
26,057 | How to use a cross-validated model for prediction? | (I'm sure we have some answers of this question already, but I cannot find them right now.)
Does that mean I'm stuck with ensembling k models for all future predictions now?
No, usually that's not what you do.
Ensemble models differ fundamentally from models that do not aggregate the predictions of many submodels.
For "normal" (unaggregated) cross validation, you typically apply the same training algorithm that was used during cross validation to fit the surrogate models to the whole data set (as it is before splitting for cross validation).
In sklearn context, that means the fit function of the estimator you hand over to cross_validate:
With the example in cross_val_predict:
>>> from sklearn import datasets, linear_model
>>> from sklearn.model_selection import cross_val_predict
>>> diabetes = datasets.load_diabetes()
>>> X = diabetes.data[:150]
>>> y = diabetes.target[:150]
>>> lasso = linear_model.Lasso()
>>> y_pred = cross_val_predict(lasso, X, y, cv=3)
Now,
>>> final_model = lasso.fit (X, y)
>>> new_predictions = final_model.predict (diabetes.data [440:442])
Why not ensemble
Ensemble models differ from "single" not aggregated models by aggregating the predictions of several submodels. The aggregated model will yield more stable predictions than each of the submodels if the submodels suffer from instability. If the submodels are stable, there's no difference in the prediction (just a waste of computational resources).
Normal cross validation compares un-aggregated predictions to the ground truth, so it doesn't evaluate possible stabilization by aggregating.
Thus,
for an un-aggregated model, an un-aggregated (i.e. the usual) cross validation can be used as approximation for predictive performance/generalization error estimate.
for an ensemble model, we also need an ensemble-type estimation of performance / generalization error, such as out-of-bag or its cross validation analogue.
And vice versa.
Using an un-aggregated cross validation estimate for an ensemble model will cause a pessimistic bias that can be anywhere between negligible and large, depending on how stable the CV surrogate models are and how many surrogate models are aggregated.
Moreover, this bias is unnecessary as using the corresponding fit function and cross validaton scheme will only be subject to the small pessimistic bias for having feweer training cases (and/or fewer submodels to aggregate) for the surrogate models. | How to use a cross-validated model for prediction? | (I'm sure we have some answers of this question already, but I cannot find them right now.)
Does that mean I'm stuck with ensembling k models for all future predictions now?
No, usually that's not w | How to use a cross-validated model for prediction?
(I'm sure we have some answers of this question already, but I cannot find them right now.)
Does that mean I'm stuck with ensembling k models for all future predictions now?
No, usually that's not what you do.
Ensemble models differ fundamentally from models that do not aggregate the predictions of many submodels.
For "normal" (unaggregated) cross validation, you typically apply the same training algorithm that was used during cross validation to fit the surrogate models to the whole data set (as it is before splitting for cross validation).
In sklearn context, that means the fit function of the estimator you hand over to cross_validate:
With the example in cross_val_predict:
>>> from sklearn import datasets, linear_model
>>> from sklearn.model_selection import cross_val_predict
>>> diabetes = datasets.load_diabetes()
>>> X = diabetes.data[:150]
>>> y = diabetes.target[:150]
>>> lasso = linear_model.Lasso()
>>> y_pred = cross_val_predict(lasso, X, y, cv=3)
Now,
>>> final_model = lasso.fit (X, y)
>>> new_predictions = final_model.predict (diabetes.data [440:442])
Why not ensemble
Ensemble models differ from "single" not aggregated models by aggregating the predictions of several submodels. The aggregated model will yield more stable predictions than each of the submodels if the submodels suffer from instability. If the submodels are stable, there's no difference in the prediction (just a waste of computational resources).
Normal cross validation compares un-aggregated predictions to the ground truth, so it doesn't evaluate possible stabilization by aggregating.
Thus,
for an un-aggregated model, an un-aggregated (i.e. the usual) cross validation can be used as approximation for predictive performance/generalization error estimate.
for an ensemble model, we also need an ensemble-type estimation of performance / generalization error, such as out-of-bag or its cross validation analogue.
And vice versa.
Using an un-aggregated cross validation estimate for an ensemble model will cause a pessimistic bias that can be anywhere between negligible and large, depending on how stable the CV surrogate models are and how many surrogate models are aggregated.
Moreover, this bias is unnecessary as using the corresponding fit function and cross validaton scheme will only be subject to the small pessimistic bias for having feweer training cases (and/or fewer submodels to aggregate) for the surrogate models. | How to use a cross-validated model for prediction?
(I'm sure we have some answers of this question already, but I cannot find them right now.)
Does that mean I'm stuck with ensembling k models for all future predictions now?
No, usually that's not w |
26,058 | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate] | NB: This historically first answer to the OP question. In statistics, the Neyman–Pearson lemma was introduced by Jerzy Neyman and Egon Pearson in a paper in 1933.. Also, it is used in practice by statisticians as a theorem, not a lemma, and it is called a lemma largely because of the 1936 paper. IMHO, the historical treatment does not answer the "why" question, and this post attempts to do that.
Lemmas are what people refer to as lemmas, and not some fixed idea of what a lemma should be. In that light, the Neyman–Pearson lemma is a lemma because that is what it is called.
What a lemma is as contrasted to a theorem or corollary is addressed elsewhere and here. More exactly, as to the matter of definition: Lemma, first meaning: A subsidiary or intermediate theorem in an argument or proof. I agree with the Oxford dictionary but would have changed the word order, and note the exact language: intermediate or subsidiary theorem. Some authors believe that a lemma must be intermediary in a proof, and this is the case for many unnamed lemmas. However, it is common, at least for named lemmas, for the lemma result to be an implication arising from an already proven theorem such that the lemma is an additional, i.e., subsidiary theorem. From the New World Encyclopedia The distinction between theorems and lemmas is rather arbitrary, since one mathematician's major result is another's minor claim. Gauss' lemma and Zorn's lemma, for example, are interesting enough per se that some authors present the nominal lemma without going on to use it in the proof of any theorem. Another example of this is Evans lemma, which follows not from proof of a simple theorem of differential geometry which...shows that the first Cartan structure equation is an equality of two tetrad postulates...The tetrad postulate [Sic, itself] is the source of the Evans Lemma of differential geometry. Wikipedia mentions the evolution of lemmas in time: In some cases, as the relative importance of different theorems becomes more clear, what was once considered a lemma is now considered a theorem, though the word "lemma" remains in the name.
However, note well that whether or not they stand alone lemmas are also theorems. That is, a theorem that is a lemmas may sometimes be an answer to the question, "What does the (above) theorem imply?" Sometimes lemmas are a stepping stone used to establish a theorem.
It is clear from reading the 1933 paper: IX. On the problem of the most efficient tests of statistical hypotheses. Jerzy Neyman, Egon Sharpe Pearson, and Karl Pearson, that the theorem being explored is Bayes' theorem. Some readers of this post have difficulty relating Bayes' theorem to the 1933 paper despite an introduction that is rather explicit in that regard. Note that the 1933 paper is littered with Venn diagrams, Venn diagrams illustrate conditional probability, which is Bayes' theorem. Some people refer to this as Bayes' rule, as it is an exaggeration to refer to that rule as being a "theorem." For example, if we were to call 'addition' a theorem, as opposed to being a rule, we would confound rather than explain.
Therefore, the Neyman-Pearson lemma is a theorem concerning the most efficient testing of Bayesian hypotheses, but is not currently called that because it was not to begin with. | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate] | NB: This historically first answer to the OP question. In statistics, the Neyman–Pearson lemma was introduced by Jerzy Neyman and Egon Pearson in a paper in 1933.. Also, it is used in practice by stat | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate]
NB: This historically first answer to the OP question. In statistics, the Neyman–Pearson lemma was introduced by Jerzy Neyman and Egon Pearson in a paper in 1933.. Also, it is used in practice by statisticians as a theorem, not a lemma, and it is called a lemma largely because of the 1936 paper. IMHO, the historical treatment does not answer the "why" question, and this post attempts to do that.
Lemmas are what people refer to as lemmas, and not some fixed idea of what a lemma should be. In that light, the Neyman–Pearson lemma is a lemma because that is what it is called.
What a lemma is as contrasted to a theorem or corollary is addressed elsewhere and here. More exactly, as to the matter of definition: Lemma, first meaning: A subsidiary or intermediate theorem in an argument or proof. I agree with the Oxford dictionary but would have changed the word order, and note the exact language: intermediate or subsidiary theorem. Some authors believe that a lemma must be intermediary in a proof, and this is the case for many unnamed lemmas. However, it is common, at least for named lemmas, for the lemma result to be an implication arising from an already proven theorem such that the lemma is an additional, i.e., subsidiary theorem. From the New World Encyclopedia The distinction between theorems and lemmas is rather arbitrary, since one mathematician's major result is another's minor claim. Gauss' lemma and Zorn's lemma, for example, are interesting enough per se that some authors present the nominal lemma without going on to use it in the proof of any theorem. Another example of this is Evans lemma, which follows not from proof of a simple theorem of differential geometry which...shows that the first Cartan structure equation is an equality of two tetrad postulates...The tetrad postulate [Sic, itself] is the source of the Evans Lemma of differential geometry. Wikipedia mentions the evolution of lemmas in time: In some cases, as the relative importance of different theorems becomes more clear, what was once considered a lemma is now considered a theorem, though the word "lemma" remains in the name.
However, note well that whether or not they stand alone lemmas are also theorems. That is, a theorem that is a lemmas may sometimes be an answer to the question, "What does the (above) theorem imply?" Sometimes lemmas are a stepping stone used to establish a theorem.
It is clear from reading the 1933 paper: IX. On the problem of the most efficient tests of statistical hypotheses. Jerzy Neyman, Egon Sharpe Pearson, and Karl Pearson, that the theorem being explored is Bayes' theorem. Some readers of this post have difficulty relating Bayes' theorem to the 1933 paper despite an introduction that is rather explicit in that regard. Note that the 1933 paper is littered with Venn diagrams, Venn diagrams illustrate conditional probability, which is Bayes' theorem. Some people refer to this as Bayes' rule, as it is an exaggeration to refer to that rule as being a "theorem." For example, if we were to call 'addition' a theorem, as opposed to being a rule, we would confound rather than explain.
Therefore, the Neyman-Pearson lemma is a theorem concerning the most efficient testing of Bayesian hypotheses, but is not currently called that because it was not to begin with. | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate]
NB: This historically first answer to the OP question. In statistics, the Neyman–Pearson lemma was introduced by Jerzy Neyman and Egon Pearson in a paper in 1933.. Also, it is used in practice by stat |
26,059 | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate] | The classic version appears in 1933, but the earliest occasion of its being referred to as a "lemma" is possibly in Neyman and Pearson's 1936 article Contributions to the theory of testing statistical hypotheses (pp. 1-37 of Statistical Research Memoirs Volume I). The lemma, and the proposition it was used to prove, were stated as follows:
This is known today as the generalized Neyman-Pearson Fundamental Lemma (cf. Chapter 3.6 of Lehman and Romano's Testing Statistical Hypotheses), and it reduces to your everyday Neyman-Pearson when $m=1$. The lemma itself was then studied by several big names from that era (e.g. P.L. Hsu, Dantzig, Wald, Chernoff, Scheffé) and the name "Neyman and Pearson's lemma" thus stuck.
Here's a list of relevant articles/books if one's interested in the history of the Neyman-Pearson lemma:
The Neyman–Pearson Story: 1926-34, E.S. Pearson, in Research Papers in Statistical: Festschrift for J. Neyman.
Introduction to Neyman and Pearson (1933) On the Problem of the Most Efficient Tests of Statistical Hypotheses, E.L. Lehmann, in Breakthroughs in Statistics: Foundations and Basic Theory.
Neyman-From Life, C. Reid. | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate] | The classic version appears in 1933, but the earliest occasion of its being referred to as a "lemma" is possibly in Neyman and Pearson's 1936 article Contributions to the theory of testing statistical | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate]
The classic version appears in 1933, but the earliest occasion of its being referred to as a "lemma" is possibly in Neyman and Pearson's 1936 article Contributions to the theory of testing statistical hypotheses (pp. 1-37 of Statistical Research Memoirs Volume I). The lemma, and the proposition it was used to prove, were stated as follows:
This is known today as the generalized Neyman-Pearson Fundamental Lemma (cf. Chapter 3.6 of Lehman and Romano's Testing Statistical Hypotheses), and it reduces to your everyday Neyman-Pearson when $m=1$. The lemma itself was then studied by several big names from that era (e.g. P.L. Hsu, Dantzig, Wald, Chernoff, Scheffé) and the name "Neyman and Pearson's lemma" thus stuck.
Here's a list of relevant articles/books if one's interested in the history of the Neyman-Pearson lemma:
The Neyman–Pearson Story: 1926-34, E.S. Pearson, in Research Papers in Statistical: Festschrift for J. Neyman.
Introduction to Neyman and Pearson (1933) On the Problem of the Most Efficient Tests of Statistical Hypotheses, E.L. Lehmann, in Breakthroughs in Statistics: Foundations and Basic Theory.
Neyman-From Life, C. Reid. | Why is the Neyman-Pearson lemma a lemma and not a theorem? [duplicate]
The classic version appears in 1933, but the earliest occasion of its being referred to as a "lemma" is possibly in Neyman and Pearson's 1936 article Contributions to the theory of testing statistical |
26,060 | Maximum likelihood estimators and overfitting | The key to understanding Bishop's statement lies in the first paragraph, second sentence, of section 3.2: "... the use of maximum likelihood, or equivalently least squares, can lead to severe over-fitting if complex models are trained using data sets of limited size".
The problem comes about because no matter how many parameters you add to the model, the MLE technique will use them to fit more and more of the data (up to the point at which you have a 100% accurate fit), and a lot of that "fit more and more of the data" is fitting randomness - i.e., overfitting. For example, if I have $100$ data points and am fitting a polynomial of degree $99$ to the data, MLE will give me a perfect in-sample fit, but that fit won't generalize at all well - I really cannot expect to achieve anywhere near a 100% accurate prediction with this model. Because MLE is not regularized in any way, there's no mechanism within the maximum likelihood framework to prevent this overfitting from occurring. This is the "unfortunate property" referred to by Bishop. You have to do that yourself, by hand, by structuring and restructuring your model, hopefully appropriately. Your statement "... it does not regulate the number of parameters whatsoever..." is actually the crux of the connection between MLE and overfitting!
Now this is all well and good, but if there were no other model estimation approaches that helped with overfitting, we wouldn't be able to say that this was an unfortunate property specifically of MLE - it would be an unfortunate property of all model estimation techniques, and therefore not really worth discussing in the context of comparing MLE to other techniques. However, there are other model estimation approaches - Lasso, Ridge regression, and Elastic Net, to name three from a classical statistics tradition, and Bayesian approaches as well - that do attempt to limit overfitting as part of the estimation procedure. One could also think of the entire field of robust statistics as being about deriving estimators and tests that are less prone to overfitting than the MLE. Naturally, these alternatives do not eliminate the need to take some care with the model specification etc. process, but they help - a lot - and therefore provide a valid contrast with MLE, which does not help at all. | Maximum likelihood estimators and overfitting | The key to understanding Bishop's statement lies in the first paragraph, second sentence, of section 3.2: "... the use of maximum likelihood, or equivalently least squares, can lead to severe over-fi | Maximum likelihood estimators and overfitting
The key to understanding Bishop's statement lies in the first paragraph, second sentence, of section 3.2: "... the use of maximum likelihood, or equivalently least squares, can lead to severe over-fitting if complex models are trained using data sets of limited size".
The problem comes about because no matter how many parameters you add to the model, the MLE technique will use them to fit more and more of the data (up to the point at which you have a 100% accurate fit), and a lot of that "fit more and more of the data" is fitting randomness - i.e., overfitting. For example, if I have $100$ data points and am fitting a polynomial of degree $99$ to the data, MLE will give me a perfect in-sample fit, but that fit won't generalize at all well - I really cannot expect to achieve anywhere near a 100% accurate prediction with this model. Because MLE is not regularized in any way, there's no mechanism within the maximum likelihood framework to prevent this overfitting from occurring. This is the "unfortunate property" referred to by Bishop. You have to do that yourself, by hand, by structuring and restructuring your model, hopefully appropriately. Your statement "... it does not regulate the number of parameters whatsoever..." is actually the crux of the connection between MLE and overfitting!
Now this is all well and good, but if there were no other model estimation approaches that helped with overfitting, we wouldn't be able to say that this was an unfortunate property specifically of MLE - it would be an unfortunate property of all model estimation techniques, and therefore not really worth discussing in the context of comparing MLE to other techniques. However, there are other model estimation approaches - Lasso, Ridge regression, and Elastic Net, to name three from a classical statistics tradition, and Bayesian approaches as well - that do attempt to limit overfitting as part of the estimation procedure. One could also think of the entire field of robust statistics as being about deriving estimators and tests that are less prone to overfitting than the MLE. Naturally, these alternatives do not eliminate the need to take some care with the model specification etc. process, but they help - a lot - and therefore provide a valid contrast with MLE, which does not help at all. | Maximum likelihood estimators and overfitting
The key to understanding Bishop's statement lies in the first paragraph, second sentence, of section 3.2: "... the use of maximum likelihood, or equivalently least squares, can lead to severe over-fi |
26,061 | Maximum likelihood estimators and overfitting | Bishop may have been talking about conditional probability tables, or "group by" aggregations of the data often used in Bayesian networks. The MLE for these probabilities overfits in that it is too particular to the training data and may not generalize. This becomes especially true once you start adding variables to that grouping and slicing your data very thin. The MLEs for these group probabilities need some kind of regularization by means of a prior distribution, pooling, or some other method. | Maximum likelihood estimators and overfitting | Bishop may have been talking about conditional probability tables, or "group by" aggregations of the data often used in Bayesian networks. The MLE for these probabilities overfits in that it is too p | Maximum likelihood estimators and overfitting
Bishop may have been talking about conditional probability tables, or "group by" aggregations of the data often used in Bayesian networks. The MLE for these probabilities overfits in that it is too particular to the training data and may not generalize. This becomes especially true once you start adding variables to that grouping and slicing your data very thin. The MLEs for these group probabilities need some kind of regularization by means of a prior distribution, pooling, or some other method. | Maximum likelihood estimators and overfitting
Bishop may have been talking about conditional probability tables, or "group by" aggregations of the data often used in Bayesian networks. The MLE for these probabilities overfits in that it is too p |
26,062 | Maximum likelihood estimators and overfitting | MLE is a technique used to estimate parameters from a model. Not only the parameter estimates of a distribution you assume on a specific variable, but just as well the parameters of any model that contains distributional assumptions such as Generalized Linear Models or Tree-based models with a conditional distribution assumption on the dependent. While a more complex model can increase the training likelihood, it does not necessarily mean the model will have an equally high likelihood on new unseen examples. Therefore, we should look at the likelihood on a separate test set, or penalize the model selection criteria for model complexity (such as AIC, BIC). | Maximum likelihood estimators and overfitting | MLE is a technique used to estimate parameters from a model. Not only the parameter estimates of a distribution you assume on a specific variable, but just as well the parameters of any model that con | Maximum likelihood estimators and overfitting
MLE is a technique used to estimate parameters from a model. Not only the parameter estimates of a distribution you assume on a specific variable, but just as well the parameters of any model that contains distributional assumptions such as Generalized Linear Models or Tree-based models with a conditional distribution assumption on the dependent. While a more complex model can increase the training likelihood, it does not necessarily mean the model will have an equally high likelihood on new unseen examples. Therefore, we should look at the likelihood on a separate test set, or penalize the model selection criteria for model complexity (such as AIC, BIC). | Maximum likelihood estimators and overfitting
MLE is a technique used to estimate parameters from a model. Not only the parameter estimates of a distribution you assume on a specific variable, but just as well the parameters of any model that con |
26,063 | Maximum likelihood estimators and overfitting | maximum likelihood can exhibit severe over-fitting for
data sets that are linearly separable. This arises because the maximum likelihood solution occurs when the hyperplane corresponding to σ = 0.5, equivalent to w^Tφ =
0, separates the two classes and the magnitude of w goes to infinity and then causes highly fluctuation in decision boundary. In this case, the
logistic sigmoid function becomes infinitely steep in feature space, corresponding to
a Heaviside step function, so that every training point from each class k is assigned a posterior probability p(C_k|x) = 1. | Maximum likelihood estimators and overfitting | maximum likelihood can exhibit severe over-fitting for
data sets that are linearly separable. This arises because the maximum likelihood solution occurs when the hyperplane corresponding to σ = 0.5, e | Maximum likelihood estimators and overfitting
maximum likelihood can exhibit severe over-fitting for
data sets that are linearly separable. This arises because the maximum likelihood solution occurs when the hyperplane corresponding to σ = 0.5, equivalent to w^Tφ =
0, separates the two classes and the magnitude of w goes to infinity and then causes highly fluctuation in decision boundary. In this case, the
logistic sigmoid function becomes infinitely steep in feature space, corresponding to
a Heaviside step function, so that every training point from each class k is assigned a posterior probability p(C_k|x) = 1. | Maximum likelihood estimators and overfitting
maximum likelihood can exhibit severe over-fitting for
data sets that are linearly separable. This arises because the maximum likelihood solution occurs when the hyperplane corresponding to σ = 0.5, e |
26,064 | Why does SAS nlmixed and R nlme give different model fit results? | FWIW, I could reproduce the sas output using a manual optimization
########## data ################
circ <- Orange$circumference
age <- Orange$age
group <- as.numeric(Orange$Tree)
#phi1 = n1[4]$coefficients$random$Tree + 192
phi1 = 192
phi2 = 728
phi3 = 353
######### likelihood function
Likelihood <- function(x,p_age,p_circ) {
phi1 <- x[1]
phi2 <- x[2]
phi3 <- x[3]
fitted <- phi1/(1 + exp(-(p_age - phi2)/phi3))
fact <- 1/(1 + exp(-(p_age - phi2)/phi3))
resid <- p_circ-fitted
sigma1 <- x[4] # phi1 term
sigma2 <- x[5] # error term
covm <- matrix(rep(0,35*35),35) # co-variance matrix for residual terms
#the residuals of the group variables will be correlated in 5 7x7 blocks
for (k in 0:4) {
for (l in 1:7) {
for (m in 1:7) {
i = l+7*k
j = m+7*k
if (i==j) {
covm[i,j] <- fact[i]*fact[j]*sigma1^2+sigma2^2
}
else {
covm[i,j] <- fact[i]*fact[j]*sigma1^2
}
}
}
}
logd <- (-0.5 * t(resid) %*% solve(covm) %*% resid) - log(sqrt((2*pi)^35*det(covm)))
logd
}
##### optimize
out <- nlm(function(p) -Likelihood(p,age,circ),
c(phi1,phi2,phi3,20,8),
print.level=1,
iterlim=100,gradtol=10^-26,steptol=10^-20,ndigit=30)
output
iteration = 0
Step:
[1] 0 0 0 0 0
Parameter:
[1] 192.0 728.0 353.0 30.0 5.5
Function Value
[1] 136.5306
Gradient:
[1] -0.003006727 -0.019069001 0.034154033 -0.021112696
[5] -5.669238697
iteration = 52
Parameter:
[1] 192.053145 727.906304 348.073030 31.646302 7.843012
Function Value
[1] 131.5719
Gradient:
[1] 0.000000e+00 5.240643e-09 0.000000e+00 0.000000e+00
[5] 0.000000e+00
Successive iterates within tolerance.
Current iterate is probably solution.
So the nlmixed output is close to this optimum and it is not a different convergence thing.
The nlme output is also close to the (different) optimum. (You can check this by changing the optimization parameters in the function call)
I do not know exactly how nlme calculates the likelihood. It seems to be the same as in the manual optimization above. When we fill in the values from nlme output, then we get the same log-likelihood value -131.5846.
> Likelihood(c(191.0499,722.5590,344.1621,31.48255,7.846255),age,circ)
[,1]
[1,] -131.5846
The manual refers to an article by Lindstrom, M.J. and Bates, D.M. in Biometrics volume 46 on pp 673-687. In that article a method is described that approximates the marginal distribution of the observations (circumference in your case). The marginal distribution is integrating over all possible values of the unobserved values of the random effects. This integration is necessary because unlike with linear models, with non-linear models the random effects can not be simply linearly added. The result is that the final expression for the residuals can be different. In the code above we took the circumference minus the fitted value, but in the article they also subtract a term that arises from the linear approximation and relates to the random effect. The method is also estimating those random effects as part of the algorithm. | Why does SAS nlmixed and R nlme give different model fit results? | FWIW, I could reproduce the sas output using a manual optimization
########## data ################
circ <- Orange$circumference
age <- Orange$age
group <- as.numeric(Orange$Tree)
#phi1 = n1[4]$coeff | Why does SAS nlmixed and R nlme give different model fit results?
FWIW, I could reproduce the sas output using a manual optimization
########## data ################
circ <- Orange$circumference
age <- Orange$age
group <- as.numeric(Orange$Tree)
#phi1 = n1[4]$coefficients$random$Tree + 192
phi1 = 192
phi2 = 728
phi3 = 353
######### likelihood function
Likelihood <- function(x,p_age,p_circ) {
phi1 <- x[1]
phi2 <- x[2]
phi3 <- x[3]
fitted <- phi1/(1 + exp(-(p_age - phi2)/phi3))
fact <- 1/(1 + exp(-(p_age - phi2)/phi3))
resid <- p_circ-fitted
sigma1 <- x[4] # phi1 term
sigma2 <- x[5] # error term
covm <- matrix(rep(0,35*35),35) # co-variance matrix for residual terms
#the residuals of the group variables will be correlated in 5 7x7 blocks
for (k in 0:4) {
for (l in 1:7) {
for (m in 1:7) {
i = l+7*k
j = m+7*k
if (i==j) {
covm[i,j] <- fact[i]*fact[j]*sigma1^2+sigma2^2
}
else {
covm[i,j] <- fact[i]*fact[j]*sigma1^2
}
}
}
}
logd <- (-0.5 * t(resid) %*% solve(covm) %*% resid) - log(sqrt((2*pi)^35*det(covm)))
logd
}
##### optimize
out <- nlm(function(p) -Likelihood(p,age,circ),
c(phi1,phi2,phi3,20,8),
print.level=1,
iterlim=100,gradtol=10^-26,steptol=10^-20,ndigit=30)
output
iteration = 0
Step:
[1] 0 0 0 0 0
Parameter:
[1] 192.0 728.0 353.0 30.0 5.5
Function Value
[1] 136.5306
Gradient:
[1] -0.003006727 -0.019069001 0.034154033 -0.021112696
[5] -5.669238697
iteration = 52
Parameter:
[1] 192.053145 727.906304 348.073030 31.646302 7.843012
Function Value
[1] 131.5719
Gradient:
[1] 0.000000e+00 5.240643e-09 0.000000e+00 0.000000e+00
[5] 0.000000e+00
Successive iterates within tolerance.
Current iterate is probably solution.
So the nlmixed output is close to this optimum and it is not a different convergence thing.
The nlme output is also close to the (different) optimum. (You can check this by changing the optimization parameters in the function call)
I do not know exactly how nlme calculates the likelihood. It seems to be the same as in the manual optimization above. When we fill in the values from nlme output, then we get the same log-likelihood value -131.5846.
> Likelihood(c(191.0499,722.5590,344.1621,31.48255,7.846255),age,circ)
[,1]
[1,] -131.5846
The manual refers to an article by Lindstrom, M.J. and Bates, D.M. in Biometrics volume 46 on pp 673-687. In that article a method is described that approximates the marginal distribution of the observations (circumference in your case). The marginal distribution is integrating over all possible values of the unobserved values of the random effects. This integration is necessary because unlike with linear models, with non-linear models the random effects can not be simply linearly added. The result is that the final expression for the residuals can be different. In the code above we took the circumference minus the fitted value, but in the article they also subtract a term that arises from the linear approximation and relates to the random effect. The method is also estimating those random effects as part of the algorithm. | Why does SAS nlmixed and R nlme give different model fit results?
FWIW, I could reproduce the sas output using a manual optimization
########## data ################
circ <- Orange$circumference
age <- Orange$age
group <- as.numeric(Orange$Tree)
#phi1 = n1[4]$coeff |
26,065 | Why does SAS nlmixed and R nlme give different model fit results? | I had dealt with the same issue and agree with Martjin that you need to tweak the convergence criteria in R to make it match SAS. More specifically, you can try this combination of argument specification (in lCtr object) that I found to work pretty well in my case.
lCtr <- lmeControl(maxIter = 200, msMaxIter=200, opt='nlminb', tolerance = 1e-6, optimMethod = "L-BFGS-B")
n1 <- nlme(circumference ~ phi1 / (1 + exp(-(age - phi2)/phi3)),
data = Orange,
fixed = list(phi1 ~ 1,
phi2 ~ 1,
phi3 ~ 1),
random = list(Tree = pdDiag(phi1 ~ 1)),
start = list(fixed = c(phi1 = 192.6873, phi2 = 728.7547, phi3 = 353.5323)),
control = lCtr)
Fair warning: this should get you the same fixed estimates between SAS and R. However, you probably wouldn't obtain the same SE of the fixed effects (which I'm still researching answers for..). | Why does SAS nlmixed and R nlme give different model fit results? | I had dealt with the same issue and agree with Martjin that you need to tweak the convergence criteria in R to make it match SAS. More specifically, you can try this combination of argument specificat | Why does SAS nlmixed and R nlme give different model fit results?
I had dealt with the same issue and agree with Martjin that you need to tweak the convergence criteria in R to make it match SAS. More specifically, you can try this combination of argument specification (in lCtr object) that I found to work pretty well in my case.
lCtr <- lmeControl(maxIter = 200, msMaxIter=200, opt='nlminb', tolerance = 1e-6, optimMethod = "L-BFGS-B")
n1 <- nlme(circumference ~ phi1 / (1 + exp(-(age - phi2)/phi3)),
data = Orange,
fixed = list(phi1 ~ 1,
phi2 ~ 1,
phi3 ~ 1),
random = list(Tree = pdDiag(phi1 ~ 1)),
start = list(fixed = c(phi1 = 192.6873, phi2 = 728.7547, phi3 = 353.5323)),
control = lCtr)
Fair warning: this should get you the same fixed estimates between SAS and R. However, you probably wouldn't obtain the same SE of the fixed effects (which I'm still researching answers for..). | Why does SAS nlmixed and R nlme give different model fit results?
I had dealt with the same issue and agree with Martjin that you need to tweak the convergence criteria in R to make it match SAS. More specifically, you can try this combination of argument specificat |
26,066 | Hamiltonian Monte Carlo (HMC): what's the intuition and justification behind a Gaussian-distributed momentum variable? | It's not so much that we are after $\pi(E)$, it's just that if $\pi(E)$ and $\pi(E|q)$ are dissimilar then our exploration will be limited by our inability to explore all of the relevant energies. Consequently, in practice empirical estimates of $\pi(E)$ and $\pi(E|q)$ are useful for identifying any potential limitations of our exploration which is the motivation for the comparative histogram and the E-BFMI diagnostic.
So, what do we know about the two distributions? As we increase the dimensionality of our target distribution then $\pi(E)$ sort-of-tends to look more and more Gaussian. If our integration times are long enough then our explorations of the level sets will equilibrate and if $\pi(p | q)$ is Gaussian then $\pi(E|q)$ will also tend to be more and more Gaussian.
Hence a Gaussian-Euclidean kinetic energy is a good starting point but it is by no means always optimal! I spend a good bit of time trying to fit models where Stan yells at me about bad E-BFMI diagnostics. A Gaussian-Riemannian kinetic energy can be a significant improvement in many cases as the position-dependent log determinant in $\pi(p | q)$ can make $\pi(E)$ significantly more Gaussian, but this there is still much more research to be done to fully understand the problem. | Hamiltonian Monte Carlo (HMC): what's the intuition and justification behind a Gaussian-distributed | It's not so much that we are after $\pi(E)$, it's just that if $\pi(E)$ and $\pi(E|q)$ are dissimilar then our exploration will be limited by our inability to explore all of the relevant energies. Co | Hamiltonian Monte Carlo (HMC): what's the intuition and justification behind a Gaussian-distributed momentum variable?
It's not so much that we are after $\pi(E)$, it's just that if $\pi(E)$ and $\pi(E|q)$ are dissimilar then our exploration will be limited by our inability to explore all of the relevant energies. Consequently, in practice empirical estimates of $\pi(E)$ and $\pi(E|q)$ are useful for identifying any potential limitations of our exploration which is the motivation for the comparative histogram and the E-BFMI diagnostic.
So, what do we know about the two distributions? As we increase the dimensionality of our target distribution then $\pi(E)$ sort-of-tends to look more and more Gaussian. If our integration times are long enough then our explorations of the level sets will equilibrate and if $\pi(p | q)$ is Gaussian then $\pi(E|q)$ will also tend to be more and more Gaussian.
Hence a Gaussian-Euclidean kinetic energy is a good starting point but it is by no means always optimal! I spend a good bit of time trying to fit models where Stan yells at me about bad E-BFMI diagnostics. A Gaussian-Riemannian kinetic energy can be a significant improvement in many cases as the position-dependent log determinant in $\pi(p | q)$ can make $\pi(E)$ significantly more Gaussian, but this there is still much more research to be done to fully understand the problem. | Hamiltonian Monte Carlo (HMC): what's the intuition and justification behind a Gaussian-distributed
It's not so much that we are after $\pi(E)$, it's just that if $\pi(E)$ and $\pi(E|q)$ are dissimilar then our exploration will be limited by our inability to explore all of the relevant energies. Co |
26,067 | "hard-mining", "hard examples", ... - Does "hard" mean anything specific in statistics when not applied to problem difficulty? | @Sycorax is correct. "Hard examples" is referring to the examples in the training set that are being mislabeled by the current version of the classifier. Oftentimes it is only used for the background class, which is too large a set for anyone to mine without some kind of a strategy (binary classification on imbalanced sets is hard).
This term was probably coined by Girshick (I think?) in the seminal article DPM and is now widely used in the Object detection community for instance in OHEM, where the negative windows used at each step of the training are chosen according to their current score.
The latter article is an example of Online hard examples mining (hence the title) whereas the ICIP article explores different Offline hard examples mining strategies. | "hard-mining", "hard examples", ... - Does "hard" mean anything specific in statistics when not appl | @Sycorax is correct. "Hard examples" is referring to the examples in the training set that are being mislabeled by the current version of the classifier. Oftentimes it is only used for the background | "hard-mining", "hard examples", ... - Does "hard" mean anything specific in statistics when not applied to problem difficulty?
@Sycorax is correct. "Hard examples" is referring to the examples in the training set that are being mislabeled by the current version of the classifier. Oftentimes it is only used for the background class, which is too large a set for anyone to mine without some kind of a strategy (binary classification on imbalanced sets is hard).
This term was probably coined by Girshick (I think?) in the seminal article DPM and is now widely used in the Object detection community for instance in OHEM, where the negative windows used at each step of the training are chosen according to their current score.
The latter article is an example of Online hard examples mining (hence the title) whereas the ICIP article explores different Offline hard examples mining strategies. | "hard-mining", "hard examples", ... - Does "hard" mean anything specific in statistics when not appl
@Sycorax is correct. "Hard examples" is referring to the examples in the training set that are being mislabeled by the current version of the classifier. Oftentimes it is only used for the background |
26,068 | Why does default auto.arima stop at (5,2,5)? | There are a number of reasons:
Restricting the search space limits the computation time required. This is an important factor if you are modeling and forecasting many time series.
More complex ARIMA models are hard to interpret. Intepretability may not be high on our list of desirable qualities if all we want to do is forecast, but often we need explain our models to a non-statistician user. I'd rather not try to explain even second differences, let alone third or higher ones.
Forecasters' experience has been that most time series are quite adequately described by ARIMA models of low orders. Let's model the 819 nonseasonal M3 series using auto.arima(,max.p=10,max.q=10,max.d=3):
library(Mcomp)
M3.nonseasonal <- M3[sapply(M3,"[[","period")%in%c("YEARLY","OTHER")]
models <- matrix(NA,nrow=length(M3.nonseasonal),ncol=3,
dimnames=list(names(M3.nonseasonal),c("p","d","q")))
pb <- winProgressBar(max=length(M3.nonseasonal))
for ( ii in seq_along(M3.nonseasonal) ) {
setWinProgressBar(pb,ii,paste(ii,"of",length(M3.nonseasonal)))
fit <- auto.arima(M3.nonseasonal[[ii]]$x,max.p=10,max.q=10,max.d=3)
models[ii,] <- fit$arma[c(1,6,2)]
}
close(pb)
sort(table(
paste0( (",apply(models,1,paste0,collapse=","),")")),decreasing=TRUE)
summary(models)
The output:
> sort(table(paste0("(",apply(models,1,paste0,collapse=","),")")),decreasing=TRUE)
(0,1,0) (0,1,1) (0,2,0) (0,2,1) (1,0,0) (1,1,0) (0,0,0) (0,0,1) (2,0,0) (1,2,0)
413 80 65 60 31 29 23 19 15 13
(1,1,1) (1,2,1) (2,1,0) (2,1,2) (0,3,0) (1,1,2) (2,2,1) (0,1,2) (0,2,2) (1,0,1)
6 6 6 6 5 5 5 4 3 3
(1,3,0) (1,0,2) (1,2,2) (2,0,1) (2,1,1) (2,2,2) (3,0,0) (0,3,1) (1,3,1) (2,2,0)
3 2 2 2 2 2 2 1 1 1
(2,3,1) (3,0,1) (3,1,0) (3,2,3)
1 1 1 1
> summary(models)
p d q
Min. :0.0000 Min. :0.0 Min. :0.0000
1st Qu.:0.0000 1st Qu.:1.0 1st Qu.:0.0000
Median :0.0000 Median :1.0 Median :0.0000
Mean :0.2393 Mean :1.1 Mean :0.2906
3rd Qu.:0.0000 3rd Qu.:1.0 3rd Qu.:1.0000
Max. :3.0000 Max. :3.0 Max. :3.0000
In some few cases, auto.arima() opts for $d=3$, but I'm skeptical about integration of order 3, both because it is very hard to interpret and because it would lead to cubic trends, which rarely make sense. $p$ and $q$ never exceed 3.
Finally, more complex ARIMA models rarely are more accurate. As a matter of fact, the simplest possible ARIMA(0,0,0) model - i.e., white noise, with the optimal forecast being simply the historical mean - often outperforms more complex ARIMA models.
As far as I am aware, the specific defaults chosen don't stem from any specific research, and any such research would of course be of questionable generality. If you are really interested in how the package authors came up with these numbers, you could ask them (perhaps report here what you heard back?), but I strongly suspect that the answer will be "experience". | Why does default auto.arima stop at (5,2,5)? | There are a number of reasons:
Restricting the search space limits the computation time required. This is an important factor if you are modeling and forecasting many time series.
More complex ARIMA m | Why does default auto.arima stop at (5,2,5)?
There are a number of reasons:
Restricting the search space limits the computation time required. This is an important factor if you are modeling and forecasting many time series.
More complex ARIMA models are hard to interpret. Intepretability may not be high on our list of desirable qualities if all we want to do is forecast, but often we need explain our models to a non-statistician user. I'd rather not try to explain even second differences, let alone third or higher ones.
Forecasters' experience has been that most time series are quite adequately described by ARIMA models of low orders. Let's model the 819 nonseasonal M3 series using auto.arima(,max.p=10,max.q=10,max.d=3):
library(Mcomp)
M3.nonseasonal <- M3[sapply(M3,"[[","period")%in%c("YEARLY","OTHER")]
models <- matrix(NA,nrow=length(M3.nonseasonal),ncol=3,
dimnames=list(names(M3.nonseasonal),c("p","d","q")))
pb <- winProgressBar(max=length(M3.nonseasonal))
for ( ii in seq_along(M3.nonseasonal) ) {
setWinProgressBar(pb,ii,paste(ii,"of",length(M3.nonseasonal)))
fit <- auto.arima(M3.nonseasonal[[ii]]$x,max.p=10,max.q=10,max.d=3)
models[ii,] <- fit$arma[c(1,6,2)]
}
close(pb)
sort(table(
paste0( (",apply(models,1,paste0,collapse=","),")")),decreasing=TRUE)
summary(models)
The output:
> sort(table(paste0("(",apply(models,1,paste0,collapse=","),")")),decreasing=TRUE)
(0,1,0) (0,1,1) (0,2,0) (0,2,1) (1,0,0) (1,1,0) (0,0,0) (0,0,1) (2,0,0) (1,2,0)
413 80 65 60 31 29 23 19 15 13
(1,1,1) (1,2,1) (2,1,0) (2,1,2) (0,3,0) (1,1,2) (2,2,1) (0,1,2) (0,2,2) (1,0,1)
6 6 6 6 5 5 5 4 3 3
(1,3,0) (1,0,2) (1,2,2) (2,0,1) (2,1,1) (2,2,2) (3,0,0) (0,3,1) (1,3,1) (2,2,0)
3 2 2 2 2 2 2 1 1 1
(2,3,1) (3,0,1) (3,1,0) (3,2,3)
1 1 1 1
> summary(models)
p d q
Min. :0.0000 Min. :0.0 Min. :0.0000
1st Qu.:0.0000 1st Qu.:1.0 1st Qu.:0.0000
Median :0.0000 Median :1.0 Median :0.0000
Mean :0.2393 Mean :1.1 Mean :0.2906
3rd Qu.:0.0000 3rd Qu.:1.0 3rd Qu.:1.0000
Max. :3.0000 Max. :3.0 Max. :3.0000
In some few cases, auto.arima() opts for $d=3$, but I'm skeptical about integration of order 3, both because it is very hard to interpret and because it would lead to cubic trends, which rarely make sense. $p$ and $q$ never exceed 3.
Finally, more complex ARIMA models rarely are more accurate. As a matter of fact, the simplest possible ARIMA(0,0,0) model - i.e., white noise, with the optimal forecast being simply the historical mean - often outperforms more complex ARIMA models.
As far as I am aware, the specific defaults chosen don't stem from any specific research, and any such research would of course be of questionable generality. If you are really interested in how the package authors came up with these numbers, you could ask them (perhaps report here what you heard back?), but I strongly suspect that the answer will be "experience". | Why does default auto.arima stop at (5,2,5)?
There are a number of reasons:
Restricting the search space limits the computation time required. This is an important factor if you are modeling and forecasting many time series.
More complex ARIMA m |
26,069 | Why reducing a regression model into a classification model by output discretization improves a model? | Let's look at the sources of error for your classification predictions, compared to those for a linear prediction. If you classify, you have two sources of error:
Error from classifying into the wrong bin
Error from the difference between the bin median and the target value (the "gold location")
If your data has low noise, then you will usually classify into the correct bin. If you also have many bins, then the second source of error will be low. If conversely, you have high-noise data, then you might misclassify into the wrong bin often, and this might dominate the overall error - even if you have many small bins, so the second source of error is small if you classify correctly. Then again, if you have few bins, then you will more often classify correctly, but your within-bin error will be larger.
In the end, it probably comes down to an interplay between the noise and the bin size.
Here is a little toy example, which I ran for 200 simulations. A simple linear relationship with noise and only two bins:
Now, let's run this with either low or high noise. (The training set above had high noise.) In each case, we record the MSEs from a linear model and from a classification model:
nn.sample <- 100
stdev <- 1
nn.runs <- 200
results <- matrix(NA,nrow=nn.runs,ncol=2,dimnames=list(NULL,c("MSE.OLS","MSE.Classification")))
for ( ii in 1:nn.runs ) {
set.seed(ii)
xx.train <- runif(nn.sample,-1,1)
yy.train <- xx.train+rnorm(nn.sample,0,stdev)
discrete.train <- yy.train>0
bin.medians <- structure(by(yy.train,discrete.train,median),.Names=c("FALSE","TRUE"))
# plot(xx.train,yy.train,pch=19,col=discrete.train+1,main="Training")
model.ols <- lm(yy.train~xx.train)
model.log <- glm(discrete.train~xx.train,"binomial")
xx.test <- runif(nn.sample,-1,1)
yy.test <- xx.test+rnorm(nn.sample,0,0.1)
results[ii,1] <- mean((yy.test-predict(model.ols,newdata=data.frame(xx.test)))^2)
results[ii,2] <- mean((yy.test-bin.medians[as.character(predict(model.log,newdata=data.frame(xx.test))>0)])^2)
}
plot(results,xlim=range(results),ylim=range(results),main=paste("Standard Deviation of Noise:",stdev))
abline(a=0,b=1)
colMeans(results)
t.test(x=results[,1],y=results[,2],paired=TRUE)
As we see, whether classification improves accuracy comes down to the noise level in this example.
You could play around a little with simulated data, or with different bin sizes.
Finally, note that if you are trying different bin sizes and keeping the ones that perform best, you shouldn't be surprised that this performs better than a linear model. After all, you are essentially adding more degrees of freedom, and if you are not careful (cross-validation!), you'll end up overfitting the bins. | Why reducing a regression model into a classification model by output discretization improves a mode | Let's look at the sources of error for your classification predictions, compared to those for a linear prediction. If you classify, you have two sources of error:
Error from classifying into the wron | Why reducing a regression model into a classification model by output discretization improves a model?
Let's look at the sources of error for your classification predictions, compared to those for a linear prediction. If you classify, you have two sources of error:
Error from classifying into the wrong bin
Error from the difference between the bin median and the target value (the "gold location")
If your data has low noise, then you will usually classify into the correct bin. If you also have many bins, then the second source of error will be low. If conversely, you have high-noise data, then you might misclassify into the wrong bin often, and this might dominate the overall error - even if you have many small bins, so the second source of error is small if you classify correctly. Then again, if you have few bins, then you will more often classify correctly, but your within-bin error will be larger.
In the end, it probably comes down to an interplay between the noise and the bin size.
Here is a little toy example, which I ran for 200 simulations. A simple linear relationship with noise and only two bins:
Now, let's run this with either low or high noise. (The training set above had high noise.) In each case, we record the MSEs from a linear model and from a classification model:
nn.sample <- 100
stdev <- 1
nn.runs <- 200
results <- matrix(NA,nrow=nn.runs,ncol=2,dimnames=list(NULL,c("MSE.OLS","MSE.Classification")))
for ( ii in 1:nn.runs ) {
set.seed(ii)
xx.train <- runif(nn.sample,-1,1)
yy.train <- xx.train+rnorm(nn.sample,0,stdev)
discrete.train <- yy.train>0
bin.medians <- structure(by(yy.train,discrete.train,median),.Names=c("FALSE","TRUE"))
# plot(xx.train,yy.train,pch=19,col=discrete.train+1,main="Training")
model.ols <- lm(yy.train~xx.train)
model.log <- glm(discrete.train~xx.train,"binomial")
xx.test <- runif(nn.sample,-1,1)
yy.test <- xx.test+rnorm(nn.sample,0,0.1)
results[ii,1] <- mean((yy.test-predict(model.ols,newdata=data.frame(xx.test)))^2)
results[ii,2] <- mean((yy.test-bin.medians[as.character(predict(model.log,newdata=data.frame(xx.test))>0)])^2)
}
plot(results,xlim=range(results),ylim=range(results),main=paste("Standard Deviation of Noise:",stdev))
abline(a=0,b=1)
colMeans(results)
t.test(x=results[,1],y=results[,2],paired=TRUE)
As we see, whether classification improves accuracy comes down to the noise level in this example.
You could play around a little with simulated data, or with different bin sizes.
Finally, note that if you are trying different bin sizes and keeping the ones that perform best, you shouldn't be surprised that this performs better than a linear model. After all, you are essentially adding more degrees of freedom, and if you are not careful (cross-validation!), you'll end up overfitting the bins. | Why reducing a regression model into a classification model by output discretization improves a mode
Let's look at the sources of error for your classification predictions, compared to those for a linear prediction. If you classify, you have two sources of error:
Error from classifying into the wron |
26,070 | Why would Netflix switch from its five-star rating system to a like/dislike system? | According to an article by Preston & Coleman (2000), 2 item-scale relaibility does not differ markedly from 5 item-scale reliability:
The subject of measurement was satisfaction with restaruants but it translates well to the movie rating. Ease of use, how quick it is to use and how well can a person express feelings on a differnt item-scales was measured as well. The results are as follows:
It is clear that users find 2 item-scale slightly easier to use and quicker to use in comparison to 5 item-scale but also very inadequate in expressing user's true beliefs. This indicates that 2 item-scale does not capture underlying variability very well and results in loss of variability. Discrimination indices are also markedly poorer for 2 item-scales in comparison to 5 item-scales.
Taking all of the above into account I would speculate that Netflix is willing to exchange some voting precision to lure more users into voting. I think they prefer more people voting since it increases sample coverage. This can lead to better understanding of less engaged users. Marginal value of additional information for less engaged users is likely much higher in comparison to engaged users. | Why would Netflix switch from its five-star rating system to a like/dislike system? | According to an article by Preston & Coleman (2000), 2 item-scale relaibility does not differ markedly from 5 item-scale reliability:
The subject of measurement was satisfaction with restaruants but | Why would Netflix switch from its five-star rating system to a like/dislike system?
According to an article by Preston & Coleman (2000), 2 item-scale relaibility does not differ markedly from 5 item-scale reliability:
The subject of measurement was satisfaction with restaruants but it translates well to the movie rating. Ease of use, how quick it is to use and how well can a person express feelings on a differnt item-scales was measured as well. The results are as follows:
It is clear that users find 2 item-scale slightly easier to use and quicker to use in comparison to 5 item-scale but also very inadequate in expressing user's true beliefs. This indicates that 2 item-scale does not capture underlying variability very well and results in loss of variability. Discrimination indices are also markedly poorer for 2 item-scales in comparison to 5 item-scales.
Taking all of the above into account I would speculate that Netflix is willing to exchange some voting precision to lure more users into voting. I think they prefer more people voting since it increases sample coverage. This can lead to better understanding of less engaged users. Marginal value of additional information for less engaged users is likely much higher in comparison to engaged users. | Why would Netflix switch from its five-star rating system to a like/dislike system?
According to an article by Preston & Coleman (2000), 2 item-scale relaibility does not differ markedly from 5 item-scale reliability:
The subject of measurement was satisfaction with restaruants but |
26,071 | Bayesian updating - coin tossing example | Your approach b) is wrong: both the single step updating, in which all data are used together to update the prior and arrive at the posterior, and the Bayesian sequential (also called recursive) updating, in which data are used one at a time to obtain a posterior which becomes the prior of the successive iteration, must give exactly the same result. This is one of the pillars of Bayesian statistics: consistency.
Your error is simple: once you updated the prior with the first sample (the first "Head"), you only have one remaining sample to include in your likelihood in order to update the new prior. In formulas:
$$P(F|HH) =\frac{P(H|H,F)P(F|H)}{P(H|H)} $$
This formula is just Bayes' theorem, applied after the first event "Head" has already happened: since conditional probabilities are probabilities themselves, Bayes' theorem is valid also for probabilities conditioned to the event "Head", and there's nothing more to prove really . However, I found that some times people don't find this result self-evident, thus I give a slightly long-winded proof.
$$P(F|HH) =\frac{P(HH|F)P(F)}{P(HH)}= \frac{P(H|H,F)P(H|F)P(F)}{P(HH)}$$
by the chain rule of conditional probabilities. Then, multiplying numerator and denominator by $P(H)$, you get
$$\frac{P(H|H,F)P(H|F)P(F)}{P(HH)}=\frac{P(H|H,F)P(H|F)P(F)P(H)}{P(HH)P(H)}=\frac{P(H|H,F)P(H)}{P(HH)}\frac{P(H|F)P(F)}{P(H)}=\frac{P(H|H,F)}{P(H|H)}\frac{P(H|F)P(F)}{P(H)}=\frac{P(H|H,F)P(F|H)}{P(H|H)}$$
where in the last step I just applied Bayes' theorem. Now:
$$P(H|H,F)= P(H|F)=0.5$$
This is obvious: conditionally on the coin being fair (or biased), we are modelling the coin tosses as i.i.d.. Applying this same idea to the denominator, we get:
$$P(H|H)= P(H|F,H)P(F|H)+P(H|B,H)P(B|H)=P(H|F)P(F|H)+P(H|B)P(B|H)=0.5\cdot0.\bar{3}+1\cdot0.\bar{6}$$
Finally:
$$P(F|HH) =\frac{P(H|H,F)P(F|H)}{P(H|H)}=\frac{0.5\cdot0.\bar{3}}{0.5\cdot0.\bar{3}+1\cdot0.\bar{6}}=0.2$$
QED
That's it: have fun using Bayesian sequential updating, it's very useful in a lot of situations! If you want to know more, there are many resources on the Internet: this is quite good. | Bayesian updating - coin tossing example | Your approach b) is wrong: both the single step updating, in which all data are used together to update the prior and arrive at the posterior, and the Bayesian sequential (also called recursive) updat | Bayesian updating - coin tossing example
Your approach b) is wrong: both the single step updating, in which all data are used together to update the prior and arrive at the posterior, and the Bayesian sequential (also called recursive) updating, in which data are used one at a time to obtain a posterior which becomes the prior of the successive iteration, must give exactly the same result. This is one of the pillars of Bayesian statistics: consistency.
Your error is simple: once you updated the prior with the first sample (the first "Head"), you only have one remaining sample to include in your likelihood in order to update the new prior. In formulas:
$$P(F|HH) =\frac{P(H|H,F)P(F|H)}{P(H|H)} $$
This formula is just Bayes' theorem, applied after the first event "Head" has already happened: since conditional probabilities are probabilities themselves, Bayes' theorem is valid also for probabilities conditioned to the event "Head", and there's nothing more to prove really . However, I found that some times people don't find this result self-evident, thus I give a slightly long-winded proof.
$$P(F|HH) =\frac{P(HH|F)P(F)}{P(HH)}= \frac{P(H|H,F)P(H|F)P(F)}{P(HH)}$$
by the chain rule of conditional probabilities. Then, multiplying numerator and denominator by $P(H)$, you get
$$\frac{P(H|H,F)P(H|F)P(F)}{P(HH)}=\frac{P(H|H,F)P(H|F)P(F)P(H)}{P(HH)P(H)}=\frac{P(H|H,F)P(H)}{P(HH)}\frac{P(H|F)P(F)}{P(H)}=\frac{P(H|H,F)}{P(H|H)}\frac{P(H|F)P(F)}{P(H)}=\frac{P(H|H,F)P(F|H)}{P(H|H)}$$
where in the last step I just applied Bayes' theorem. Now:
$$P(H|H,F)= P(H|F)=0.5$$
This is obvious: conditionally on the coin being fair (or biased), we are modelling the coin tosses as i.i.d.. Applying this same idea to the denominator, we get:
$$P(H|H)= P(H|F,H)P(F|H)+P(H|B,H)P(B|H)=P(H|F)P(F|H)+P(H|B)P(B|H)=0.5\cdot0.\bar{3}+1\cdot0.\bar{6}$$
Finally:
$$P(F|HH) =\frac{P(H|H,F)P(F|H)}{P(H|H)}=\frac{0.5\cdot0.\bar{3}}{0.5\cdot0.\bar{3}+1\cdot0.\bar{6}}=0.2$$
QED
That's it: have fun using Bayesian sequential updating, it's very useful in a lot of situations! If you want to know more, there are many resources on the Internet: this is quite good. | Bayesian updating - coin tossing example
Your approach b) is wrong: both the single step updating, in which all data are used together to update the prior and arrive at the posterior, and the Bayesian sequential (also called recursive) updat |
26,072 | What is the information storage capacity of a neural network? | Well, a table is definitely not the right way to look at this. Consider the function $f(x)=x^2$. I can create an infinite table of input-output pairs that are represented by this function. However I can only represent exactly 1 such table with this function. Now consider this function: $g(x)=c\cdot x^2$. For different values of $c$, this function can represent an infinite number of tables (even an uncountable number).
The best way that I can come up with to describe the information storage capacity of a neural network is to quote the universal approximation theorem: https://en.wikipedia.org/wiki/Universal_approximation_theorem. To summarize it, say we have an arbitrary continuous function and we want to approximate the output of this function. Now say that for every input, the output of our approximation shouldn't deviate more than some given $\epsilon>0$. Then we can create a neural network with a single hidden layer that satisfies this constraint, no matter the continuous function, no matter how small the error tolerance. The only requirement is that the amount of nodes in the hidden layer might grow arbitrarily large if we choose the error-rate smaller and smaller. | What is the information storage capacity of a neural network? | Well, a table is definitely not the right way to look at this. Consider the function $f(x)=x^2$. I can create an infinite table of input-output pairs that are represented by this function. However I c | What is the information storage capacity of a neural network?
Well, a table is definitely not the right way to look at this. Consider the function $f(x)=x^2$. I can create an infinite table of input-output pairs that are represented by this function. However I can only represent exactly 1 such table with this function. Now consider this function: $g(x)=c\cdot x^2$. For different values of $c$, this function can represent an infinite number of tables (even an uncountable number).
The best way that I can come up with to describe the information storage capacity of a neural network is to quote the universal approximation theorem: https://en.wikipedia.org/wiki/Universal_approximation_theorem. To summarize it, say we have an arbitrary continuous function and we want to approximate the output of this function. Now say that for every input, the output of our approximation shouldn't deviate more than some given $\epsilon>0$. Then we can create a neural network with a single hidden layer that satisfies this constraint, no matter the continuous function, no matter how small the error tolerance. The only requirement is that the amount of nodes in the hidden layer might grow arbitrarily large if we choose the error-rate smaller and smaller. | What is the information storage capacity of a neural network?
Well, a table is definitely not the right way to look at this. Consider the function $f(x)=x^2$. I can create an infinite table of input-output pairs that are represented by this function. However I c |
26,073 | What is the information storage capacity of a neural network? | 4 years later I have yet to see a concrete answer for this. The best I could find is this paper.
As @dimpol pointed out, it is useful to think of the neural network as a function with a finite number of parameters. If the number of parameters and the dataset match exactly then the function (neural network) is perfectly over fitted. This is the "storage capacity" so to speak.
If we go beyond that, something magical happens. It starts to generalize again. Its yet not fully understood why it happens.
https://arxiv.org/abs/1812.11118
Open AI also talks about it
https://openai.com/blog/deep-double-descent/
Edit (27/04/2022)
Almost 5.5 years later we still dont really know the answer but for large language models, we can estimate the optimal amount of training data that we should use to train the model.
Here is the paper from deepmind https://arxiv.org/abs/2203.15556# | What is the information storage capacity of a neural network? | 4 years later I have yet to see a concrete answer for this. The best I could find is this paper.
As @dimpol pointed out, it is useful to think of the neural network as a function with a finite number | What is the information storage capacity of a neural network?
4 years later I have yet to see a concrete answer for this. The best I could find is this paper.
As @dimpol pointed out, it is useful to think of the neural network as a function with a finite number of parameters. If the number of parameters and the dataset match exactly then the function (neural network) is perfectly over fitted. This is the "storage capacity" so to speak.
If we go beyond that, something magical happens. It starts to generalize again. Its yet not fully understood why it happens.
https://arxiv.org/abs/1812.11118
Open AI also talks about it
https://openai.com/blog/deep-double-descent/
Edit (27/04/2022)
Almost 5.5 years later we still dont really know the answer but for large language models, we can estimate the optimal amount of training data that we should use to train the model.
Here is the paper from deepmind https://arxiv.org/abs/2203.15556# | What is the information storage capacity of a neural network?
4 years later I have yet to see a concrete answer for this. The best I could find is this paper.
As @dimpol pointed out, it is useful to think of the neural network as a function with a finite number |
26,074 | Bonferroni Correction & machine learning | There is a degree to which what you are talking about with p-value correction is related, but there are some details that make the two cases very different. The big one is that in parameter selection there is no independence in the parameters you are evaluating or in the data you are evaluating them on. For ease of discussion, I will take choosing k in a K-Nearest-Neighbors regression model as an example, but the concept generalizes to other models as well.
Lets say we have a validation instance V that we are predicting to get an accuracy of the model in for various values of k in our sample. To do this we find the k = 1,...,n closest values in the training set which we will define as T1, ... ,Tn. For our first value of k = 1 our prediction P11 will equal T1, for k=2, prediction P2 will be (T1 + T2)/2 or P1/2 + T2/2, for k=3 it will be (T1 + T2 + T3)/3 or P2*2/3 + T3/3. In fact for any value k we can define the prediction Pk = Pk-1(k-1)/k + Tk/k. We see that the predictions are not independant of each other so therefore the accuracy of the predictions won't be either. In fact, we see that the value of the prediction is approaching the mean of the sample. As a result, in most cases testing values of k = 1:20 will select the same value of k as testing k = 1:10,000 unless the best fit you can get out of your model is just the mean of the data.
This is why it is ok to test a bunch of different parameters on your data without worrying too much about multiple hypothesis testing. Since the impact of the parameters on the prediction isn't random, your prediction accuracy is much less likely to get a good fit due solely to chance. You do have to worry about over fitting still, but that is a separate problem from multiple hypothesis testing.
To clarify the difference between multiple hypothesis testing and over fitting, this time we will imagine making a linear model. If we repeatedly resample data for to make our linear model (the multiple lines below) and evaluate it, on testing data (the dark points), by chance one of the lines will make a good model (the red line). This is not due to it actually being a great model, but rather that if you sample the data enough, some subset will work. The important thing to note here is that the accuracy looks good on the held out testing data because of all the models tested. In fact since we are picking the "best" model based on the testing data, the model may actually fit the testing data better than the training data.
Over fitting on the other hand is when you build a single model, but contort the parameters to allow the model to fit the training data beyond what is generalizeable. In the example below the the model (line) perfectly fits the training data (empty circles) but when evaluated on the testing data (filled circles) the fit is far worse. | Bonferroni Correction & machine learning | There is a degree to which what you are talking about with p-value correction is related, but there are some details that make the two cases very different. The big one is that in parameter selection | Bonferroni Correction & machine learning
There is a degree to which what you are talking about with p-value correction is related, but there are some details that make the two cases very different. The big one is that in parameter selection there is no independence in the parameters you are evaluating or in the data you are evaluating them on. For ease of discussion, I will take choosing k in a K-Nearest-Neighbors regression model as an example, but the concept generalizes to other models as well.
Lets say we have a validation instance V that we are predicting to get an accuracy of the model in for various values of k in our sample. To do this we find the k = 1,...,n closest values in the training set which we will define as T1, ... ,Tn. For our first value of k = 1 our prediction P11 will equal T1, for k=2, prediction P2 will be (T1 + T2)/2 or P1/2 + T2/2, for k=3 it will be (T1 + T2 + T3)/3 or P2*2/3 + T3/3. In fact for any value k we can define the prediction Pk = Pk-1(k-1)/k + Tk/k. We see that the predictions are not independant of each other so therefore the accuracy of the predictions won't be either. In fact, we see that the value of the prediction is approaching the mean of the sample. As a result, in most cases testing values of k = 1:20 will select the same value of k as testing k = 1:10,000 unless the best fit you can get out of your model is just the mean of the data.
This is why it is ok to test a bunch of different parameters on your data without worrying too much about multiple hypothesis testing. Since the impact of the parameters on the prediction isn't random, your prediction accuracy is much less likely to get a good fit due solely to chance. You do have to worry about over fitting still, but that is a separate problem from multiple hypothesis testing.
To clarify the difference between multiple hypothesis testing and over fitting, this time we will imagine making a linear model. If we repeatedly resample data for to make our linear model (the multiple lines below) and evaluate it, on testing data (the dark points), by chance one of the lines will make a good model (the red line). This is not due to it actually being a great model, but rather that if you sample the data enough, some subset will work. The important thing to note here is that the accuracy looks good on the held out testing data because of all the models tested. In fact since we are picking the "best" model based on the testing data, the model may actually fit the testing data better than the training data.
Over fitting on the other hand is when you build a single model, but contort the parameters to allow the model to fit the training data beyond what is generalizeable. In the example below the the model (line) perfectly fits the training data (empty circles) but when evaluated on the testing data (filled circles) the fit is far worse. | Bonferroni Correction & machine learning
There is a degree to which what you are talking about with p-value correction is related, but there are some details that make the two cases very different. The big one is that in parameter selection |
26,075 | Bonferroni Correction & machine learning | I agree with Barker to some extend, however model selection is not only kNN. You should use cross-validation scheme, with both a validation and a test set. You use the validation set for model selection and the test set for final estimation of the model error. It could be nested k-fold CV or simple split of the training data. The measured performance by the validation set of the best performing model will be biased, as you cherry picked the best performing model. The measured performance of the test set is not biased, as you honestly only tested one model. Whenever in doubt, wrap you entire data processing and modeling in an outer cross validation to get the least biased estimation of future accuracy.
As I know of, there are no reliable simple math correction that would suit any selection between multiple non-linear models. We tend to rely on brute force bootstrapping to simulate, what would be the future model accuracy. By the way when estimating future prediction error, we assume the training set was sampled randomly from a population, and that future test predictions are sampled from the same population. If not, well who knows...
If you e.g. use an inner 5-fold CV to select model and an outer 10-fold CV repeated 10 times to estimate error, then you're unlikely to fool yourself with an overconfident model accuracy estimate. | Bonferroni Correction & machine learning | I agree with Barker to some extend, however model selection is not only kNN. You should use cross-validation scheme, with both a validation and a test set. You use the validation set for model selecti | Bonferroni Correction & machine learning
I agree with Barker to some extend, however model selection is not only kNN. You should use cross-validation scheme, with both a validation and a test set. You use the validation set for model selection and the test set for final estimation of the model error. It could be nested k-fold CV or simple split of the training data. The measured performance by the validation set of the best performing model will be biased, as you cherry picked the best performing model. The measured performance of the test set is not biased, as you honestly only tested one model. Whenever in doubt, wrap you entire data processing and modeling in an outer cross validation to get the least biased estimation of future accuracy.
As I know of, there are no reliable simple math correction that would suit any selection between multiple non-linear models. We tend to rely on brute force bootstrapping to simulate, what would be the future model accuracy. By the way when estimating future prediction error, we assume the training set was sampled randomly from a population, and that future test predictions are sampled from the same population. If not, well who knows...
If you e.g. use an inner 5-fold CV to select model and an outer 10-fold CV repeated 10 times to estimate error, then you're unlikely to fool yourself with an overconfident model accuracy estimate. | Bonferroni Correction & machine learning
I agree with Barker to some extend, however model selection is not only kNN. You should use cross-validation scheme, with both a validation and a test set. You use the validation set for model selecti |
26,076 | Replicating results for glmnet linear regression using a generic optimizer | tl;dr version:
The objective implicitly contains a scaling factor $\hat{s} = sd(y)$, where $sd(y)$ is the sample standard deviation.
Longer version
If you read the fine print of the glmnet documentation, you will see:
Note that the objective function for ‘"gaussian"’ is
1/2 RSS/nobs + lambda*penalty,
and for the other models it is
-loglik/nobs + lambda*penalty.
Note also that for ‘"gaussian"’, ‘glmnet’ standardizes y to have
unit variance before computing its lambda sequence (and then
unstandardizes the resulting coefficients); if you wish to
reproduce/compare results with other software, best to supply a
standardized y.
Now this means that the objective is actually
$$
\frac{1}{2n} \lVert y/\hat{s}-X\beta \rVert_2^2 + \lambda\alpha \lVert \beta \rVert_1 + \lambda(1-\alpha)\lVert \beta \rVert_2^2,
$$
and that glmnet reports $\tilde{\beta} = \hat{s} \beta$.
Now, when you were using a pure lasso ($\alpha=1$), then unstandardization of glmnet's $\tilde{\beta}$ means that the answers are equivalent. On the other hand, with a pure ridge, then you need to scale the penalty by a factor $1/\hat{s}$ in order for the glmnet path to agree, because an extra factor of $\hat{s}$ pops out from the square in the $\ell_2$ penalty.
For intermediate $\alpha$, there is not an easy way to scale the penalty of coefficients to reproduce glmnets output.
Once I scale the $y$ to have unit variance, I find
which still doesn't match exactly. This seems to be due to two things:
The lambda sequence may be too short for the warm-start cyclic coordinate descent algorithm to be fully convergent.
There's no error term in your data (the $R^2$ of the regression is 1).
Note also there's a bug in the code as provided in which it takes lambda[2] for the initial fit, but that should be lambda[1].
Once I rectify items 1-3, I get the following result (though YMMV depending on the random seed): | Replicating results for glmnet linear regression using a generic optimizer | tl;dr version:
The objective implicitly contains a scaling factor $\hat{s} = sd(y)$, where $sd(y)$ is the sample standard deviation.
Longer version
If you read the fine print of the glmnet documentati | Replicating results for glmnet linear regression using a generic optimizer
tl;dr version:
The objective implicitly contains a scaling factor $\hat{s} = sd(y)$, where $sd(y)$ is the sample standard deviation.
Longer version
If you read the fine print of the glmnet documentation, you will see:
Note that the objective function for ‘"gaussian"’ is
1/2 RSS/nobs + lambda*penalty,
and for the other models it is
-loglik/nobs + lambda*penalty.
Note also that for ‘"gaussian"’, ‘glmnet’ standardizes y to have
unit variance before computing its lambda sequence (and then
unstandardizes the resulting coefficients); if you wish to
reproduce/compare results with other software, best to supply a
standardized y.
Now this means that the objective is actually
$$
\frac{1}{2n} \lVert y/\hat{s}-X\beta \rVert_2^2 + \lambda\alpha \lVert \beta \rVert_1 + \lambda(1-\alpha)\lVert \beta \rVert_2^2,
$$
and that glmnet reports $\tilde{\beta} = \hat{s} \beta$.
Now, when you were using a pure lasso ($\alpha=1$), then unstandardization of glmnet's $\tilde{\beta}$ means that the answers are equivalent. On the other hand, with a pure ridge, then you need to scale the penalty by a factor $1/\hat{s}$ in order for the glmnet path to agree, because an extra factor of $\hat{s}$ pops out from the square in the $\ell_2$ penalty.
For intermediate $\alpha$, there is not an easy way to scale the penalty of coefficients to reproduce glmnets output.
Once I scale the $y$ to have unit variance, I find
which still doesn't match exactly. This seems to be due to two things:
The lambda sequence may be too short for the warm-start cyclic coordinate descent algorithm to be fully convergent.
There's no error term in your data (the $R^2$ of the regression is 1).
Note also there's a bug in the code as provided in which it takes lambda[2] for the initial fit, but that should be lambda[1].
Once I rectify items 1-3, I get the following result (though YMMV depending on the random seed): | Replicating results for glmnet linear regression using a generic optimizer
tl;dr version:
The objective implicitly contains a scaling factor $\hat{s} = sd(y)$, where $sd(y)$ is the sample standard deviation.
Longer version
If you read the fine print of the glmnet documentati |
26,077 | How To Solve Logistic Regression Using Ordinary Least Squares? | The sigmoid function in the logistic regression model precludes utilizing the close algebraic parameter estimation as in ordinary least squares (OLS). Instead nonlinear analytical methods, such as gradient descent or Newton's method will be used to minimize the cost function of the form:
$\text{cost}(\sigma(\Theta^\top {\bf x}),{\bf y})=\color{blue}{-{\bf y}\log(\sigma(\Theta^\top {\bf x}))}\color{red}{-(1-{\bf y})\log(1-\sigma(\Theta^\top {\bf x}))}$, where
$\large \sigma(z)=\frac{1}{1+e^{-\Theta^\top{\bf x}}}$, i.e. the sigmoid function. Notice that if $y=1$, we want the predicted probability, $\sigma(\Theta^\top x)$, to be high, and the minus sign in the blue part of the cost function will minimize the cost; contrarily, if $y=0$, only the red part of the equation comes into place, and the smaller $\sigma(\Theta^\top x)$, the closer the cost will be to zero.
Equivalently, we can maximize the likelihood function as:
$p({\bf y \vert x,\theta}) = \left(\sigma(\Theta^\top {\bf x})\right)^{\bf y}\,\left(1 - \sigma(\Theta^\top {\bf x})\right)^{1 -\bf y}$.
The sentence you quote, though, makes reference, I believe, to the relatively linear part of the sigmoid function:
Because the model can be expressed as a generalized linear model (see
below), for $0<p<1$, ordinary least squares can suffice, with R-squared
as the measure of goodness of fit in the fitting space. When $p=0$ or $1$,
more complex methods are required.
The logistic regression model is:
$$\text{odds(Y=1)} = \frac{p\,(Y=1)}{1\,-\,p\,(Y=1)} = e^{\,\theta_0 + \theta_1 x_1 + \cdots + \theta_p x_p} $$
or,
$\log \left(\text{odds(Y=1)}\right) = \log\left(\frac{p\,(Y=1)}{1\,-\,p\,(Y=1)}\right) = \theta_0 + \theta_1 x_1 + \cdots + \theta_p x_p=\Theta^\top{\bf X}\tag{*}$
Hence, this is "close enough" to an OLS model ($\bf y=\Theta^\top \bf X+\epsilon$) to be fit as such, and for the parameters to be estimated in closed form, provided the probability of $\bf y = 1$ (remember the Bernoulli modeling of the response variable in logistic regression) is not close to $0$ or $1$. In other words, while $\log\left(\frac{p\,(Y=1)}{1\,-\,p\,(Y=1)}\right)$ in Eq. * stays away from the asymptotic regions.
See for instance this interesting entry in Statistical Horizons, which I wanted to test with the mtcars dataset in R. The variable for automatic transmission am is binary, so we can regress it over miles-per-gallon mpg. Can we predict that a car model has automatic transmission based on its gas consumption?
If I go ahead, and just plow through the problem with OLS estimates I get a prediction accuracy of $75\%$ just based on this single predictor. And guess what? I get the exact same confusion matrix and accuracy rate if I fit a logistic regression.
The thing is that the output of OLS is not binary, but rather continuous, and trying to estimate the real binary $\bf y$ values, they are typically between $0$ and $1$, much like probability values, although not strictly bounded like in logistic regression (sigmoid function).
Here is the code:
> d = mtcars
> summary(as.factor(d$am))
0 1
19 13
> fit_LR = glm(as.factor(am) ~ mpg, family = binomial, d)
> pr_LR = predict(fit, type="response")
>
> # all.equal(pr_LR, 1 / (1 + exp( - predict(fit_LR) ) ) ) - predict() is log odds P(Y =1)
>
> d$predict_LR = ifelse(pr_LR > 0.5, 1, 0)
> t_LR = table(d$am,d$predict_LR)
> (accuracy = (t_LR[1,1] + t_LR[2,2]) / sum(t))
[1] 0.75
>
> fit_OLS = lm(am ~ mpg, d)
> pr_OLS = predict(fitOLS)
> d$predict_OLS = ifelse(pr_OLS > 0.5, 1, 0)
> (t_OLS = table(d$am, d$predict_OLS))
0 1
0 17 2
1 6 7
> (accuracy = (t[1,1] + t[2,2]) / sum(t_OLS))
[1] 0.75
The frequency of automatic v manual cars is pretty balanced, and the OLS model is good enough as a perceptron: | How To Solve Logistic Regression Using Ordinary Least Squares? | The sigmoid function in the logistic regression model precludes utilizing the close algebraic parameter estimation as in ordinary least squares (OLS). Instead nonlinear analytical methods, such as gra | How To Solve Logistic Regression Using Ordinary Least Squares?
The sigmoid function in the logistic regression model precludes utilizing the close algebraic parameter estimation as in ordinary least squares (OLS). Instead nonlinear analytical methods, such as gradient descent or Newton's method will be used to minimize the cost function of the form:
$\text{cost}(\sigma(\Theta^\top {\bf x}),{\bf y})=\color{blue}{-{\bf y}\log(\sigma(\Theta^\top {\bf x}))}\color{red}{-(1-{\bf y})\log(1-\sigma(\Theta^\top {\bf x}))}$, where
$\large \sigma(z)=\frac{1}{1+e^{-\Theta^\top{\bf x}}}$, i.e. the sigmoid function. Notice that if $y=1$, we want the predicted probability, $\sigma(\Theta^\top x)$, to be high, and the minus sign in the blue part of the cost function will minimize the cost; contrarily, if $y=0$, only the red part of the equation comes into place, and the smaller $\sigma(\Theta^\top x)$, the closer the cost will be to zero.
Equivalently, we can maximize the likelihood function as:
$p({\bf y \vert x,\theta}) = \left(\sigma(\Theta^\top {\bf x})\right)^{\bf y}\,\left(1 - \sigma(\Theta^\top {\bf x})\right)^{1 -\bf y}$.
The sentence you quote, though, makes reference, I believe, to the relatively linear part of the sigmoid function:
Because the model can be expressed as a generalized linear model (see
below), for $0<p<1$, ordinary least squares can suffice, with R-squared
as the measure of goodness of fit in the fitting space. When $p=0$ or $1$,
more complex methods are required.
The logistic regression model is:
$$\text{odds(Y=1)} = \frac{p\,(Y=1)}{1\,-\,p\,(Y=1)} = e^{\,\theta_0 + \theta_1 x_1 + \cdots + \theta_p x_p} $$
or,
$\log \left(\text{odds(Y=1)}\right) = \log\left(\frac{p\,(Y=1)}{1\,-\,p\,(Y=1)}\right) = \theta_0 + \theta_1 x_1 + \cdots + \theta_p x_p=\Theta^\top{\bf X}\tag{*}$
Hence, this is "close enough" to an OLS model ($\bf y=\Theta^\top \bf X+\epsilon$) to be fit as such, and for the parameters to be estimated in closed form, provided the probability of $\bf y = 1$ (remember the Bernoulli modeling of the response variable in logistic regression) is not close to $0$ or $1$. In other words, while $\log\left(\frac{p\,(Y=1)}{1\,-\,p\,(Y=1)}\right)$ in Eq. * stays away from the asymptotic regions.
See for instance this interesting entry in Statistical Horizons, which I wanted to test with the mtcars dataset in R. The variable for automatic transmission am is binary, so we can regress it over miles-per-gallon mpg. Can we predict that a car model has automatic transmission based on its gas consumption?
If I go ahead, and just plow through the problem with OLS estimates I get a prediction accuracy of $75\%$ just based on this single predictor. And guess what? I get the exact same confusion matrix and accuracy rate if I fit a logistic regression.
The thing is that the output of OLS is not binary, but rather continuous, and trying to estimate the real binary $\bf y$ values, they are typically between $0$ and $1$, much like probability values, although not strictly bounded like in logistic regression (sigmoid function).
Here is the code:
> d = mtcars
> summary(as.factor(d$am))
0 1
19 13
> fit_LR = glm(as.factor(am) ~ mpg, family = binomial, d)
> pr_LR = predict(fit, type="response")
>
> # all.equal(pr_LR, 1 / (1 + exp( - predict(fit_LR) ) ) ) - predict() is log odds P(Y =1)
>
> d$predict_LR = ifelse(pr_LR > 0.5, 1, 0)
> t_LR = table(d$am,d$predict_LR)
> (accuracy = (t_LR[1,1] + t_LR[2,2]) / sum(t))
[1] 0.75
>
> fit_OLS = lm(am ~ mpg, d)
> pr_OLS = predict(fitOLS)
> d$predict_OLS = ifelse(pr_OLS > 0.5, 1, 0)
> (t_OLS = table(d$am, d$predict_OLS))
0 1
0 17 2
1 6 7
> (accuracy = (t[1,1] + t[2,2]) / sum(t_OLS))
[1] 0.75
The frequency of automatic v manual cars is pretty balanced, and the OLS model is good enough as a perceptron: | How To Solve Logistic Regression Using Ordinary Least Squares?
The sigmoid function in the logistic regression model precludes utilizing the close algebraic parameter estimation as in ordinary least squares (OLS). Instead nonlinear analytical methods, such as gra |
26,078 | How To Solve Logistic Regression Using Ordinary Least Squares? | You misinterpret the statement you quote. A generalized linear model (normally estimated by maximum likelihood) is not a least squares problem*.
See wikipedia's page Generalized linear model for example.
However, the likelihood is often solved as a sequence of linear least squares approximations -- iteratively reweighted least squares (similarly to a common approach for nonlinear least squares problems).
So in practice quite often a sequence of weighted least squares problems are solved to obtain the parameter estimates. These are obtained by starting at some approximate estimate (there are some standard ways to obtain these), then constructing working response values and weights for a linear approximation to the model which is fitted by weighted least squares, yielding new estimates which in turn are used to update the working response values and weights; this cycle being repeated multiple times.
It's not the only way to fit these models, but one used by a number of stats packages.
* (NB not to be confused with a general linear model which the estimation of can be cast as a form of least squares, nor with generalized least squares) | How To Solve Logistic Regression Using Ordinary Least Squares? | You misinterpret the statement you quote. A generalized linear model (normally estimated by maximum likelihood) is not a least squares problem*.
See wikipedia's page Generalized linear model for exam | How To Solve Logistic Regression Using Ordinary Least Squares?
You misinterpret the statement you quote. A generalized linear model (normally estimated by maximum likelihood) is not a least squares problem*.
See wikipedia's page Generalized linear model for example.
However, the likelihood is often solved as a sequence of linear least squares approximations -- iteratively reweighted least squares (similarly to a common approach for nonlinear least squares problems).
So in practice quite often a sequence of weighted least squares problems are solved to obtain the parameter estimates. These are obtained by starting at some approximate estimate (there are some standard ways to obtain these), then constructing working response values and weights for a linear approximation to the model which is fitted by weighted least squares, yielding new estimates which in turn are used to update the working response values and weights; this cycle being repeated multiple times.
It's not the only way to fit these models, but one used by a number of stats packages.
* (NB not to be confused with a general linear model which the estimation of can be cast as a form of least squares, nor with generalized least squares) | How To Solve Logistic Regression Using Ordinary Least Squares?
You misinterpret the statement you quote. A generalized linear model (normally estimated by maximum likelihood) is not a least squares problem*.
See wikipedia's page Generalized linear model for exam |
26,079 | Relation between Covariance matrix and Jacobian in Nonlinear Least Squares | This is based on the standard approximation to the Hessian of a nonlinear least squares problem used by Gauss-Newton and Levenberg-Marquardt algorithms.
Consider the nonlinear least squares problem: minimize $1/2r(x)^Tr(x)$. Let $J$ = Jacobian of r(x). The Hessian of the objective = $J^TJ +$ higher order terms. The Gauss-Newton or Levenberg-Marquardt approximation is to ignore the higher order terms, and approximate the Hessian as $J^TJ$. This approximation for the Hessian is what is used in the formula CovB = inv(J'*J)*MSE in MATLAB's nlinfit.
The higher order terms are close to zero at the solution if the residuals r(x) are close to zero. If the residuals are large at the solution, the approximation may be very inaccurate. See the first 7 slides of https://www8.cs.umu.se/kurser/5DA001/HT07/lectures/lsq-handouts.pdf . There is also mention, with less detail provided, at https://en.wikipedia.org/wiki/Gauss%E2%80%93Newton_algorithm. | Relation between Covariance matrix and Jacobian in Nonlinear Least Squares | This is based on the standard approximation to the Hessian of a nonlinear least squares problem used by Gauss-Newton and Levenberg-Marquardt algorithms.
Consider the nonlinear least squares problem: m | Relation between Covariance matrix and Jacobian in Nonlinear Least Squares
This is based on the standard approximation to the Hessian of a nonlinear least squares problem used by Gauss-Newton and Levenberg-Marquardt algorithms.
Consider the nonlinear least squares problem: minimize $1/2r(x)^Tr(x)$. Let $J$ = Jacobian of r(x). The Hessian of the objective = $J^TJ +$ higher order terms. The Gauss-Newton or Levenberg-Marquardt approximation is to ignore the higher order terms, and approximate the Hessian as $J^TJ$. This approximation for the Hessian is what is used in the formula CovB = inv(J'*J)*MSE in MATLAB's nlinfit.
The higher order terms are close to zero at the solution if the residuals r(x) are close to zero. If the residuals are large at the solution, the approximation may be very inaccurate. See the first 7 slides of https://www8.cs.umu.se/kurser/5DA001/HT07/lectures/lsq-handouts.pdf . There is also mention, with less detail provided, at https://en.wikipedia.org/wiki/Gauss%E2%80%93Newton_algorithm. | Relation between Covariance matrix and Jacobian in Nonlinear Least Squares
This is based on the standard approximation to the Hessian of a nonlinear least squares problem used by Gauss-Newton and Levenberg-Marquardt algorithms.
Consider the nonlinear least squares problem: m |
26,080 | When does the maximum likelihood correspond to a reference prior? | Correct, as long as the support of the uniform prior contains the MLE. The reason for this is that the posterior and the likelihood are proportional on the support of the uniform prior. Even if the MAP and MLE coincide numerically, their interpretation is completely different.
False. The support of the prior is certainly location and scale dependent (e.g. if the data are reported in nanometers or in parsecs), but an appropriate choice is often possible. You may need to use a huge compact set as the support, but it is still possible.
It does not use prior information in the sense of a prior distribution (since they are completely different inferential approaches) but there is always information injected by the user. The choice of the model is a form of prior information. If you put 10 people to fit a dataset, some of them would probably come up with different answers.
Yes. Have a look at the following references
The formal definition of reference priors
Jeffreys Priors and Reference Priors
The reference prior and the Jeffreys prior are the same in uniparametric models (unidimensional parameter), but this is not the case in general. They are uniform for location parameters, but this is not the case of scale and shape parameters. They are different even for the scale parameter of the normal distribution (see my previous references).
False. Truly Bayesians use the posterior distribution in order to obtain Bayes estimators. The MAP is one of them, but there are many others. See Wikipedia's article on the Bayes estimator.
Non-Bayesians do not always use the MLE. An example of this is the James-Stein estimator, which is based on a different criterion than maximizing a likelihood function. | When does the maximum likelihood correspond to a reference prior? | Correct, as long as the support of the uniform prior contains the MLE. The reason for this is that the posterior and the likelihood are proportional on the support of the uniform prior. Even if the MA | When does the maximum likelihood correspond to a reference prior?
Correct, as long as the support of the uniform prior contains the MLE. The reason for this is that the posterior and the likelihood are proportional on the support of the uniform prior. Even if the MAP and MLE coincide numerically, their interpretation is completely different.
False. The support of the prior is certainly location and scale dependent (e.g. if the data are reported in nanometers or in parsecs), but an appropriate choice is often possible. You may need to use a huge compact set as the support, but it is still possible.
It does not use prior information in the sense of a prior distribution (since they are completely different inferential approaches) but there is always information injected by the user. The choice of the model is a form of prior information. If you put 10 people to fit a dataset, some of them would probably come up with different answers.
Yes. Have a look at the following references
The formal definition of reference priors
Jeffreys Priors and Reference Priors
The reference prior and the Jeffreys prior are the same in uniparametric models (unidimensional parameter), but this is not the case in general. They are uniform for location parameters, but this is not the case of scale and shape parameters. They are different even for the scale parameter of the normal distribution (see my previous references).
False. Truly Bayesians use the posterior distribution in order to obtain Bayes estimators. The MAP is one of them, but there are many others. See Wikipedia's article on the Bayes estimator.
Non-Bayesians do not always use the MLE. An example of this is the James-Stein estimator, which is based on a different criterion than maximizing a likelihood function. | When does the maximum likelihood correspond to a reference prior?
Correct, as long as the support of the uniform prior contains the MLE. The reason for this is that the posterior and the likelihood are proportional on the support of the uniform prior. Even if the MA |
26,081 | When does the maximum likelihood correspond to a reference prior? | A few more remarks in addition to the points made by Richard Price:
The MLE always corresponds to the uniform prior (the MAP of the
uniform prior is the MLE).
This is incorrect for a simple if often overlooked reason: the MLE does not require a dominating measure on the parameter space while a Bayesian approach does. This means that both "the" flat (constant) prior and "the" MAP are actually depending on the choice of the dominating measure. An alternative explanation (already made in a comment) is that the MLE is invariant by reparameterisation, that is under any bijective transform of the parameter, while a flat prior does not remain constant under bijective transforms and the MAP is not invariant by reparameterisation. My general view on MAPs is that they are not Bayesian procedures.
Sometimes a uniform prior is not possible (when the data lacks an
upper or lower bound).
This is both correct and incorrect. Choosing a Uniform prior $\mathcal U(a,b)$ is always possible, but requires a choice of $a$ and $b$. If the prior density is constant over the entire parameter space (against the chosen dominating measure) then it is not a Uniform density because it is not a probability density. The prior then becomes improper, that is, a $\sigma$-finite measure.
Non-Bayesian analysis, which uses the MLE instead of the MAP,
essentially sidesteps or ignores the issue of modeling prior
information and thus always assumes that there is none.
This is too vague a statement to validate or invalidate. As signaled by Richard Price]1, the choice of a model is a type of information, which may become increasingly Bayesian when bringing in random effects for instance. Further, non-Bayesian analysis is not defined as an approach per se.
Non-informative (also called reference) priors correspond to the
maximizing the Kullback-Leibler divergence between posterior and
prior, or equivalently the mutual information between the parameter 𝜃
and the random variable 𝑋.
Correct: Reference priors in the specific sense of Bernardo (1979), Berger, Bernardo, and Sun (2009), and others, are maximising the expected Kullback-Leibler divergence between prior and posterior for the parameter(s) of interest. As this is usually impossible when considering proper priors, it gets complicated.
Sometimes the reference prior is not uniform, it can also be a
Jeffreys prior instead.
This is again a vague and not so useful statement. For the same reason as above, namely the lack of invariance under reparameterisation, the reference prior [assuming a specific definition of said prior] is almost never uniform. Jeffreys' approach enjoys invariance under reparameterisation in the sense that its definition is consistent under changes of parameterisation.
Bayesian inference always uses the MAP and non-Bayesian inference
always uses the MLE.
This is incorrect, for both parts. Bayesian inference always uses the full posterior distribution and only derives procedures like point estimates in cases a decision is required and a loss function provided. MAP estimates are not available as decision-theoretic procedures. Non-Bayesian inference covers all possible answers to an inference problem and hence cannot be characterised. | When does the maximum likelihood correspond to a reference prior? | A few more remarks in addition to the points made by Richard Price:
The MLE always corresponds to the uniform prior (the MAP of the
uniform prior is the MLE).
This is incorrect for a simple if o | When does the maximum likelihood correspond to a reference prior?
A few more remarks in addition to the points made by Richard Price:
The MLE always corresponds to the uniform prior (the MAP of the
uniform prior is the MLE).
This is incorrect for a simple if often overlooked reason: the MLE does not require a dominating measure on the parameter space while a Bayesian approach does. This means that both "the" flat (constant) prior and "the" MAP are actually depending on the choice of the dominating measure. An alternative explanation (already made in a comment) is that the MLE is invariant by reparameterisation, that is under any bijective transform of the parameter, while a flat prior does not remain constant under bijective transforms and the MAP is not invariant by reparameterisation. My general view on MAPs is that they are not Bayesian procedures.
Sometimes a uniform prior is not possible (when the data lacks an
upper or lower bound).
This is both correct and incorrect. Choosing a Uniform prior $\mathcal U(a,b)$ is always possible, but requires a choice of $a$ and $b$. If the prior density is constant over the entire parameter space (against the chosen dominating measure) then it is not a Uniform density because it is not a probability density. The prior then becomes improper, that is, a $\sigma$-finite measure.
Non-Bayesian analysis, which uses the MLE instead of the MAP,
essentially sidesteps or ignores the issue of modeling prior
information and thus always assumes that there is none.
This is too vague a statement to validate or invalidate. As signaled by Richard Price]1, the choice of a model is a type of information, which may become increasingly Bayesian when bringing in random effects for instance. Further, non-Bayesian analysis is not defined as an approach per se.
Non-informative (also called reference) priors correspond to the
maximizing the Kullback-Leibler divergence between posterior and
prior, or equivalently the mutual information between the parameter 𝜃
and the random variable 𝑋.
Correct: Reference priors in the specific sense of Bernardo (1979), Berger, Bernardo, and Sun (2009), and others, are maximising the expected Kullback-Leibler divergence between prior and posterior for the parameter(s) of interest. As this is usually impossible when considering proper priors, it gets complicated.
Sometimes the reference prior is not uniform, it can also be a
Jeffreys prior instead.
This is again a vague and not so useful statement. For the same reason as above, namely the lack of invariance under reparameterisation, the reference prior [assuming a specific definition of said prior] is almost never uniform. Jeffreys' approach enjoys invariance under reparameterisation in the sense that its definition is consistent under changes of parameterisation.
Bayesian inference always uses the MAP and non-Bayesian inference
always uses the MLE.
This is incorrect, for both parts. Bayesian inference always uses the full posterior distribution and only derives procedures like point estimates in cases a decision is required and a loss function provided. MAP estimates are not available as decision-theoretic procedures. Non-Bayesian inference covers all possible answers to an inference problem and hence cannot be characterised. | When does the maximum likelihood correspond to a reference prior?
A few more remarks in addition to the points made by Richard Price:
The MLE always corresponds to the uniform prior (the MAP of the
uniform prior is the MLE).
This is incorrect for a simple if o |
26,082 | Multivariate time series clustering | The R package pdc offers clustering for multivariate time series. Permutation Distribution Clustering is a complexity-based dissimilarity measure for time series. If you can assume that differences in time series are due to differences w.r.t. complexity and, specifically not due to differences in means, variances, or the moments in general, this may be a valid approach. The algorithmic time complexity of calculating the pdc representation of a multivariate time series is in O(DTN) with D being the number of dimensions, T being the length of the time series and N being the number of time series. This is probably as efficient as it gets since a single sweep over each dimension of each time series is enough to obtain the compressed complexity representation. This representation can be used to calculate dissimilarity between two time series at low cost (depending on the chosen representational complexity which can either be pre-specified or derived from the data).
Here is a simple worked example with a hierarchical clustering of multivariate white-noise time series (the plot illustrates only the first dimension of each time series):
require("pdc")
num.ts <- 20 # number of time series
num.dim <- 12 # number of dimensions
len.ts <- 600*10 # number of time series
# generate Gaussian white noise
data <- array(dim = c(len.ts, num.ts, num.dim),data = rnorm(num.ts*num.dim*len.ts))
# obtain clustering with embedding dimension of 5
pdc <- pdclust(X = data, m=5,t=1)
# plot hierarchical clustering
plot(pdc)
The command pdcDist(data) generates a dissimilarity matrix:
Since the data are all white noise, there is no apparent structure in the dissimilarity matrix.
1 2 3 4 5 6 7
2 4.832894
3 4.810718 4.790286
4 4.812738 4.796530 4.809482
5 4.798458 4.772756 4.751079 4.786206
6 4.812076 4.793027 4.798996 4.758193 4.751691
7 4.786515 4.771505 4.754735 4.837236 4.775775 4.794706
8 4.808709 4.832403 4.722993 4.781267 4.784397 4.776600 4.787757
For more information refer to:
Brandmaier, A. M. (2015). pdc: An R package for complexity-based clustering of time series. Journal of Statistical Software, 67. doi:10.18637/jss.v067.i05
(Full text) | Multivariate time series clustering | The R package pdc offers clustering for multivariate time series. Permutation Distribution Clustering is a complexity-based dissimilarity measure for time series. If you can assume that differences in | Multivariate time series clustering
The R package pdc offers clustering for multivariate time series. Permutation Distribution Clustering is a complexity-based dissimilarity measure for time series. If you can assume that differences in time series are due to differences w.r.t. complexity and, specifically not due to differences in means, variances, or the moments in general, this may be a valid approach. The algorithmic time complexity of calculating the pdc representation of a multivariate time series is in O(DTN) with D being the number of dimensions, T being the length of the time series and N being the number of time series. This is probably as efficient as it gets since a single sweep over each dimension of each time series is enough to obtain the compressed complexity representation. This representation can be used to calculate dissimilarity between two time series at low cost (depending on the chosen representational complexity which can either be pre-specified or derived from the data).
Here is a simple worked example with a hierarchical clustering of multivariate white-noise time series (the plot illustrates only the first dimension of each time series):
require("pdc")
num.ts <- 20 # number of time series
num.dim <- 12 # number of dimensions
len.ts <- 600*10 # number of time series
# generate Gaussian white noise
data <- array(dim = c(len.ts, num.ts, num.dim),data = rnorm(num.ts*num.dim*len.ts))
# obtain clustering with embedding dimension of 5
pdc <- pdclust(X = data, m=5,t=1)
# plot hierarchical clustering
plot(pdc)
The command pdcDist(data) generates a dissimilarity matrix:
Since the data are all white noise, there is no apparent structure in the dissimilarity matrix.
1 2 3 4 5 6 7
2 4.832894
3 4.810718 4.790286
4 4.812738 4.796530 4.809482
5 4.798458 4.772756 4.751079 4.786206
6 4.812076 4.793027 4.798996 4.758193 4.751691
7 4.786515 4.771505 4.754735 4.837236 4.775775 4.794706
8 4.808709 4.832403 4.722993 4.781267 4.784397 4.776600 4.787757
For more information refer to:
Brandmaier, A. M. (2015). pdc: An R package for complexity-based clustering of time series. Journal of Statistical Software, 67. doi:10.18637/jss.v067.i05
(Full text) | Multivariate time series clustering
The R package pdc offers clustering for multivariate time series. Permutation Distribution Clustering is a complexity-based dissimilarity measure for time series. If you can assume that differences in |
26,083 | Multivariate time series clustering | Check RTEFC ("Real Time Exponential Filter Clustering") or RTMAC ("Real Time Moving Average Clustering), which are efficient, simple real-time variants of K-means, suited for real time use when prototype clustering is appropriate. They cluster sequences of vectors. See https://gregstanleyandassociates.com/whitepapers/BDAC/Clustering/clustering.htm
and the associated material on representing multivariate time series as one larger vector at each time step (the representation for "BDAC"), with a sliding time window. Pictorially,
These were developed to simultaneously accomplish both filtering of noise and clustering in real time to recognize and track different conditions. RTMAC limits memory growth by retaining the most recent observations close to a given cluster. RTEFC only retains the centroids from one time step to the next, which is enough for many applications. Pictorially, RTEFC looks like:
Dawg asked to compare this to HDBSCAN, in particular the approximate_predict() function. The major difference is that HDBSCAN is still assuming there is occasional retraining from original data points, an expensive operation. The HDBSCAN approximate_predict() function is used to get a quick cluster assignment for new data without retraining. In the RTEFC case, there is never any large retraining computation, because the original data points are not stored. Instead, only the cluster centers are stored. Each new data point updates only one cluster center (either creating a new one if needed and within the specified upper limit on the number of clusters, or updating one previous center). The computational cost at each step is low and predictable. So RTEFC computation would be comparable to the approximate_predict() case in finding the closest existing match, except that additionally, one cluster center is then updated with the simple filter equation (or created).
The pictures have some similarities, except the HDBSCAN picture wouldn't have the starred point indicating a recomputed cluster center for a new data point near an existing cluster, and the HDBSCAN picture would reject the new cluster case or the forced update case as outliers.
RTEFC is also optionally modified when causality is known a priori (when systems have defined inputs and outputs). The same system inputs (and initial conditions for dynamic systems) should produce the same system outputs. They don't because of noise or system changes. In that case, any distance metric used for clustering is modified to only account for closeness of the system inputs & initial conditions. So, because of the linear combination of repeated cases, noise is partly canceled, and slow adaptation to system changes occurs. The centroids are actually better representations of typical system behavior than any particular data point, because of the noise reduction.
Another difference is that all that has been developed for RTEFC is just the core algorithm. It's simple enough to implement with just a few lines of code, that is fast and with predictable maximum computation time at each step. This differs from an entire facility with lots of options. Those sorts of things are reasonable extensions. Outlier rejection, for instance, could simply require that after some time, points outside the defined distance to an existing cluster center be ignored rather than used to create new clusters or update the nearest cluster.
The goals of RTEFC are to end up with a set of representative points defining the possible behavior of an observed system, adapt to system changes over time, and optionally reduce the effect of noise in repeated cases with known causality. It's not to maintain all the original data, some of which may become obsolete as the observed system changes over time. This minimizes storage requirements as well as computing time. This set of characteristics (cluster centers as representative points are all that's needed, adaptation over time, predictable and low computation time) won't fit all applications. This could be applied to maintaining online training data sets for batch-oriented clustering, neural net function approximation models, or other scheme for analysis or model building. Example applications could include fault detection/diagnosis; process control; or other places where models can be created from the representative points or behavior just interpolated between those points. The systems being observed would be ones described mostly by a set of continuous variables, that might otherwise require modeling with algebraic equations and/or time series models (including difference equations/differential equations), as well as inequality constraints. | Multivariate time series clustering | Check RTEFC ("Real Time Exponential Filter Clustering") or RTMAC ("Real Time Moving Average Clustering), which are efficient, simple real-time variants of K-means, suited for real time use when protot | Multivariate time series clustering
Check RTEFC ("Real Time Exponential Filter Clustering") or RTMAC ("Real Time Moving Average Clustering), which are efficient, simple real-time variants of K-means, suited for real time use when prototype clustering is appropriate. They cluster sequences of vectors. See https://gregstanleyandassociates.com/whitepapers/BDAC/Clustering/clustering.htm
and the associated material on representing multivariate time series as one larger vector at each time step (the representation for "BDAC"), with a sliding time window. Pictorially,
These were developed to simultaneously accomplish both filtering of noise and clustering in real time to recognize and track different conditions. RTMAC limits memory growth by retaining the most recent observations close to a given cluster. RTEFC only retains the centroids from one time step to the next, which is enough for many applications. Pictorially, RTEFC looks like:
Dawg asked to compare this to HDBSCAN, in particular the approximate_predict() function. The major difference is that HDBSCAN is still assuming there is occasional retraining from original data points, an expensive operation. The HDBSCAN approximate_predict() function is used to get a quick cluster assignment for new data without retraining. In the RTEFC case, there is never any large retraining computation, because the original data points are not stored. Instead, only the cluster centers are stored. Each new data point updates only one cluster center (either creating a new one if needed and within the specified upper limit on the number of clusters, or updating one previous center). The computational cost at each step is low and predictable. So RTEFC computation would be comparable to the approximate_predict() case in finding the closest existing match, except that additionally, one cluster center is then updated with the simple filter equation (or created).
The pictures have some similarities, except the HDBSCAN picture wouldn't have the starred point indicating a recomputed cluster center for a new data point near an existing cluster, and the HDBSCAN picture would reject the new cluster case or the forced update case as outliers.
RTEFC is also optionally modified when causality is known a priori (when systems have defined inputs and outputs). The same system inputs (and initial conditions for dynamic systems) should produce the same system outputs. They don't because of noise or system changes. In that case, any distance metric used for clustering is modified to only account for closeness of the system inputs & initial conditions. So, because of the linear combination of repeated cases, noise is partly canceled, and slow adaptation to system changes occurs. The centroids are actually better representations of typical system behavior than any particular data point, because of the noise reduction.
Another difference is that all that has been developed for RTEFC is just the core algorithm. It's simple enough to implement with just a few lines of code, that is fast and with predictable maximum computation time at each step. This differs from an entire facility with lots of options. Those sorts of things are reasonable extensions. Outlier rejection, for instance, could simply require that after some time, points outside the defined distance to an existing cluster center be ignored rather than used to create new clusters or update the nearest cluster.
The goals of RTEFC are to end up with a set of representative points defining the possible behavior of an observed system, adapt to system changes over time, and optionally reduce the effect of noise in repeated cases with known causality. It's not to maintain all the original data, some of which may become obsolete as the observed system changes over time. This minimizes storage requirements as well as computing time. This set of characteristics (cluster centers as representative points are all that's needed, adaptation over time, predictable and low computation time) won't fit all applications. This could be applied to maintaining online training data sets for batch-oriented clustering, neural net function approximation models, or other scheme for analysis or model building. Example applications could include fault detection/diagnosis; process control; or other places where models can be created from the representative points or behavior just interpolated between those points. The systems being observed would be ones described mostly by a set of continuous variables, that might otherwise require modeling with algebraic equations and/or time series models (including difference equations/differential equations), as well as inequality constraints. | Multivariate time series clustering
Check RTEFC ("Real Time Exponential Filter Clustering") or RTMAC ("Real Time Moving Average Clustering), which are efficient, simple real-time variants of K-means, suited for real time use when protot |
26,084 | How does cross-validation in train (caret) precisely work? | Yes, you are correct. If you want to look at the details:
For observing the results over parametrization, and the final model chosen, you can compare fit$results with fit$bestTune and fit$finalModel (with same performance the less complex model is chosen).
For observing the performance of the final model parametrization per partition and resample, look at fit$resample. Note that with changing the value for returnResamp in ?trainControl you can configure which results you see here (e.g. if you want to see those also for other than the finally selected parameter set) - but usually the default should be fine.
For observing the individual predictions done during CV you can enable savePredictions = T in ?trainControl, then look at fit$pred, e.g. as table(fit$pred$Resample). | How does cross-validation in train (caret) precisely work? | Yes, you are correct. If you want to look at the details:
For observing the results over parametrization, and the final model chosen, you can compare fit$results with fit$bestTune and fit$finalModel | How does cross-validation in train (caret) precisely work?
Yes, you are correct. If you want to look at the details:
For observing the results over parametrization, and the final model chosen, you can compare fit$results with fit$bestTune and fit$finalModel (with same performance the less complex model is chosen).
For observing the performance of the final model parametrization per partition and resample, look at fit$resample. Note that with changing the value for returnResamp in ?trainControl you can configure which results you see here (e.g. if you want to see those also for other than the finally selected parameter set) - but usually the default should be fine.
For observing the individual predictions done during CV you can enable savePredictions = T in ?trainControl, then look at fit$pred, e.g. as table(fit$pred$Resample). | How does cross-validation in train (caret) precisely work?
Yes, you are correct. If you want to look at the details:
For observing the results over parametrization, and the final model chosen, you can compare fit$results with fit$bestTune and fit$finalModel |
26,085 | How to predict factor scores in Lavaan | This question has received a number of views since it was first posed, but no answers. Here is a solution, which may be useful to future readers of this question.
To demonstrate it works I will first run a cfa() model in using the HolzingerSwineford1939. The model is taken from the lavaan tutorial page.
library(lavaan)
dat<-data.frame(HolzingerSwineford1939[,7:15])
mod<-'
visual=~x1+x2+x3
textual=~x4+x5+x6
speed=~x7+x8+x9
'
fit<-cfa(mod, data = dat)
This returns the following solution:
> summary(fit)
lavaan (0.5-22) converged normally after 35 iterations
Number of observations 301
Estimator ML
Minimum Function Test Statistic 85.306
Degrees of freedom 24
P-value (Chi-square) 0.000
Parameter Estimates:
Information Expected
Standard Errors Standard
Latent Variables:
Estimate Std.Err z-value P(>|z|)
visual =~
x1 1.000
x2 0.554 0.100 5.554 0.000
x3 0.729 0.109 6.685 0.000
textual =~
x4 1.000
x5 1.113 0.065 17.014 0.000
x6 0.926 0.055 16.703 0.000
speed =~
x7 1.000
x8 1.180 0.165 7.152 0.000
x9 1.082 0.151 7.155 0.000
Covariances:
Estimate Std.Err z-value P(>|z|)
visual ~~
textual 0.408 0.074 5.552 0.000
speed 0.262 0.056 4.660 0.000
textual ~~
speed 0.173 0.049 3.518 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.x1 0.549 0.114 4.833 0.000
.x2 1.134 0.102 11.146 0.000
.x3 0.844 0.091 9.317 0.000
.x4 0.371 0.048 7.779 0.000
.x5 0.446 0.058 7.642 0.000
.x6 0.356 0.043 8.277 0.000
.x7 0.799 0.081 9.823 0.000
.x8 0.488 0.074 6.573 0.000
.x9 0.566 0.071 8.003 0.000
visual 0.809 0.145 5.564 0.000
textual 0.979 0.112 8.737 0.000
speed 0.384 0.086 4.451 0.000
When using raw data for input the lavPredict() and predict() return predicted values for the latent variables.
> head(lavPredict(fit))
visual textual speed
[1,] -0.81767524 -0.13754501 0.06150726
[2,] 0.04951940 -1.01272402 0.62549360
[3,] -0.76139670 -1.87228634 -0.84057276
[4,] 0.41934153 0.01848569 -0.27133710
[5,] -0.41590481 -0.12225009 0.19432951
[6,] 0.02325632 -1.32981727 0.70885348
Running the same model with the covariance matrix as input returns the same results, but as the original poster notes yields an error when attempting to derive the factor scores.
> COV<-cov(dat)
> fit1<-cfa(mod, sample.cov = COV, sample.nobs = 301, sample.mean = colMeans(dat))
> lavPredict(fit1)
Error in lavPredict(fit1) :
lavaan ERROR: sample statistics were used for fitting and newdata is empty
The solution is fairly straightforward as what the package needs is some raw data to "chew on" so to speak. Here you amend the code to identify the original dataset as raw data input for the prediction function (lavPredict(fit1, newdata = dat)). This returns the following (which remember is the same model fitted in lavaan but using the covariance matrix as input).
> head(lavPredict(fit1, newdata = dat))
visual textual speed
[1,] -0.81767524 -0.13754501 0.06150726
[2,] 0.04951940 -1.01272402 0.62549360
[3,] -0.76139670 -1.87228634 -0.84057276
[4,] 0.41934153 0.01848569 -0.27133710
[5,] -0.41590481 -0.12225009 0.19432951
[6,] 0.02325632 -1.32981727 0.70885348
As you can see the results are identical. | How to predict factor scores in Lavaan | This question has received a number of views since it was first posed, but no answers. Here is a solution, which may be useful to future readers of this question.
To demonstrate it works I will first | How to predict factor scores in Lavaan
This question has received a number of views since it was first posed, but no answers. Here is a solution, which may be useful to future readers of this question.
To demonstrate it works I will first run a cfa() model in using the HolzingerSwineford1939. The model is taken from the lavaan tutorial page.
library(lavaan)
dat<-data.frame(HolzingerSwineford1939[,7:15])
mod<-'
visual=~x1+x2+x3
textual=~x4+x5+x6
speed=~x7+x8+x9
'
fit<-cfa(mod, data = dat)
This returns the following solution:
> summary(fit)
lavaan (0.5-22) converged normally after 35 iterations
Number of observations 301
Estimator ML
Minimum Function Test Statistic 85.306
Degrees of freedom 24
P-value (Chi-square) 0.000
Parameter Estimates:
Information Expected
Standard Errors Standard
Latent Variables:
Estimate Std.Err z-value P(>|z|)
visual =~
x1 1.000
x2 0.554 0.100 5.554 0.000
x3 0.729 0.109 6.685 0.000
textual =~
x4 1.000
x5 1.113 0.065 17.014 0.000
x6 0.926 0.055 16.703 0.000
speed =~
x7 1.000
x8 1.180 0.165 7.152 0.000
x9 1.082 0.151 7.155 0.000
Covariances:
Estimate Std.Err z-value P(>|z|)
visual ~~
textual 0.408 0.074 5.552 0.000
speed 0.262 0.056 4.660 0.000
textual ~~
speed 0.173 0.049 3.518 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.x1 0.549 0.114 4.833 0.000
.x2 1.134 0.102 11.146 0.000
.x3 0.844 0.091 9.317 0.000
.x4 0.371 0.048 7.779 0.000
.x5 0.446 0.058 7.642 0.000
.x6 0.356 0.043 8.277 0.000
.x7 0.799 0.081 9.823 0.000
.x8 0.488 0.074 6.573 0.000
.x9 0.566 0.071 8.003 0.000
visual 0.809 0.145 5.564 0.000
textual 0.979 0.112 8.737 0.000
speed 0.384 0.086 4.451 0.000
When using raw data for input the lavPredict() and predict() return predicted values for the latent variables.
> head(lavPredict(fit))
visual textual speed
[1,] -0.81767524 -0.13754501 0.06150726
[2,] 0.04951940 -1.01272402 0.62549360
[3,] -0.76139670 -1.87228634 -0.84057276
[4,] 0.41934153 0.01848569 -0.27133710
[5,] -0.41590481 -0.12225009 0.19432951
[6,] 0.02325632 -1.32981727 0.70885348
Running the same model with the covariance matrix as input returns the same results, but as the original poster notes yields an error when attempting to derive the factor scores.
> COV<-cov(dat)
> fit1<-cfa(mod, sample.cov = COV, sample.nobs = 301, sample.mean = colMeans(dat))
> lavPredict(fit1)
Error in lavPredict(fit1) :
lavaan ERROR: sample statistics were used for fitting and newdata is empty
The solution is fairly straightforward as what the package needs is some raw data to "chew on" so to speak. Here you amend the code to identify the original dataset as raw data input for the prediction function (lavPredict(fit1, newdata = dat)). This returns the following (which remember is the same model fitted in lavaan but using the covariance matrix as input).
> head(lavPredict(fit1, newdata = dat))
visual textual speed
[1,] -0.81767524 -0.13754501 0.06150726
[2,] 0.04951940 -1.01272402 0.62549360
[3,] -0.76139670 -1.87228634 -0.84057276
[4,] 0.41934153 0.01848569 -0.27133710
[5,] -0.41590481 -0.12225009 0.19432951
[6,] 0.02325632 -1.32981727 0.70885348
As you can see the results are identical. | How to predict factor scores in Lavaan
This question has received a number of views since it was first posed, but no answers. Here is a solution, which may be useful to future readers of this question.
To demonstrate it works I will first |
26,086 | How to predict factor scores in Lavaan | A solution to this problem, can be to use the covariance matrix together with the mean and std devitation to create a simulation of the data. Then after testing that the simulated data follows your assumptions, you could run the analysis.
I have done this, to replicate papers that did not share their data.
I would do the following...
# Set your means and stddev
mu <- c(4.23, 3.01, 2.91)
stddev <- c(1.23, 0.92, 1.32)
Then get your correlation matrix and you will be able to get your covariance.
corMat <- matrix(c(1, 0.78, 0.23,
0.78, 1, 0.27,
0.23, 0.27, 1),
ncol = 3)
corMat
#Create the covariance matrix:
covMat <- stddev %*% t(stddev) * corMat
covMat
Now i will use MASS library to cast the mvrnorm function...
set.seed(1)
library(MASS)
dat1 <- mvrnorm(n = 1000, mu = mu, Sigma = covMat, empirical = FALSE)
Finally, you can use this to check if what you have done makes sense
colMeans(dat1)
cor(dat1)
If you are comfortable with this synthetic data, the next step will be to run your simulation.
I hope it helps someone!
Best,
J | How to predict factor scores in Lavaan | A solution to this problem, can be to use the covariance matrix together with the mean and std devitation to create a simulation of the data. Then after testing that the simulated data follows your as | How to predict factor scores in Lavaan
A solution to this problem, can be to use the covariance matrix together with the mean and std devitation to create a simulation of the data. Then after testing that the simulated data follows your assumptions, you could run the analysis.
I have done this, to replicate papers that did not share their data.
I would do the following...
# Set your means and stddev
mu <- c(4.23, 3.01, 2.91)
stddev <- c(1.23, 0.92, 1.32)
Then get your correlation matrix and you will be able to get your covariance.
corMat <- matrix(c(1, 0.78, 0.23,
0.78, 1, 0.27,
0.23, 0.27, 1),
ncol = 3)
corMat
#Create the covariance matrix:
covMat <- stddev %*% t(stddev) * corMat
covMat
Now i will use MASS library to cast the mvrnorm function...
set.seed(1)
library(MASS)
dat1 <- mvrnorm(n = 1000, mu = mu, Sigma = covMat, empirical = FALSE)
Finally, you can use this to check if what you have done makes sense
colMeans(dat1)
cor(dat1)
If you are comfortable with this synthetic data, the next step will be to run your simulation.
I hope it helps someone!
Best,
J | How to predict factor scores in Lavaan
A solution to this problem, can be to use the covariance matrix together with the mean and std devitation to create a simulation of the data. Then after testing that the simulated data follows your as |
26,087 | Cross entropy-equivalent loss suitable for real-valued labels | Cross entropy is defined on probability distributions, not single values. The reason it works for classification is that classifier output is (often) a probability distribution over class labels. For example, the outputs of logistic/softmax functions are interpreted as probabilities. The observed class label is also treated as a probability distribution: the empirical distribution (where the probability is 1 for the observed class and 0 for the others).
The concept of cross entropy applies equally well to continuous distributions. But, it can't be used for regression models that output a point estimate (e.g. the conditional mean) but not a full probability distribution. If you had a model that gave the full conditional distribution (probability of output given input), you could use cross entropy as a loss function.
For continuous distributions $p$ and $q$, the cross entropy is defined as:
$$H(p, q) = -\int_{Y} p(y) \log q(y) dy$$
Just considering a single observed input/output pair $(x, y)$, $p$ would be the empirical conditional distribution (a delta function over the observed output value), and $q$ would be the modeled conditional distribution (probability of output given input). In this case, the cross entropy reduces to $-\log q(y \mid x)$. Summing over data points, this is just the negative log likelihood! | Cross entropy-equivalent loss suitable for real-valued labels | Cross entropy is defined on probability distributions, not single values. The reason it works for classification is that classifier output is (often) a probability distribution over class labels. For | Cross entropy-equivalent loss suitable for real-valued labels
Cross entropy is defined on probability distributions, not single values. The reason it works for classification is that classifier output is (often) a probability distribution over class labels. For example, the outputs of logistic/softmax functions are interpreted as probabilities. The observed class label is also treated as a probability distribution: the empirical distribution (where the probability is 1 for the observed class and 0 for the others).
The concept of cross entropy applies equally well to continuous distributions. But, it can't be used for regression models that output a point estimate (e.g. the conditional mean) but not a full probability distribution. If you had a model that gave the full conditional distribution (probability of output given input), you could use cross entropy as a loss function.
For continuous distributions $p$ and $q$, the cross entropy is defined as:
$$H(p, q) = -\int_{Y} p(y) \log q(y) dy$$
Just considering a single observed input/output pair $(x, y)$, $p$ would be the empirical conditional distribution (a delta function over the observed output value), and $q$ would be the modeled conditional distribution (probability of output given input). In this case, the cross entropy reduces to $-\log q(y \mid x)$. Summing over data points, this is just the negative log likelihood! | Cross entropy-equivalent loss suitable for real-valued labels
Cross entropy is defined on probability distributions, not single values. The reason it works for classification is that classifier output is (often) a probability distribution over class labels. For |
26,088 | The difference between the Bayes Classifier and The Naive Bayes Classifier? | Naive Bayes assumes conditional independence,
$P(X|Y,Z)=P(X|Z)$, Whereas more general Bayes Nets (sometimes called Bayesian Belief Networks) will allow the user to specify which attributes are, in fact, conditionally independent.
There is a very good discussion of this in Tan, Kumar, Steinbach's Introduction to Data Mining textbook. They also have instructor powerpoint slides here
which should give an example of this assumption and why it can be flawed. | The difference between the Bayes Classifier and The Naive Bayes Classifier? | Naive Bayes assumes conditional independence,
$P(X|Y,Z)=P(X|Z)$, Whereas more general Bayes Nets (sometimes called Bayesian Belief Networks) will allow the user to specify which attributes are, in fa | The difference between the Bayes Classifier and The Naive Bayes Classifier?
Naive Bayes assumes conditional independence,
$P(X|Y,Z)=P(X|Z)$, Whereas more general Bayes Nets (sometimes called Bayesian Belief Networks) will allow the user to specify which attributes are, in fact, conditionally independent.
There is a very good discussion of this in Tan, Kumar, Steinbach's Introduction to Data Mining textbook. They also have instructor powerpoint slides here
which should give an example of this assumption and why it can be flawed. | The difference between the Bayes Classifier and The Naive Bayes Classifier?
Naive Bayes assumes conditional independence,
$P(X|Y,Z)=P(X|Z)$, Whereas more general Bayes Nets (sometimes called Bayesian Belief Networks) will allow the user to specify which attributes are, in fa |
26,089 | The difference between the Bayes Classifier and The Naive Bayes Classifier? | How would a "non-naive" Bayesian classification work?
Each record is classified as:
Find all records that have exactly the same features
Determine what class of those records is most common
Assign the most common class to the record
Problem: if there are many features, it is unlikely to find records that match exactly the same features.
Solution: Naive Bayes classifiers compute therefore the probabilities of each feature occurring in a class independently. | The difference between the Bayes Classifier and The Naive Bayes Classifier? | How would a "non-naive" Bayesian classification work?
Each record is classified as:
Find all records that have exactly the same features
Determine what class of those records is most common
Assign | The difference between the Bayes Classifier and The Naive Bayes Classifier?
How would a "non-naive" Bayesian classification work?
Each record is classified as:
Find all records that have exactly the same features
Determine what class of those records is most common
Assign the most common class to the record
Problem: if there are many features, it is unlikely to find records that match exactly the same features.
Solution: Naive Bayes classifiers compute therefore the probabilities of each feature occurring in a class independently. | The difference between the Bayes Classifier and The Naive Bayes Classifier?
How would a "non-naive" Bayesian classification work?
Each record is classified as:
Find all records that have exactly the same features
Determine what class of those records is most common
Assign |
26,090 | The difference between the Bayes Classifier and The Naive Bayes Classifier? | For the Bayesian network as a classifier, the features are selected based on some scoring functions like Bayesian scoring function and minimal description length(the two are equivalent in theory to each other given that there are enough training data). The scoring functions mainly restrict the structure (connections and directions) and the parameters(likelihood) using the data. After the structure has been learned the class is only determined by the nodes in the Markov blanket(its parents, its children, and the parents of its children), and all variables given the Markov blanket are discarded.
For the Naive Bayesian Network which is more well-known nowadays, all features are considered as attributes(all attributes are part of the class variable Markov blanket) and are independent given the class.
Bayesian networks and naive Bayesian network have their own advantages and disadvantages and we can see the performance comparison(done on 25 data sets mainly from the UCI repository) as depicted below:
We can see that there are some points below the diagonal line representing the Naive Bayes performs better than the Bayesian Network on those datasets and some points above the diagonal line representing the reverse on some other datasets.
Bayesian Network is more complicated than the Naive Bayes but they almost perform equally well, and the reason is that all the datasets on which the Bayesian network performs worse than the Naive Bayes have more than 15 attributes. That's during the structure learning some crucial attributes are discarded.
We can combine the two and add some connections between the features of the Naive Bayes and it becomes the tree augmented Naive Bayes or k-dependence Bayesian classifier.
References:
1. Bayesian Network Classifiers | The difference between the Bayes Classifier and The Naive Bayes Classifier? | For the Bayesian network as a classifier, the features are selected based on some scoring functions like Bayesian scoring function and minimal description length(the two are equivalent in theory to ea | The difference between the Bayes Classifier and The Naive Bayes Classifier?
For the Bayesian network as a classifier, the features are selected based on some scoring functions like Bayesian scoring function and minimal description length(the two are equivalent in theory to each other given that there are enough training data). The scoring functions mainly restrict the structure (connections and directions) and the parameters(likelihood) using the data. After the structure has been learned the class is only determined by the nodes in the Markov blanket(its parents, its children, and the parents of its children), and all variables given the Markov blanket are discarded.
For the Naive Bayesian Network which is more well-known nowadays, all features are considered as attributes(all attributes are part of the class variable Markov blanket) and are independent given the class.
Bayesian networks and naive Bayesian network have their own advantages and disadvantages and we can see the performance comparison(done on 25 data sets mainly from the UCI repository) as depicted below:
We can see that there are some points below the diagonal line representing the Naive Bayes performs better than the Bayesian Network on those datasets and some points above the diagonal line representing the reverse on some other datasets.
Bayesian Network is more complicated than the Naive Bayes but they almost perform equally well, and the reason is that all the datasets on which the Bayesian network performs worse than the Naive Bayes have more than 15 attributes. That's during the structure learning some crucial attributes are discarded.
We can combine the two and add some connections between the features of the Naive Bayes and it becomes the tree augmented Naive Bayes or k-dependence Bayesian classifier.
References:
1. Bayesian Network Classifiers | The difference between the Bayes Classifier and The Naive Bayes Classifier?
For the Bayesian network as a classifier, the features are selected based on some scoring functions like Bayesian scoring function and minimal description length(the two are equivalent in theory to ea |
26,091 | Variable coefficient rises, then falls as lambda decreases (LASSO) | It's not only possible, it's a very common occurrence.
Note that the penalty is $\ \lambda\,||\beta||_1$. So some components can increase in magnitude as long as others decrease, without increasing the norm overall. Sometimes as $\lambda$ increases, one (or a few) coefficient(s) may increase in size at the expense of others which together decrease at least as rapidly, because it helps keep down the rate of increase in the lack of fit term more than reducing them all together would.
You might like to plot what happens to $\sum_i |\beta_i|$ as $\log\lambda$ increases.
You'll often see this kind of behaviour when there's some correlation amongst the predictors - there can be a sort of substitution effect.
Note that in your top plot $|\beta_4|+|\beta_{11}|$ is pretty nearly always decreasing or fairly stable (the occasional small increase will be offset by decreases in the coefficients of still other variables) | Variable coefficient rises, then falls as lambda decreases (LASSO) | It's not only possible, it's a very common occurrence.
Note that the penalty is $\ \lambda\,||\beta||_1$. So some components can increase in magnitude as long as others decrease, without increasing th | Variable coefficient rises, then falls as lambda decreases (LASSO)
It's not only possible, it's a very common occurrence.
Note that the penalty is $\ \lambda\,||\beta||_1$. So some components can increase in magnitude as long as others decrease, without increasing the norm overall. Sometimes as $\lambda$ increases, one (or a few) coefficient(s) may increase in size at the expense of others which together decrease at least as rapidly, because it helps keep down the rate of increase in the lack of fit term more than reducing them all together would.
You might like to plot what happens to $\sum_i |\beta_i|$ as $\log\lambda$ increases.
You'll often see this kind of behaviour when there's some correlation amongst the predictors - there can be a sort of substitution effect.
Note that in your top plot $|\beta_4|+|\beta_{11}|$ is pretty nearly always decreasing or fairly stable (the occasional small increase will be offset by decreases in the coefficients of still other variables) | Variable coefficient rises, then falls as lambda decreases (LASSO)
It's not only possible, it's a very common occurrence.
Note that the penalty is $\ \lambda\,||\beta||_1$. So some components can increase in magnitude as long as others decrease, without increasing th |
26,092 | Good books for learning Applied Probability? | 1000 Exercices is the best book you can buy.
Why ?
Cover the full range of probability.
Provide exercice based of the probability: Put in practise because
there is a big gap between Theory books and real Proba problems.
Prepare you well for Quizz, and make your brain in good shape....
You can keep forever as a book of how to solve problems...
http://www.amazon.com/Thousand-Exercises-Probability-Geoffrey-Grimmett/dp/0198572212 | Good books for learning Applied Probability? | 1000 Exercices is the best book you can buy.
Why ?
Cover the full range of probability.
Provide exercice based of the probability: Put in practise because
there is a big gap between Theory books an | Good books for learning Applied Probability?
1000 Exercices is the best book you can buy.
Why ?
Cover the full range of probability.
Provide exercice based of the probability: Put in practise because
there is a big gap between Theory books and real Proba problems.
Prepare you well for Quizz, and make your brain in good shape....
You can keep forever as a book of how to solve problems...
http://www.amazon.com/Thousand-Exercises-Probability-Geoffrey-Grimmett/dp/0198572212 | Good books for learning Applied Probability?
1000 Exercices is the best book you can buy.
Why ?
Cover the full range of probability.
Provide exercice based of the probability: Put in practise because
there is a big gap between Theory books an |
26,093 | Good books for learning Applied Probability? | Frederick Mosteller's Fifty Challenging Problems in Probability sounds made to order for you. Check out the comments on Amazon about it...
http://www.amazon.com/Challenging-Problems-Probability-Solutions-Mathematics/dp/0486653552/ref=sr_1_1?ie=UTF8&qid=1459445736&sr=8-1&keywords=frederick+mosteller | Good books for learning Applied Probability? | Frederick Mosteller's Fifty Challenging Problems in Probability sounds made to order for you. Check out the comments on Amazon about it...
http://www.amazon.com/Challenging-Problems-Probability-Soluti | Good books for learning Applied Probability?
Frederick Mosteller's Fifty Challenging Problems in Probability sounds made to order for you. Check out the comments on Amazon about it...
http://www.amazon.com/Challenging-Problems-Probability-Solutions-Mathematics/dp/0486653552/ref=sr_1_1?ie=UTF8&qid=1459445736&sr=8-1&keywords=frederick+mosteller | Good books for learning Applied Probability?
Frederick Mosteller's Fifty Challenging Problems in Probability sounds made to order for you. Check out the comments on Amazon about it...
http://www.amazon.com/Challenging-Problems-Probability-Soluti |
26,094 | Good books for learning Applied Probability? | Applied Probability by Kenneth Lange
Huge breadth of applied probability topics, with a few chapters on computational probability.
Tons of examples (albeit sometimes too concise)
Very good balance between theory and applications.
HUGE collection of good problems, difficulty range from mildly trivial to pretty challenging. I particularly like his problems because most of them are very difficult to do, until you see how to do it and the proof becomes less than 1/3 of a page.
I used this book for a stochastic process class, and it remains one of my all time favorite books.
"Theory divorced from applications runs the risk of alienating many potential practitioners of the art of stochastic modeling. Applications without a clear statement of relevant theory drift in a sea of confusion."
https://www.amazon.com/Applied-Probability-Springer-Texts-Statistics/dp/1441971645/ref=sr_1_1?ie=UTF8&qid=1509045816&sr=8-1&keywords=applied+probability+lange | Good books for learning Applied Probability? | Applied Probability by Kenneth Lange
Huge breadth of applied probability topics, with a few chapters on computational probability.
Tons of examples (albeit sometimes too concise)
Very good balance b | Good books for learning Applied Probability?
Applied Probability by Kenneth Lange
Huge breadth of applied probability topics, with a few chapters on computational probability.
Tons of examples (albeit sometimes too concise)
Very good balance between theory and applications.
HUGE collection of good problems, difficulty range from mildly trivial to pretty challenging. I particularly like his problems because most of them are very difficult to do, until you see how to do it and the proof becomes less than 1/3 of a page.
I used this book for a stochastic process class, and it remains one of my all time favorite books.
"Theory divorced from applications runs the risk of alienating many potential practitioners of the art of stochastic modeling. Applications without a clear statement of relevant theory drift in a sea of confusion."
https://www.amazon.com/Applied-Probability-Springer-Texts-Statistics/dp/1441971645/ref=sr_1_1?ie=UTF8&qid=1509045816&sr=8-1&keywords=applied+probability+lange | Good books for learning Applied Probability?
Applied Probability by Kenneth Lange
Huge breadth of applied probability topics, with a few chapters on computational probability.
Tons of examples (albeit sometimes too concise)
Very good balance b |
26,095 | Number of Markov chain Monte Carlo Samples | How many samples (post burn-in) that you need depends on what you are trying to do with those samples and how your chain mixes.
Typically we are interested in posterior expectations (or quantiles) and we approximate these expectations by averages of our posterior samples, i.e.
$$
E[h(\theta)|y] \approx \frac{1}{M} \sum_{m=1}^M h(\theta^{(m)}) = E_M
$$
where $\theta^{(m)}$ are samples from your MCMC. By the Law of Large Numbers the MCMC estimate converges almost surely to the desired expectation.
But to address the question of how many samples we need to be assured that we are close enough to the desired expectation, we need a Central Limit Theorem (CLT) result, i.e. something like
$$
\frac{E_M -E[h(\theta)|y]}{\sqrt{M}} \stackrel{d}{\to} N(0,v_h^2)
$$
With this CLT we could then make probabilitic statements such as "there is 95% probability that $E[h(\theta)|y]$ is between $E_M \pm 1.96 v_h$."
The two issues here are
Does the CLT apply?
How can we estimate $v_h^2$.
We have some results on when the CLT applies, e.g. discete state chains, reversible chains, geometrically ergodic chains. See Robert and Casella (2nd ed) section 6.7.2 for some results in this direction. Unfortunately the vast majority of Markov chains that are out there have no proof that CLT exists.
If a CLT does exist, we still need to estimate the variance in the CLT. One way to estimate this variance involves breaking the chain up into blocks, see Gong and Flegal and references therein. The method has been implemented in the R package mcmcse with the functions mcse and mcse.q to estimate the variance for expectations and quantiles. | Number of Markov chain Monte Carlo Samples | How many samples (post burn-in) that you need depends on what you are trying to do with those samples and how your chain mixes.
Typically we are interested in posterior expectations (or quantiles) an | Number of Markov chain Monte Carlo Samples
How many samples (post burn-in) that you need depends on what you are trying to do with those samples and how your chain mixes.
Typically we are interested in posterior expectations (or quantiles) and we approximate these expectations by averages of our posterior samples, i.e.
$$
E[h(\theta)|y] \approx \frac{1}{M} \sum_{m=1}^M h(\theta^{(m)}) = E_M
$$
where $\theta^{(m)}$ are samples from your MCMC. By the Law of Large Numbers the MCMC estimate converges almost surely to the desired expectation.
But to address the question of how many samples we need to be assured that we are close enough to the desired expectation, we need a Central Limit Theorem (CLT) result, i.e. something like
$$
\frac{E_M -E[h(\theta)|y]}{\sqrt{M}} \stackrel{d}{\to} N(0,v_h^2)
$$
With this CLT we could then make probabilitic statements such as "there is 95% probability that $E[h(\theta)|y]$ is between $E_M \pm 1.96 v_h$."
The two issues here are
Does the CLT apply?
How can we estimate $v_h^2$.
We have some results on when the CLT applies, e.g. discete state chains, reversible chains, geometrically ergodic chains. See Robert and Casella (2nd ed) section 6.7.2 for some results in this direction. Unfortunately the vast majority of Markov chains that are out there have no proof that CLT exists.
If a CLT does exist, we still need to estimate the variance in the CLT. One way to estimate this variance involves breaking the chain up into blocks, see Gong and Flegal and references therein. The method has been implemented in the R package mcmcse with the functions mcse and mcse.q to estimate the variance for expectations and quantiles. | Number of Markov chain Monte Carlo Samples
How many samples (post burn-in) that you need depends on what you are trying to do with those samples and how your chain mixes.
Typically we are interested in posterior expectations (or quantiles) an |
26,096 | Number of Markov chain Monte Carlo Samples | John Kruschke in Doing Bayesian Data Analysis recommends that for parameters of interest, MCMC chains should be run until their effective sample size is at least 10,000. Although no simulations are presented, I believe his rationale is that ESS > 10,000 ensures numerically stable estimates. However, I have seen that Andrew Gelman and other Stan developers recommend less (e.g. 2000 - 3000 is fine; no exact link, unfortunately, but see discussions on the Stan Google users group). Moreover, for complex models, running chains long enough for an ESS > 10,000 can be arduous! | Number of Markov chain Monte Carlo Samples | John Kruschke in Doing Bayesian Data Analysis recommends that for parameters of interest, MCMC chains should be run until their effective sample size is at least 10,000. Although no simulations are pr | Number of Markov chain Monte Carlo Samples
John Kruschke in Doing Bayesian Data Analysis recommends that for parameters of interest, MCMC chains should be run until their effective sample size is at least 10,000. Although no simulations are presented, I believe his rationale is that ESS > 10,000 ensures numerically stable estimates. However, I have seen that Andrew Gelman and other Stan developers recommend less (e.g. 2000 - 3000 is fine; no exact link, unfortunately, but see discussions on the Stan Google users group). Moreover, for complex models, running chains long enough for an ESS > 10,000 can be arduous! | Number of Markov chain Monte Carlo Samples
John Kruschke in Doing Bayesian Data Analysis recommends that for parameters of interest, MCMC chains should be run until their effective sample size is at least 10,000. Although no simulations are pr |
26,097 | Number of Markov chain Monte Carlo Samples | This is indeed one of the big downsides of MCMC simulations, since there is no general and apriori estimate on the number of samples. I think a good literature here is "Some things we've learned (about MCMC)" by Persi Diaconis which deals with a lot of subtleties of MCMC simulations which might indicates that there is no easy answer to this question.
In general, making good estimates on how long to run the chain requires a good understanding of the mixing time of the Markov chain, which heavily depends on properties of the underlying graph. There are many "burn-in-free"-methods out there to bound the mixing time from above, but all of these methods have in common that they need a deeper understanding of the underlying Markov chain and the involved constants are typically hard to compute. See for example "Conductance and Rapidly Mixing Markov Chains" by King, "Path Coupling: a Technique for Proving Rapid Mixing in Markov Chains" by Bubley et al., or "Nash inequalities for finite Markov chains" by Diaconis et al. | Number of Markov chain Monte Carlo Samples | This is indeed one of the big downsides of MCMC simulations, since there is no general and apriori estimate on the number of samples. I think a good literature here is "Some things we've learned (abou | Number of Markov chain Monte Carlo Samples
This is indeed one of the big downsides of MCMC simulations, since there is no general and apriori estimate on the number of samples. I think a good literature here is "Some things we've learned (about MCMC)" by Persi Diaconis which deals with a lot of subtleties of MCMC simulations which might indicates that there is no easy answer to this question.
In general, making good estimates on how long to run the chain requires a good understanding of the mixing time of the Markov chain, which heavily depends on properties of the underlying graph. There are many "burn-in-free"-methods out there to bound the mixing time from above, but all of these methods have in common that they need a deeper understanding of the underlying Markov chain and the involved constants are typically hard to compute. See for example "Conductance and Rapidly Mixing Markov Chains" by King, "Path Coupling: a Technique for Proving Rapid Mixing in Markov Chains" by Bubley et al., or "Nash inequalities for finite Markov chains" by Diaconis et al. | Number of Markov chain Monte Carlo Samples
This is indeed one of the big downsides of MCMC simulations, since there is no general and apriori estimate on the number of samples. I think a good literature here is "Some things we've learned (abou |
26,098 | What's rollout policy in AlphaGo's paper? | It appears that the policy network determines a probability distribution $p(a \mid s)$ over the possible moves $a$ when in game state $s$. When the program is searching the game tree it does so in a random fashion, and $p$ determines how it does this search. The hope is that this function will "guide" the program to good moves that a strong player is likely to make. This makes sense because when you search the game tree the branches that begin with mistakes are less relevant when evaluating the current board position against an intelligent opponent.
When they say that the rollout policy (I believe they borrowed the term "rollout" from backgammon) is a linear softmax function they're referring to a generalization of the sigmoid function used in logistic regression. This function takes the form
$$
\frac{e^{\beta^T_i x}}{\sum_{j=1}^{k} e^{\beta_j^T x}}
$$
where $x$ is a vector that is a function of the current board position (according to the paper the linear softmax is only used at the last step of the policy network) and $\beta_i$ is a vector of weights which together determine the probability that the policy network will choose action $a_i$. | What's rollout policy in AlphaGo's paper? | It appears that the policy network determines a probability distribution $p(a \mid s)$ over the possible moves $a$ when in game state $s$. When the program is searching the game tree it does so in a | What's rollout policy in AlphaGo's paper?
It appears that the policy network determines a probability distribution $p(a \mid s)$ over the possible moves $a$ when in game state $s$. When the program is searching the game tree it does so in a random fashion, and $p$ determines how it does this search. The hope is that this function will "guide" the program to good moves that a strong player is likely to make. This makes sense because when you search the game tree the branches that begin with mistakes are less relevant when evaluating the current board position against an intelligent opponent.
When they say that the rollout policy (I believe they borrowed the term "rollout" from backgammon) is a linear softmax function they're referring to a generalization of the sigmoid function used in logistic regression. This function takes the form
$$
\frac{e^{\beta^T_i x}}{\sum_{j=1}^{k} e^{\beta_j^T x}}
$$
where $x$ is a vector that is a function of the current board position (according to the paper the linear softmax is only used at the last step of the policy network) and $\beta_i$ is a vector of weights which together determine the probability that the policy network will choose action $a_i$. | What's rollout policy in AlphaGo's paper?
It appears that the policy network determines a probability distribution $p(a \mid s)$ over the possible moves $a$ when in game state $s$. When the program is searching the game tree it does so in a |
26,099 | "Good" classifier destroyed my Precision-Recall curve. What happened? | I've found that there isn't an incredible benefit in using downsampling/upsampling when classes are moderately imbalanced (i.e., no worse than 100:1) in conjunction with a threshold invariant metric (like AUC). Sampling makes the biggest impact for metrics like F1-score and Accuracy, because the sampling artificially moves the threshold to be closer to what might be considered as the "optimal" location on an ROC curve. You can see an example of this in the caret documentation.
I would disagree with @Chris in that having a good AUC is better than precision, as it totally relates to the context of the problem. Additionally, having a good AUC doesn't necessarily translate to a good Precision-Recall curve when the classes are imbalanced. If a model shows good AUC, but still has poor early retrieval, the Precision-Recall curve will leave a lot to be desired. You can see a great example of this happening in this answer to a similar question. For this reason, Saito et al. recommend using area under the Precision-Recall curve rather than AUC when you have imbalanced classes. | "Good" classifier destroyed my Precision-Recall curve. What happened? | I've found that there isn't an incredible benefit in using downsampling/upsampling when classes are moderately imbalanced (i.e., no worse than 100:1) in conjunction with a threshold invariant metric ( | "Good" classifier destroyed my Precision-Recall curve. What happened?
I've found that there isn't an incredible benefit in using downsampling/upsampling when classes are moderately imbalanced (i.e., no worse than 100:1) in conjunction with a threshold invariant metric (like AUC). Sampling makes the biggest impact for metrics like F1-score and Accuracy, because the sampling artificially moves the threshold to be closer to what might be considered as the "optimal" location on an ROC curve. You can see an example of this in the caret documentation.
I would disagree with @Chris in that having a good AUC is better than precision, as it totally relates to the context of the problem. Additionally, having a good AUC doesn't necessarily translate to a good Precision-Recall curve when the classes are imbalanced. If a model shows good AUC, but still has poor early retrieval, the Precision-Recall curve will leave a lot to be desired. You can see a great example of this happening in this answer to a similar question. For this reason, Saito et al. recommend using area under the Precision-Recall curve rather than AUC when you have imbalanced classes. | "Good" classifier destroyed my Precision-Recall curve. What happened?
I've found that there isn't an incredible benefit in using downsampling/upsampling when classes are moderately imbalanced (i.e., no worse than 100:1) in conjunction with a threshold invariant metric ( |
26,100 | "Good" classifier destroyed my Precision-Recall curve. What happened? | I could understand this as a class imbalance problem, since PR curves
are sensitive to imbalance and ROC curves aren't. However, the
imbalance doesn't seem to affect the individual features: I can get
pretty high precision using the individual features (blue and cyan).
May I just point out that this is actually the other way around: ROC is sensitive to class imbalance while PR is more robust when dealing with skewed class distributions. See https://www.biostat.wisc.edu/~page/rocpr.pdf.
They also show that "algorithms that optimize the area under the ROC curve are not
guaranteed to optimize the area under the PR curve." | "Good" classifier destroyed my Precision-Recall curve. What happened? | I could understand this as a class imbalance problem, since PR curves
are sensitive to imbalance and ROC curves aren't. However, the
imbalance doesn't seem to affect the individual features: I can | "Good" classifier destroyed my Precision-Recall curve. What happened?
I could understand this as a class imbalance problem, since PR curves
are sensitive to imbalance and ROC curves aren't. However, the
imbalance doesn't seem to affect the individual features: I can get
pretty high precision using the individual features (blue and cyan).
May I just point out that this is actually the other way around: ROC is sensitive to class imbalance while PR is more robust when dealing with skewed class distributions. See https://www.biostat.wisc.edu/~page/rocpr.pdf.
They also show that "algorithms that optimize the area under the ROC curve are not
guaranteed to optimize the area under the PR curve." | "Good" classifier destroyed my Precision-Recall curve. What happened?
I could understand this as a class imbalance problem, since PR curves
are sensitive to imbalance and ROC curves aren't. However, the
imbalance doesn't seem to affect the individual features: I can |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.