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
47,601
In feature selection, what is the reason for considering removing low variance features?
Imagine the limiting case in which you have a feature $x$ which is constant (no variance) will it have an effect on the output $y$? If $y$ is changing, then $x$ should be irrelevant in the relationship because it is constant. This is the reason, why people tend to discard variables with low variance. The problem is that there is no rigorous method to determine if a feature has a "low" variance. Comparison with other features is often difficulty because they might have different scales (eg. if you compare the variance of the length of screws with the variance of weights of ships than you will have different scales). A $z$-transform will impose same scale and directly normalize the variance. Hence, $z$-transforms (mean = 0, variance = 1 for all variables) don't really help at this comparison. One way to investigate this problem would be to look at the distribution of values. If you see a variable that has a very sharp spike (almost only one value is present) then you might consider discarding it. To be quite honest I seldomly saw a feature in practice that had such a pathological distribution (no one would invest time and money to measure something that is constant all the time). These zero variance variables are often meta informations that were added because they were easy to gather. Hence, in my opinion, this condition is only used to rule out such pathological cases, where the variance is $0$. In all other cases, you must further investigate the variable.
In feature selection, what is the reason for considering removing low variance features?
Imagine the limiting case in which you have a feature $x$ which is constant (no variance) will it have an effect on the output $y$? If $y$ is changing, then $x$ should be irrelevant in the relationshi
In feature selection, what is the reason for considering removing low variance features? Imagine the limiting case in which you have a feature $x$ which is constant (no variance) will it have an effect on the output $y$? If $y$ is changing, then $x$ should be irrelevant in the relationship because it is constant. This is the reason, why people tend to discard variables with low variance. The problem is that there is no rigorous method to determine if a feature has a "low" variance. Comparison with other features is often difficulty because they might have different scales (eg. if you compare the variance of the length of screws with the variance of weights of ships than you will have different scales). A $z$-transform will impose same scale and directly normalize the variance. Hence, $z$-transforms (mean = 0, variance = 1 for all variables) don't really help at this comparison. One way to investigate this problem would be to look at the distribution of values. If you see a variable that has a very sharp spike (almost only one value is present) then you might consider discarding it. To be quite honest I seldomly saw a feature in practice that had such a pathological distribution (no one would invest time and money to measure something that is constant all the time). These zero variance variables are often meta informations that were added because they were easy to gather. Hence, in my opinion, this condition is only used to rule out such pathological cases, where the variance is $0$. In all other cases, you must further investigate the variable.
In feature selection, what is the reason for considering removing low variance features? Imagine the limiting case in which you have a feature $x$ which is constant (no variance) will it have an effect on the output $y$? If $y$ is changing, then $x$ should be irrelevant in the relationshi
47,602
In feature selection, what is the reason for considering removing low variance features?
Your guess is why I do it. If they have low variance, they likely won't improve your model anyway, so it's safe to remove them. For example, in MNIST, pixels that almost always background. Or some questionnaire items that are nearly always false and so on. Of course, 'variance' is not a good measure for any modality, and it might not be comparable between features. Another reason is that low/no variance features sometimes make algorithms crash or fail to converge without any meaningful error message. When this happens, my first instinct is to remove invariant features and try again. Lastly, it can reduce the dimensionality of your problem and make your model fit faster with less memory consumption.
In feature selection, what is the reason for considering removing low variance features?
Your guess is why I do it. If they have low variance, they likely won't improve your model anyway, so it's safe to remove them. For example, in MNIST, pixels that almost always background. Or some que
In feature selection, what is the reason for considering removing low variance features? Your guess is why I do it. If they have low variance, they likely won't improve your model anyway, so it's safe to remove them. For example, in MNIST, pixels that almost always background. Or some questionnaire items that are nearly always false and so on. Of course, 'variance' is not a good measure for any modality, and it might not be comparable between features. Another reason is that low/no variance features sometimes make algorithms crash or fail to converge without any meaningful error message. When this happens, my first instinct is to remove invariant features and try again. Lastly, it can reduce the dimensionality of your problem and make your model fit faster with less memory consumption.
In feature selection, what is the reason for considering removing low variance features? Your guess is why I do it. If they have low variance, they likely won't improve your model anyway, so it's safe to remove them. For example, in MNIST, pixels that almost always background. Or some que
47,603
Difference between manifest and observed variables
I agree that this is confusing. Manifest variables and "observed" variables are both observed, in the sense that they are part of the input dataset, and not latent variables. The distinction made in the semopy package is that manifest variables are part of the measurement model (ie the definition of the latent variables), whereas "observed" variables are part of the structural model (the relations between and among the latent variables and the "observed" variables) From your description, you will define some latent variables as your measurement model, using the features as manifest variables. You won't have "observed" variables unless you have features that are part of the structural model.
Difference between manifest and observed variables
I agree that this is confusing. Manifest variables and "observed" variables are both observed, in the sense that they are part of the input dataset, and not latent variables. The distinction made in t
Difference between manifest and observed variables I agree that this is confusing. Manifest variables and "observed" variables are both observed, in the sense that they are part of the input dataset, and not latent variables. The distinction made in the semopy package is that manifest variables are part of the measurement model (ie the definition of the latent variables), whereas "observed" variables are part of the structural model (the relations between and among the latent variables and the "observed" variables) From your description, you will define some latent variables as your measurement model, using the features as manifest variables. You won't have "observed" variables unless you have features that are part of the structural model.
Difference between manifest and observed variables I agree that this is confusing. Manifest variables and "observed" variables are both observed, in the sense that they are part of the input dataset, and not latent variables. The distinction made in t
47,604
Expectation of sum of absolute values for correlated normal random variables
Expectation operator distributes over the sum, so correlation amongst $y_i$ is not important in the calculation: $$\mathbb E\left[\sum_{i=1}^N|y_i|\right]=N\mathbb E[|y_1|]$$ $y_1\sim\mathcal N(0, \sigma_y^2)$ where $\sigma_y^2=\sigma_x^2+\gamma^2\sigma_z^2$. You can calculate the expected value using the mean entry of Folded Normal distribution by letting $\mu=0, \sigma^2=\sigma_y^2$. You can choose to calculate it by yourself as well, since the integral will be trivial.
Expectation of sum of absolute values for correlated normal random variables
Expectation operator distributes over the sum, so correlation amongst $y_i$ is not important in the calculation: $$\mathbb E\left[\sum_{i=1}^N|y_i|\right]=N\mathbb E[|y_1|]$$ $y_1\sim\mathcal N(0, \si
Expectation of sum of absolute values for correlated normal random variables Expectation operator distributes over the sum, so correlation amongst $y_i$ is not important in the calculation: $$\mathbb E\left[\sum_{i=1}^N|y_i|\right]=N\mathbb E[|y_1|]$$ $y_1\sim\mathcal N(0, \sigma_y^2)$ where $\sigma_y^2=\sigma_x^2+\gamma^2\sigma_z^2$. You can calculate the expected value using the mean entry of Folded Normal distribution by letting $\mu=0, \sigma^2=\sigma_y^2$. You can choose to calculate it by yourself as well, since the integral will be trivial.
Expectation of sum of absolute values for correlated normal random variables Expectation operator distributes over the sum, so correlation amongst $y_i$ is not important in the calculation: $$\mathbb E\left[\sum_{i=1}^N|y_i|\right]=N\mathbb E[|y_1|]$$ $y_1\sim\mathcal N(0, \si
47,605
Interview question: How to measure performance of linear regression?
The question is rather broad, though I guess that is the intention with an interview question :) How to measure performance of linear regression? You question then goes on to talk about training and test sets, and of course this could be part of the answer, however I would back up a bit and suggest that performance should really be in terms of whatever question the model was built to answer. If asked this question in a real world setting by someone who had fitted a model and came to me for advice, the first thing I would ask is: What question is the model trying to answer ? In any applied setting be it traditional statistical analysis, "modern" data science, or whatever, context is vitally important. As a large part of this I would want to know if the model is going to be used for inference or prediction. With inference, there is almost always a underlying causal question: For example, does wearing seatbelts cause road traffic accident casualties to decrease? Does smoking reduce poor outcomes in those who test positive for COVID-19? In such cases one of the most important aspects of a linear regression is variable selection. It is important not to condition on mediators, or to over-adjust for confounders, but the inclusion of competing exposures is helpful. If there are several questions, as is often the case in data science settings, such as "which of these variables are most important for understanding the outcome" - the usual (mistaken) approach is some stepwise procedure based on p-values, AIC, BIC etc. This is a terrible idea because it completely overlooks the causal relationships and is based on arbitrary thresholds (even with AIC/BIC this really boils down to p-value thresholds). The key point is that, for each variable of interest, a different model is usually needed, because, for example, a variable that is a confounder for one association, will be a mediator for another, and should be excluded in the former and included in the latter. It should be obvious to anyone who reads published papers that this is the "Table 2 Fallacy" where researchers simply put everything in multivariable linear regression models and report all the estimates and p-values! Once we are happy with the set of variables we would want to look at the usual diagnostics to assess whether the assumption of linearity holds. Other assumptions such as observation independence and variance homogeneity might also be considered. Then we might want to think about prediction. People often think that prediction and inference are two separate things, and they are, but the problem is that many people who think they are only interested in prediction are actually interested in inference as well. For instance, right now there are teams of data scientists and machine learning practitioners busy trying to apply their methods to COVID-19 datasets (I was one of them until quite recently), and for the most part all the discussion was around prediction. Yet, after you build a model and find that (and I am making this up for confidentiality reasons) vaping is strongly predictive of better outcome in those aged under 35 who test positive for COVID-19, there ALWAYS follows questions from clinicians about interpreting model output as a causal effect - either with a view to promoting some kind of intervention, or to explain an "apparent paradox". But the regression models were not built with causal inference in mind. This type of thing is happening all the time, and it is utterly bonkers. If there is genuinely no interest in inference then the "blind" methods of train, test, (cross) validate can of course be used and things like MSE are of course good metrics. However, if there is some element of causality involved then it is important to consider the issues I described above.
Interview question: How to measure performance of linear regression?
The question is rather broad, though I guess that is the intention with an interview question :) How to measure performance of linear regression? You question then goes on to talk about training and
Interview question: How to measure performance of linear regression? The question is rather broad, though I guess that is the intention with an interview question :) How to measure performance of linear regression? You question then goes on to talk about training and test sets, and of course this could be part of the answer, however I would back up a bit and suggest that performance should really be in terms of whatever question the model was built to answer. If asked this question in a real world setting by someone who had fitted a model and came to me for advice, the first thing I would ask is: What question is the model trying to answer ? In any applied setting be it traditional statistical analysis, "modern" data science, or whatever, context is vitally important. As a large part of this I would want to know if the model is going to be used for inference or prediction. With inference, there is almost always a underlying causal question: For example, does wearing seatbelts cause road traffic accident casualties to decrease? Does smoking reduce poor outcomes in those who test positive for COVID-19? In such cases one of the most important aspects of a linear regression is variable selection. It is important not to condition on mediators, or to over-adjust for confounders, but the inclusion of competing exposures is helpful. If there are several questions, as is often the case in data science settings, such as "which of these variables are most important for understanding the outcome" - the usual (mistaken) approach is some stepwise procedure based on p-values, AIC, BIC etc. This is a terrible idea because it completely overlooks the causal relationships and is based on arbitrary thresholds (even with AIC/BIC this really boils down to p-value thresholds). The key point is that, for each variable of interest, a different model is usually needed, because, for example, a variable that is a confounder for one association, will be a mediator for another, and should be excluded in the former and included in the latter. It should be obvious to anyone who reads published papers that this is the "Table 2 Fallacy" where researchers simply put everything in multivariable linear regression models and report all the estimates and p-values! Once we are happy with the set of variables we would want to look at the usual diagnostics to assess whether the assumption of linearity holds. Other assumptions such as observation independence and variance homogeneity might also be considered. Then we might want to think about prediction. People often think that prediction and inference are two separate things, and they are, but the problem is that many people who think they are only interested in prediction are actually interested in inference as well. For instance, right now there are teams of data scientists and machine learning practitioners busy trying to apply their methods to COVID-19 datasets (I was one of them until quite recently), and for the most part all the discussion was around prediction. Yet, after you build a model and find that (and I am making this up for confidentiality reasons) vaping is strongly predictive of better outcome in those aged under 35 who test positive for COVID-19, there ALWAYS follows questions from clinicians about interpreting model output as a causal effect - either with a view to promoting some kind of intervention, or to explain an "apparent paradox". But the regression models were not built with causal inference in mind. This type of thing is happening all the time, and it is utterly bonkers. If there is genuinely no interest in inference then the "blind" methods of train, test, (cross) validate can of course be used and things like MSE are of course good metrics. However, if there is some element of causality involved then it is important to consider the issues I described above.
Interview question: How to measure performance of linear regression? The question is rather broad, though I guess that is the intention with an interview question :) How to measure performance of linear regression? You question then goes on to talk about training and
47,606
Looking for book recommendations for numerical optimization
Another two books similar to Nocedal & Wright are Numerical Optimization, by Bonnans et al. Optimization Theory and Methods, by Sun & Yuan But since you're looking for optimization methods applicable in data science and machine learning, keep in mind that the sheer size of models in this field usually requires stochastic versions of algorithms discussed in these books (generally some version of stochastic gradient descent). This field is still in flux, and new algorithms seem to be developed every other month, so there aren't any comprehensive textbooks available at the moment (at least to my knowledge). The closest thing I could think of would be this review article by Ruder.
Looking for book recommendations for numerical optimization
Another two books similar to Nocedal & Wright are Numerical Optimization, by Bonnans et al. Optimization Theory and Methods, by Sun & Yuan But since you're looking for optimization methods applicabl
Looking for book recommendations for numerical optimization Another two books similar to Nocedal & Wright are Numerical Optimization, by Bonnans et al. Optimization Theory and Methods, by Sun & Yuan But since you're looking for optimization methods applicable in data science and machine learning, keep in mind that the sheer size of models in this field usually requires stochastic versions of algorithms discussed in these books (generally some version of stochastic gradient descent). This field is still in flux, and new algorithms seem to be developed every other month, so there aren't any comprehensive textbooks available at the moment (at least to my knowledge). The closest thing I could think of would be this review article by Ruder.
Looking for book recommendations for numerical optimization Another two books similar to Nocedal & Wright are Numerical Optimization, by Bonnans et al. Optimization Theory and Methods, by Sun & Yuan But since you're looking for optimization methods applicabl
47,607
Looking for book recommendations for numerical optimization
Aside Nocedal & Wright (2006), as books of a similar level, I have found: "Iterative methods in Optimisation" by Kelley (1999) and "Optimization" by Lange (2013). Both books are equally easy to follow too with N&W and cover standard numerical optimisation topics (KKT Theory, Newton's Method, Quasi-Newton, etc.) nicely. Kelley's book is free to download too.
Looking for book recommendations for numerical optimization
Aside Nocedal & Wright (2006), as books of a similar level, I have found: "Iterative methods in Optimisation" by Kelley (1999) and "Optimization" by Lange (2013). Both books are equally easy to foll
Looking for book recommendations for numerical optimization Aside Nocedal & Wright (2006), as books of a similar level, I have found: "Iterative methods in Optimisation" by Kelley (1999) and "Optimization" by Lange (2013). Both books are equally easy to follow too with N&W and cover standard numerical optimisation topics (KKT Theory, Newton's Method, Quasi-Newton, etc.) nicely. Kelley's book is free to download too.
Looking for book recommendations for numerical optimization Aside Nocedal & Wright (2006), as books of a similar level, I have found: "Iterative methods in Optimisation" by Kelley (1999) and "Optimization" by Lange (2013). Both books are equally easy to foll
47,608
Looking for book recommendations for numerical optimization
It's great that you shared your books. Thanks a lot for it! I really like Numerical Optimization (Springer Series in Operations Research and Financial Engineering), which you already mentioned, but I would still recommend Numerical Recipes 3rd Edition: The Art of Scientific Computing to study. I also recommend reading other educational resources, for example, you can find on eduzaurus many short articles on the key "Numerical". I think you will find a lot of useful information there.
Looking for book recommendations for numerical optimization
It's great that you shared your books. Thanks a lot for it! I really like Numerical Optimization (Springer Series in Operations Research and Financial Engineering), which you already mentioned, but I
Looking for book recommendations for numerical optimization It's great that you shared your books. Thanks a lot for it! I really like Numerical Optimization (Springer Series in Operations Research and Financial Engineering), which you already mentioned, but I would still recommend Numerical Recipes 3rd Edition: The Art of Scientific Computing to study. I also recommend reading other educational resources, for example, you can find on eduzaurus many short articles on the key "Numerical". I think you will find a lot of useful information there.
Looking for book recommendations for numerical optimization It's great that you shared your books. Thanks a lot for it! I really like Numerical Optimization (Springer Series in Operations Research and Financial Engineering), which you already mentioned, but I
47,609
Is the average of n independent Laplace random variables a Gaussian distribution?
TL;DR You cannot use either the Lyapunov or the Lindeberg CLT to say anything about the convergence in distribution of $\frac{1}{s_n}\sum_{i=1}^n X_i$ (where $s_n^2=\sum_{i=1}^n\sigma_i^2$) without additional conditions on the sequence of variances $(\sigma_i^2)$. Neither CLT would say anything about $\frac{1}{n}\sum_{i=1}^n X_i$. If the sequence of variances $(\sigma_i^2)$ grows fast enough, I strongly doubt that this average converges to anything reasonable. Assume that $X_i\sim\text{Laplace}(0,b_i)$ for a parameter $b_i>0$. Then $\sigma_i^2=2b_i^2$. As above, let $$ s_n^2=\sum_{i=1}^n\sigma_i^2=2\sum_{i=1}^n b_i^2.$$ The key property we need is that $|X_i|\sim\text{Exp}\big(\frac{1}{b_i}\big)$. This allows us to easily calculate the expectations we need in the Lyapunov or Lindeberg CLTs. The condition for the Lyapunov CLT is that there is some $\delta>0$ such that $$\lim_{n\to\infty}\frac{1}{s_n^{2+\delta}} \sum_{i=1}^nE\big(|X_i|^{2+\delta}\big) =0. $$ We have $$ E\big(|X_i|^{2+\delta}\big) = b_i^{2+\delta}\Gamma(\delta+3), $$ so $$ \frac{1}{s_n^{2+\delta}} \sum_{i=1}^nE\big(|X_i|^{2+\delta}\big) = \frac{\sum_{i=1}^n b_i^{2+\delta}\Gamma(\delta+3)}{\big(\sum_{i=1}^n 2b_i^2\big)^\frac{2+\delta}{2}} = \frac{\Gamma(\delta+3)}{2^\frac{2+\delta}{2}}\frac{\sum_{i=1}^n b_i^{2+\delta}}{\big(\sum_{i=1}^n b_i^2\big)^\frac{2+\delta}{2}}. $$ So the condition is that there is some $\delta>0$ such that $$\frac{\sum_{i=1}^n b_i^{2+\delta}}{\big(\sum_{i=1}^n b_i^2\big)^\frac{2+\delta}{2}} \to 0. $$ However, this does not hold in general. Consider $b_i=\frac{1}{i}$. Recall that $\sum_{i=1}^\infty\frac{1}{i^2}=\frac{\pi^2}{6}$. So the denominator in the fraction goes to $\frac{\pi^{2+\delta}}{\sqrt{6}^{2+\delta}}$, whereas the numerator has some other finite but nonzero limit. So the condition that the fraction goes to zero does not hold for this choice of $(b_i)$. The condition for the Lindeberg CLT is that for all $\epsilon>0$, $$ \lim_{n\to\infty}\frac{1}{s_n^2}\sum_{i=1}^nE\big(X_i^21_{|X_i|>\epsilon s_n}\big) = 0. $$ The expectation here is just a moment of a left-truncated exponential distribution. We have $$ E\big(X_i^21_{|X_i|>k}\big) = \int_k^\infty \frac{x^2}{b_i}e^{-\frac{x}{b_i}}\,dx = e^{-\frac{k}{b_i}}(2b_i^2+2b_ik+k^2). $$ So the Lindeberg condition is that $$ \frac{1}{s_n^2}\sum_{i=1}^nE\big(X_i^21_{|X_i|>\epsilon s_n}\big) = \sum_{i=1}^n e^{-\frac{\epsilon s_n}{b_i}}\frac{2b_i^2+2b_i\epsilon s_n+\epsilon^2 s_n^2}{s_n^2} \to 0. $$ But that again does not hold in general: consider any sequence $(b_i)$ such that the series of variances $(s_n)$ stays bounded.
Is the average of n independent Laplace random variables a Gaussian distribution?
TL;DR You cannot use either the Lyapunov or the Lindeberg CLT to say anything about the convergence in distribution of $\frac{1}{s_n}\sum_{i=1}^n X_i$ (where $s_n^2=\sum_{i=1}^n\sigma_i^2$) without ad
Is the average of n independent Laplace random variables a Gaussian distribution? TL;DR You cannot use either the Lyapunov or the Lindeberg CLT to say anything about the convergence in distribution of $\frac{1}{s_n}\sum_{i=1}^n X_i$ (where $s_n^2=\sum_{i=1}^n\sigma_i^2$) without additional conditions on the sequence of variances $(\sigma_i^2)$. Neither CLT would say anything about $\frac{1}{n}\sum_{i=1}^n X_i$. If the sequence of variances $(\sigma_i^2)$ grows fast enough, I strongly doubt that this average converges to anything reasonable. Assume that $X_i\sim\text{Laplace}(0,b_i)$ for a parameter $b_i>0$. Then $\sigma_i^2=2b_i^2$. As above, let $$ s_n^2=\sum_{i=1}^n\sigma_i^2=2\sum_{i=1}^n b_i^2.$$ The key property we need is that $|X_i|\sim\text{Exp}\big(\frac{1}{b_i}\big)$. This allows us to easily calculate the expectations we need in the Lyapunov or Lindeberg CLTs. The condition for the Lyapunov CLT is that there is some $\delta>0$ such that $$\lim_{n\to\infty}\frac{1}{s_n^{2+\delta}} \sum_{i=1}^nE\big(|X_i|^{2+\delta}\big) =0. $$ We have $$ E\big(|X_i|^{2+\delta}\big) = b_i^{2+\delta}\Gamma(\delta+3), $$ so $$ \frac{1}{s_n^{2+\delta}} \sum_{i=1}^nE\big(|X_i|^{2+\delta}\big) = \frac{\sum_{i=1}^n b_i^{2+\delta}\Gamma(\delta+3)}{\big(\sum_{i=1}^n 2b_i^2\big)^\frac{2+\delta}{2}} = \frac{\Gamma(\delta+3)}{2^\frac{2+\delta}{2}}\frac{\sum_{i=1}^n b_i^{2+\delta}}{\big(\sum_{i=1}^n b_i^2\big)^\frac{2+\delta}{2}}. $$ So the condition is that there is some $\delta>0$ such that $$\frac{\sum_{i=1}^n b_i^{2+\delta}}{\big(\sum_{i=1}^n b_i^2\big)^\frac{2+\delta}{2}} \to 0. $$ However, this does not hold in general. Consider $b_i=\frac{1}{i}$. Recall that $\sum_{i=1}^\infty\frac{1}{i^2}=\frac{\pi^2}{6}$. So the denominator in the fraction goes to $\frac{\pi^{2+\delta}}{\sqrt{6}^{2+\delta}}$, whereas the numerator has some other finite but nonzero limit. So the condition that the fraction goes to zero does not hold for this choice of $(b_i)$. The condition for the Lindeberg CLT is that for all $\epsilon>0$, $$ \lim_{n\to\infty}\frac{1}{s_n^2}\sum_{i=1}^nE\big(X_i^21_{|X_i|>\epsilon s_n}\big) = 0. $$ The expectation here is just a moment of a left-truncated exponential distribution. We have $$ E\big(X_i^21_{|X_i|>k}\big) = \int_k^\infty \frac{x^2}{b_i}e^{-\frac{x}{b_i}}\,dx = e^{-\frac{k}{b_i}}(2b_i^2+2b_ik+k^2). $$ So the Lindeberg condition is that $$ \frac{1}{s_n^2}\sum_{i=1}^nE\big(X_i^21_{|X_i|>\epsilon s_n}\big) = \sum_{i=1}^n e^{-\frac{\epsilon s_n}{b_i}}\frac{2b_i^2+2b_i\epsilon s_n+\epsilon^2 s_n^2}{s_n^2} \to 0. $$ But that again does not hold in general: consider any sequence $(b_i)$ such that the series of variances $(s_n)$ stays bounded.
Is the average of n independent Laplace random variables a Gaussian distribution? TL;DR You cannot use either the Lyapunov or the Lindeberg CLT to say anything about the convergence in distribution of $\frac{1}{s_n}\sum_{i=1}^n X_i$ (where $s_n^2=\sum_{i=1}^n\sigma_i^2$) without ad
47,610
Is the average of n independent Laplace random variables a Gaussian distribution?
The other answer by Stephen Kolassa gives you an excellent analysis of the Lyapunov condition in this case. However, I think it is also fruitful to look at this problem using moment generating functions. In your problem you have independent values $X_i \sim \text{Laplace}(0, \sigma_i/\sqrt{2})$, so these random variables have scaled moment generating functions given by: $$\begin{align} \varphi_{i}(t/n) \equiv \mathbb{E}(\exp(tX_i/n)) = \frac{1}{1 - \sigma_i^2 t^2/2n^2} &= 1 + \frac{\sigma_i^{2}}{2} \cdot \frac{t^2}{n^2} + \mathcal{O}(n^{-4}). \\[6pt] \end{align}$$ Letting $\bar{X}_n \equiv \sum_{i=1}^n X_i/n$ denote the sample mean of interest, this latter random variable has moment generating function, we have the characteristic function: $$\begin{align} \varphi_{\bar{X}_n}(t) = \prod_{i=1}^n \varphi_{i}(t/n) &= \prod_{i=1}^n \frac{1}{1 - \sigma_i^2 t^2/2n^2}. \\[6pt] \end{align}$$ Taking $n \rightarrow \infty$ gives the asymptotic form: $$\begin{align} \varphi_{\bar{X}_n}(t) &\rightarrow \prod_{i=1}^n \Bigg( 1 + \frac{\sigma_i^{2}}{2} \cdot \frac{t^{2}}{n^{2}} \Bigg). \\[6pt] \end{align}$$ In the special case where $\sigma_1 = \sigma_2 = \sigma_3 = \cdots$ this function converges to an exponential function in $t^2$, which is the moment generating function for the normal distribution. In the more general case, the moment generating function will not converge to the exponential function in $t^2$, and so the distribution of the sample mean does not converge to the normal distribution. If you would like to go further than this, I suggest you look into conditions on the $\sigma_i$ values that will allow you to get a useful convergence result for the above asymptotic form. It may be possible to simplify this asymptotic form under some conditions on these values, but I will leave this to you to investigate.
Is the average of n independent Laplace random variables a Gaussian distribution?
The other answer by Stephen Kolassa gives you an excellent analysis of the Lyapunov condition in this case. However, I think it is also fruitful to look at this problem using moment generating functi
Is the average of n independent Laplace random variables a Gaussian distribution? The other answer by Stephen Kolassa gives you an excellent analysis of the Lyapunov condition in this case. However, I think it is also fruitful to look at this problem using moment generating functions. In your problem you have independent values $X_i \sim \text{Laplace}(0, \sigma_i/\sqrt{2})$, so these random variables have scaled moment generating functions given by: $$\begin{align} \varphi_{i}(t/n) \equiv \mathbb{E}(\exp(tX_i/n)) = \frac{1}{1 - \sigma_i^2 t^2/2n^2} &= 1 + \frac{\sigma_i^{2}}{2} \cdot \frac{t^2}{n^2} + \mathcal{O}(n^{-4}). \\[6pt] \end{align}$$ Letting $\bar{X}_n \equiv \sum_{i=1}^n X_i/n$ denote the sample mean of interest, this latter random variable has moment generating function, we have the characteristic function: $$\begin{align} \varphi_{\bar{X}_n}(t) = \prod_{i=1}^n \varphi_{i}(t/n) &= \prod_{i=1}^n \frac{1}{1 - \sigma_i^2 t^2/2n^2}. \\[6pt] \end{align}$$ Taking $n \rightarrow \infty$ gives the asymptotic form: $$\begin{align} \varphi_{\bar{X}_n}(t) &\rightarrow \prod_{i=1}^n \Bigg( 1 + \frac{\sigma_i^{2}}{2} \cdot \frac{t^{2}}{n^{2}} \Bigg). \\[6pt] \end{align}$$ In the special case where $\sigma_1 = \sigma_2 = \sigma_3 = \cdots$ this function converges to an exponential function in $t^2$, which is the moment generating function for the normal distribution. In the more general case, the moment generating function will not converge to the exponential function in $t^2$, and so the distribution of the sample mean does not converge to the normal distribution. If you would like to go further than this, I suggest you look into conditions on the $\sigma_i$ values that will allow you to get a useful convergence result for the above asymptotic form. It may be possible to simplify this asymptotic form under some conditions on these values, but I will leave this to you to investigate.
Is the average of n independent Laplace random variables a Gaussian distribution? The other answer by Stephen Kolassa gives you an excellent analysis of the Lyapunov condition in this case. However, I think it is also fruitful to look at this problem using moment generating functi
47,611
Understanding The Visual Representation Of A Neural Network?
I believe you've misunderstood the role of input variables (or I've misunderstood you). $X_1...X_5$ are your features belonging to a single observation in the data. So, input dimension is $5$, meaning your data is five dimensional. This has nothing to do with the output dimension, which is typically equal to the number of classes in your data. So, when a new data sample comes, you just feed its $X_1..X_5$ to the network and get your output.
Understanding The Visual Representation Of A Neural Network?
I believe you've misunderstood the role of input variables (or I've misunderstood you). $X_1...X_5$ are your features belonging to a single observation in the data. So, input dimension is $5$, meaning
Understanding The Visual Representation Of A Neural Network? I believe you've misunderstood the role of input variables (or I've misunderstood you). $X_1...X_5$ are your features belonging to a single observation in the data. So, input dimension is $5$, meaning your data is five dimensional. This has nothing to do with the output dimension, which is typically equal to the number of classes in your data. So, when a new data sample comes, you just feed its $X_1..X_5$ to the network and get your output.
Understanding The Visual Representation Of A Neural Network? I believe you've misunderstood the role of input variables (or I've misunderstood you). $X_1...X_5$ are your features belonging to a single observation in the data. So, input dimension is $5$, meaning
47,612
Understanding The Visual Representation Of A Neural Network?
Just for clarity I will refer to the image of your question. From left to right, this Neural Network (NN) has one input layer of 5 neurons, one hidden layer of 2 neurons and one output layer of 5 neurons. how does the graphical representation work? Let's say you have a single new predictor value and you feed it into the NN below. How does NN know which coefficient is assigned to this single predictor value? What happens to the other coefficients? Would the vector of Xs values be equal to [X1, 0, 0, 0, 0]? Once we have already set up all the weights and biases the Neural Network has been already trained. Thereby the net is ready to receive data in its input layer and make the correct prediction at the output layer. In the NN of the image, we have an input layer formed by 5 neurons. This 5 neurons will ''receive'' the data whose values are known e.g. they could be a 5x1 vector of pixel gray scale values of an image formed by 5 pixels (the same as the number of neurons of the input layer). After this, the network will do all the mathematical operations needed and will give as a result, following the example of the image, a 5x1 vector at the output layer. This output could give some information of it e.g. if it contains 1 of a total of 5 objects, so if the 1st neuron of the output layer is asociated with object1, this neuron will be activated meaning that this object is present. Following this, if object1, object3 and object4 are present in the image, we will have at the output layer a vector like this: $[1, 0, 1, 1, 0]^T$. Note: In practice, this will happen only ideally. If the network is well trained, the most likely thing to happen is that the vector will have elements close to $0$ for the non-activated neurons, and close to $1$ for the activated neurons. and how it relates to the matrix math behind it? In order to answer this question I am going to need some notation. As the Network is already trained, we know all the elements of the matrices of the image: Each weight $w_{jk}$ and each bias $b_{j}$ where $j$ represents the row of the weight matrix (or vector of biases) and it is also related to the neuron position in the layer from we want to calculate the vector of activations. On the other hand, $k$ represents the column of the weight matrix or the position of the neuron in the previous layer of the current one in wich we are calculating the activations. With this notation we can calculate the activations of each neuron $j$ in a layer as: $x_j = f(z_j)\,\,$ with $\,\,z_j = \sum_k w_{jk}\times x_k + b_j$ where $f$ represents the activation function, this can be of different kinds like Sigmoid or Softmax. Note that this is the same as calculating separately each $Z_i$ of the equation that appears in the image of the question. So this is what the matrix math do "behind the scenes". Edit: As Gunes has correctly say, the number of neurons at the input layer has nothing to do with the number of neurons at the output layer.
Understanding The Visual Representation Of A Neural Network?
Just for clarity I will refer to the image of your question. From left to right, this Neural Network (NN) has one input layer of 5 neurons, one hidden layer of 2 neurons and one output layer of 5 neur
Understanding The Visual Representation Of A Neural Network? Just for clarity I will refer to the image of your question. From left to right, this Neural Network (NN) has one input layer of 5 neurons, one hidden layer of 2 neurons and one output layer of 5 neurons. how does the graphical representation work? Let's say you have a single new predictor value and you feed it into the NN below. How does NN know which coefficient is assigned to this single predictor value? What happens to the other coefficients? Would the vector of Xs values be equal to [X1, 0, 0, 0, 0]? Once we have already set up all the weights and biases the Neural Network has been already trained. Thereby the net is ready to receive data in its input layer and make the correct prediction at the output layer. In the NN of the image, we have an input layer formed by 5 neurons. This 5 neurons will ''receive'' the data whose values are known e.g. they could be a 5x1 vector of pixel gray scale values of an image formed by 5 pixels (the same as the number of neurons of the input layer). After this, the network will do all the mathematical operations needed and will give as a result, following the example of the image, a 5x1 vector at the output layer. This output could give some information of it e.g. if it contains 1 of a total of 5 objects, so if the 1st neuron of the output layer is asociated with object1, this neuron will be activated meaning that this object is present. Following this, if object1, object3 and object4 are present in the image, we will have at the output layer a vector like this: $[1, 0, 1, 1, 0]^T$. Note: In practice, this will happen only ideally. If the network is well trained, the most likely thing to happen is that the vector will have elements close to $0$ for the non-activated neurons, and close to $1$ for the activated neurons. and how it relates to the matrix math behind it? In order to answer this question I am going to need some notation. As the Network is already trained, we know all the elements of the matrices of the image: Each weight $w_{jk}$ and each bias $b_{j}$ where $j$ represents the row of the weight matrix (or vector of biases) and it is also related to the neuron position in the layer from we want to calculate the vector of activations. On the other hand, $k$ represents the column of the weight matrix or the position of the neuron in the previous layer of the current one in wich we are calculating the activations. With this notation we can calculate the activations of each neuron $j$ in a layer as: $x_j = f(z_j)\,\,$ with $\,\,z_j = \sum_k w_{jk}\times x_k + b_j$ where $f$ represents the activation function, this can be of different kinds like Sigmoid or Softmax. Note that this is the same as calculating separately each $Z_i$ of the equation that appears in the image of the question. So this is what the matrix math do "behind the scenes". Edit: As Gunes has correctly say, the number of neurons at the input layer has nothing to do with the number of neurons at the output layer.
Understanding The Visual Representation Of A Neural Network? Just for clarity I will refer to the image of your question. From left to right, this Neural Network (NN) has one input layer of 5 neurons, one hidden layer of 2 neurons and one output layer of 5 neur
47,613
How to get log odds from these results of logistic regression
The question title is: How to get log odds from these results of logistic regression The estimates are already on the log-odds scale. All you have to do is read the relevant entry. What are the odds of a male surviving as compared to a female? The log-odds of a male surviving compared to a female is -2.5221, holding the other variables constant. If we exponentiate this we get > exp(-2.5221) [1] 0.0803 and this is the odds ratio of survival for males compared to females - that is the odds of survival for males is 92% lower than the odds of survival for females How do odds change for every 1 year increase in age of the person? Every 1 year increase in age is associated with a 0.3693 decrease in log-odds of survival holding the other variables constant. If we exponentiate this: > exp(-0.3693) [1] 0.691 So every 1 unit increase in age is associated with a decrease in the odds of survival of 31%, holding the other variables constant.
How to get log odds from these results of logistic regression
The question title is: How to get log odds from these results of logistic regression The estimates are already on the log-odds scale. All you have to do is read the relevant entry. What are the odd
How to get log odds from these results of logistic regression The question title is: How to get log odds from these results of logistic regression The estimates are already on the log-odds scale. All you have to do is read the relevant entry. What are the odds of a male surviving as compared to a female? The log-odds of a male surviving compared to a female is -2.5221, holding the other variables constant. If we exponentiate this we get > exp(-2.5221) [1] 0.0803 and this is the odds ratio of survival for males compared to females - that is the odds of survival for males is 92% lower than the odds of survival for females How do odds change for every 1 year increase in age of the person? Every 1 year increase in age is associated with a 0.3693 decrease in log-odds of survival holding the other variables constant. If we exponentiate this: > exp(-0.3693) [1] 0.691 So every 1 unit increase in age is associated with a decrease in the odds of survival of 31%, holding the other variables constant.
How to get log odds from these results of logistic regression The question title is: How to get log odds from these results of logistic regression The estimates are already on the log-odds scale. All you have to do is read the relevant entry. What are the odd
47,614
Interpretation of binomial GLM (glmer) with interaction and results description
Please try not to be too concerned with p-values. They don't tell you anything about practical significance. I am wondering if the interpretation is as simply as, for example, there is a significant difference in the maximum depth (max_depths) reached between feeding and non-feeding dives, with maximum depth taking higher (deeper) values in feeding dives. Unfortunately not. max_depths is involved in an interaction with diel_2 so it's main effect, 1.91, is conditional on diel_2 being zero (or since it's a categorical variable, at it's reference level, which is Day). That is, for every 1 unit increase in max_depths, there is an estimated expected 1.91 increase in the log-odds of feeding being 1, for whales feeding in the day time. And for diel2_Night, does it means there are more feeding dives at night? No. Again, because diel2 is ivolved in the same interaction, with max_depths, this is conditional on max_depths being zero. That is, there is an estimated expected 1.55 increase in the log-odds of feeding being 1, for whales feeding at night compared to whales feeding at daytime, when max_depths is zero. For this reason alone you may want to centre the max_depths variable so that a value of zero makes more sense. How do I interpret the interaction? Maximum depth is higher in feeding dives at night? What about during the day? Not quite. The slope for max_depths is 1.90 higher for whales feeding at night, compared to whales feeding in the daytime. In other words, every 1 unit increase in max_depths is associated with a 1.90 higher increase in the log-odds of feeding being 1 for whales feeding at night, compared to whales feeding in the daytime. All of the raw estimates are based on the log-odds scale. You can exponentiate them to obtain odds ratios if you wish. What is the typical form of presentation of these results. I guess I should refer the p-value but do I have to state the estimate as well for example? Unfortunately there is nothing typical. If you are preparing a paper for publication then my practical advice is to read the submission guidelines for the journal you are submitting to, as well as looking at previously published articles in your field in that journal. Focus on the effect sizes. Rather than quoting p values, remark that the effect size is significant (at whatever significance level you choose). If you have some "non signifcant" findings, these might also be interesting. Also, compute confidence intervals and quote them alongside the effect sizes (rather than quoting p values)
Interpretation of binomial GLM (glmer) with interaction and results description
Please try not to be too concerned with p-values. They don't tell you anything about practical significance. I am wondering if the interpretation is as simply as, for example, there is a significant
Interpretation of binomial GLM (glmer) with interaction and results description Please try not to be too concerned with p-values. They don't tell you anything about practical significance. I am wondering if the interpretation is as simply as, for example, there is a significant difference in the maximum depth (max_depths) reached between feeding and non-feeding dives, with maximum depth taking higher (deeper) values in feeding dives. Unfortunately not. max_depths is involved in an interaction with diel_2 so it's main effect, 1.91, is conditional on diel_2 being zero (or since it's a categorical variable, at it's reference level, which is Day). That is, for every 1 unit increase in max_depths, there is an estimated expected 1.91 increase in the log-odds of feeding being 1, for whales feeding in the day time. And for diel2_Night, does it means there are more feeding dives at night? No. Again, because diel2 is ivolved in the same interaction, with max_depths, this is conditional on max_depths being zero. That is, there is an estimated expected 1.55 increase in the log-odds of feeding being 1, for whales feeding at night compared to whales feeding at daytime, when max_depths is zero. For this reason alone you may want to centre the max_depths variable so that a value of zero makes more sense. How do I interpret the interaction? Maximum depth is higher in feeding dives at night? What about during the day? Not quite. The slope for max_depths is 1.90 higher for whales feeding at night, compared to whales feeding in the daytime. In other words, every 1 unit increase in max_depths is associated with a 1.90 higher increase in the log-odds of feeding being 1 for whales feeding at night, compared to whales feeding in the daytime. All of the raw estimates are based on the log-odds scale. You can exponentiate them to obtain odds ratios if you wish. What is the typical form of presentation of these results. I guess I should refer the p-value but do I have to state the estimate as well for example? Unfortunately there is nothing typical. If you are preparing a paper for publication then my practical advice is to read the submission guidelines for the journal you are submitting to, as well as looking at previously published articles in your field in that journal. Focus on the effect sizes. Rather than quoting p values, remark that the effect size is significant (at whatever significance level you choose). If you have some "non signifcant" findings, these might also be interesting. Also, compute confidence intervals and quote them alongside the effect sizes (rather than quoting p values)
Interpretation of binomial GLM (glmer) with interaction and results description Please try not to be too concerned with p-values. They don't tell you anything about practical significance. I am wondering if the interpretation is as simply as, for example, there is a significant
47,615
What's the MSE of $\hat{Y}$ in ordinary least squares using bias-variance decomposition?
More explanation in the edit below I think the confusion arises because of the two different meanings of the MSE: A value calculated from a sample of fitted values or predictions; this is usually what we mean when we write $\operatorname{MSE}(\hat{Y})$ in the context of OLS, since $\hat{Y}$ is the vector of fitted values. A value calculated from an estimator. It is this meaning where we have the variance–bias decomposition. We use this meaning of the MSE in the context of OLS too, but usually for the MSE of $\hat{\beta}$, where $\hat{\beta}$ is an estimator of the parameter $\beta$. By the Gauss–Markov theorem we know that $\operatorname{Bias}(\hat{\beta}) = 0$ and thus $\operatorname{MSE}(\hat{\beta}) = \operatorname{Var}(\hat{\beta})$ by the variance–bias decomposition if we take $\hat{\beta} = (X^TX)^{-1}X^TY$. However, we can view $\hat{Y}$ as an estimator of $X\beta$ and thus consider $\operatorname{MSE}(\hat{Y})$ in the second sense. This is really just a rephrasing of the usual OLS estimator of $\beta$: In the normal setup we estimate the parameter $\beta$ given $X$ and $Y$, while in this new setup we estimate the parameter $X\beta$ given $X$ and $Y$. Alas the notation is now confusing, since the notation $\hat{Y}$ suggests that we are estimating $Y$ (a random variable), which we are not doing. To simplify the formalism, we will use the notation of the OP and define $\mu = X\beta$. Don't confuse this with a mean! We also have to clarify some definitions, since we are now dealing with a vector-valued estimator. First the variance (see this answer for some explanation): \begin{equation*} \operatorname{Var}(\hat{Y}) = \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T\right] \end{equation*} The definition of the bias doesn't change from the 1-dimensional case: \begin{equation*} \operatorname{Bias}(\hat{Y}) = \operatorname{E}[\hat{Y}]-\mu \end{equation*} However, we do have to find a vector-valued equivalent of the 1-dimensional expression $\operatorname{Bias}_\mu(\hat{Y})^2$, since this appears in the variance–bias decomposition. In the same vein as the vector-valued variance, this equivalent expression is the following: \begin{equation*} \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \end{equation*} Note that $\operatorname{Bias}(\hat{Y})$ is a fixed vector, so if the expression $\operatorname{E}[\hat{Y}]-\mu$ appears within the scope of an expected-value operator, we can take it out as a constant. This question is about this fact, albeit for the 1-dimensional case. And finally the MSE itself: \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E} \left [\left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T \right] \end{equation*} So, with all this in hand, we can now prove the variance–bias decomposition of the MSE for a vector-valued estimator, which is really just a rephrasing of the usual proof for the 1-dimensional case: \begin{align*} \operatorname{MSE}(\hat{Y}) &= \operatorname{E} \left [\left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T \right] \\ &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]+\operatorname{E}[\hat{Y}]-\mu\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]+\operatorname{E}[\hat{Y}]-\mu\right)^T\right]\\ &= \operatorname{E}\left[\left(\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)+\left(\operatorname{E}[\hat{Y}]-\mu\right)\right)\left(\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T+\left(\operatorname{E}[\hat{Y}]-\mu\right)^T\right)\right]\\ &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T +\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right ) \left (\operatorname{E}[\hat{Y}]-\mu \right)^T\right. \\ &\hphantom{xxxxxxxxxx} + \left.\left(\operatorname{E}[\hat{Y}]-\mu \right)\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right)^T +\left( \operatorname{E}[\hat{Y}]-\mu \right)\left( \operatorname{E}[\hat{Y}]-\mu \right)^T\right] \\ &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T\right] + \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right ) \left (\operatorname{E}[\hat{Y}]-\mu \right)^T\right] \\ &\hphantom{xxxxxxxxxx} + \operatorname{E}\left[\left (\operatorname{E}[\hat{Y}]-\mu \right)\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right)^T\right] + \operatorname{E}\left[\left( \operatorname{E}[\hat{Y}]-\mu \right)\left( \operatorname{E}[\hat{Y}]-\mu \right)^T\right] \\ &=\operatorname{Var}(\hat{Y}) + \operatorname{E}\left[\hat{Y}-\operatorname{E}[\hat{Y}] \right]\left(\operatorname{E}[\hat{Y}]-\mu \right)^T \\ &\hphantom{xxxxxxxxxx} + \left (\operatorname{E}[\hat{Y}]-\mu \right)\operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right)^T\right]+ \left( \operatorname{E}[\hat{Y}]-\mu \right)\left( \operatorname{E}[\hat{Y}]-\mu \right)^T \hphantom{xx} (*)\\ &=\operatorname{Var}(\hat{Y}) + \left(\operatorname{E}[\hat{Y}]-\operatorname{E}[\hat{Y}] \right)\left(\operatorname{E}[\hat{Y}]-\mu \right)^T \\ & \hphantom{xxxxxxxxxx}+ \left (\operatorname{E}[\hat{Y}]-\mu \right)\left(\operatorname{E}[\hat{Y}]-\operatorname{E}[\hat{Y}] \right)^T + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \\ &=\operatorname{Var}(\hat{Y}) + 0\left(\operatorname{E}[\hat{Y}]-\mu \right)^T + \left (\operatorname{E}[\hat{Y}]-\mu \right)0^T + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \\ &= \operatorname{Var}(\hat{Y}) + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \end{align*} Let's now actually calculate the bias and the variance of the estimator $\hat{Y}$: \begin{align*} \operatorname{Bias}(\hat{Y}) &= \operatorname{E}[\hat{Y}]-\mu \\ &= \operatorname{E}[\hat{Y}-\mu] \\ &= \operatorname{E}\left[X(X^TX)^{-1}X^TY-X\beta\right] \\ &= \operatorname{E}\left[X\left((X^TX)^{-1}X^TY-\beta\right)\right] \\ &= X\operatorname{E}\left[(X^TX)^{-1}X^TY-\beta\right] \\ &= X\operatorname{E}[\hat{\beta}-\beta] \\ &= X0 \\ &= 0 \end{align*} The equality $\operatorname{E}[\hat{\beta}-\beta]=0$ is a consequence of the Gauss–Markov theorem. Note that $\operatorname{Bias}(\hat{Y})=0$ implies that $\operatorname{E}[\hat{Y}]=\mu$ by simple rearrangement. We now calculate the variance: \begin{align*} \operatorname{Var}(\hat{Y}) &= \operatorname{E}\left[(\hat{Y}-\operatorname{E}[\hat{Y}])(\hat{Y}-\operatorname{E}[\hat{Y}])^T\right]\\ &= \operatorname{E}\left[(\hat{Y}-\mu)(\hat{Y}-\mu)^T\right]\\ &= \operatorname{E}\left[(X\hat{\beta}-X\beta)(X\hat{\beta}-X\beta)^T\right]\\ &= \operatorname{E}\left[X(\hat{\beta}-\beta)(\hat{\beta}-\beta)^TX^T\right]\\ &= X\operatorname{E}\left[(\hat{\beta}-\beta)(\hat{\beta}-\beta)^T\right]X^T\\ &= X\operatorname{E}\left[(\hat{\beta}-\operatorname{E}[\hat{\beta}])(\hat{\beta}-\operatorname{E}[\hat{\beta}])^T\right]X^T \hphantom{xx} (\text{by the Gauss–Markow theorem})\\ &= X\operatorname{Var}(\hat{\beta})X^T\\ &= X(\sigma^2(X^TX)^{-1}X^T) \hphantom{xx} (**)\\ &= X(\sigma^2(X^TX)^{-1}X^T)\\ &= \sigma^2X(X^TX)^{-1}X^T\\ &= \sigma^2H \end{align*} We prove the step marked $(**)$, namely that $\operatorname{Var}(\hat{\beta}) = \sigma^2(X^TX)^{-1}$: \begin{align*} \hat{\beta} - \beta &= (X^TX)^{-1}X^TY - \beta \\ &= (X^TX)^{-1}X^T(X\beta + \epsilon) - \beta \\ &= (X^TX)^{-1}X^TX\beta + (X^TX)^{-1}X^T\epsilon - \beta \\ &= \beta + (X^TX)^{-1}X^T\epsilon - \beta \\ &= (X^TX)^{-1}X^T\epsilon \end{align*} Thus: \begin{align*} \operatorname{Var}(\hat{\beta}) &=\operatorname{E}\left[(\hat{\beta}-\beta)(\hat{\beta}-\beta)^T\right] \\ &= \operatorname{E}\left[(X^TX)^{-1}X^T\epsilon((X^TX)^{-1}X^T\epsilon)^T\right] \\ &= \operatorname{E}\left[(X^TX)^{-1}X^T\epsilon\epsilon^TX(X^TX)^{-T}\right] \\ &= (X^TX)^{-1}X^T\operatorname{E}\left[\epsilon\epsilon^T\right]X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T\operatorname{E}\left[(\epsilon-0)(\epsilon-0)^T\right]X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T\operatorname{E}\left[(\epsilon-\operatorname{E}[\epsilon])(\epsilon-\operatorname{E}[\epsilon])^T\right]X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T\operatorname{Var}(\epsilon)X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T(\sigma^2I)X(X^TX)^{-T} \hphantom{xx} (\text{since the errors are uncorrelated with each other})\\ &= (X^TX)^{-1}X^T(\sigma^2I)X(X^TX)^{-T} \\ &= \sigma^2(X^TX)^{-1}X^TX(X^TX)^{-T} \\ &= \sigma^2(X^TX)^{-T} \\ &= \sigma^2((X^TX)^T)^{-1} \\ &= \sigma^2(X^TX)^{-1} \\ \end{align*} So, putting it all together: \begin{align*} \operatorname{MSE}(\hat{Y}) &= \operatorname{Var}(\hat{Y}) + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \\ &= \sigma^2H + 00^T \\ &= \sigma^2H \end{align*} This is the answer that the OP calculated. :) EDIT The OP asked in the comments why we define \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E} \left [\left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T \right] \end{equation*} and not \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E} \left[\left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right) \right]. \end{equation*} This is a good question; indeed, it's the crux of the OP's original question and I didn't address it properly. I will attempt to redress this oversight. In the 1-dimensional case, the meaning of the definition \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E}\left[\left(\hat{Y}-\mu\right)^2\right] \end{equation*} is unambiguous. But if $\hat{Y}-\mu$ is a vector, then we have to decide how to interpret the expression $\left(\hat{Y}-\mu\right)^2$. We have two options: $\left(\hat{Y}-\mu\right)^2 = \left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right)$ $\left(\hat{Y}-\mu\right)^2 = \left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T$ In my original answer I went with the second option (based on arguments given here). But what about the first option? Well, we still have the variance–bias decomposition! Let's show that. We start by defining all the relevant terms; I mark them with a superscript asterisk * in order to distinguish them from the definitions given in my original answer, but please note that this is not standard notation: \begin{align*} \operatorname{MSE}^*(\hat{Y}) &= \operatorname{E}\left[\left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right) \right] \\ \operatorname{Var}^*(\hat{Y}) &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\right] \\ \operatorname{Bias}^*(\hat{Y}) &= \operatorname{E}[\hat{Y}]-\mu \left(= \operatorname{Bias}(\hat{Y}) \right)\\ \operatorname{Bias}^*(\hat{Y})^2 &= \operatorname{Bias}^*(\hat{Y})^T\operatorname{Bias}^*(\hat{Y}) \end{align*} (Note that we could multiply by the constant factor $\frac{1}{n}$, i.e. define \begin{equation*} \operatorname{MSE}^*(\hat{Y}) = \operatorname{E}\left[\tfrac{1}{n}\left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right) \right]. \end{equation*} It doesn't really matter whether we include this constant factor, since it has no effect on the expected-value operator.) With these definitions, the MSE still decomposes into the sum of the variance and the square of the bias: \begin{equation*} \operatorname{MSE}^*(\hat{Y}) = \operatorname{Var}^*(\hat{Y}) + \operatorname{Bias}^*(\hat{Y})^2 \end{equation*} The proof is all but identical to the one given above: One just has to move a few superscript $T$s around. What the OP did in their original calculation was to mix up the different definitions when they applied the variance–bias decomposition: They used $\operatorname{Var}^*(\hat{Y})$ but $\operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T$. This is why the dimensions didn't match.
What's the MSE of $\hat{Y}$ in ordinary least squares using bias-variance decomposition?
More explanation in the edit below I think the confusion arises because of the two different meanings of the MSE: A value calculated from a sample of fitted values or predictions; this is usually wha
What's the MSE of $\hat{Y}$ in ordinary least squares using bias-variance decomposition? More explanation in the edit below I think the confusion arises because of the two different meanings of the MSE: A value calculated from a sample of fitted values or predictions; this is usually what we mean when we write $\operatorname{MSE}(\hat{Y})$ in the context of OLS, since $\hat{Y}$ is the vector of fitted values. A value calculated from an estimator. It is this meaning where we have the variance–bias decomposition. We use this meaning of the MSE in the context of OLS too, but usually for the MSE of $\hat{\beta}$, where $\hat{\beta}$ is an estimator of the parameter $\beta$. By the Gauss–Markov theorem we know that $\operatorname{Bias}(\hat{\beta}) = 0$ and thus $\operatorname{MSE}(\hat{\beta}) = \operatorname{Var}(\hat{\beta})$ by the variance–bias decomposition if we take $\hat{\beta} = (X^TX)^{-1}X^TY$. However, we can view $\hat{Y}$ as an estimator of $X\beta$ and thus consider $\operatorname{MSE}(\hat{Y})$ in the second sense. This is really just a rephrasing of the usual OLS estimator of $\beta$: In the normal setup we estimate the parameter $\beta$ given $X$ and $Y$, while in this new setup we estimate the parameter $X\beta$ given $X$ and $Y$. Alas the notation is now confusing, since the notation $\hat{Y}$ suggests that we are estimating $Y$ (a random variable), which we are not doing. To simplify the formalism, we will use the notation of the OP and define $\mu = X\beta$. Don't confuse this with a mean! We also have to clarify some definitions, since we are now dealing with a vector-valued estimator. First the variance (see this answer for some explanation): \begin{equation*} \operatorname{Var}(\hat{Y}) = \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T\right] \end{equation*} The definition of the bias doesn't change from the 1-dimensional case: \begin{equation*} \operatorname{Bias}(\hat{Y}) = \operatorname{E}[\hat{Y}]-\mu \end{equation*} However, we do have to find a vector-valued equivalent of the 1-dimensional expression $\operatorname{Bias}_\mu(\hat{Y})^2$, since this appears in the variance–bias decomposition. In the same vein as the vector-valued variance, this equivalent expression is the following: \begin{equation*} \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \end{equation*} Note that $\operatorname{Bias}(\hat{Y})$ is a fixed vector, so if the expression $\operatorname{E}[\hat{Y}]-\mu$ appears within the scope of an expected-value operator, we can take it out as a constant. This question is about this fact, albeit for the 1-dimensional case. And finally the MSE itself: \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E} \left [\left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T \right] \end{equation*} So, with all this in hand, we can now prove the variance–bias decomposition of the MSE for a vector-valued estimator, which is really just a rephrasing of the usual proof for the 1-dimensional case: \begin{align*} \operatorname{MSE}(\hat{Y}) &= \operatorname{E} \left [\left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T \right] \\ &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]+\operatorname{E}[\hat{Y}]-\mu\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]+\operatorname{E}[\hat{Y}]-\mu\right)^T\right]\\ &= \operatorname{E}\left[\left(\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)+\left(\operatorname{E}[\hat{Y}]-\mu\right)\right)\left(\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T+\left(\operatorname{E}[\hat{Y}]-\mu\right)^T\right)\right]\\ &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T +\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right ) \left (\operatorname{E}[\hat{Y}]-\mu \right)^T\right. \\ &\hphantom{xxxxxxxxxx} + \left.\left(\operatorname{E}[\hat{Y}]-\mu \right)\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right)^T +\left( \operatorname{E}[\hat{Y}]-\mu \right)\left( \operatorname{E}[\hat{Y}]-\mu \right)^T\right] \\ &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T\right] + \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right ) \left (\operatorname{E}[\hat{Y}]-\mu \right)^T\right] \\ &\hphantom{xxxxxxxxxx} + \operatorname{E}\left[\left (\operatorname{E}[\hat{Y}]-\mu \right)\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right)^T\right] + \operatorname{E}\left[\left( \operatorname{E}[\hat{Y}]-\mu \right)\left( \operatorname{E}[\hat{Y}]-\mu \right)^T\right] \\ &=\operatorname{Var}(\hat{Y}) + \operatorname{E}\left[\hat{Y}-\operatorname{E}[\hat{Y}] \right]\left(\operatorname{E}[\hat{Y}]-\mu \right)^T \\ &\hphantom{xxxxxxxxxx} + \left (\operatorname{E}[\hat{Y}]-\mu \right)\operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}] \right)^T\right]+ \left( \operatorname{E}[\hat{Y}]-\mu \right)\left( \operatorname{E}[\hat{Y}]-\mu \right)^T \hphantom{xx} (*)\\ &=\operatorname{Var}(\hat{Y}) + \left(\operatorname{E}[\hat{Y}]-\operatorname{E}[\hat{Y}] \right)\left(\operatorname{E}[\hat{Y}]-\mu \right)^T \\ & \hphantom{xxxxxxxxxx}+ \left (\operatorname{E}[\hat{Y}]-\mu \right)\left(\operatorname{E}[\hat{Y}]-\operatorname{E}[\hat{Y}] \right)^T + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \\ &=\operatorname{Var}(\hat{Y}) + 0\left(\operatorname{E}[\hat{Y}]-\mu \right)^T + \left (\operatorname{E}[\hat{Y}]-\mu \right)0^T + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \\ &= \operatorname{Var}(\hat{Y}) + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \end{align*} Let's now actually calculate the bias and the variance of the estimator $\hat{Y}$: \begin{align*} \operatorname{Bias}(\hat{Y}) &= \operatorname{E}[\hat{Y}]-\mu \\ &= \operatorname{E}[\hat{Y}-\mu] \\ &= \operatorname{E}\left[X(X^TX)^{-1}X^TY-X\beta\right] \\ &= \operatorname{E}\left[X\left((X^TX)^{-1}X^TY-\beta\right)\right] \\ &= X\operatorname{E}\left[(X^TX)^{-1}X^TY-\beta\right] \\ &= X\operatorname{E}[\hat{\beta}-\beta] \\ &= X0 \\ &= 0 \end{align*} The equality $\operatorname{E}[\hat{\beta}-\beta]=0$ is a consequence of the Gauss–Markov theorem. Note that $\operatorname{Bias}(\hat{Y})=0$ implies that $\operatorname{E}[\hat{Y}]=\mu$ by simple rearrangement. We now calculate the variance: \begin{align*} \operatorname{Var}(\hat{Y}) &= \operatorname{E}\left[(\hat{Y}-\operatorname{E}[\hat{Y}])(\hat{Y}-\operatorname{E}[\hat{Y}])^T\right]\\ &= \operatorname{E}\left[(\hat{Y}-\mu)(\hat{Y}-\mu)^T\right]\\ &= \operatorname{E}\left[(X\hat{\beta}-X\beta)(X\hat{\beta}-X\beta)^T\right]\\ &= \operatorname{E}\left[X(\hat{\beta}-\beta)(\hat{\beta}-\beta)^TX^T\right]\\ &= X\operatorname{E}\left[(\hat{\beta}-\beta)(\hat{\beta}-\beta)^T\right]X^T\\ &= X\operatorname{E}\left[(\hat{\beta}-\operatorname{E}[\hat{\beta}])(\hat{\beta}-\operatorname{E}[\hat{\beta}])^T\right]X^T \hphantom{xx} (\text{by the Gauss–Markow theorem})\\ &= X\operatorname{Var}(\hat{\beta})X^T\\ &= X(\sigma^2(X^TX)^{-1}X^T) \hphantom{xx} (**)\\ &= X(\sigma^2(X^TX)^{-1}X^T)\\ &= \sigma^2X(X^TX)^{-1}X^T\\ &= \sigma^2H \end{align*} We prove the step marked $(**)$, namely that $\operatorname{Var}(\hat{\beta}) = \sigma^2(X^TX)^{-1}$: \begin{align*} \hat{\beta} - \beta &= (X^TX)^{-1}X^TY - \beta \\ &= (X^TX)^{-1}X^T(X\beta + \epsilon) - \beta \\ &= (X^TX)^{-1}X^TX\beta + (X^TX)^{-1}X^T\epsilon - \beta \\ &= \beta + (X^TX)^{-1}X^T\epsilon - \beta \\ &= (X^TX)^{-1}X^T\epsilon \end{align*} Thus: \begin{align*} \operatorname{Var}(\hat{\beta}) &=\operatorname{E}\left[(\hat{\beta}-\beta)(\hat{\beta}-\beta)^T\right] \\ &= \operatorname{E}\left[(X^TX)^{-1}X^T\epsilon((X^TX)^{-1}X^T\epsilon)^T\right] \\ &= \operatorname{E}\left[(X^TX)^{-1}X^T\epsilon\epsilon^TX(X^TX)^{-T}\right] \\ &= (X^TX)^{-1}X^T\operatorname{E}\left[\epsilon\epsilon^T\right]X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T\operatorname{E}\left[(\epsilon-0)(\epsilon-0)^T\right]X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T\operatorname{E}\left[(\epsilon-\operatorname{E}[\epsilon])(\epsilon-\operatorname{E}[\epsilon])^T\right]X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T\operatorname{Var}(\epsilon)X(X^TX)^{-T} \\ &= (X^TX)^{-1}X^T(\sigma^2I)X(X^TX)^{-T} \hphantom{xx} (\text{since the errors are uncorrelated with each other})\\ &= (X^TX)^{-1}X^T(\sigma^2I)X(X^TX)^{-T} \\ &= \sigma^2(X^TX)^{-1}X^TX(X^TX)^{-T} \\ &= \sigma^2(X^TX)^{-T} \\ &= \sigma^2((X^TX)^T)^{-1} \\ &= \sigma^2(X^TX)^{-1} \\ \end{align*} So, putting it all together: \begin{align*} \operatorname{MSE}(\hat{Y}) &= \operatorname{Var}(\hat{Y}) + \operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T \\ &= \sigma^2H + 00^T \\ &= \sigma^2H \end{align*} This is the answer that the OP calculated. :) EDIT The OP asked in the comments why we define \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E} \left [\left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T \right] \end{equation*} and not \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E} \left[\left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right) \right]. \end{equation*} This is a good question; indeed, it's the crux of the OP's original question and I didn't address it properly. I will attempt to redress this oversight. In the 1-dimensional case, the meaning of the definition \begin{equation*} \operatorname{MSE}(\hat{Y}) = \operatorname{E}\left[\left(\hat{Y}-\mu\right)^2\right] \end{equation*} is unambiguous. But if $\hat{Y}-\mu$ is a vector, then we have to decide how to interpret the expression $\left(\hat{Y}-\mu\right)^2$. We have two options: $\left(\hat{Y}-\mu\right)^2 = \left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right)$ $\left(\hat{Y}-\mu\right)^2 = \left(\hat{Y}-\mu\right)\left(\hat{Y}-\mu\right)^T$ In my original answer I went with the second option (based on arguments given here). But what about the first option? Well, we still have the variance–bias decomposition! Let's show that. We start by defining all the relevant terms; I mark them with a superscript asterisk * in order to distinguish them from the definitions given in my original answer, but please note that this is not standard notation: \begin{align*} \operatorname{MSE}^*(\hat{Y}) &= \operatorname{E}\left[\left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right) \right] \\ \operatorname{Var}^*(\hat{Y}) &= \operatorname{E}\left[\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)^T\left(\hat{Y}-\operatorname{E}[\hat{Y}]\right)\right] \\ \operatorname{Bias}^*(\hat{Y}) &= \operatorname{E}[\hat{Y}]-\mu \left(= \operatorname{Bias}(\hat{Y}) \right)\\ \operatorname{Bias}^*(\hat{Y})^2 &= \operatorname{Bias}^*(\hat{Y})^T\operatorname{Bias}^*(\hat{Y}) \end{align*} (Note that we could multiply by the constant factor $\frac{1}{n}$, i.e. define \begin{equation*} \operatorname{MSE}^*(\hat{Y}) = \operatorname{E}\left[\tfrac{1}{n}\left(\hat{Y}-\mu\right)^T\left(\hat{Y}-\mu\right) \right]. \end{equation*} It doesn't really matter whether we include this constant factor, since it has no effect on the expected-value operator.) With these definitions, the MSE still decomposes into the sum of the variance and the square of the bias: \begin{equation*} \operatorname{MSE}^*(\hat{Y}) = \operatorname{Var}^*(\hat{Y}) + \operatorname{Bias}^*(\hat{Y})^2 \end{equation*} The proof is all but identical to the one given above: One just has to move a few superscript $T$s around. What the OP did in their original calculation was to mix up the different definitions when they applied the variance–bias decomposition: They used $\operatorname{Var}^*(\hat{Y})$ but $\operatorname{Bias}(\hat{Y})\operatorname{Bias}(\hat{Y})^T$. This is why the dimensions didn't match.
What's the MSE of $\hat{Y}$ in ordinary least squares using bias-variance decomposition? More explanation in the edit below I think the confusion arises because of the two different meanings of the MSE: A value calculated from a sample of fitted values or predictions; this is usually wha
47,616
What is the difference between a confounder, collinearity, and interaction term?
Your understanding of confounding and collinearity is correct. Note that in many contexts collinearity really refers to "perfect collinearity" where one variable is a linear combination of one or more other variables, but in some contexts it just refers to "high correlation" between variables. Of course, in order for confounding to occur, there has to be a degree of correlation, though I would avoid saying "collinearity" due to the above. However: interaction term: joint effect of independent variables (but doesn't this require correlation between those variables?) A "joint effect" is a good way to undersdand it, but in no way does it require correlation between the variables. Consider an orthogonal factorial design experiment for example. As another example we could also show this with a simple simulation of bivariate data where X1 and X2 are uncorrelated yet a meaningful interaction exists: > set.seed(1) > N <- 100 > X1 <- rnorm(N) > X2 <- rnorm(N) > cor(X1, X2) [1] -0.0009943199 # X1 and X2 are uncorrelated > > Y <- X1 * X2 + rnorm(N) > lm(Y ~ X1 * X2) %>% summary() Call: lm(formula = Y ~ X1 * X2) Residuals: Min 1Q Median 3Q Max -2.92554 -0.43139 0.00249 0.65651 2.60188 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.03107 0.10439 0.298 0.767 X1 -0.03352 0.12064 -0.278 0.782 X2 -0.02822 0.10970 -0.257 0.798 X1:X2 0.76032 0.14847 5.121 1.57e-06 ***
What is the difference between a confounder, collinearity, and interaction term?
Your understanding of confounding and collinearity is correct. Note that in many contexts collinearity really refers to "perfect collinearity" where one variable is a linear combination of one or more
What is the difference between a confounder, collinearity, and interaction term? Your understanding of confounding and collinearity is correct. Note that in many contexts collinearity really refers to "perfect collinearity" where one variable is a linear combination of one or more other variables, but in some contexts it just refers to "high correlation" between variables. Of course, in order for confounding to occur, there has to be a degree of correlation, though I would avoid saying "collinearity" due to the above. However: interaction term: joint effect of independent variables (but doesn't this require correlation between those variables?) A "joint effect" is a good way to undersdand it, but in no way does it require correlation between the variables. Consider an orthogonal factorial design experiment for example. As another example we could also show this with a simple simulation of bivariate data where X1 and X2 are uncorrelated yet a meaningful interaction exists: > set.seed(1) > N <- 100 > X1 <- rnorm(N) > X2 <- rnorm(N) > cor(X1, X2) [1] -0.0009943199 # X1 and X2 are uncorrelated > > Y <- X1 * X2 + rnorm(N) > lm(Y ~ X1 * X2) %>% summary() Call: lm(formula = Y ~ X1 * X2) Residuals: Min 1Q Median 3Q Max -2.92554 -0.43139 0.00249 0.65651 2.60188 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.03107 0.10439 0.298 0.767 X1 -0.03352 0.12064 -0.278 0.782 X2 -0.02822 0.10970 -0.257 0.798 X1:X2 0.76032 0.14847 5.121 1.57e-06 ***
What is the difference between a confounder, collinearity, and interaction term? Your understanding of confounding and collinearity is correct. Note that in many contexts collinearity really refers to "perfect collinearity" where one variable is a linear combination of one or more
47,617
How to identify which variables are collinear in a singular regression matrix? [duplicate]
You can use the QR decomposition with column pivoting (see e.g. "The Behavior of the QR-Factorization Algorithm with Column Pivoting" by Engler (1997)). As described in that paper, the pivots give an ordering of the columns by "most linearly independent". Assuming we've computed the rank of the matrix already (which is a fair assumption since in general we'd need to do this to know it's low rank in the first place) we can then take the first $\text{rank}(X)$ pivots and should get a full rank matrix. Here's an example. set.seed(1) n <- 50 inputs <- matrix(rnorm(n*3), n, 3) x <- cbind( inputs[,1], inputs[,2], inputs[,1] + inputs[,2], inputs[,3], -.25 * inputs[,3] ) print(Matrix::rankMatrix(x)) # 5 columns but rank 3 cor(x) # only detects the columns 4,5 collinearity, not 1,2,3 svd(x)$d # two singular values are numerically zero as expected qr.x <- qr(x) print(qr.x$pivot) rank.x <- Matrix::rankMatrix(x) print(Matrix::rankMatrix(x[,qr.x$pivot[1:rank.x]])) # full rank Another comment on issues with just using pairwise correlation is that two columns having a perfect correlation doesn't even guarantee the matrix is low rank. As an example: set.seed(1) x <- rnorm(n) x <- cbind(x, x + 1) print(Matrix::rankMatrix(x)) cor(x) These two columns are perfectly correlated, but since the constant vector is not in their span, it doesn't actually affect the rank. If there also was an intercept column then this matrix would indeed be rank $2$ (almost surely).
How to identify which variables are collinear in a singular regression matrix? [duplicate]
You can use the QR decomposition with column pivoting (see e.g. "The Behavior of the QR-Factorization Algorithm with Column Pivoting" by Engler (1997)). As described in that paper, the pivots give an
How to identify which variables are collinear in a singular regression matrix? [duplicate] You can use the QR decomposition with column pivoting (see e.g. "The Behavior of the QR-Factorization Algorithm with Column Pivoting" by Engler (1997)). As described in that paper, the pivots give an ordering of the columns by "most linearly independent". Assuming we've computed the rank of the matrix already (which is a fair assumption since in general we'd need to do this to know it's low rank in the first place) we can then take the first $\text{rank}(X)$ pivots and should get a full rank matrix. Here's an example. set.seed(1) n <- 50 inputs <- matrix(rnorm(n*3), n, 3) x <- cbind( inputs[,1], inputs[,2], inputs[,1] + inputs[,2], inputs[,3], -.25 * inputs[,3] ) print(Matrix::rankMatrix(x)) # 5 columns but rank 3 cor(x) # only detects the columns 4,5 collinearity, not 1,2,3 svd(x)$d # two singular values are numerically zero as expected qr.x <- qr(x) print(qr.x$pivot) rank.x <- Matrix::rankMatrix(x) print(Matrix::rankMatrix(x[,qr.x$pivot[1:rank.x]])) # full rank Another comment on issues with just using pairwise correlation is that two columns having a perfect correlation doesn't even guarantee the matrix is low rank. As an example: set.seed(1) x <- rnorm(n) x <- cbind(x, x + 1) print(Matrix::rankMatrix(x)) cor(x) These two columns are perfectly correlated, but since the constant vector is not in their span, it doesn't actually affect the rank. If there also was an intercept column then this matrix would indeed be rank $2$ (almost surely).
How to identify which variables are collinear in a singular regression matrix? [duplicate] You can use the QR decomposition with column pivoting (see e.g. "The Behavior of the QR-Factorization Algorithm with Column Pivoting" by Engler (1997)). As described in that paper, the pivots give an
47,618
How to identify which variables are collinear in a singular regression matrix? [duplicate]
It looks like you have perfect collinearity among one of the pairs of your 3 independent variables. Run a correlation matrix, and check which pair has a correlation of exactly 1. In R, cor(count_FGT_free) You could also create a smaller dataframe with just those three variables if count_FGT_free is large.
How to identify which variables are collinear in a singular regression matrix? [duplicate]
It looks like you have perfect collinearity among one of the pairs of your 3 independent variables. Run a correlation matrix, and check which pair has a correlation of exactly 1. In R, cor(count_FGT_f
How to identify which variables are collinear in a singular regression matrix? [duplicate] It looks like you have perfect collinearity among one of the pairs of your 3 independent variables. Run a correlation matrix, and check which pair has a correlation of exactly 1. In R, cor(count_FGT_free) You could also create a smaller dataframe with just those three variables if count_FGT_free is large.
How to identify which variables are collinear in a singular regression matrix? [duplicate] It looks like you have perfect collinearity among one of the pairs of your 3 independent variables. Run a correlation matrix, and check which pair has a correlation of exactly 1. In R, cor(count_FGT_f
47,619
R: Post-hoc test on lmer. emmeans and multcomp packages
In modeling you have to be careful not to include the exact same situation in different ways. For example, you already found that the design with all the period = 0 cases having Treatment C made it impossible to get useful results. In the summary(lm1) output, that led to reporting only 1 coefficient for period when the 3 levels meant there should have been 2 coefficients (that's how I figured out the problem) and a correct refusal by emmeans to provide contrasts involving Treatment C when that couldn't be disentangled from period = 0. Similarly, you can't include both sequence and period in the model, as they represent the same thing. The sequence = 1 value means getting Treatment A then Treatment B; sequence = 2 means the reverse. So at period = 1 all measurements for those having sequence = 1 will be taken following Treatment A, measurements for those having sequence = 2 will be taken following Treatment B, with the opposite at period = 2. If you only have 10 individuals with 3 measurements each (baseline, after first treatment, after second treatment) you face a risk of overfitting if you try to evaluate more than 1 or 2 predictors. The usual rule of thumb for biomedical situations with continuous outcomes is about 15 observations per predictor evaluated. But if this is a randomized trial then you can take advantage of randomization itself, which ideally should wash out any contributions to outcome except for those included in the design: in your case, the two Treatments and the order of their application. It would be good to demonstrate that the randomization did a reasonable job of balancing the things you know about (baseline lipid values, sex, age), but you might not have to include sex or age in the model as covariates. Correction for covariates can be helpful in larger studies but you don't have enough cases to do that adequately with only 10 participants. I like the recommendation in a comment by @Isabella Ghement to incorporate the baseline lipid values as covariates rather than modeling them as outcomes. There seems to have been no actual Treatment C, or if there was there doesn't seem to be a record of lipid values before that Treatment, so there's really nothing to model. Following that recommendation might remove the need to include a random-effects intercept term, which would impose a Gaussian structure on the intercepts that might not be appropriate. Then your model comes down to an evaluation of Treatment A versus Treatment B and the 2 orders in which the treatments were given. That would seem to require an interaction term (lipid ~ baselineLipid + Treatment + sequence + Treatment:sequence), where Treatment is 0 for TreatmentA and 1 for TreatmentB. Your study still might not be large enough to handle even this many predictors, but I think that this model has a better chance of representing your results fairly.
R: Post-hoc test on lmer. emmeans and multcomp packages
In modeling you have to be careful not to include the exact same situation in different ways. For example, you already found that the design with all the period = 0 cases having Treatment C made it im
R: Post-hoc test on lmer. emmeans and multcomp packages In modeling you have to be careful not to include the exact same situation in different ways. For example, you already found that the design with all the period = 0 cases having Treatment C made it impossible to get useful results. In the summary(lm1) output, that led to reporting only 1 coefficient for period when the 3 levels meant there should have been 2 coefficients (that's how I figured out the problem) and a correct refusal by emmeans to provide contrasts involving Treatment C when that couldn't be disentangled from period = 0. Similarly, you can't include both sequence and period in the model, as they represent the same thing. The sequence = 1 value means getting Treatment A then Treatment B; sequence = 2 means the reverse. So at period = 1 all measurements for those having sequence = 1 will be taken following Treatment A, measurements for those having sequence = 2 will be taken following Treatment B, with the opposite at period = 2. If you only have 10 individuals with 3 measurements each (baseline, after first treatment, after second treatment) you face a risk of overfitting if you try to evaluate more than 1 or 2 predictors. The usual rule of thumb for biomedical situations with continuous outcomes is about 15 observations per predictor evaluated. But if this is a randomized trial then you can take advantage of randomization itself, which ideally should wash out any contributions to outcome except for those included in the design: in your case, the two Treatments and the order of their application. It would be good to demonstrate that the randomization did a reasonable job of balancing the things you know about (baseline lipid values, sex, age), but you might not have to include sex or age in the model as covariates. Correction for covariates can be helpful in larger studies but you don't have enough cases to do that adequately with only 10 participants. I like the recommendation in a comment by @Isabella Ghement to incorporate the baseline lipid values as covariates rather than modeling them as outcomes. There seems to have been no actual Treatment C, or if there was there doesn't seem to be a record of lipid values before that Treatment, so there's really nothing to model. Following that recommendation might remove the need to include a random-effects intercept term, which would impose a Gaussian structure on the intercepts that might not be appropriate. Then your model comes down to an evaluation of Treatment A versus Treatment B and the 2 orders in which the treatments were given. That would seem to require an interaction term (lipid ~ baselineLipid + Treatment + sequence + Treatment:sequence), where Treatment is 0 for TreatmentA and 1 for TreatmentB. Your study still might not be large enough to handle even this many predictors, but I think that this model has a better chance of representing your results fairly.
R: Post-hoc test on lmer. emmeans and multcomp packages In modeling you have to be careful not to include the exact same situation in different ways. For example, you already found that the design with all the period = 0 cases having Treatment C made it im
47,620
R: Post-hoc test on lmer. emmeans and multcomp packages
I will attempt to answer (2). First, the code given does not produce the results shown. In order to obtain those results, I needed the following manipulations of the data before fitting the model: DF$Treatment = relevel(factor(DF$Treatment), ref = "C") DF$age = as.numeric(DF$age) DF$period = factor(DF$period) In future postings, please actually test the code that is presented to ensure you are accurately representing what happened. Now, on to the question. The emmeans package, unlike many (most) others such as multcomp, tests for estimability. Estimability has to do with ambiguities arising from rank-deficient models. The fact that the model is rank deficient is an important omission from what is shown in the question. Note the warning message: > lm1 <- lmer(lipid~Treatment + sequence + period + sex + age + (1|id), data = DF, REML = F) fixed-effect model matrix is rank deficient so dropping 1 column / coefficient When there is rank deficiency, that means that certain model predictions are not unique; they differ depending on how the model is parameterized. In this case, the model lm1 was fitted with the default contrast coding, contr.treatment, in which 0--1 indicators are used for each factor, with the one for the reference level omitted. With that contrast coding, we obtain the results shown in the OP: (some output is omitted) > library(emmeans) > pairs(emmeans(lm1, "Treatment")) contrast estimate SE df t.ratio p.value C - A nonEst NA NA NA NA C - B nonEst NA NA NA NA A - B -5.12 2.93 23.5 -1.750 0.2078 > library(multcomp) > summary(glht(lm1, linfct = mcp(Treatment = "Tukey")), test = adjusted("fdr")) Estimate Std. Error z value Pr(>|z|) A - C == 0 -2.850 2.857 -0.997 0.463 B - C == 0 2.275 3.102 0.733 0.463 B - A == 0 5.125 2.700 1.898 0.173 (Adjusted p values reported -- fdr method) Now, let's fit the same model using contr.sum codings: > lm2 = update(lm1, contrasts = list(Treatment = "contr.sum", + sequence = "contr.sum", period = "contr.sum", sex = "contr.sum")) fixed-effect model matrix is rank deficient so dropping 1 column / coefficient > fixef(lm2) (Intercept) Treatment1 Treatment2 sequence1 period1 sex1 age 23.6587644 1.6916667 -3.4083333 -2.3539871 -1.1250000 1.9175647 -0.1077586 Note that most of the regression coeffiicients are different from those in lm1, because of the different contrast coding. Now do the same analyses with this model: > pairs(emmeans(lm2, "Treatment")) contrast estimate SE df t.ratio p.value C - A nonEst NA NA NA NA C - B nonEst NA NA NA NA A - B -5.12 2.93 23.5 -1.750 0.2078 > summary(glht(lm2, linfct = mcp(Treatment = "Tukey")), test = adjusted("fdr")) Estimate Std. Error z value Pr(>|z|) A - C == 0 -5.100 5.065 -1.007 0.471 B - C == 0 0.025 4.613 0.005 0.996 B - A == 0 5.125 2.700 1.898 0.173 (Adjusted p values reported -- fdr method) The emmeans results are identical for the two models. However, the multcomp results are different, albeit the same for the B - A contrast. That contrast is the one that is uniquely estimable. I hope this explains why emmeans does not show two of the comparisons, and why multcomp really should test estimability also. I cannot answer why multcomp produces a different standard error for the one estimable comparison.
R: Post-hoc test on lmer. emmeans and multcomp packages
I will attempt to answer (2). First, the code given does not produce the results shown. In order to obtain those results, I needed the following manipulations of the data before fitting the model: DF$
R: Post-hoc test on lmer. emmeans and multcomp packages I will attempt to answer (2). First, the code given does not produce the results shown. In order to obtain those results, I needed the following manipulations of the data before fitting the model: DF$Treatment = relevel(factor(DF$Treatment), ref = "C") DF$age = as.numeric(DF$age) DF$period = factor(DF$period) In future postings, please actually test the code that is presented to ensure you are accurately representing what happened. Now, on to the question. The emmeans package, unlike many (most) others such as multcomp, tests for estimability. Estimability has to do with ambiguities arising from rank-deficient models. The fact that the model is rank deficient is an important omission from what is shown in the question. Note the warning message: > lm1 <- lmer(lipid~Treatment + sequence + period + sex + age + (1|id), data = DF, REML = F) fixed-effect model matrix is rank deficient so dropping 1 column / coefficient When there is rank deficiency, that means that certain model predictions are not unique; they differ depending on how the model is parameterized. In this case, the model lm1 was fitted with the default contrast coding, contr.treatment, in which 0--1 indicators are used for each factor, with the one for the reference level omitted. With that contrast coding, we obtain the results shown in the OP: (some output is omitted) > library(emmeans) > pairs(emmeans(lm1, "Treatment")) contrast estimate SE df t.ratio p.value C - A nonEst NA NA NA NA C - B nonEst NA NA NA NA A - B -5.12 2.93 23.5 -1.750 0.2078 > library(multcomp) > summary(glht(lm1, linfct = mcp(Treatment = "Tukey")), test = adjusted("fdr")) Estimate Std. Error z value Pr(>|z|) A - C == 0 -2.850 2.857 -0.997 0.463 B - C == 0 2.275 3.102 0.733 0.463 B - A == 0 5.125 2.700 1.898 0.173 (Adjusted p values reported -- fdr method) Now, let's fit the same model using contr.sum codings: > lm2 = update(lm1, contrasts = list(Treatment = "contr.sum", + sequence = "contr.sum", period = "contr.sum", sex = "contr.sum")) fixed-effect model matrix is rank deficient so dropping 1 column / coefficient > fixef(lm2) (Intercept) Treatment1 Treatment2 sequence1 period1 sex1 age 23.6587644 1.6916667 -3.4083333 -2.3539871 -1.1250000 1.9175647 -0.1077586 Note that most of the regression coeffiicients are different from those in lm1, because of the different contrast coding. Now do the same analyses with this model: > pairs(emmeans(lm2, "Treatment")) contrast estimate SE df t.ratio p.value C - A nonEst NA NA NA NA C - B nonEst NA NA NA NA A - B -5.12 2.93 23.5 -1.750 0.2078 > summary(glht(lm2, linfct = mcp(Treatment = "Tukey")), test = adjusted("fdr")) Estimate Std. Error z value Pr(>|z|) A - C == 0 -5.100 5.065 -1.007 0.471 B - C == 0 0.025 4.613 0.005 0.996 B - A == 0 5.125 2.700 1.898 0.173 (Adjusted p values reported -- fdr method) The emmeans results are identical for the two models. However, the multcomp results are different, albeit the same for the B - A contrast. That contrast is the one that is uniquely estimable. I hope this explains why emmeans does not show two of the comparisons, and why multcomp really should test estimability also. I cannot answer why multcomp produces a different standard error for the one estimable comparison.
R: Post-hoc test on lmer. emmeans and multcomp packages I will attempt to answer (2). First, the code given does not produce the results shown. In order to obtain those results, I needed the following manipulations of the data before fitting the model: DF$
47,621
R: Post-hoc test on lmer. emmeans and multcomp packages
Following the current advice of removing sequence, I suggest also including period as nested within ID and removing it from fixed effects i.e. lmer(lipid~Treatment + sex + age + (1|id/period), data = DF, REML = F) I have found this guide to be quite helpful: https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#model-specification
R: Post-hoc test on lmer. emmeans and multcomp packages
Following the current advice of removing sequence, I suggest also including period as nested within ID and removing it from fixed effects i.e. lmer(lipid~Treatment + sex + age + (1|id/period), data =
R: Post-hoc test on lmer. emmeans and multcomp packages Following the current advice of removing sequence, I suggest also including period as nested within ID and removing it from fixed effects i.e. lmer(lipid~Treatment + sex + age + (1|id/period), data = DF, REML = F) I have found this guide to be quite helpful: https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#model-specification
R: Post-hoc test on lmer. emmeans and multcomp packages Following the current advice of removing sequence, I suggest also including period as nested within ID and removing it from fixed effects i.e. lmer(lipid~Treatment + sex + age + (1|id/period), data =
47,622
Covariance matrix of the residuals in the linear regression model
After some investigation, I think I found a small (but crucial!) imprecision in what your post. The first formula you wrote : $var(\varepsilon) = \sigma^2 (I - H)$ is actually not totally exact. The formula should be $var(\hat \varepsilon) = \sigma ^2 (I - H)$ where $\hat\varepsilon = Y - \hat\beta X$ considering the OLS estimator $\hat\beta = (X^TX)^{-1}X^TY$. Thus $\hat\sigma(I - H)$ is an estimator of the variance of the estimated residuals associated with OLS estimator. This formula does not suppose independance of the $\varepsilon_i$, just that they all have same variance $\sigma^2$. But this is not what you want! You want an estimate of the variance of the true residuals, not the estimated residuals under OLS estimation. OLS estimator corresponds to maximum likelihood estimator under the hypothesis that residuals are i.i.d. and normal. The estimated residuals can thus be very poor estimates of the true residuals if these hypothesis are not met, and there covariance matrix can be very different from the covariance of the true residuals. The second formula you wrote does correspond to the covariance matrix of the $\varepsilon_i$ under the hypothesis that they follow an AR(1) process. Estimating covariance matrix of the residuals of a linear regression without any asumption cannot easily be done: you would have more unknown than datapoints... So you need to specify some form for the covariance matrix of the residuals. Supposing that they follow an AR(1) process (if this is relevent) is a way of doing so. You can also assume that they have a stationnary parametrized autocorrelation function, whose parameters you can estimate, and use it to deduce the covariance matrix.
Covariance matrix of the residuals in the linear regression model
After some investigation, I think I found a small (but crucial!) imprecision in what your post. The first formula you wrote : $var(\varepsilon) = \sigma^2 (I - H)$ is actually not totally exact. The f
Covariance matrix of the residuals in the linear regression model After some investigation, I think I found a small (but crucial!) imprecision in what your post. The first formula you wrote : $var(\varepsilon) = \sigma^2 (I - H)$ is actually not totally exact. The formula should be $var(\hat \varepsilon) = \sigma ^2 (I - H)$ where $\hat\varepsilon = Y - \hat\beta X$ considering the OLS estimator $\hat\beta = (X^TX)^{-1}X^TY$. Thus $\hat\sigma(I - H)$ is an estimator of the variance of the estimated residuals associated with OLS estimator. This formula does not suppose independance of the $\varepsilon_i$, just that they all have same variance $\sigma^2$. But this is not what you want! You want an estimate of the variance of the true residuals, not the estimated residuals under OLS estimation. OLS estimator corresponds to maximum likelihood estimator under the hypothesis that residuals are i.i.d. and normal. The estimated residuals can thus be very poor estimates of the true residuals if these hypothesis are not met, and there covariance matrix can be very different from the covariance of the true residuals. The second formula you wrote does correspond to the covariance matrix of the $\varepsilon_i$ under the hypothesis that they follow an AR(1) process. Estimating covariance matrix of the residuals of a linear regression without any asumption cannot easily be done: you would have more unknown than datapoints... So you need to specify some form for the covariance matrix of the residuals. Supposing that they follow an AR(1) process (if this is relevent) is a way of doing so. You can also assume that they have a stationnary parametrized autocorrelation function, whose parameters you can estimate, and use it to deduce the covariance matrix.
Covariance matrix of the residuals in the linear regression model After some investigation, I think I found a small (but crucial!) imprecision in what your post. The first formula you wrote : $var(\varepsilon) = \sigma^2 (I - H)$ is actually not totally exact. The f
47,623
Covariance matrix of the residuals in the linear regression model
In basic OLS you don't estimate the covariance matrix of residuals. You assume that errors (not residuals) are spherical, meaning that they're not correlated with each other. Residuals will come out of OLS uncorrelated. What you described as a second method is a different assumption. When applying basic OLS to time series you run into an issue that its assumptions are not practical. In time series the residuals are often correlated. So, you could assume that they're AR(1) process, and that what that method does: it estimates the model assuming the errors are AR(1). This is called feasible generalized least squares
Covariance matrix of the residuals in the linear regression model
In basic OLS you don't estimate the covariance matrix of residuals. You assume that errors (not residuals) are spherical, meaning that they're not correlated with each other. Residuals will come out o
Covariance matrix of the residuals in the linear regression model In basic OLS you don't estimate the covariance matrix of residuals. You assume that errors (not residuals) are spherical, meaning that they're not correlated with each other. Residuals will come out of OLS uncorrelated. What you described as a second method is a different assumption. When applying basic OLS to time series you run into an issue that its assumptions are not practical. In time series the residuals are often correlated. So, you could assume that they're AR(1) process, and that what that method does: it estimates the model assuming the errors are AR(1). This is called feasible generalized least squares
Covariance matrix of the residuals in the linear regression model In basic OLS you don't estimate the covariance matrix of residuals. You assume that errors (not residuals) are spherical, meaning that they're not correlated with each other. Residuals will come out o
47,624
Tukey depth intuition
Bagplot A bagplot is a method in robust statistics for visualizing two- or three-dimensional statistical data, analogous to the one-dimensional box plot. Construction of a Bagplot The bagplot consists of three nested polygons, called the "bag", the "fence", and the "loop". The inner polygon, called the bag, is constructed on the basis of Tukey depth, the smallest number of observations that can be contained by a half-plane that also contains a given point. It contains at most $50\%$ of the data points. For more refer to Functional bagplot An asterisk symbol (*) near the center of the graph is used to mark the depth median, the point with the highest possible Tukey depth. The outermost of the three polygons, called the fence is not drawn as part of the bagplot but is used to construct it. It is formed by inflating the bag by a certain factor (usually 3). Observations outside the fence are flagged as outliers. The observations that are not marked as outliers are surrounded by a loop, the convex hull of the observations within the fence. Tukey Depth Tukey depth is also known as location depth or halfspace depth. The Tukey depth is a measure of the depth of a point in a fixed set of points. Given a finite set $S$ of $n$ points and a point $p$ in $\mathbb{R}^d$, the Tukey depth of $p$ is defined as the minimum number of points of $S$ contained in any closed halfspace with $p$ on its boundary. An equivalent definition is the minimum number of points of $S$ contained in any halfspace which also contains $p$. Many different algorithms have been developed to compute the Tukey depth of a point. This problem is equivalent to the $\textit{maximum feasible subsystem} ~\textrm{(MAX FS)}$ problem which is a long-standing problem and has been extensively studied. Calculating Tukey Depth Suppose points in $S$ are in general position (no $d+1$ points of $S\cup\{p\}$ lie on a common hyperplane), an upper bound on the Tukey depth of $p$ can be obtained by selecting any non-trivial vector $v\in\mathbb{R}^d$ and computing the Tukey depth of $p\cdot v$ in the one-dimensional point set $$S\cdot v=\{x\cdot v:~x {\in} S\}.\tag 1$$ If $v$ is the inner-normal of the boundary of the halfspace $\hbar$ that defines the depth value of $p$, then $$\mathrm{depth}(p,S)=\mathrm{depth}(p\cdot v,S\cdot v).\tag 2$$ In $\mathbb{R}^1$, we rank the points $S\cup\{p\}$ starting with $0$ from both ends to the median, then the depth of $p$ is its rank. More generally, given any $k$-flat $f$ orthogonal to the boundary of $\hbar$ we have $\mathrm{depth}(p,S)=\mathrm{depth}(p\cdot f,S\cdot f),\tag 3$$ where $p\cdot f$ is the orthogonal projection of $p$ onto $f,$ and $S\cdot f$ is the orthogonal projection of $S$ onto $f.$ From this paper Absolute approximation of Tukey depth: Theory and experiments Theorem 1 Let $S$ be a set of $n$ points in general position in $\mathbb{R}^d,~S^1$ be a subset of $d-1$ elements chosen at random and without replacement from $S, v$ be the vector perpendicular to the plane containing $S^1$ and another point $p$, $σ$ be an integer such that $$0\leqslant\sigma\leqslant\left\lfloor\frac nd\right\rfloor-1.$$ Then $$\Pr{\{\mathrm{depth}(p\cdot v,S\cdot v)\leqslant\mathrm{depth}(p,S)+\sigma\}}\geqslant\frac{{\sigma+d-1}\choose{d-1}}{n\choose{d-1}}.$$ Under point/hyperplane duality, the selection of $v$ is equivalent to selecting a random vertex in an arrangement of hyperplanes in $d-1$ dimensions. This selection of $v$ approximates $\text{depth}(p, S)$ to within $\sigma$ provided that the vertex is contained in a particular pseudo-ball of radius $\sigma.$ Therefore the proof boils down to showing that the number of vertices of an arrangement in a pseudo-ball of radius $σ$ is sufficiently large. In particular, we show that the number of vertices in such a pseudo-ball is at least ${\sigma+d-1}\choose{d-1}.$ Calculating Tukey Depth in R Rdocumentation - depth.halfspace to calculate Tukey Depth # NOT RUN { # 3-dimensional normal distribution data <- mvrnorm(200, rep(0, 3), matrix(c(1, 0, 0, 0, 2, 0, 0, 0, 1), nrow = 3)) x <- mvrnorm(10, rep(1, 3), matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1), nrow = 3)) # default - random Tukey depth depths <- depth.halfspace(x, data) cat("Depths: ", depths, "\n") # default exact method - "recursive" depths <- depth.halfspace(x, data, exact = TRUE) cat("Depths: ", depths, "\n") # method "line" depths <- depth.halfspace(x, data, method = "line") cat("Depths: ", depths, "\n") # }
Tukey depth intuition
Bagplot A bagplot is a method in robust statistics for visualizing two- or three-dimensional statistical data, analogous to the one-dimensional box plot. Construction of a Bagplot The bagplot consis
Tukey depth intuition Bagplot A bagplot is a method in robust statistics for visualizing two- or three-dimensional statistical data, analogous to the one-dimensional box plot. Construction of a Bagplot The bagplot consists of three nested polygons, called the "bag", the "fence", and the "loop". The inner polygon, called the bag, is constructed on the basis of Tukey depth, the smallest number of observations that can be contained by a half-plane that also contains a given point. It contains at most $50\%$ of the data points. For more refer to Functional bagplot An asterisk symbol (*) near the center of the graph is used to mark the depth median, the point with the highest possible Tukey depth. The outermost of the three polygons, called the fence is not drawn as part of the bagplot but is used to construct it. It is formed by inflating the bag by a certain factor (usually 3). Observations outside the fence are flagged as outliers. The observations that are not marked as outliers are surrounded by a loop, the convex hull of the observations within the fence. Tukey Depth Tukey depth is also known as location depth or halfspace depth. The Tukey depth is a measure of the depth of a point in a fixed set of points. Given a finite set $S$ of $n$ points and a point $p$ in $\mathbb{R}^d$, the Tukey depth of $p$ is defined as the minimum number of points of $S$ contained in any closed halfspace with $p$ on its boundary. An equivalent definition is the minimum number of points of $S$ contained in any halfspace which also contains $p$. Many different algorithms have been developed to compute the Tukey depth of a point. This problem is equivalent to the $\textit{maximum feasible subsystem} ~\textrm{(MAX FS)}$ problem which is a long-standing problem and has been extensively studied. Calculating Tukey Depth Suppose points in $S$ are in general position (no $d+1$ points of $S\cup\{p\}$ lie on a common hyperplane), an upper bound on the Tukey depth of $p$ can be obtained by selecting any non-trivial vector $v\in\mathbb{R}^d$ and computing the Tukey depth of $p\cdot v$ in the one-dimensional point set $$S\cdot v=\{x\cdot v:~x {\in} S\}.\tag 1$$ If $v$ is the inner-normal of the boundary of the halfspace $\hbar$ that defines the depth value of $p$, then $$\mathrm{depth}(p,S)=\mathrm{depth}(p\cdot v,S\cdot v).\tag 2$$ In $\mathbb{R}^1$, we rank the points $S\cup\{p\}$ starting with $0$ from both ends to the median, then the depth of $p$ is its rank. More generally, given any $k$-flat $f$ orthogonal to the boundary of $\hbar$ we have $\mathrm{depth}(p,S)=\mathrm{depth}(p\cdot f,S\cdot f),\tag 3$$ where $p\cdot f$ is the orthogonal projection of $p$ onto $f,$ and $S\cdot f$ is the orthogonal projection of $S$ onto $f.$ From this paper Absolute approximation of Tukey depth: Theory and experiments Theorem 1 Let $S$ be a set of $n$ points in general position in $\mathbb{R}^d,~S^1$ be a subset of $d-1$ elements chosen at random and without replacement from $S, v$ be the vector perpendicular to the plane containing $S^1$ and another point $p$, $σ$ be an integer such that $$0\leqslant\sigma\leqslant\left\lfloor\frac nd\right\rfloor-1.$$ Then $$\Pr{\{\mathrm{depth}(p\cdot v,S\cdot v)\leqslant\mathrm{depth}(p,S)+\sigma\}}\geqslant\frac{{\sigma+d-1}\choose{d-1}}{n\choose{d-1}}.$$ Under point/hyperplane duality, the selection of $v$ is equivalent to selecting a random vertex in an arrangement of hyperplanes in $d-1$ dimensions. This selection of $v$ approximates $\text{depth}(p, S)$ to within $\sigma$ provided that the vertex is contained in a particular pseudo-ball of radius $\sigma.$ Therefore the proof boils down to showing that the number of vertices of an arrangement in a pseudo-ball of radius $σ$ is sufficiently large. In particular, we show that the number of vertices in such a pseudo-ball is at least ${\sigma+d-1}\choose{d-1}.$ Calculating Tukey Depth in R Rdocumentation - depth.halfspace to calculate Tukey Depth # NOT RUN { # 3-dimensional normal distribution data <- mvrnorm(200, rep(0, 3), matrix(c(1, 0, 0, 0, 2, 0, 0, 0, 1), nrow = 3)) x <- mvrnorm(10, rep(1, 3), matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1), nrow = 3)) # default - random Tukey depth depths <- depth.halfspace(x, data) cat("Depths: ", depths, "\n") # default exact method - "recursive" depths <- depth.halfspace(x, data, exact = TRUE) cat("Depths: ", depths, "\n") # method "line" depths <- depth.halfspace(x, data, method = "line") cat("Depths: ", depths, "\n") # }
Tukey depth intuition Bagplot A bagplot is a method in robust statistics for visualizing two- or three-dimensional statistical data, analogous to the one-dimensional box plot. Construction of a Bagplot The bagplot consis
47,625
Are inconsistent estimators ever preferable? A twist
In the previous question, the example by whuber was actually a cost function that was minimized when the estimate $t$ equals the true parameter value $t=\mu$, Namely it was zero for $\mu \leq t \leq \mu+1$, and thus at the minimum value for $t=\mu$. Edit: The question has changed, but that example by whuber will still work, even when the minimum of the cost function is uniquely located at $t = \mu$. For instance consider this loss function: $$L(t \vert \mu)= \begin{cases} 1 & \quad \text{if} \quad t < \mu \\ (t - \mu)^2& \quad\text{if}\quad \mu \leq t \leq \mu + 1 \\ 1 & \quad\text{if}\quad \mu + 1 < t \end{cases}$$ The consistent estimator, which will approach $\mu$ for $n \to \infty$ will result in an expectation value for the cost of $0.5$, and any estimator with a slight bias overestimating the mean with $d$ will approach $d^2$ as the expectation value for the cost. Continuity The trick of that example is that the cost function had a discontinuity at the 'true parameter'. If instead, the cost/loss function at the true parameter value $L(\mu)$ is continuous then the consistent estimator will approach this value (by the continuous mapping theorem) $$ \lim_{n \to \infty} L(t_n) = L(\mu)$$ Then if $L(\mu)$ is also the lowest possible value $$\forall x\neq \mu : L(\mu) \leq L(x)$$ then the consistent estimator can not be outperformed for all $n$. This is a bit of a handwaving argument, I imagine that there might be some pathological case where the cost function for the consistent estimator and the non-consistent estimator both approach the minimum value but the consistent estimator does this faster. E.g. adjust the cost function for whuber's example to be two blocks with some small size $d$, e.g. 0 for $\mu-d<t<\mu+d$ and 0 for $\mu+0.5-2d<t<\mu+0.5+2d$ and 1 elsewhere. Unique minimum In the case that $$\forall x\neq \mu : L(\mu) < L(x)$$ I can not imagine these pathological cases to remain. (But maybe you should accurately define 'consistency' and 'dominate'/'outperform' because I can imagine discrepancies there, for instance consistent estimators with infinite variance, which will not dominate the variance of the error when compared with a biased estimator with finite variance) Example plots: In the plot below you can see that non-biased estimator is half the time negative (and for negative values the cost function is equal to one) which is why the expected value is >0.5 for any finite sample size. In the next plot you can see that the cost function is at a minimum for the estimator equal to the true value, But, if this is not a unique minimum for the cost function (in the example the cost is 0 for all values $\mu \leq t \leq \mu+1$) then the limit for the biased estimator can be also the minimum value. In addition, the biased estimator has for all finite values a lower expected value of the cost function (because it is in the middle of the place where the cost value is zero, whereas the unbiased estimator is at the edge where the cost function is higher). As noted in the other question. It is not every consistent estimator that performs less good than a non-consistent estimator. In the first example we can make a biased but consistent estimator by letting the bias reduce to zero as the sample size increases, and for this estimator the estimated cost can get as close to zero as we like as long as we can increase the sample size without limit. A comment by Richard Hardy was made related to the second example I also wish we had a better suited vocabulary to discuss these problems. Both of the estimators in your answer are "consistent", but for different targets We could call a consistent estimator an estimator that gets as close to the target value as we like by increasing the sample size. (e.g. close measured by the variance of the difference with the target going to zero). Then If the cost function has a minimum at some point different from the mean (or when the minimum is not uniquely at the mean) then it is a bit trivial that the consistent estimator for the cost function is not necessarily a consistent estimator for the parameter estimate. And we might be able to construct non-consistent estimators (with respect to the parameter estimate) that perform better with respect to the cost. If there is a discontinuity of the cost function at the true parameter value, then not every consistent estimator for the parameter needs to be a consistent estimator for the cost function.
Are inconsistent estimators ever preferable? A twist
In the previous question, the example by whuber was actually a cost function that was minimized when the estimate $t$ equals the true parameter value $t=\mu$, Namely it was zero for $\mu \leq t \leq \
Are inconsistent estimators ever preferable? A twist In the previous question, the example by whuber was actually a cost function that was minimized when the estimate $t$ equals the true parameter value $t=\mu$, Namely it was zero for $\mu \leq t \leq \mu+1$, and thus at the minimum value for $t=\mu$. Edit: The question has changed, but that example by whuber will still work, even when the minimum of the cost function is uniquely located at $t = \mu$. For instance consider this loss function: $$L(t \vert \mu)= \begin{cases} 1 & \quad \text{if} \quad t < \mu \\ (t - \mu)^2& \quad\text{if}\quad \mu \leq t \leq \mu + 1 \\ 1 & \quad\text{if}\quad \mu + 1 < t \end{cases}$$ The consistent estimator, which will approach $\mu$ for $n \to \infty$ will result in an expectation value for the cost of $0.5$, and any estimator with a slight bias overestimating the mean with $d$ will approach $d^2$ as the expectation value for the cost. Continuity The trick of that example is that the cost function had a discontinuity at the 'true parameter'. If instead, the cost/loss function at the true parameter value $L(\mu)$ is continuous then the consistent estimator will approach this value (by the continuous mapping theorem) $$ \lim_{n \to \infty} L(t_n) = L(\mu)$$ Then if $L(\mu)$ is also the lowest possible value $$\forall x\neq \mu : L(\mu) \leq L(x)$$ then the consistent estimator can not be outperformed for all $n$. This is a bit of a handwaving argument, I imagine that there might be some pathological case where the cost function for the consistent estimator and the non-consistent estimator both approach the minimum value but the consistent estimator does this faster. E.g. adjust the cost function for whuber's example to be two blocks with some small size $d$, e.g. 0 for $\mu-d<t<\mu+d$ and 0 for $\mu+0.5-2d<t<\mu+0.5+2d$ and 1 elsewhere. Unique minimum In the case that $$\forall x\neq \mu : L(\mu) < L(x)$$ I can not imagine these pathological cases to remain. (But maybe you should accurately define 'consistency' and 'dominate'/'outperform' because I can imagine discrepancies there, for instance consistent estimators with infinite variance, which will not dominate the variance of the error when compared with a biased estimator with finite variance) Example plots: In the plot below you can see that non-biased estimator is half the time negative (and for negative values the cost function is equal to one) which is why the expected value is >0.5 for any finite sample size. In the next plot you can see that the cost function is at a minimum for the estimator equal to the true value, But, if this is not a unique minimum for the cost function (in the example the cost is 0 for all values $\mu \leq t \leq \mu+1$) then the limit for the biased estimator can be also the minimum value. In addition, the biased estimator has for all finite values a lower expected value of the cost function (because it is in the middle of the place where the cost value is zero, whereas the unbiased estimator is at the edge where the cost function is higher). As noted in the other question. It is not every consistent estimator that performs less good than a non-consistent estimator. In the first example we can make a biased but consistent estimator by letting the bias reduce to zero as the sample size increases, and for this estimator the estimated cost can get as close to zero as we like as long as we can increase the sample size without limit. A comment by Richard Hardy was made related to the second example I also wish we had a better suited vocabulary to discuss these problems. Both of the estimators in your answer are "consistent", but for different targets We could call a consistent estimator an estimator that gets as close to the target value as we like by increasing the sample size. (e.g. close measured by the variance of the difference with the target going to zero). Then If the cost function has a minimum at some point different from the mean (or when the minimum is not uniquely at the mean) then it is a bit trivial that the consistent estimator for the cost function is not necessarily a consistent estimator for the parameter estimate. And we might be able to construct non-consistent estimators (with respect to the parameter estimate) that perform better with respect to the cost. If there is a discontinuity of the cost function at the true parameter value, then not every consistent estimator for the parameter needs to be a consistent estimator for the cost function.
Are inconsistent estimators ever preferable? A twist In the previous question, the example by whuber was actually a cost function that was minimized when the estimate $t$ equals the true parameter value $t=\mu$, Namely it was zero for $\mu \leq t \leq \
47,626
Are inconsistent estimators ever preferable? A twist
I think the correct question here is not whether an inconsistent estimator can be better than one specific consistent estimator. With this question, you can create very lousy consistent estimators that can be beaten by lousy inconsistent estimators. The correct question here seems to be if there aren't any consistent estimators which are guaranteed to be better than all inconsistent estimator given large enough $n$. Both examples here fail to show whether this is the case. In both examples, we can still make the estimate arbitrarily close to the true mean. The trick is simply to start reducing the "correction" we add to the sample mean according to the sample size. The larger the sample size, the less we need to add to the sample mean to make sure we are overestimating. Thus these examples just show that if you use a naive estimator that does not take into account the shape of the loss function, like the sample mean, which is treating underestimation and overestimation in equal footing, then you can do better with a simple naive inconsistent estimator that adds the same constant all the time. But this doesn't mean that you can't adjust the degree of overestimation according to sample size, and thus obtain a consistent estimator that still takes the asymmetric loss function into account. In sum, the problem of the sample mean as an estimator in these examples is not about consistency at all. And the gains of the inconsistent estimator are also not due to its inconsistency.
Are inconsistent estimators ever preferable? A twist
I think the correct question here is not whether an inconsistent estimator can be better than one specific consistent estimator. With this question, you can create very lousy consistent estimators tha
Are inconsistent estimators ever preferable? A twist I think the correct question here is not whether an inconsistent estimator can be better than one specific consistent estimator. With this question, you can create very lousy consistent estimators that can be beaten by lousy inconsistent estimators. The correct question here seems to be if there aren't any consistent estimators which are guaranteed to be better than all inconsistent estimator given large enough $n$. Both examples here fail to show whether this is the case. In both examples, we can still make the estimate arbitrarily close to the true mean. The trick is simply to start reducing the "correction" we add to the sample mean according to the sample size. The larger the sample size, the less we need to add to the sample mean to make sure we are overestimating. Thus these examples just show that if you use a naive estimator that does not take into account the shape of the loss function, like the sample mean, which is treating underestimation and overestimation in equal footing, then you can do better with a simple naive inconsistent estimator that adds the same constant all the time. But this doesn't mean that you can't adjust the degree of overestimation according to sample size, and thus obtain a consistent estimator that still takes the asymmetric loss function into account. In sum, the problem of the sample mean as an estimator in these examples is not about consistency at all. And the gains of the inconsistent estimator are also not due to its inconsistency.
Are inconsistent estimators ever preferable? A twist I think the correct question here is not whether an inconsistent estimator can be better than one specific consistent estimator. With this question, you can create very lousy consistent estimators tha
47,627
Why McFadden's pseudo-R^2?
McFadden's pseudo-$R^2$ is consistent with the log-likelihood model we optimise in logistic regression. The ordinary $R^2$ is consistent with the log-likelihood model for the linear regression. In linear regression, we maximise the log-likelihood: $$ - \sum_i (y_i - \beta x_i)^2 $$ Compare this with the definition of $R^2$: $$ R^2 = 1 - \frac{\sum_i (y_i - \beta x_i)^2}{\sum_i (y_i - \bar y)^2} $$ In the numerator we have the likelihood of our model, and in the denominator the likelihood of the null-model. McFadden's pseudo-$R^2$ is constructed according to the exactly the same schema, just that the log-likelihoods are defined differently for logistic regression. In fact, one can use McFadden's pseudo-$R^2$ for any log-likelihood-based model, just by plugging in the corresponding log-likelihood function. Maybe "generalised $R^2$" would be a more appropriate name. Homo/heteroskedasticity is not the actual issue here. In linear regression it is implied in the log-likelihood (actually each term in the sum can be thought of as divided by $2 \sigma^2$, but that doesn't matter, since it doesn't change the vector $\beta$). But, in logistic regression, variance doesn't figure at all.* *Well, it does on a different level, but we have implicitly accepted that as soon as we agreed on using logistic regression in the first place.
Why McFadden's pseudo-R^2?
McFadden's pseudo-$R^2$ is consistent with the log-likelihood model we optimise in logistic regression. The ordinary $R^2$ is consistent with the log-likelihood model for the linear regression. In lin
Why McFadden's pseudo-R^2? McFadden's pseudo-$R^2$ is consistent with the log-likelihood model we optimise in logistic regression. The ordinary $R^2$ is consistent with the log-likelihood model for the linear regression. In linear regression, we maximise the log-likelihood: $$ - \sum_i (y_i - \beta x_i)^2 $$ Compare this with the definition of $R^2$: $$ R^2 = 1 - \frac{\sum_i (y_i - \beta x_i)^2}{\sum_i (y_i - \bar y)^2} $$ In the numerator we have the likelihood of our model, and in the denominator the likelihood of the null-model. McFadden's pseudo-$R^2$ is constructed according to the exactly the same schema, just that the log-likelihoods are defined differently for logistic regression. In fact, one can use McFadden's pseudo-$R^2$ for any log-likelihood-based model, just by plugging in the corresponding log-likelihood function. Maybe "generalised $R^2$" would be a more appropriate name. Homo/heteroskedasticity is not the actual issue here. In linear regression it is implied in the log-likelihood (actually each term in the sum can be thought of as divided by $2 \sigma^2$, but that doesn't matter, since it doesn't change the vector $\beta$). But, in logistic regression, variance doesn't figure at all.* *Well, it does on a different level, but we have implicitly accepted that as soon as we agreed on using logistic regression in the first place.
Why McFadden's pseudo-R^2? McFadden's pseudo-$R^2$ is consistent with the log-likelihood model we optimise in logistic regression. The ordinary $R^2$ is consistent with the log-likelihood model for the linear regression. In lin
47,628
regarding profile function in the context of linear mixed effects models
Let's start by clarifying what the .sig01 (etc) and .sigma represent in the output from confint(). (I figure that you understand, but other readers might not have studied so diligently.) The .sigma is for the standard deviation of the residual error. The others of the form .sig0n are for the standard deviation estimates for the random effects in the model. The default call to profile() provides these cryptic names (you can instead set 'signames=FALSE' in the call), but as the help page for profile() in lme4 says "these are ordered as in getME(.,"theta")." In this case: > getME(model,"theta") Subject.(Intercept) Subject.Days.(Intercept) Subject.Days 0.96673279 0.01516906 0.23090960 Your call to lmer() allows for random intercepts (Subject.(Intercept)), random slopes (Subject.Days), and correlations between the random slopes and intercepts (Subject.Days.(Intercept)). Next, it helps to put the deviance profile into the broader context of significance tests for models fit by maximum likelihood,* as explained on this page. Instead of just using a slope (score test) or the estimated width (Wald test) of the relationship between log-likelihood and values of an estimated parameter to gauge its significance, you must calculate the entire log-likelihood profile as a function of its possible values around its maximum-likelihood estimate. With multiple parameters estimated, you have to fix in place one of those possible values at a time and then re-optimize all of the others to get the deviance. The entire object returned by profile() combines sets of rows from this analysis for all 6 of the estimated parameters. The number of rows in the object just represents how many specific values of parameters happened to be used for this analysis. The value in the .par column shows which particular parameter was being explicitly varied along a set of rows. In each row within a single set of .par values, the value for the column of the corresponding parameter shows a choice of a value around its maximum-likelihood value, and those for the columns of the other parameters are their re-optimized estimates given that choice for the parameter being varied. That leaves .zeta. Section 5.1 of the lmer vignette describes in detail where that comes from. For each row (a choice of a parameter and its value), it's a transformation of the likelihood-ratio test statistic to put it on the scale of a standard normal distribution. We apply a signed square root transformation to this statistic and plot the resulting function, which we call the profile zeta function or ζ, versus the parameter value. The signed aspect of this transformation means that ζ is positive where the deviation from the parameter estimate is positive and negative otherwise, leading to a monotonically increasing function which is zero at the global optimum. A ζ value can be compared to the quantiles of the standard normal distribution. For example, a 95% profile deviance confidence interval on the parameter consists of the values for which −1.96 < ζ < 1.96. You should find that the 95% confidence intervals reported by confint() for a parameter correspond to its values interpolated at ζ = -1.96 and ζ = 1.96 when it was the parameter being deliberately varied (the rows with its name in the .par column). Note that the issues around significance tests and confidence intervals for mixed-model parameter estimates can be quite difficult. Ben Bolker's FAQ page provides one good source for initial discussion and entry into the literature, and for discussion of additional issues when you move from standard linear to generalized linear mixed models. Bootstrapping or (pseudo or fully) Bayesian approaches might be considered if you are already willing to pay the extra computational cost of profile likelihood calculations. *I'm ignoring for simplicity the distinction between REML, the default in your lmer() call, and maximum likelihood.
regarding profile function in the context of linear mixed effects models
Let's start by clarifying what the .sig01 (etc) and .sigma represent in the output from confint(). (I figure that you understand, but other readers might not have studied so diligently.) The .sigma is
regarding profile function in the context of linear mixed effects models Let's start by clarifying what the .sig01 (etc) and .sigma represent in the output from confint(). (I figure that you understand, but other readers might not have studied so diligently.) The .sigma is for the standard deviation of the residual error. The others of the form .sig0n are for the standard deviation estimates for the random effects in the model. The default call to profile() provides these cryptic names (you can instead set 'signames=FALSE' in the call), but as the help page for profile() in lme4 says "these are ordered as in getME(.,"theta")." In this case: > getME(model,"theta") Subject.(Intercept) Subject.Days.(Intercept) Subject.Days 0.96673279 0.01516906 0.23090960 Your call to lmer() allows for random intercepts (Subject.(Intercept)), random slopes (Subject.Days), and correlations between the random slopes and intercepts (Subject.Days.(Intercept)). Next, it helps to put the deviance profile into the broader context of significance tests for models fit by maximum likelihood,* as explained on this page. Instead of just using a slope (score test) or the estimated width (Wald test) of the relationship between log-likelihood and values of an estimated parameter to gauge its significance, you must calculate the entire log-likelihood profile as a function of its possible values around its maximum-likelihood estimate. With multiple parameters estimated, you have to fix in place one of those possible values at a time and then re-optimize all of the others to get the deviance. The entire object returned by profile() combines sets of rows from this analysis for all 6 of the estimated parameters. The number of rows in the object just represents how many specific values of parameters happened to be used for this analysis. The value in the .par column shows which particular parameter was being explicitly varied along a set of rows. In each row within a single set of .par values, the value for the column of the corresponding parameter shows a choice of a value around its maximum-likelihood value, and those for the columns of the other parameters are their re-optimized estimates given that choice for the parameter being varied. That leaves .zeta. Section 5.1 of the lmer vignette describes in detail where that comes from. For each row (a choice of a parameter and its value), it's a transformation of the likelihood-ratio test statistic to put it on the scale of a standard normal distribution. We apply a signed square root transformation to this statistic and plot the resulting function, which we call the profile zeta function or ζ, versus the parameter value. The signed aspect of this transformation means that ζ is positive where the deviation from the parameter estimate is positive and negative otherwise, leading to a monotonically increasing function which is zero at the global optimum. A ζ value can be compared to the quantiles of the standard normal distribution. For example, a 95% profile deviance confidence interval on the parameter consists of the values for which −1.96 < ζ < 1.96. You should find that the 95% confidence intervals reported by confint() for a parameter correspond to its values interpolated at ζ = -1.96 and ζ = 1.96 when it was the parameter being deliberately varied (the rows with its name in the .par column). Note that the issues around significance tests and confidence intervals for mixed-model parameter estimates can be quite difficult. Ben Bolker's FAQ page provides one good source for initial discussion and entry into the literature, and for discussion of additional issues when you move from standard linear to generalized linear mixed models. Bootstrapping or (pseudo or fully) Bayesian approaches might be considered if you are already willing to pay the extra computational cost of profile likelihood calculations. *I'm ignoring for simplicity the distinction between REML, the default in your lmer() call, and maximum likelihood.
regarding profile function in the context of linear mixed effects models Let's start by clarifying what the .sig01 (etc) and .sigma represent in the output from confint(). (I figure that you understand, but other readers might not have studied so diligently.) The .sigma is
47,629
What is the $dF(X)$ in some integrals concerning probability densities?
This notation refers to the Lebesgue-Stieltjes integral and $F$ is the cumulative distribution function of the random variable under consideration. This integral form is a useful way to write expectations of functions of random variables in cases where you want to include both continuous and discrete cases (and mixed cases). In the event that $Z$ is a continuous random variable with density function $f_Z$ we obtain: $$R(\alpha) = \int Q(z, \alpha) dF(z) = \int Q(z, \alpha) f_Z(z) dz.$$ In the event that $Z$ is a discrete random variable with mass function $f_Z$ we obtain: $$R(\alpha) = \int Q(z, \alpha) dF(z) = \sum_z Q(z, \alpha) f_z(z).$$ If $dF$ is to be considered an object of its own (as opposed to just being a component of the notation of the Lebesgue-Stieltjes integral) then its meaning must be established by context and usage. It usually refers to an infinitesimal induced by the cumulative distribution function $F$, which is technically a linear map. With a slight abuse of notation it might refer to a measure, depending on context and usage. What is certainly true is that the cumulative distribution function $F$ induces a unique probability measure for $X$ (this follows from the famous Carathéodory extension theorem) and we can write the Lebesgue-Stieltjes integral as a Lebesgue integral with respect to that measure. It is usual to denote this measure with some standard measure notation such as $\mu_Z$, $\mathbb{P}_Z$, etc. I suppose it is possible that some texts might use the notation $dF$ for this measure, but that would not be standard notation, and it would be confusing.
What is the $dF(X)$ in some integrals concerning probability densities?
This notation refers to the Lebesgue-Stieltjes integral and $F$ is the cumulative distribution function of the random variable under consideration. This integral form is a useful way to write expecta
What is the $dF(X)$ in some integrals concerning probability densities? This notation refers to the Lebesgue-Stieltjes integral and $F$ is the cumulative distribution function of the random variable under consideration. This integral form is a useful way to write expectations of functions of random variables in cases where you want to include both continuous and discrete cases (and mixed cases). In the event that $Z$ is a continuous random variable with density function $f_Z$ we obtain: $$R(\alpha) = \int Q(z, \alpha) dF(z) = \int Q(z, \alpha) f_Z(z) dz.$$ In the event that $Z$ is a discrete random variable with mass function $f_Z$ we obtain: $$R(\alpha) = \int Q(z, \alpha) dF(z) = \sum_z Q(z, \alpha) f_z(z).$$ If $dF$ is to be considered an object of its own (as opposed to just being a component of the notation of the Lebesgue-Stieltjes integral) then its meaning must be established by context and usage. It usually refers to an infinitesimal induced by the cumulative distribution function $F$, which is technically a linear map. With a slight abuse of notation it might refer to a measure, depending on context and usage. What is certainly true is that the cumulative distribution function $F$ induces a unique probability measure for $X$ (this follows from the famous Carathéodory extension theorem) and we can write the Lebesgue-Stieltjes integral as a Lebesgue integral with respect to that measure. It is usual to denote this measure with some standard measure notation such as $\mu_Z$, $\mathbb{P}_Z$, etc. I suppose it is possible that some texts might use the notation $dF$ for this measure, but that would not be standard notation, and it would be confusing.
What is the $dF(X)$ in some integrals concerning probability densities? This notation refers to the Lebesgue-Stieltjes integral and $F$ is the cumulative distribution function of the random variable under consideration. This integral form is a useful way to write expecta
47,630
How can I find the asymptotic variance of the MLE of $\beta$ for $f_y(y|\beta,\mathbf{x})=\frac{\beta x}{1+\beta x}(\frac{1}{1+\beta x})^{y-1}$?
Your present working appears to be taking all the $x_i$ values to be the same, which is not sufficient generality to properly describe your problem. In your initial setup for the problem there is no stipulation that these values must be the same. Taking the values $\mathbf{x} = (x_1,...,x_n)$ to be fixed explanatory variables, your response variables are independent (but not identically distributed) geometric random variables: $$y_i | \mathbf{x} \sim \text{Geom}(\theta_i) \quad \quad \quad \theta_i \equiv \frac{\beta x_i}{1 + \beta x_i}.$$ As you can see, this generality makes the problem much more complicated than how you are treating it. If the $x_i$ values are different to each other then the response variables $y_i$ are not identically distributed, which will give you a more complicated likelihood function than what you are using. As shown below, this leads to an MLE that is defined (in general) only by an implicit function. Finding the MLE: To get you back on track, I will show you how to derive the implicit equation for the MLE. For the observed data $\mathbf{y} = (y_1,...,y_n)$ we have the log-likelihood function: $$\begin{aligned} \ell_{\mathbf{y}}(\beta) &= \sum_{i=1}^n \ln \text{Geom} \bigg( y_i \Bigg| \frac{\beta x_i}{1 + \beta x_i} \bigg) \\[6pt] &= \sum_{i=1}^n \Big[ \ln(\beta) + \ln(x_i) - y_i \ln(1+\beta x_i) \Big] \\[6pt] &= n \ln(\beta) + \sum_{i=1}^n \ln(x_i) - \sum_{i=1}^n y_i \ln(1+\beta x_i). \\[6pt] \end{aligned}$$ So you have the score function and Hessian function: $$\begin{aligned} s_\mathbf{y}(\beta) \equiv \frac{\partial \ell_{\mathbf{y}}}{\partial \beta} (\beta) &= \frac{n}{\beta} - \sum_{i=1}^n \frac{x_i y_i}{1+\beta x_i}, \\[6pt] H_\mathbf{y}(\beta) \equiv \frac{\partial^2 \ell_{\mathbf{y}}}{\partial \beta^2} (\beta) &= - \frac{n}{\beta^2} + \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\beta x_i)^2}. \\[6pt] \end{aligned}$$ At any critical point $\hat{\beta}$ (satisfying the critical point equation $s_\mathbf{y}(\hat{\beta}) =0$) you have: $$\begin{aligned} H_\mathbf{y}(\hat{\beta}) &= - \frac{n}{\hat{\beta}^2} + \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\hat{\beta} x_i)^2} \\[6pt] &= - \Bigg[ \frac{1}{n} \bigg( \sum_{i=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i} \bigg)^2 - \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\hat{\beta} x_i)^2} \Bigg] \\[6pt] &= - \Bigg[ \frac{1}{n} \bigg( \sum_{i=1}^n \sum_{j=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i} \frac{x_j y_j}{1+\hat{\beta} x_j} \bigg) - \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\hat{\beta} x_i)^2} \Bigg] \\[6pt] &= - \sum_{i=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i} \bigg( \frac{1}{n} \sum_{j=1}^n \frac{x_j y_j}{1+\hat{\beta} x_j} - \frac{x_i}{1+\hat{\beta} x_i} \bigg). \\[6pt] \end{aligned}$$ The maximising point is defined implicitly by the critical point equation: $$\frac{n}{\hat{\beta}} = \sum_{i=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i}.$$ In the special case where $x \equiv x_1 = \cdots = x_n$ you have $\hat{\beta} = 1/(x (\bar{y}_n-1))$, but this explicit result does not hold in general. Finding the asymptotic distribution of the MLE: If you want to find the asymptotic variance of the MLE, there are a few ways to do it. The complicated way is to differentiate the implicit function multiple times to get a Taylor approximation to the MLE, and then use this to get an asymptotic result for the variance of the MLE. That is quite a bit of work, and I will leave you to do it if you want to, but the above should get you started by giving you the correct equation for the MLE. You can read more about dealing with implicitly defined random variables using Taylor series and the delta method in Benichou and Gail (1989). The simpler way to get the MLE is to rely on asymptotic theory for MLEs. Under some regularity conditions, you have the asymptotic distribution: $$\sqrt{n}(\hat{\beta} - \beta)\overset{\rightarrow}{\sim} \text{N} \bigg( 0, \frac{1}{\mathcal{I}(\beta)} \bigg),$$ where $\mathcal{I}$ is the expected Fisher information for a single observation. Since $\mathbb{E}(\theta_i Y_i) = 1$ and $\mathbb{E}(\theta_i^2 Y_i^2) = 2-\theta_i$, in this case we have the Fisher information function for $n$ observations as being: $$\begin{aligned} n\mathcal{I}(\beta) &= \mathbb{E}(s_\mathbf{Y}(\beta)^2) \\[6pt] &= \mathbb{E} \Bigg( \bigg( \frac{n}{\beta} - \sum_{i=1}^n \frac{x_i Y_i}{1+\beta x_i} \bigg)^2 \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \mathbb{E} \Bigg( \bigg( 1 - \frac{1}{n} \sum_{i=1}^n \theta_i Y_i \bigg)^2 \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \mathbb{E} \Bigg( 1 - \frac{2}{n} \sum_{i=1}^n \theta_i Y_i + \frac{1}{n^2} \sum_{i=1}^n \sum_{j=1}^n \theta_i \theta_j Y_i Y_j \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \mathbb{E} \Bigg( 1 - \frac{2}{n} \sum_{i=1}^n \theta_i Y_i + \frac{1}{n^2} \sum_{i=1}^n \theta_i^2 Y_i^2 + \frac{1}{n^2} \sum_{i \neq j} \theta_i \theta_j Y_i Y_j \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \Bigg( 1 - 2 + \frac{1}{n^2} \sum_{i=1}^n (2-\theta_i) + \frac{n-1}{n} \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \Bigg( 1 - 2 + \frac{2}{n} - \frac{1}{n^2} \sum_{i=1}^n \theta_i + 1 - \frac{1}{n} \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \Bigg( \frac{1}{n} - \frac{1}{n^2} \sum_{i=1}^n \theta_i \Bigg) \\[6pt] &= \frac{n(1 - \bar{\theta}_n)}{\beta^2}. \\[6pt] \end{aligned}$$ Here is an alternative derivation using the regularity conditions: $$\begin{aligned} n\mathcal{I}(\beta) &= -\mathbb{E}(H_\mathbf{Y}(\beta)) \\[6pt] &= \mathbb{E} \Bigg( \frac{n}{\beta^2} - \sum_{i=1}^n \frac{x_i^2 Y_i}{(1+\beta x_i)^2} \Bigg) \\[6pt] &= \frac{n}{\beta^2} \cdot \mathbb{E} \Bigg( 1 - \frac{1}{n} \sum_{i=1}^n \theta_i^2 Y_i \Bigg) \\[6pt] &= \frac{n}{\beta^2} \cdot \Bigg( 1 - \frac{1}{n} \sum_{i=1}^n \theta_i \Bigg) \\[6pt] &= \frac{n(1-\bar{\theta}_n)}{\beta^2}. \\[6pt] \end{aligned}$$ So in this case you have the asymptotic variance: $$\frac{1}{\mathcal{I}(\beta)} = \frac{\beta^2}{(1 - \bar{\theta}_\infty)}$$ where $\bar\theta_\infty = \lim_{n\rightarrow\infty} \bar\theta_n$. Based on this, for large but finite sample sizes, a large-sample variance for your estimator $\hat\beta$ is given by $$\mathbb{V}(\hat{\beta}) \approx \frac{\hat\beta^2}{n(1 - \bar{\theta}_n)}$$
How can I find the asymptotic variance of the MLE of $\beta$ for $f_y(y|\beta,\mathbf{x})=\frac{\bet
Your present working appears to be taking all the $x_i$ values to be the same, which is not sufficient generality to properly describe your problem. In your initial setup for the problem there is no
How can I find the asymptotic variance of the MLE of $\beta$ for $f_y(y|\beta,\mathbf{x})=\frac{\beta x}{1+\beta x}(\frac{1}{1+\beta x})^{y-1}$? Your present working appears to be taking all the $x_i$ values to be the same, which is not sufficient generality to properly describe your problem. In your initial setup for the problem there is no stipulation that these values must be the same. Taking the values $\mathbf{x} = (x_1,...,x_n)$ to be fixed explanatory variables, your response variables are independent (but not identically distributed) geometric random variables: $$y_i | \mathbf{x} \sim \text{Geom}(\theta_i) \quad \quad \quad \theta_i \equiv \frac{\beta x_i}{1 + \beta x_i}.$$ As you can see, this generality makes the problem much more complicated than how you are treating it. If the $x_i$ values are different to each other then the response variables $y_i$ are not identically distributed, which will give you a more complicated likelihood function than what you are using. As shown below, this leads to an MLE that is defined (in general) only by an implicit function. Finding the MLE: To get you back on track, I will show you how to derive the implicit equation for the MLE. For the observed data $\mathbf{y} = (y_1,...,y_n)$ we have the log-likelihood function: $$\begin{aligned} \ell_{\mathbf{y}}(\beta) &= \sum_{i=1}^n \ln \text{Geom} \bigg( y_i \Bigg| \frac{\beta x_i}{1 + \beta x_i} \bigg) \\[6pt] &= \sum_{i=1}^n \Big[ \ln(\beta) + \ln(x_i) - y_i \ln(1+\beta x_i) \Big] \\[6pt] &= n \ln(\beta) + \sum_{i=1}^n \ln(x_i) - \sum_{i=1}^n y_i \ln(1+\beta x_i). \\[6pt] \end{aligned}$$ So you have the score function and Hessian function: $$\begin{aligned} s_\mathbf{y}(\beta) \equiv \frac{\partial \ell_{\mathbf{y}}}{\partial \beta} (\beta) &= \frac{n}{\beta} - \sum_{i=1}^n \frac{x_i y_i}{1+\beta x_i}, \\[6pt] H_\mathbf{y}(\beta) \equiv \frac{\partial^2 \ell_{\mathbf{y}}}{\partial \beta^2} (\beta) &= - \frac{n}{\beta^2} + \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\beta x_i)^2}. \\[6pt] \end{aligned}$$ At any critical point $\hat{\beta}$ (satisfying the critical point equation $s_\mathbf{y}(\hat{\beta}) =0$) you have: $$\begin{aligned} H_\mathbf{y}(\hat{\beta}) &= - \frac{n}{\hat{\beta}^2} + \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\hat{\beta} x_i)^2} \\[6pt] &= - \Bigg[ \frac{1}{n} \bigg( \sum_{i=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i} \bigg)^2 - \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\hat{\beta} x_i)^2} \Bigg] \\[6pt] &= - \Bigg[ \frac{1}{n} \bigg( \sum_{i=1}^n \sum_{j=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i} \frac{x_j y_j}{1+\hat{\beta} x_j} \bigg) - \sum_{i=1}^n \frac{x_i^2 y_i}{(1+\hat{\beta} x_i)^2} \Bigg] \\[6pt] &= - \sum_{i=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i} \bigg( \frac{1}{n} \sum_{j=1}^n \frac{x_j y_j}{1+\hat{\beta} x_j} - \frac{x_i}{1+\hat{\beta} x_i} \bigg). \\[6pt] \end{aligned}$$ The maximising point is defined implicitly by the critical point equation: $$\frac{n}{\hat{\beta}} = \sum_{i=1}^n \frac{x_i y_i}{1+\hat{\beta} x_i}.$$ In the special case where $x \equiv x_1 = \cdots = x_n$ you have $\hat{\beta} = 1/(x (\bar{y}_n-1))$, but this explicit result does not hold in general. Finding the asymptotic distribution of the MLE: If you want to find the asymptotic variance of the MLE, there are a few ways to do it. The complicated way is to differentiate the implicit function multiple times to get a Taylor approximation to the MLE, and then use this to get an asymptotic result for the variance of the MLE. That is quite a bit of work, and I will leave you to do it if you want to, but the above should get you started by giving you the correct equation for the MLE. You can read more about dealing with implicitly defined random variables using Taylor series and the delta method in Benichou and Gail (1989). The simpler way to get the MLE is to rely on asymptotic theory for MLEs. Under some regularity conditions, you have the asymptotic distribution: $$\sqrt{n}(\hat{\beta} - \beta)\overset{\rightarrow}{\sim} \text{N} \bigg( 0, \frac{1}{\mathcal{I}(\beta)} \bigg),$$ where $\mathcal{I}$ is the expected Fisher information for a single observation. Since $\mathbb{E}(\theta_i Y_i) = 1$ and $\mathbb{E}(\theta_i^2 Y_i^2) = 2-\theta_i$, in this case we have the Fisher information function for $n$ observations as being: $$\begin{aligned} n\mathcal{I}(\beta) &= \mathbb{E}(s_\mathbf{Y}(\beta)^2) \\[6pt] &= \mathbb{E} \Bigg( \bigg( \frac{n}{\beta} - \sum_{i=1}^n \frac{x_i Y_i}{1+\beta x_i} \bigg)^2 \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \mathbb{E} \Bigg( \bigg( 1 - \frac{1}{n} \sum_{i=1}^n \theta_i Y_i \bigg)^2 \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \mathbb{E} \Bigg( 1 - \frac{2}{n} \sum_{i=1}^n \theta_i Y_i + \frac{1}{n^2} \sum_{i=1}^n \sum_{j=1}^n \theta_i \theta_j Y_i Y_j \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \mathbb{E} \Bigg( 1 - \frac{2}{n} \sum_{i=1}^n \theta_i Y_i + \frac{1}{n^2} \sum_{i=1}^n \theta_i^2 Y_i^2 + \frac{1}{n^2} \sum_{i \neq j} \theta_i \theta_j Y_i Y_j \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \Bigg( 1 - 2 + \frac{1}{n^2} \sum_{i=1}^n (2-\theta_i) + \frac{n-1}{n} \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \Bigg( 1 - 2 + \frac{2}{n} - \frac{1}{n^2} \sum_{i=1}^n \theta_i + 1 - \frac{1}{n} \Bigg) \\[6pt] &= \frac{n^2}{\beta^2} \cdot \Bigg( \frac{1}{n} - \frac{1}{n^2} \sum_{i=1}^n \theta_i \Bigg) \\[6pt] &= \frac{n(1 - \bar{\theta}_n)}{\beta^2}. \\[6pt] \end{aligned}$$ Here is an alternative derivation using the regularity conditions: $$\begin{aligned} n\mathcal{I}(\beta) &= -\mathbb{E}(H_\mathbf{Y}(\beta)) \\[6pt] &= \mathbb{E} \Bigg( \frac{n}{\beta^2} - \sum_{i=1}^n \frac{x_i^2 Y_i}{(1+\beta x_i)^2} \Bigg) \\[6pt] &= \frac{n}{\beta^2} \cdot \mathbb{E} \Bigg( 1 - \frac{1}{n} \sum_{i=1}^n \theta_i^2 Y_i \Bigg) \\[6pt] &= \frac{n}{\beta^2} \cdot \Bigg( 1 - \frac{1}{n} \sum_{i=1}^n \theta_i \Bigg) \\[6pt] &= \frac{n(1-\bar{\theta}_n)}{\beta^2}. \\[6pt] \end{aligned}$$ So in this case you have the asymptotic variance: $$\frac{1}{\mathcal{I}(\beta)} = \frac{\beta^2}{(1 - \bar{\theta}_\infty)}$$ where $\bar\theta_\infty = \lim_{n\rightarrow\infty} \bar\theta_n$. Based on this, for large but finite sample sizes, a large-sample variance for your estimator $\hat\beta$ is given by $$\mathbb{V}(\hat{\beta}) \approx \frac{\hat\beta^2}{n(1 - \bar{\theta}_n)}$$
How can I find the asymptotic variance of the MLE of $\beta$ for $f_y(y|\beta,\mathbf{x})=\frac{\bet Your present working appears to be taking all the $x_i$ values to be the same, which is not sufficient generality to properly describe your problem. In your initial setup for the problem there is no
47,631
What are continuous distributions that are additive and have finite support
A minimal example is obtained by taking literally any distribution with compact support on the nonnegative reals. Letting $F$ be its cumulative distribution function, this means there exist $0\le a\le b$ for which $F(a)=0$ and $F(b)=1.$ Repeated convolution produces the sequence of distribution functions $F_n,$ $n=1,2,3,\ldots,$ for which $F_1 = F$ and for all $n\ge 1,$ $$F_{n+1}(x) = \int_{\mathbb{R}} F_n(x-y)\,\mathrm{d} F(y).$$ Because this corresponds to addition of random variables, the support of $F_n$ is contained in the interval $[na,nb],$ which is compact and non-negative. When $X_n$ is a random variable with distribution $F_n$ and $X_m$ a random variable with distribution $F_m,$ this ensures that $X_n+X_m$ has distribution $F_{n+m},$ showing this family $(F_n)$ is closed under addition. Its parameter is $n.$ When $F$ is a continuous distribution, so is $F_n.$ Thus, $(F_n)$ satisfies all the requirements of the question. At https://stats.stackexchange.com/a/43075/919 I describe such a family explicitly (and in great detail) where $F$ is the Uniform$(0,1)$ distribution. This shows that the construction of $(F_n)$ is not just an abstraction: it can lead to distributions with computable formulas and concrete applications. It might be objected that $n$ can attain only integral values. We can try to fix that. If there were such a family associated with all positive real $n$ it would be infinitely divisible: for all $n,$ the distribution $F_n$ could be expressed as the convolution of $F_{n/2}$ with itself, or generally the $k$-fold convolution of $F_{n/k}$ for any whole number $k.$ The Wikipedia article on infinite divisibility asserts that apart from atomic distributions (which concentrate all probability on a single value), there exist no infinitely divisible family of distributions with "bounded (finite) support." It does not prove this, but refers to Sato, Ken-iti (1999), Lévy Processes and Infinitely Divisible Distributions for the details. The minimal example can, however, be enlarged by adding in other distributions. For instance, by adding in any atomic distribution supported on a non-negative value $\mu$ we can introduce a location parameter. In effect, writing $$F_{n;\mu}(x) = F_n(x-\mu)$$ we create a two-parameter family where the parameter $n$ must be a whole number and $\mu$ can be any non-negative real number. These distributions are supported on the intervals $[na+\mu,nb+\mu]$ which are non-negative and compact. For corresponding random variables $X_{n;\nu}$ and $X_{m;\mu},$ clearly $$X_{n;\nu}+X_{m;\mu}$$ has $F_{m+n;\mu+\nu}$ for its distribution. Thus, the family $$(F_{n;\mu}),\, n=1,2,3,\ldots;\, \mu \ge 0$$ satisfies the condition of the question. We can generate larger families very generally by emulating this process of combining two families of distributions under addition. When $(G_n)$ is also an additively closed family of distributions with non-negative compact support, then for any pairs of whole numbers $m$ and $n$ let $H_{m,n}$ be the distribution of $X_m+Y_n$ where $X_m\sim F_m$ and $Y_n\sim G_n.$ The family $(H_{m,n},\, m=1,2,3,\ldots;\, n=1,2,3,\ldots)$ satisfies all the conditions of the question. This process can be repeated as many times as you like. In a specific sense, all solutions to this problem arise in this way. When $\mathcal F$ is any set of distributions with compact non-negative support, define the "additive closure" of $\mathcal F$ to be the intersection of all sets of distributions that are additively closed and include $\mathcal F.$ This intersection exists because the set of all distributions is one such set. All additively closed families obviously equal their own additive closures. As we noted before, the only distributions in $\mathcal F$ that can be infinitely divisible would have to be atomic.
What are continuous distributions that are additive and have finite support
A minimal example is obtained by taking literally any distribution with compact support on the nonnegative reals. Letting $F$ be its cumulative distribution function, this means there exist $0\le a\l
What are continuous distributions that are additive and have finite support A minimal example is obtained by taking literally any distribution with compact support on the nonnegative reals. Letting $F$ be its cumulative distribution function, this means there exist $0\le a\le b$ for which $F(a)=0$ and $F(b)=1.$ Repeated convolution produces the sequence of distribution functions $F_n,$ $n=1,2,3,\ldots,$ for which $F_1 = F$ and for all $n\ge 1,$ $$F_{n+1}(x) = \int_{\mathbb{R}} F_n(x-y)\,\mathrm{d} F(y).$$ Because this corresponds to addition of random variables, the support of $F_n$ is contained in the interval $[na,nb],$ which is compact and non-negative. When $X_n$ is a random variable with distribution $F_n$ and $X_m$ a random variable with distribution $F_m,$ this ensures that $X_n+X_m$ has distribution $F_{n+m},$ showing this family $(F_n)$ is closed under addition. Its parameter is $n.$ When $F$ is a continuous distribution, so is $F_n.$ Thus, $(F_n)$ satisfies all the requirements of the question. At https://stats.stackexchange.com/a/43075/919 I describe such a family explicitly (and in great detail) where $F$ is the Uniform$(0,1)$ distribution. This shows that the construction of $(F_n)$ is not just an abstraction: it can lead to distributions with computable formulas and concrete applications. It might be objected that $n$ can attain only integral values. We can try to fix that. If there were such a family associated with all positive real $n$ it would be infinitely divisible: for all $n,$ the distribution $F_n$ could be expressed as the convolution of $F_{n/2}$ with itself, or generally the $k$-fold convolution of $F_{n/k}$ for any whole number $k.$ The Wikipedia article on infinite divisibility asserts that apart from atomic distributions (which concentrate all probability on a single value), there exist no infinitely divisible family of distributions with "bounded (finite) support." It does not prove this, but refers to Sato, Ken-iti (1999), Lévy Processes and Infinitely Divisible Distributions for the details. The minimal example can, however, be enlarged by adding in other distributions. For instance, by adding in any atomic distribution supported on a non-negative value $\mu$ we can introduce a location parameter. In effect, writing $$F_{n;\mu}(x) = F_n(x-\mu)$$ we create a two-parameter family where the parameter $n$ must be a whole number and $\mu$ can be any non-negative real number. These distributions are supported on the intervals $[na+\mu,nb+\mu]$ which are non-negative and compact. For corresponding random variables $X_{n;\nu}$ and $X_{m;\mu},$ clearly $$X_{n;\nu}+X_{m;\mu}$$ has $F_{m+n;\mu+\nu}$ for its distribution. Thus, the family $$(F_{n;\mu}),\, n=1,2,3,\ldots;\, \mu \ge 0$$ satisfies the condition of the question. We can generate larger families very generally by emulating this process of combining two families of distributions under addition. When $(G_n)$ is also an additively closed family of distributions with non-negative compact support, then for any pairs of whole numbers $m$ and $n$ let $H_{m,n}$ be the distribution of $X_m+Y_n$ where $X_m\sim F_m$ and $Y_n\sim G_n.$ The family $(H_{m,n},\, m=1,2,3,\ldots;\, n=1,2,3,\ldots)$ satisfies all the conditions of the question. This process can be repeated as many times as you like. In a specific sense, all solutions to this problem arise in this way. When $\mathcal F$ is any set of distributions with compact non-negative support, define the "additive closure" of $\mathcal F$ to be the intersection of all sets of distributions that are additively closed and include $\mathcal F.$ This intersection exists because the set of all distributions is one such set. All additively closed families obviously equal their own additive closures. As we noted before, the only distributions in $\mathcal F$ that can be infinitely divisible would have to be atomic.
What are continuous distributions that are additive and have finite support A minimal example is obtained by taking literally any distribution with compact support on the nonnegative reals. Letting $F$ be its cumulative distribution function, this means there exist $0\le a\l
47,632
What are continuous distributions that are additive and have finite support
Let $X$ and $Y$ are from same continues distribution with finite support $(a,b)$. so $a<X<b$ and $a<Y<b$ , in-hence $2a<X+Y<2b$. Since the support of $X+Y$ equal to $(2a,2b)$ so I think it can not be happen. at least one of $a$ , $b$ $\rightarrow$ $\infty$ and other should be zero. like Chi-square distribution.
What are continuous distributions that are additive and have finite support
Let $X$ and $Y$ are from same continues distribution with finite support $(a,b)$. so $a<X<b$ and $a<Y<b$ , in-hence $2a<X+Y<2b$. Since the support of $X+Y$ equal to $(2a,2b)$ so I think it can not b
What are continuous distributions that are additive and have finite support Let $X$ and $Y$ are from same continues distribution with finite support $(a,b)$. so $a<X<b$ and $a<Y<b$ , in-hence $2a<X+Y<2b$. Since the support of $X+Y$ equal to $(2a,2b)$ so I think it can not be happen. at least one of $a$ , $b$ $\rightarrow$ $\infty$ and other should be zero. like Chi-square distribution.
What are continuous distributions that are additive and have finite support Let $X$ and $Y$ are from same continues distribution with finite support $(a,b)$. so $a<X<b$ and $a<Y<b$ , in-hence $2a<X+Y<2b$. Since the support of $X+Y$ equal to $(2a,2b)$ so I think it can not b
47,633
Sufficient Statistics - Relating the Intuition with the Mathematical Definition
I think a common way to motivate the mathematical definition is the following. Say you have the sufficient statistic $T(X)$, and I just have the data/random sample $X$. By the mathematical definition of sufficiency, $$ p(X|T(X), \theta) = P(X|T(X)).$$ The r.h.s. is a probability distribution you, again per definition and in theory, know, and can use to do inference. In particular, if you draw a sample $X' \sim P(X'|T(X))$, then this sample is also a draw from the distribution of interest, in particular, the distribution that depends directly on $\theta$. But you have now recovered a sample using just the sufficient statistic that contains as much information as the original sample $X$. Thus just using your sufficient statistic you can infer just as much (confidence intervals, for example) as me who enjoyed access to the full sample $X$, and it is therefore sufficient to know $T(X)$.
Sufficient Statistics - Relating the Intuition with the Mathematical Definition
I think a common way to motivate the mathematical definition is the following. Say you have the sufficient statistic $T(X)$, and I just have the data/random sample $X$. By the mathematical definition
Sufficient Statistics - Relating the Intuition with the Mathematical Definition I think a common way to motivate the mathematical definition is the following. Say you have the sufficient statistic $T(X)$, and I just have the data/random sample $X$. By the mathematical definition of sufficiency, $$ p(X|T(X), \theta) = P(X|T(X)).$$ The r.h.s. is a probability distribution you, again per definition and in theory, know, and can use to do inference. In particular, if you draw a sample $X' \sim P(X'|T(X))$, then this sample is also a draw from the distribution of interest, in particular, the distribution that depends directly on $\theta$. But you have now recovered a sample using just the sufficient statistic that contains as much information as the original sample $X$. Thus just using your sufficient statistic you can infer just as much (confidence intervals, for example) as me who enjoyed access to the full sample $X$, and it is therefore sufficient to know $T(X)$.
Sufficient Statistics - Relating the Intuition with the Mathematical Definition I think a common way to motivate the mathematical definition is the following. Say you have the sufficient statistic $T(X)$, and I just have the data/random sample $X$. By the mathematical definition
47,634
Sufficient Statistics - Relating the Intuition with the Mathematical Definition
"A statistic t=T(X) is sufficient for underlying parameter θ precisely if the conditional probability distribution of the data X, given the statistic t = T(X), does not depend on the parameter θ." If the sampling distribution for some data $X$ does not depend on $\theta$ then how can that data say anything about $\theta$? It would be like estimating some value by observing something irrelevant (that does not depend on the value to be estimated). This is a general statement. In this case we have more specifically as data 'the rest of the data conditional on the sufficient statistic'. And that is confusing because the sample distribution for the rest of the data does depend on the parameter to be estimated. It is only that the conditional distribution of that data does not depend on the parameter to estimated. example 3 (different outcomes of data, but with the same probability for a given $\theta$) (edit: based on the comments I came up with a much more simple/intuitive explanation) Say you do a urn problem trying to estimate the fraction of blue balls in an urn. You perform an experiment by drawing balls with replacement. Say you got "$x_1 = red$, $x_2 = blue$, $x_3 = red$, $x_4 = blue$, $x_5 = blue$" That is 3 blue balls in total (the total is the sufficient statistic). You could base on this a point estimate of 0.6 for the fraction of blue balls in the urn. (in reality you should take a bigger sample if you want to make a confidence interval with a narrow bandwith, but that makes this example difficult to write down) Now, does it matter (for the fraction) which particular balls $x_i$ where blue (beyond the fact that we already know the total number 3)? Is the estimate gonna be different for "$x_1 = blue$, $x_2 = red$, $x_3 = red$, $x_4 = blue$, $x_5 = blue$" or any other different observation that also has 3 blue balls in total? Each of these outcomes, with a total of 3 blue balls, are equally possible. So they will not give more information about the fraction of balls in the urn. We could tabulate all the different outcomes and how the probability of observing them depends on $\theta$ (the fraction of blue in the vase) observation probability of observing given theta bbbbb (1-theta)^0(theta)^5 rbbbb (1-theta)^1(theta)^4 brbbb (1-theta)^1(theta)^4 bbrbb (1-theta)^1(theta)^4 bbbrb (1-theta)^1(theta)^4 bbbbr (1-theta)^1(theta)^4 rrbbb (1-theta)^2(theta)^3 rbrbb (1-theta)^2(theta)^3 rbbrb (1-theta)^2(theta)^3 rbbbr (1-theta)^2(theta)^3 brrbb (1-theta)^2(theta)^3 brbrb (1-theta)^2(theta)^3 brbbr (1-theta)^2(theta)^3 bbrrb (1-theta)^2(theta)^3 bbrbr (1-theta)^2(theta)^3 bbbrr (1-theta)^2(theta)^3 rrrbb (1-theta)^3(theta)^2 rrbrb (1-theta)^3(theta)^2 rbrrb (1-theta)^3(theta)^2 brrrb (1-theta)^3(theta)^2 rrbbr (1-theta)^3(theta)^2 rbrbr (1-theta)^3(theta)^2 brrbr (1-theta)^3(theta)^2 rbbrr (1-theta)^3(theta)^2 brbrr (1-theta)^3(theta)^2 bbrrr (1-theta)^3(theta)^2 brrrr (1-theta)^4(theta)^1 rbrrr (1-theta)^4(theta)^1 rrbrr (1-theta)^4(theta)^1 rrrbr (1-theta)^4(theta)^1 rrrrb (1-theta)^4(theta)^1 rrrrr (1-theta)^5(theta)^0 Notice that in this table above there are groups of potential observations/outcomes for which the probability to be observed have exactly the same dependency on $\theta$. This means that it doesn't matter whether you observe rbrbb or brrbb, they relate to $\theta$ in the same way. All the observations with three blue balls can be considered to provide the same information about $\theta$. This is sort of what the sufficient statistic does. It groups together the observations whose Likelihood dependency on $\theta$ is the same. I have deleted examples 1 and 2, because it makes the post very large, but you can still see them in the history of this post
Sufficient Statistics - Relating the Intuition with the Mathematical Definition
"A statistic t=T(X) is sufficient for underlying parameter θ precisely if the conditional probability distribution of the data X, given the statistic t = T(X), does not depend on the parameter θ." If
Sufficient Statistics - Relating the Intuition with the Mathematical Definition "A statistic t=T(X) is sufficient for underlying parameter θ precisely if the conditional probability distribution of the data X, given the statistic t = T(X), does not depend on the parameter θ." If the sampling distribution for some data $X$ does not depend on $\theta$ then how can that data say anything about $\theta$? It would be like estimating some value by observing something irrelevant (that does not depend on the value to be estimated). This is a general statement. In this case we have more specifically as data 'the rest of the data conditional on the sufficient statistic'. And that is confusing because the sample distribution for the rest of the data does depend on the parameter to be estimated. It is only that the conditional distribution of that data does not depend on the parameter to estimated. example 3 (different outcomes of data, but with the same probability for a given $\theta$) (edit: based on the comments I came up with a much more simple/intuitive explanation) Say you do a urn problem trying to estimate the fraction of blue balls in an urn. You perform an experiment by drawing balls with replacement. Say you got "$x_1 = red$, $x_2 = blue$, $x_3 = red$, $x_4 = blue$, $x_5 = blue$" That is 3 blue balls in total (the total is the sufficient statistic). You could base on this a point estimate of 0.6 for the fraction of blue balls in the urn. (in reality you should take a bigger sample if you want to make a confidence interval with a narrow bandwith, but that makes this example difficult to write down) Now, does it matter (for the fraction) which particular balls $x_i$ where blue (beyond the fact that we already know the total number 3)? Is the estimate gonna be different for "$x_1 = blue$, $x_2 = red$, $x_3 = red$, $x_4 = blue$, $x_5 = blue$" or any other different observation that also has 3 blue balls in total? Each of these outcomes, with a total of 3 blue balls, are equally possible. So they will not give more information about the fraction of balls in the urn. We could tabulate all the different outcomes and how the probability of observing them depends on $\theta$ (the fraction of blue in the vase) observation probability of observing given theta bbbbb (1-theta)^0(theta)^5 rbbbb (1-theta)^1(theta)^4 brbbb (1-theta)^1(theta)^4 bbrbb (1-theta)^1(theta)^4 bbbrb (1-theta)^1(theta)^4 bbbbr (1-theta)^1(theta)^4 rrbbb (1-theta)^2(theta)^3 rbrbb (1-theta)^2(theta)^3 rbbrb (1-theta)^2(theta)^3 rbbbr (1-theta)^2(theta)^3 brrbb (1-theta)^2(theta)^3 brbrb (1-theta)^2(theta)^3 brbbr (1-theta)^2(theta)^3 bbrrb (1-theta)^2(theta)^3 bbrbr (1-theta)^2(theta)^3 bbbrr (1-theta)^2(theta)^3 rrrbb (1-theta)^3(theta)^2 rrbrb (1-theta)^3(theta)^2 rbrrb (1-theta)^3(theta)^2 brrrb (1-theta)^3(theta)^2 rrbbr (1-theta)^3(theta)^2 rbrbr (1-theta)^3(theta)^2 brrbr (1-theta)^3(theta)^2 rbbrr (1-theta)^3(theta)^2 brbrr (1-theta)^3(theta)^2 bbrrr (1-theta)^3(theta)^2 brrrr (1-theta)^4(theta)^1 rbrrr (1-theta)^4(theta)^1 rrbrr (1-theta)^4(theta)^1 rrrbr (1-theta)^4(theta)^1 rrrrb (1-theta)^4(theta)^1 rrrrr (1-theta)^5(theta)^0 Notice that in this table above there are groups of potential observations/outcomes for which the probability to be observed have exactly the same dependency on $\theta$. This means that it doesn't matter whether you observe rbrbb or brrbb, they relate to $\theta$ in the same way. All the observations with three blue balls can be considered to provide the same information about $\theta$. This is sort of what the sufficient statistic does. It groups together the observations whose Likelihood dependency on $\theta$ is the same. I have deleted examples 1 and 2, because it makes the post very large, but you can still see them in the history of this post
Sufficient Statistics - Relating the Intuition with the Mathematical Definition "A statistic t=T(X) is sufficient for underlying parameter θ precisely if the conditional probability distribution of the data X, given the statistic t = T(X), does not depend on the parameter θ." If
47,635
Sufficient Statistics - Relating the Intuition with the Mathematical Definition
Here is a very simple example that might make things clear. For a normal model $X\sim N(\theta,1)$ with a sample size of $n=1$, $X$ is sufficient for $\theta$. Without conditioning on $T(X)=X$, then $P(X\le x)=\Phi(x-\theta)$ depends on $\theta$. If I condition on $T(X)=X=c$ then $$ P(X\le x|X=c)=\left\{\begin{array}{ll} 0 & \text{if } x < c\\ 1 & \text{if } x \ge c \end{array} \right.$$ does not depend on $\theta$. This shows that once $T(X)$ is known there is no other information available for estimating $\theta$. If there was additional information available then $P(X\le x|T(X)=c)$ would depend on $\theta$ just like $P(X\le x)$ did (and certainly would not be degenerate). Let me known if I have made any mistakes.
Sufficient Statistics - Relating the Intuition with the Mathematical Definition
Here is a very simple example that might make things clear. For a normal model $X\sim N(\theta,1)$ with a sample size of $n=1$, $X$ is sufficient for $\theta$. Without conditioning on $T(X)=X$, then
Sufficient Statistics - Relating the Intuition with the Mathematical Definition Here is a very simple example that might make things clear. For a normal model $X\sim N(\theta,1)$ with a sample size of $n=1$, $X$ is sufficient for $\theta$. Without conditioning on $T(X)=X$, then $P(X\le x)=\Phi(x-\theta)$ depends on $\theta$. If I condition on $T(X)=X=c$ then $$ P(X\le x|X=c)=\left\{\begin{array}{ll} 0 & \text{if } x < c\\ 1 & \text{if } x \ge c \end{array} \right.$$ does not depend on $\theta$. This shows that once $T(X)$ is known there is no other information available for estimating $\theta$. If there was additional information available then $P(X\le x|T(X)=c)$ would depend on $\theta$ just like $P(X\le x)$ did (and certainly would not be degenerate). Let me known if I have made any mistakes.
Sufficient Statistics - Relating the Intuition with the Mathematical Definition Here is a very simple example that might make things clear. For a normal model $X\sim N(\theta,1)$ with a sample size of $n=1$, $X$ is sufficient for $\theta$. Without conditioning on $T(X)=X$, then
47,636
Was Amazon's AI tool, more than human recruiters, biased against women?
This is not a full answer. In the question I mentioned one way how I can imagine a small bias being amplified. In this question I write it down in more detail. I consider this way of amplification a bit trivial and wonder whether there are more reasons why Amazon's recruitment tool was considered biased, especially why it was biased because AI was being used and amplified the bias in the data. Say that some model is fitted to predict a probability that a 'candidate in a particular class' is being hired/successful or not (like logistic regression). In these probabilities there might be 'only' a slight bias against women due to being based on biased history of hiring. We could plot this as a distribution by ranking the classes that are occurring in the population according to how high the probability of success is and as a function of this probability describe how many people are in a related class. Below this is done for men and women separately with hypothetical beta distributions (parameters 3,3 and 2.75,3.25) and for these women have a slight disadvantage and, on average, have a ~8% less probability to be hired. Sidenote: these distributions might in practice/reality be more like discrete distributions The big problem with these numbers occurs when some classification is being made in the tails. E.g. if this model would be used in proactive recruitment and is used to scan profiles on large databases of potential recruits. For such purpose many candidates are being scanned and we do not want a large false positive error rate, so say that we set a boundary at 0.9 probability that a recruit would be successful. In that case we see that suddenly there are double as many male candidates as female candidates. Is there something else? For me the problems in this way of recruitment are not in the inner mechanics of some algorithm and some black box algorithm that we do not understand that is making magical mistakes and wrongly selecting candidates because it is misinterpreting words like "woman's chess club" (the estimates of probability might be very accurate, so no mistake there) or can't handle unbalanced data. But instead it is due to the dichotomous classification which only selected people from the tails. That is a human choice and not intrinsic to the fact of using an algorithm or human. When Amazon is replacing the recruitment tool by humans then it might just again become biased (or even more biased). Among high potential recruits a human might just as well place mostly men (or at least that appears to be what they did in history). It are the human recruiters that, for certain given properties (that relate to a high probability success), bias men in favor of women. This bias has not been amplified, it is only filtered out by the strict choice of only recruiting high potential candidates. Are there other modes that amplify bias? Edit, interaction with unbalanced data and the effect of selecting tails After writing this answer, I realize now that there is an interaction in this 'comparison of tails' and 'unbalanced data'. In the example above I use two distributions with different means, but it would also occur if the distributions have different variance (or it will especially occur in those cases and the means don't need to differ at all). This difference in variation could occur when some machine learning algorithm is trained on mostly male resume's which makes it very good at classifying men (e.g. relating mostly to activities that correlate with being men like certain sports activities or membership of gender specific clubs). Such training on men is creating a large variance in the predicted probabilities (the model is good at classifying men), and being able to assign to men more often extreme probability categories. Then the scores that are generated by the model could look like: On average, the model/algorithm does not assign a different probability of recruitment success to women, but it might place women more often in the middle categories which might be less interesting to recruiters.
Was Amazon's AI tool, more than human recruiters, biased against women?
This is not a full answer. In the question I mentioned one way how I can imagine a small bias being amplified. In this question I write it down in more detail. I consider this way of amplification a b
Was Amazon's AI tool, more than human recruiters, biased against women? This is not a full answer. In the question I mentioned one way how I can imagine a small bias being amplified. In this question I write it down in more detail. I consider this way of amplification a bit trivial and wonder whether there are more reasons why Amazon's recruitment tool was considered biased, especially why it was biased because AI was being used and amplified the bias in the data. Say that some model is fitted to predict a probability that a 'candidate in a particular class' is being hired/successful or not (like logistic regression). In these probabilities there might be 'only' a slight bias against women due to being based on biased history of hiring. We could plot this as a distribution by ranking the classes that are occurring in the population according to how high the probability of success is and as a function of this probability describe how many people are in a related class. Below this is done for men and women separately with hypothetical beta distributions (parameters 3,3 and 2.75,3.25) and for these women have a slight disadvantage and, on average, have a ~8% less probability to be hired. Sidenote: these distributions might in practice/reality be more like discrete distributions The big problem with these numbers occurs when some classification is being made in the tails. E.g. if this model would be used in proactive recruitment and is used to scan profiles on large databases of potential recruits. For such purpose many candidates are being scanned and we do not want a large false positive error rate, so say that we set a boundary at 0.9 probability that a recruit would be successful. In that case we see that suddenly there are double as many male candidates as female candidates. Is there something else? For me the problems in this way of recruitment are not in the inner mechanics of some algorithm and some black box algorithm that we do not understand that is making magical mistakes and wrongly selecting candidates because it is misinterpreting words like "woman's chess club" (the estimates of probability might be very accurate, so no mistake there) or can't handle unbalanced data. But instead it is due to the dichotomous classification which only selected people from the tails. That is a human choice and not intrinsic to the fact of using an algorithm or human. When Amazon is replacing the recruitment tool by humans then it might just again become biased (or even more biased). Among high potential recruits a human might just as well place mostly men (or at least that appears to be what they did in history). It are the human recruiters that, for certain given properties (that relate to a high probability success), bias men in favor of women. This bias has not been amplified, it is only filtered out by the strict choice of only recruiting high potential candidates. Are there other modes that amplify bias? Edit, interaction with unbalanced data and the effect of selecting tails After writing this answer, I realize now that there is an interaction in this 'comparison of tails' and 'unbalanced data'. In the example above I use two distributions with different means, but it would also occur if the distributions have different variance (or it will especially occur in those cases and the means don't need to differ at all). This difference in variation could occur when some machine learning algorithm is trained on mostly male resume's which makes it very good at classifying men (e.g. relating mostly to activities that correlate with being men like certain sports activities or membership of gender specific clubs). Such training on men is creating a large variance in the predicted probabilities (the model is good at classifying men), and being able to assign to men more often extreme probability categories. Then the scores that are generated by the model could look like: On average, the model/algorithm does not assign a different probability of recruitment success to women, but it might place women more often in the middle categories which might be less interesting to recruiters.
Was Amazon's AI tool, more than human recruiters, biased against women? This is not a full answer. In the question I mentioned one way how I can imagine a small bias being amplified. In this question I write it down in more detail. I consider this way of amplification a b
47,637
Was Amazon's AI tool, more than human recruiters, biased against women?
Sample selection bias is introduced by the selection of individuals, groups, or data for analysis in such a way that the samples are not representative of the population intended to be analyzed.9 In particular, sample selection bias occurs during data analysis as a result of conditioning on some variables in the dataset (for example, a particular skin color, gender, among others), which in turn can create spurious correlations. For example, in analyzing the effect of motherhood on wages, if the study is restricted to women who are already employed, then the measured effect will be biased as a result of conditioning on employed women.9 Common types of sample selection bias include Berkson's paradox20 and sample truncation.9
Was Amazon's AI tool, more than human recruiters, biased against women?
Sample selection bias is introduced by the selection of individuals, groups, or data for analysis in such a way that the samples are not representative of the population intended to be analyzed.9 In p
Was Amazon's AI tool, more than human recruiters, biased against women? Sample selection bias is introduced by the selection of individuals, groups, or data for analysis in such a way that the samples are not representative of the population intended to be analyzed.9 In particular, sample selection bias occurs during data analysis as a result of conditioning on some variables in the dataset (for example, a particular skin color, gender, among others), which in turn can create spurious correlations. For example, in analyzing the effect of motherhood on wages, if the study is restricted to women who are already employed, then the measured effect will be biased as a result of conditioning on employed women.9 Common types of sample selection bias include Berkson's paradox20 and sample truncation.9
Was Amazon's AI tool, more than human recruiters, biased against women? Sample selection bias is introduced by the selection of individuals, groups, or data for analysis in such a way that the samples are not representative of the population intended to be analyzed.9 In p
47,638
Was Amazon's AI tool, more than human recruiters, biased against women?
One additional thought, not fully explored: Maybe we should think whether overfitting can amplify existing bias. In a linear model (where we understand better what happens), we observe overfitting with coefficents being of too large absolute size. Increased bias against women then may be expressed as the coefficient for gender: female being too large (negative), not only compared to that we believe it should be zero, but also compared to the input data. Or a set of coefficients for input variates that are correlated with gender have large size in opposite directions and do not perfectly cancel themselves, leading to a net outcome that gives a too-sharp distinction between female and male candidates. Or, to put in in a different way: overfitted models tend to be overconfident in their predictions (not well-calibrated in a probabilistic sense). If the "attitude" behind the training data is somewhat reluctant (e.g. due to sexistic bias) to hire women, the overconfident prediction may amplify this into confidently rejecting (most) women. In general, I believe we (machine learning community) don't do overly well in terms of preventing overfitting. I did not check whether this would lead to a bias against the minority class as in systematic effect over a large number of models, but: we have an additional selection effect/publication bias here: even if this effect only leads to high variance: we have a number of minorities or protected classes* (sociologial meaning here). We are (rightly!) concerned if an existing bias against any of these is amplified by the AI. But even if there were only the question of bias against women being amplified, and models were equally likely to amplify or deamplify (bias against men) the input data bias, given that there is historically a bias against women, those models would likely be judged differently. Amplified bias against women is bad (again: rightly so); Deamplified bias against women (or maybe even bias against men) is likely seen more leniently since it counteracts the existing bias. (Personally, I'm not so sure I'd agree with that lenience, I very much prefer countermeasures with negative feedback loop which stop exerting force when there is no more bias.) In any case, a model amplifying bias against women is IMHO more likely to be brought to our attention. *I think it somehow weird if we women are considered a 50 % "minority".
Was Amazon's AI tool, more than human recruiters, biased against women?
One additional thought, not fully explored: Maybe we should think whether overfitting can amplify existing bias. In a linear model (where we understand better what happens), we observe overfitting wit
Was Amazon's AI tool, more than human recruiters, biased against women? One additional thought, not fully explored: Maybe we should think whether overfitting can amplify existing bias. In a linear model (where we understand better what happens), we observe overfitting with coefficents being of too large absolute size. Increased bias against women then may be expressed as the coefficient for gender: female being too large (negative), not only compared to that we believe it should be zero, but also compared to the input data. Or a set of coefficients for input variates that are correlated with gender have large size in opposite directions and do not perfectly cancel themselves, leading to a net outcome that gives a too-sharp distinction between female and male candidates. Or, to put in in a different way: overfitted models tend to be overconfident in their predictions (not well-calibrated in a probabilistic sense). If the "attitude" behind the training data is somewhat reluctant (e.g. due to sexistic bias) to hire women, the overconfident prediction may amplify this into confidently rejecting (most) women. In general, I believe we (machine learning community) don't do overly well in terms of preventing overfitting. I did not check whether this would lead to a bias against the minority class as in systematic effect over a large number of models, but: we have an additional selection effect/publication bias here: even if this effect only leads to high variance: we have a number of minorities or protected classes* (sociologial meaning here). We are (rightly!) concerned if an existing bias against any of these is amplified by the AI. But even if there were only the question of bias against women being amplified, and models were equally likely to amplify or deamplify (bias against men) the input data bias, given that there is historically a bias against women, those models would likely be judged differently. Amplified bias against women is bad (again: rightly so); Deamplified bias against women (or maybe even bias against men) is likely seen more leniently since it counteracts the existing bias. (Personally, I'm not so sure I'd agree with that lenience, I very much prefer countermeasures with negative feedback loop which stop exerting force when there is no more bias.) In any case, a model amplifying bias against women is IMHO more likely to be brought to our attention. *I think it somehow weird if we women are considered a 50 % "minority".
Was Amazon's AI tool, more than human recruiters, biased against women? One additional thought, not fully explored: Maybe we should think whether overfitting can amplify existing bias. In a linear model (where we understand better what happens), we observe overfitting wit
47,639
Was Amazon's AI tool, more than human recruiters, biased against women?
Also, the AI was focusing on patterns that negatively biased women, e.g. "women’s chess club captain" doing worse than "chess club captain". In effect, Amazon’s system taught itself that male candidates were preferable. It penalized resumes that included the word “women’s,” as in “women’s chess club captain.” And it downgraded graduates of two all-women’s colleges, according to people familiar with the matter. They did not specify the names of the schools. This could be a problem where an AI is bad at solving problems. If a "chess club captain" is a bonus on a curriculum vitae then so will be a "women's chess club captain". A human recruiter will understand this immediately. A computer/AI recruiter will not understand this because it has much less understanding of complex patterns that it did not encounter before it has not been trained to 'understand'. A more clear example is Roger Penrose's chess problem For a human this is an obvious draw as black's pieces are all blocked and the three bishops are on black fields making them unable to capture white pieces on white fields. For a computer this is apparently a very difficult problem. It does not understand chess in the way that we do. And it can not figure out the situation in this simple problem. This can make computer/AI recruiters more harsh and stick to old patterns. They are less able to adapt to a situation where more women are applying for specific jobs whereas human recruiters can (if they want). The situation of more and better women applying for jobs is a new situation like Roger Penrose's chess puzzle.
Was Amazon's AI tool, more than human recruiters, biased against women?
Also, the AI was focusing on patterns that negatively biased women, e.g. "women’s chess club captain" doing worse than "chess club captain". In effect, Amazon’s system taught itself that male candida
Was Amazon's AI tool, more than human recruiters, biased against women? Also, the AI was focusing on patterns that negatively biased women, e.g. "women’s chess club captain" doing worse than "chess club captain". In effect, Amazon’s system taught itself that male candidates were preferable. It penalized resumes that included the word “women’s,” as in “women’s chess club captain.” And it downgraded graduates of two all-women’s colleges, according to people familiar with the matter. They did not specify the names of the schools. This could be a problem where an AI is bad at solving problems. If a "chess club captain" is a bonus on a curriculum vitae then so will be a "women's chess club captain". A human recruiter will understand this immediately. A computer/AI recruiter will not understand this because it has much less understanding of complex patterns that it did not encounter before it has not been trained to 'understand'. A more clear example is Roger Penrose's chess problem For a human this is an obvious draw as black's pieces are all blocked and the three bishops are on black fields making them unable to capture white pieces on white fields. For a computer this is apparently a very difficult problem. It does not understand chess in the way that we do. And it can not figure out the situation in this simple problem. This can make computer/AI recruiters more harsh and stick to old patterns. They are less able to adapt to a situation where more women are applying for specific jobs whereas human recruiters can (if they want). The situation of more and better women applying for jobs is a new situation like Roger Penrose's chess puzzle.
Was Amazon's AI tool, more than human recruiters, biased against women? Also, the AI was focusing on patterns that negatively biased women, e.g. "women’s chess club captain" doing worse than "chess club captain". In effect, Amazon’s system taught itself that male candida
47,640
Is a singular fit with no correlations near +/- 1 or variances of zero, a false positive in lme4
Does this mean the warning is a "false positive" and can safely be ignored ? No. A singular fit is quite specifically defined, at least in lme4, which I assume is what you are using. The warning in lme4 comes from a principal components analysis of the variance-covariance matrix of estimated random effects. If this is not of full rank, then the fit is singular. This is the definition of a singular fit. Correlations close to +/- 1 or variances close to zero, are very common symptoms when the random structure is simple, but when it is complex, these symptoms are not always present. A model that has a singular fit is an over-fitted model so it is not a good idea to ignore the warning. For one thing, it will not be generalisable, but also, at least in my experience, such models can always be simplified, and result in much more parsimonious models that are easier to interpret. They are also often underpowered. It is worth bearing in mind that correlations of +/- 1 are possible, but we should take a moment to think what that means.If we had such correlations in our observed data, then our fixed effects model matrix would be rank deficient and our model would be unidentifiable. Common sense would prevail and we would remove one of the variables from the model. The same applies to the random effects structure. Similarly, it is certainly possible that a variance for a random effect is zero. If so why would we wish to retain it ?
Is a singular fit with no correlations near +/- 1 or variances of zero, a false positive in lme4
Does this mean the warning is a "false positive" and can safely be ignored ? No. A singular fit is quite specifically defined, at least in lme4, which I assume is what you are using. The warning i
Is a singular fit with no correlations near +/- 1 or variances of zero, a false positive in lme4 Does this mean the warning is a "false positive" and can safely be ignored ? No. A singular fit is quite specifically defined, at least in lme4, which I assume is what you are using. The warning in lme4 comes from a principal components analysis of the variance-covariance matrix of estimated random effects. If this is not of full rank, then the fit is singular. This is the definition of a singular fit. Correlations close to +/- 1 or variances close to zero, are very common symptoms when the random structure is simple, but when it is complex, these symptoms are not always present. A model that has a singular fit is an over-fitted model so it is not a good idea to ignore the warning. For one thing, it will not be generalisable, but also, at least in my experience, such models can always be simplified, and result in much more parsimonious models that are easier to interpret. They are also often underpowered. It is worth bearing in mind that correlations of +/- 1 are possible, but we should take a moment to think what that means.If we had such correlations in our observed data, then our fixed effects model matrix would be rank deficient and our model would be unidentifiable. Common sense would prevail and we would remove one of the variables from the model. The same applies to the random effects structure. Similarly, it is certainly possible that a variance for a random effect is zero. If so why would we wish to retain it ?
Is a singular fit with no correlations near +/- 1 or variances of zero, a false positive in lme4 Does this mean the warning is a "false positive" and can safely be ignored ? No. A singular fit is quite specifically defined, at least in lme4, which I assume is what you are using. The warning i
47,641
Extract confidence intervals confint() for random estimates of lmer models
Try confint(linear.mod.n, oldNames=FALSE) for more useful labels; .sig02 represents the intercept-slope correlation (which is completely undetermined — the confidence intervals span the entire possible range from -1 to 1 ...)
Extract confidence intervals confint() for random estimates of lmer models
Try confint(linear.mod.n, oldNames=FALSE) for more useful labels; .sig02 represents the intercept-slope correlation (which is completely undetermined — the confidence intervals span the entire possibl
Extract confidence intervals confint() for random estimates of lmer models Try confint(linear.mod.n, oldNames=FALSE) for more useful labels; .sig02 represents the intercept-slope correlation (which is completely undetermined — the confidence intervals span the entire possible range from -1 to 1 ...)
Extract confidence intervals confint() for random estimates of lmer models Try confint(linear.mod.n, oldNames=FALSE) for more useful labels; .sig02 represents the intercept-slope correlation (which is completely undetermined — the confidence intervals span the entire possibl
47,642
Extract confidence intervals confint() for random estimates of lmer models
Welcome to the site, nguyenllp! With random effects (varying parameters) in mixed models, looking at statistical significance of estimates do not make the same sense that they do with fixed effects (non-varying parameters). Instead, we use likelihood ratio testing of competing models to determine whether the added complexity of an additional random effect provides a better fit to the data. In your case, imagine that you had estimated this model first, in which you forced the association between time and n to be the same across ids: model_a <- lmer(n ~ time +(1|id), data = long) Then you ran your model that relaxed the assumption that the association between time and n was the same for each id, by including a random slope for time: model <- lmer(n ~ time +(1+time|id), data = long) To determine whether allowing for this variation provides a better fit to the data, you can run a likelihood ratio test comparing the two models: anova(model_a, model) The likelihood ratio test is $\chi^2$-distributed; here the models differ by two degrees of freedom - one for the random slope variance and the other for the slope-intercept covariance. If the $\chi^2$ test is significant, then you reject the null hypothesis that the two models provide equivalent fit. The less parsimonious model with the random slope provides a better fit to your data. This is how you would justify your model choice in a manuscript.
Extract confidence intervals confint() for random estimates of lmer models
Welcome to the site, nguyenllp! With random effects (varying parameters) in mixed models, looking at statistical significance of estimates do not make the same sense that they do with fixed effects (
Extract confidence intervals confint() for random estimates of lmer models Welcome to the site, nguyenllp! With random effects (varying parameters) in mixed models, looking at statistical significance of estimates do not make the same sense that they do with fixed effects (non-varying parameters). Instead, we use likelihood ratio testing of competing models to determine whether the added complexity of an additional random effect provides a better fit to the data. In your case, imagine that you had estimated this model first, in which you forced the association between time and n to be the same across ids: model_a <- lmer(n ~ time +(1|id), data = long) Then you ran your model that relaxed the assumption that the association between time and n was the same for each id, by including a random slope for time: model <- lmer(n ~ time +(1+time|id), data = long) To determine whether allowing for this variation provides a better fit to the data, you can run a likelihood ratio test comparing the two models: anova(model_a, model) The likelihood ratio test is $\chi^2$-distributed; here the models differ by two degrees of freedom - one for the random slope variance and the other for the slope-intercept covariance. If the $\chi^2$ test is significant, then you reject the null hypothesis that the two models provide equivalent fit. The less parsimonious model with the random slope provides a better fit to your data. This is how you would justify your model choice in a manuscript.
Extract confidence intervals confint() for random estimates of lmer models Welcome to the site, nguyenllp! With random effects (varying parameters) in mixed models, looking at statistical significance of estimates do not make the same sense that they do with fixed effects (
47,643
Putting prior on a function of parameters
Another perspective on this: Yes, of course you can do that, the only question in practice is how you do it. There's several options: You can work out the changes in variables etc. and explicitly define the implied priors on the untransformed variables. This is often impractical / requires a lot of work. If you can define your model in terms of the function of the variables, you can directly apply the prior and just work with the transformed variables. You can use software that lets you specify such a prior and deals with the rest automatically (well, for non-linear transformations, you may have to figure out the determinant of the Jacobian of the transform). One example is Stan, in which you can e.g. specify something like the following: parameters { vector[4] beta; } model { sum(beta) ~ normal(0,1); ... The last approach is what I would use in practice. The only downside is that it may be hard to understand the implied prior on the original parameters, but to explore that, you can sample without data (and look at the resulting prior on the parameters, as well as the prior predictive distribution). As a side remark, this is also very useful for overparameterized models for introducing additional (soft) constraints. E.g. if you have a categorical outcome and 3 parameters $\theta_i$ and your model is $Y_j \sim \text{Categorical}(\text{softmax}(\boldsymbol{\theta}))$, then the $\theta_i$ are only identifiable up to a constant. That actually tends to result in sampling problems, that you can get rid off in this manner.
Putting prior on a function of parameters
Another perspective on this: Yes, of course you can do that, the only question in practice is how you do it. There's several options: You can work out the changes in variables etc. and explicitly de
Putting prior on a function of parameters Another perspective on this: Yes, of course you can do that, the only question in practice is how you do it. There's several options: You can work out the changes in variables etc. and explicitly define the implied priors on the untransformed variables. This is often impractical / requires a lot of work. If you can define your model in terms of the function of the variables, you can directly apply the prior and just work with the transformed variables. You can use software that lets you specify such a prior and deals with the rest automatically (well, for non-linear transformations, you may have to figure out the determinant of the Jacobian of the transform). One example is Stan, in which you can e.g. specify something like the following: parameters { vector[4] beta; } model { sum(beta) ~ normal(0,1); ... The last approach is what I would use in practice. The only downside is that it may be hard to understand the implied prior on the original parameters, but to explore that, you can sample without data (and look at the resulting prior on the parameters, as well as the prior predictive distribution). As a side remark, this is also very useful for overparameterized models for introducing additional (soft) constraints. E.g. if you have a categorical outcome and 3 parameters $\theta_i$ and your model is $Y_j \sim \text{Categorical}(\text{softmax}(\boldsymbol{\theta}))$, then the $\theta_i$ are only identifiable up to a constant. That actually tends to result in sampling problems, that you can get rid off in this manner.
Putting prior on a function of parameters Another perspective on this: Yes, of course you can do that, the only question in practice is how you do it. There's several options: You can work out the changes in variables etc. and explicitly de
47,644
Putting prior on a function of parameters
As I understand your question, I don't know weither this approach has a name ; expect maybe those of change-of-variable. Indeed, by defining a prior on $g(\theta)$, you are simply defining a prior on $\theta$ (assuming $g$ is monotonic, or bijective in multidimensional setting). More formally, using change of variable relationship gives: $$ p(\theta|y) \propto p(y|\theta) \cdot p_{\theta}(\theta) \\ \propto p(y|\theta) \cdot p_{\theta}(g^{-1}(\mu)) \\ \propto p(y|g^{-1}(\mu)) \cdot p_{\mu}(\mu) \cdot \frac{\partial}{\partial \mu}(g^{-1}(\mu)) $$ As you can see, the equivalence between the two formulations (one in $\theta$ and one in $\mu$) involves a third term that must be accounted for to pass from one formulation to another. Finally, consider two points : first, if $g$ is not bijective, the inverse function is not defined and thus you have no way to go back from $\mu$ to $\theta$. Second, regarding your initial formulation -that included the regressors $X$- all I wrote above is still consistent if your replace $\theta$ by $\theta^{'}=[\theta,X]$.
Putting prior on a function of parameters
As I understand your question, I don't know weither this approach has a name ; expect maybe those of change-of-variable. Indeed, by defining a prior on $g(\theta)$, you are simply defining a prior on
Putting prior on a function of parameters As I understand your question, I don't know weither this approach has a name ; expect maybe those of change-of-variable. Indeed, by defining a prior on $g(\theta)$, you are simply defining a prior on $\theta$ (assuming $g$ is monotonic, or bijective in multidimensional setting). More formally, using change of variable relationship gives: $$ p(\theta|y) \propto p(y|\theta) \cdot p_{\theta}(\theta) \\ \propto p(y|\theta) \cdot p_{\theta}(g^{-1}(\mu)) \\ \propto p(y|g^{-1}(\mu)) \cdot p_{\mu}(\mu) \cdot \frac{\partial}{\partial \mu}(g^{-1}(\mu)) $$ As you can see, the equivalence between the two formulations (one in $\theta$ and one in $\mu$) involves a third term that must be accounted for to pass from one formulation to another. Finally, consider two points : first, if $g$ is not bijective, the inverse function is not defined and thus you have no way to go back from $\mu$ to $\theta$. Second, regarding your initial formulation -that included the regressors $X$- all I wrote above is still consistent if your replace $\theta$ by $\theta^{'}=[\theta,X]$.
Putting prior on a function of parameters As I understand your question, I don't know weither this approach has a name ; expect maybe those of change-of-variable. Indeed, by defining a prior on $g(\theta)$, you are simply defining a prior on
47,645
Putting prior on a function of parameters
When you can not compute a posterior for $\mu$ because of missing information in the likelihood Below is a counterexample for a case where the likelihood function $p(y\vert \mu)$ is not uniquely defined by $\mu$, but depends in a more complex way on the vector $\theta$. Say you have the likelihoodfunction: $$Y \vert \theta_1+\theta_2 \sim N(\theta_1+\theta_2,1) \quad \text{with} \quad\theta_1 + \theta_2 \sim N(0,1)$$ Now this is like $$Y \vert \mu \sim N(\mu,1) \quad \text{with} \quad\mu_{prior} \sim N(0,1)$$ and after observing value $Y$ the posterior becomes: $$\mu_{posterior \vert Y} \sim N(1/2 Y,1/2)$$ In the above you can factor out the different $\theta$ from the likelihood function in a single function $\pi (X,\theta_1, ... , \theta_n) = \pi^\prime(g (X, \theta_1, ... , \theta_n)) = \pi ^\prime(\mu)$. That works fine. But say we have now instead some more complicated likelihood function: $$Y \vert \theta_1+\theta_2 \sim N(\theta_1+\theta_2,\theta_1^2) \quad \text{with} \quad\theta_1 + \theta_2 \sim N(0,1)$$ Now this is like $$Y \vert \mu, \theta_1 \sim N(\mu,\theta_1) \quad \text{with} \quad\mu_{prior} \sim N(0,1)$$ Which includes an extra (meta-)parameter $\theta_1$ in the likelihood function and we can not (independent from that meta-parameter) express $\mathbb{P}(Y,\mu)$ from which we could compute the posterior for $\mu$. After observing a value $Y$ the posterior for $\mu$ becomes*: $$\mu_{posterior \vert Y} \sim N( cY,d)$$ with $c = \frac{1}{\theta_1^2+1}$ and $d = \frac{\theta_1^2}{\theta_1^2+1}$ So you can not solve the posterior of $\mu$ for that problem because you have this metaparameter on which it depends as well. When you can not compute $\theta$ based on $\mu$ This problem is a bit like Is it possible to derive joint probabilities from marginals with assumptions about the conditionals? Your distribution for $\mu=g(\theta)$ is turning a joint distribution for multiple variables (if $\theta$ is a vector) into a distribution for a single variable (some 'sort' of marginal distribution). You can not invert this Say in the first example above. You might be able to find the distribution for $\mu = \theta_1 + \theta_2$ like $$\mu_{posterior \vert Y} \sim N(1/2 Y,1/2)$$ But it is not possible to turn this into a joint distribution for $\theta_1$ and $\theta_2$ without more information. *This can be derived by the joint distribution $f(y,\mu\vert \theta_1) = \frac{1}{2 \pi \theta_1} e^{-\frac{1}{2} \left(\frac{(y-\mu)^2}{\theta_1^2}+ \mu^2\right)}$
Putting prior on a function of parameters
When you can not compute a posterior for $\mu$ because of missing information in the likelihood Below is a counterexample for a case where the likelihood function $p(y\vert \mu)$ is not uniquely defin
Putting prior on a function of parameters When you can not compute a posterior for $\mu$ because of missing information in the likelihood Below is a counterexample for a case where the likelihood function $p(y\vert \mu)$ is not uniquely defined by $\mu$, but depends in a more complex way on the vector $\theta$. Say you have the likelihoodfunction: $$Y \vert \theta_1+\theta_2 \sim N(\theta_1+\theta_2,1) \quad \text{with} \quad\theta_1 + \theta_2 \sim N(0,1)$$ Now this is like $$Y \vert \mu \sim N(\mu,1) \quad \text{with} \quad\mu_{prior} \sim N(0,1)$$ and after observing value $Y$ the posterior becomes: $$\mu_{posterior \vert Y} \sim N(1/2 Y,1/2)$$ In the above you can factor out the different $\theta$ from the likelihood function in a single function $\pi (X,\theta_1, ... , \theta_n) = \pi^\prime(g (X, \theta_1, ... , \theta_n)) = \pi ^\prime(\mu)$. That works fine. But say we have now instead some more complicated likelihood function: $$Y \vert \theta_1+\theta_2 \sim N(\theta_1+\theta_2,\theta_1^2) \quad \text{with} \quad\theta_1 + \theta_2 \sim N(0,1)$$ Now this is like $$Y \vert \mu, \theta_1 \sim N(\mu,\theta_1) \quad \text{with} \quad\mu_{prior} \sim N(0,1)$$ Which includes an extra (meta-)parameter $\theta_1$ in the likelihood function and we can not (independent from that meta-parameter) express $\mathbb{P}(Y,\mu)$ from which we could compute the posterior for $\mu$. After observing a value $Y$ the posterior for $\mu$ becomes*: $$\mu_{posterior \vert Y} \sim N( cY,d)$$ with $c = \frac{1}{\theta_1^2+1}$ and $d = \frac{\theta_1^2}{\theta_1^2+1}$ So you can not solve the posterior of $\mu$ for that problem because you have this metaparameter on which it depends as well. When you can not compute $\theta$ based on $\mu$ This problem is a bit like Is it possible to derive joint probabilities from marginals with assumptions about the conditionals? Your distribution for $\mu=g(\theta)$ is turning a joint distribution for multiple variables (if $\theta$ is a vector) into a distribution for a single variable (some 'sort' of marginal distribution). You can not invert this Say in the first example above. You might be able to find the distribution for $\mu = \theta_1 + \theta_2$ like $$\mu_{posterior \vert Y} \sim N(1/2 Y,1/2)$$ But it is not possible to turn this into a joint distribution for $\theta_1$ and $\theta_2$ without more information. *This can be derived by the joint distribution $f(y,\mu\vert \theta_1) = \frac{1}{2 \pi \theta_1} e^{-\frac{1}{2} \left(\frac{(y-\mu)^2}{\theta_1^2}+ \mu^2\right)}$
Putting prior on a function of parameters When you can not compute a posterior for $\mu$ because of missing information in the likelihood Below is a counterexample for a case where the likelihood function $p(y\vert \mu)$ is not uniquely defin
47,646
The lines on my scatterplot for ANCOVA results doesn't look right, personal error or model error?
You appear to be misunderstanding the output from your model. In your code, the line: abline(fit.mice$coefficients[1:2], col="skyblue3") plots a line with the correct intercept, but the wrong slope. fit.mice$coefficients[1] is the intercept, but fit.mice$coefficients[2] is the estimate for treat in the Mice added group, hence this is an offset to the intercept for the Mice added group. What you want for the slope in the Control group is simply the estimate for plants which is fit.mice$coefficients[3]. So: abline(fit.mice$coefficients[1], fit.mice$coefficients[3] , col="skyblue3") Then to plot the line for the Mice added group, the intercept will be the global intercept plus the estimate for treat and the slope will be the estimate for plants plus the interaction term. So: abline(fit.mice$coefficients[1] + fit.mice$coefficients[2], fit.mice$coefficients[3] + fit.mice$coefficients[4], col="salmon")
The lines on my scatterplot for ANCOVA results doesn't look right, personal error or model error?
You appear to be misunderstanding the output from your model. In your code, the line: abline(fit.mice$coefficients[1:2], col="skyblue3") plots a line with the correct intercept, but the wrong slope.
The lines on my scatterplot for ANCOVA results doesn't look right, personal error or model error? You appear to be misunderstanding the output from your model. In your code, the line: abline(fit.mice$coefficients[1:2], col="skyblue3") plots a line with the correct intercept, but the wrong slope. fit.mice$coefficients[1] is the intercept, but fit.mice$coefficients[2] is the estimate for treat in the Mice added group, hence this is an offset to the intercept for the Mice added group. What you want for the slope in the Control group is simply the estimate for plants which is fit.mice$coefficients[3]. So: abline(fit.mice$coefficients[1], fit.mice$coefficients[3] , col="skyblue3") Then to plot the line for the Mice added group, the intercept will be the global intercept plus the estimate for treat and the slope will be the estimate for plants plus the interaction term. So: abline(fit.mice$coefficients[1] + fit.mice$coefficients[2], fit.mice$coefficients[3] + fit.mice$coefficients[4], col="salmon")
The lines on my scatterplot for ANCOVA results doesn't look right, personal error or model error? You appear to be misunderstanding the output from your model. In your code, the line: abline(fit.mice$coefficients[1:2], col="skyblue3") plots a line with the correct intercept, but the wrong slope.
47,647
Fitting a Regression Model to log-log distributed data
Two points: Your data are log-log scaled. So why don't you take the logs of them? Since you expect a sigmoid function behind the data, why not trying fitting it to the data? Below, I model your log-transformed data as a (scaled) difference of two softplus functions, $y = log(1+e^x)$, plus a constant term: $$ y = log(1 + e^{\alpha_1 + \beta x}) - log(1 + e^{\alpha_2 + \beta x}) + C $$ This is a sigmoid function whose linearly rising part can be made as long as necessary: Here is my code: # first, log-convert the data: x = np.log10(df.eps) y = np.log10(df.dist) plt.plot(x, y, 'x', label='log-distance to Solution') # the function to fit: # the difference of two scaled softplus, plus a constant term: func = lambda t, alpha1, alpha2, beta, C : \ np.log(1+np.exp(alpha1 + beta*t)) - \ np.log(1+np.exp(alpha2 + beta*t)) + C # the initial guess for the function parameters: p0 = [12, 6, 2, -4] plt.plot(x, func(x, *p0)) popt, pcov = curve_fit(func, x, y, p0) yfit = func(x, *popt) plt.plot(x, yfit, 'r-') plt.show() and the fitted curve (red) and the initial guess (orange): You are, of course, free to try out other sigmoid functions, especially if you have theoretical reasons to assume a particular form. In this case, the function I used seemed appropriate because of the long linear part in the middle. Edit: And, of course, it is trivial to convert the fitted curve back to the original (non-transformed) scale: yfit_exp = 10**(func(np.log10(df.eps), *popt)) plt.loglog(df.eps, df.dist, 'x') plt.loglog(df.eps, yfit_exp, 'r-') plt.show()
Fitting a Regression Model to log-log distributed data
Two points: Your data are log-log scaled. So why don't you take the logs of them? Since you expect a sigmoid function behind the data, why not trying fitting it to the data? Below, I model your log-
Fitting a Regression Model to log-log distributed data Two points: Your data are log-log scaled. So why don't you take the logs of them? Since you expect a sigmoid function behind the data, why not trying fitting it to the data? Below, I model your log-transformed data as a (scaled) difference of two softplus functions, $y = log(1+e^x)$, plus a constant term: $$ y = log(1 + e^{\alpha_1 + \beta x}) - log(1 + e^{\alpha_2 + \beta x}) + C $$ This is a sigmoid function whose linearly rising part can be made as long as necessary: Here is my code: # first, log-convert the data: x = np.log10(df.eps) y = np.log10(df.dist) plt.plot(x, y, 'x', label='log-distance to Solution') # the function to fit: # the difference of two scaled softplus, plus a constant term: func = lambda t, alpha1, alpha2, beta, C : \ np.log(1+np.exp(alpha1 + beta*t)) - \ np.log(1+np.exp(alpha2 + beta*t)) + C # the initial guess for the function parameters: p0 = [12, 6, 2, -4] plt.plot(x, func(x, *p0)) popt, pcov = curve_fit(func, x, y, p0) yfit = func(x, *popt) plt.plot(x, yfit, 'r-') plt.show() and the fitted curve (red) and the initial guess (orange): You are, of course, free to try out other sigmoid functions, especially if you have theoretical reasons to assume a particular form. In this case, the function I used seemed appropriate because of the long linear part in the middle. Edit: And, of course, it is trivial to convert the fitted curve back to the original (non-transformed) scale: yfit_exp = 10**(func(np.log10(df.eps), *popt)) plt.loglog(df.eps, df.dist, 'x') plt.loglog(df.eps, yfit_exp, 'r-') plt.show()
Fitting a Regression Model to log-log distributed data Two points: Your data are log-log scaled. So why don't you take the logs of them? Since you expect a sigmoid function behind the data, why not trying fitting it to the data? Below, I model your log-
47,648
What is the computational complexity of a 1D convolutional layer?
I realized what may be missing is the number of filters in the layer. Even though they don't have a letter for it in the table, the authors might be assuming implicitly that the order of magnitude of the number of filters is the same as that of the number of depth dimensions. Or even more simply, that the number of filters is equal to $d$ (in that case, the conv layer does not change the depth dimensionality). So, in that case, the time complexity indeed amounts to $\mathcal{O}(k\cdot n \cdot d^2)$ because we're repeating the $\mathcal{O}(k\cdot n \cdot d)$ routine described in the question for each of the $d$ filters.
What is the computational complexity of a 1D convolutional layer?
I realized what may be missing is the number of filters in the layer. Even though they don't have a letter for it in the table, the authors might be assuming implicitly that the order of magnitude of
What is the computational complexity of a 1D convolutional layer? I realized what may be missing is the number of filters in the layer. Even though they don't have a letter for it in the table, the authors might be assuming implicitly that the order of magnitude of the number of filters is the same as that of the number of depth dimensions. Or even more simply, that the number of filters is equal to $d$ (in that case, the conv layer does not change the depth dimensionality). So, in that case, the time complexity indeed amounts to $\mathcal{O}(k\cdot n \cdot d^2)$ because we're repeating the $\mathcal{O}(k\cdot n \cdot d)$ routine described in the question for each of the $d$ filters.
What is the computational complexity of a 1D convolutional layer? I realized what may be missing is the number of filters in the layer. Even though they don't have a letter for it in the table, the authors might be assuming implicitly that the order of magnitude of
47,649
Non-tautological explanation for why do low-probability events happen rarely?
Probabilities are units used to quantify statements like "I don't need umbrella today, because it's unlikely to rain". They measure what they measure because this is how we defined them. What you mention are different possible interpretations of probability. There are different possible interpretations, because "probability does not exist" as said by Bruno de Finetti, it is just something we use to quantify statements like "likely", "unlikely", "equally possible" etc.
Non-tautological explanation for why do low-probability events happen rarely?
Probabilities are units used to quantify statements like "I don't need umbrella today, because it's unlikely to rain". They measure what they measure because this is how we defined them. What you ment
Non-tautological explanation for why do low-probability events happen rarely? Probabilities are units used to quantify statements like "I don't need umbrella today, because it's unlikely to rain". They measure what they measure because this is how we defined them. What you mention are different possible interpretations of probability. There are different possible interpretations, because "probability does not exist" as said by Bruno de Finetti, it is just something we use to quantify statements like "likely", "unlikely", "equally possible" etc.
Non-tautological explanation for why do low-probability events happen rarely? Probabilities are units used to quantify statements like "I don't need umbrella today, because it's unlikely to rain". They measure what they measure because this is how we defined them. What you ment
47,650
Non-tautological explanation for why do low-probability events happen rarely?
By definition (or measurement), low probability events rarely happen. But your example of your choice to take an umbrella suggests your underlying inquiry really has more to do with decision-making under uncertainty. You might find Daniel Kahneman's book "Thinking, fast and slow" to be a good guide to understanding such issues.
Non-tautological explanation for why do low-probability events happen rarely?
By definition (or measurement), low probability events rarely happen. But your example of your choice to take an umbrella suggests your underlying inquiry really has more to do with decision-making un
Non-tautological explanation for why do low-probability events happen rarely? By definition (or measurement), low probability events rarely happen. But your example of your choice to take an umbrella suggests your underlying inquiry really has more to do with decision-making under uncertainty. You might find Daniel Kahneman's book "Thinking, fast and slow" to be a good guide to understanding such issues.
Non-tautological explanation for why do low-probability events happen rarely? By definition (or measurement), low probability events rarely happen. But your example of your choice to take an umbrella suggests your underlying inquiry really has more to do with decision-making un
47,651
Overfitting the validation set
One thing that is not widely appreciated is that over-fitting the model selection criteria (e.g. validation set performance) can result in a model that over-fits the training data or it can result in a model that underfits the training data. This example is from my paper (with Mrs Marsupial) Gavin C. Cawley, Nicola L. C. Talbot, "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation", Journal of Machine Learning Research, 11(70):2079−2107, 2010. (www) Here is a heat-map for the model selection criteria for tuning the hyper-parameters of a Least-Squares Support Vector Machine (or Kernel Ridge Regression model) with different training & validation samples. The training set of 256 patterns is identical each time, but a new sample of 64 patterns is used for each validation set. The criterion is a smoothed error rate on the validation set. You can see there is considerable variation between splits in the optimal hyper-parameters (yellow crosses) Here are the corresponding models, as you can see there is large variation in whether the models over- or under-fit the data. If you set the hyper-parameters in the position shown in (d) you tend to get a sensible model for all training-test splits, which suggest the problem is in over-fitting the model selection criterion. In this case, as it is only the validation set that changes, we know this is purely due to over-fitting the validation set during model selection. Consider a classification task, where there are 1000 binary features and one binary response variable, but they are all generated by flipping a fair coin. We then make ten models, each of which is given a disjoint set of 100 of the attributes. We form a training set of 10 patterns, a validation set of 10 patterns and a test set of 1,000,000 patterns. Note that the validation, test and training sets are entirely independent because all of the data is generated at random with no underlying structure. Each model generates it's output by picking the attribute that is most similar to the response variable for the training set out of the 100 attributes it has to choose from. If it is predicting a sequence of 10 random binary values using 100 similar sequences of 10 random variables, then it is highly likely to have an accuracy on the training set greater than 0.5, just by random chance. But we know the true optimal error rate of 0.5, so we know it is overfitting the training set. We then use the validation set to pick the best model. We will be picking the model that has the highest accuracy on the validation set. Now in this case, it is rather less likely that the best validation set accuracy will be greater than 0.5, but I would still say it is over-fitting the validation set because you would be choosing the model purely on the basis that the randomness of one of the models was a better match than the others for the randomness of the validation data. So what we will end up with is a model that obviously over-fits the training data (many degrees of freedom in selecting the attribute, so accuracy > 0.5), one that probably over-fits the validation data in the sense of accuracy > 0 (fewer degrees of freedom, only 10 models to choose from), but definitely overfits in the sense of the choice being dominated by the noise. But whatever the choice, the test set will show us that the final model is just guessing (which is why you need the test set or nested cross-validation) The basic point is that if data has been used to optimise the model in any way, then it will give an optimistically biased performance estimate. How biased it is depends on how hard you try to optimise the model (how many feature choices, how many hyper-parameters, how fine a grid you use in gridsearch etc.) and the characteristics of the dataset. In some cases it is fairly benign: Jacques Wainer, Gavin Cawley, "Nested cross-validation when selecting classifiers is overzealous for most practical applications", Expert Systems with Applications, Volume 182, 2021. (www) Unfortunately, sometimes it can be as large as the difference in performance between a state of the art classifier and an average one (see Cawley and Talbot).
Overfitting the validation set
One thing that is not widely appreciated is that over-fitting the model selection criteria (e.g. validation set performance) can result in a model that over-fits the training data or it can result in
Overfitting the validation set One thing that is not widely appreciated is that over-fitting the model selection criteria (e.g. validation set performance) can result in a model that over-fits the training data or it can result in a model that underfits the training data. This example is from my paper (with Mrs Marsupial) Gavin C. Cawley, Nicola L. C. Talbot, "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation", Journal of Machine Learning Research, 11(70):2079−2107, 2010. (www) Here is a heat-map for the model selection criteria for tuning the hyper-parameters of a Least-Squares Support Vector Machine (or Kernel Ridge Regression model) with different training & validation samples. The training set of 256 patterns is identical each time, but a new sample of 64 patterns is used for each validation set. The criterion is a smoothed error rate on the validation set. You can see there is considerable variation between splits in the optimal hyper-parameters (yellow crosses) Here are the corresponding models, as you can see there is large variation in whether the models over- or under-fit the data. If you set the hyper-parameters in the position shown in (d) you tend to get a sensible model for all training-test splits, which suggest the problem is in over-fitting the model selection criterion. In this case, as it is only the validation set that changes, we know this is purely due to over-fitting the validation set during model selection. Consider a classification task, where there are 1000 binary features and one binary response variable, but they are all generated by flipping a fair coin. We then make ten models, each of which is given a disjoint set of 100 of the attributes. We form a training set of 10 patterns, a validation set of 10 patterns and a test set of 1,000,000 patterns. Note that the validation, test and training sets are entirely independent because all of the data is generated at random with no underlying structure. Each model generates it's output by picking the attribute that is most similar to the response variable for the training set out of the 100 attributes it has to choose from. If it is predicting a sequence of 10 random binary values using 100 similar sequences of 10 random variables, then it is highly likely to have an accuracy on the training set greater than 0.5, just by random chance. But we know the true optimal error rate of 0.5, so we know it is overfitting the training set. We then use the validation set to pick the best model. We will be picking the model that has the highest accuracy on the validation set. Now in this case, it is rather less likely that the best validation set accuracy will be greater than 0.5, but I would still say it is over-fitting the validation set because you would be choosing the model purely on the basis that the randomness of one of the models was a better match than the others for the randomness of the validation data. So what we will end up with is a model that obviously over-fits the training data (many degrees of freedom in selecting the attribute, so accuracy > 0.5), one that probably over-fits the validation data in the sense of accuracy > 0 (fewer degrees of freedom, only 10 models to choose from), but definitely overfits in the sense of the choice being dominated by the noise. But whatever the choice, the test set will show us that the final model is just guessing (which is why you need the test set or nested cross-validation) The basic point is that if data has been used to optimise the model in any way, then it will give an optimistically biased performance estimate. How biased it is depends on how hard you try to optimise the model (how many feature choices, how many hyper-parameters, how fine a grid you use in gridsearch etc.) and the characteristics of the dataset. In some cases it is fairly benign: Jacques Wainer, Gavin Cawley, "Nested cross-validation when selecting classifiers is overzealous for most practical applications", Expert Systems with Applications, Volume 182, 2021. (www) Unfortunately, sometimes it can be as large as the difference in performance between a state of the art classifier and an average one (see Cawley and Talbot).
Overfitting the validation set One thing that is not widely appreciated is that over-fitting the model selection criteria (e.g. validation set performance) can result in a model that over-fits the training data or it can result in
47,652
Overfitting the validation set
Choosing the best model is nothing but like hyper parameter optimization. We’re using training set to learn the parameters and validation set to learn the hyper parameters. In HPO, we typically evaluate the model on the candidate configurations and choose the best. In training, we use fancier stuff like gradient descent, adam optimizer etc. But still, they all aim to find the global optimum. What if we don’t use any of these fancier algorithms and just be able to iterate over the space of possible parameters? How is it different than what we do for the validation set? Thus, during the whole process we actually have a look at the training and validation sets and tune our model/algorithm. Any evaluation over these sets is not an unbiased estimation of the test performance.
Overfitting the validation set
Choosing the best model is nothing but like hyper parameter optimization. We’re using training set to learn the parameters and validation set to learn the hyper parameters. In HPO, we typically evalua
Overfitting the validation set Choosing the best model is nothing but like hyper parameter optimization. We’re using training set to learn the parameters and validation set to learn the hyper parameters. In HPO, we typically evaluate the model on the candidate configurations and choose the best. In training, we use fancier stuff like gradient descent, adam optimizer etc. But still, they all aim to find the global optimum. What if we don’t use any of these fancier algorithms and just be able to iterate over the space of possible parameters? How is it different than what we do for the validation set? Thus, during the whole process we actually have a look at the training and validation sets and tune our model/algorithm. Any evaluation over these sets is not an unbiased estimation of the test performance.
Overfitting the validation set Choosing the best model is nothing but like hyper parameter optimization. We’re using training set to learn the parameters and validation set to learn the hyper parameters. In HPO, we typically evalua
47,653
exact form for the marginal posterior
Answer: Posterior of $\sigma^2|Y_1,..., Y_n$ is an instance of inverse gamma distribution with the probability density $$ p(\sigma^2|Y_1,...,Y_n) = \frac{\beta^\alpha}{\Gamma(\alpha)} (\sigma^2)^{-\alpha+1}\exp(-\frac{\beta}{\sigma^2}), $$ where \begin{align} \alpha:=\frac{\nu_0+n}{2}, \quad& \beta:=\frac{\nu_0\sigma_0^2+n(\hat \sigma^2 + \frac{k_0}{k_0+n}(\bar Y - \mu_0)^2)}{2},\\ \bar Y := \frac{1}{n}\sum_i Y_i, \quad &\hat \sigma^2 := \frac{1}{n}\sum_i(Y_i-\bar Y)^2. \end{align} The posterior of $\mu|Y_1,...,Y_n$ is a shifted and scaled Student's t-distribution. It's probability density function can be written down as $$ p(\mu|Y_1,...,Y_n) = \frac{\Gamma \left(\frac{\nu+1}{2} \right)} {\sqrt{\nu\pi\gamma}\,\Gamma \left(\frac{\nu}{2} \right)} \left(1+\frac{(\mu-\mu')^2}{\nu \gamma} \right)^{-\frac{\nu+1}{2}},$$ where $\Gamma(x)$ is the Gamma function, $\nu:=\nu_0+n$ is the number of degrees of freedom, $\gamma:=\frac{\beta}{\alpha(n+k_0)}$ is the scale parameter $\mu' := \frac{n}{n+k_0}\bar Y + \frac{k_0}{n+k_0}\mu_0 $ is the mean of the interim posterior $\mu|\tau,\mathbf{Y}$: \begin{equation} \mu|\tau,\mathbf{Y} \sim N(\mu', ((n+k_0)\tau)^{-1}). \qquad\qquad (\star) \end{equation} Detailed steps: (There is a great variety of sources online, one of which I am reproducing almost without changes: lectures of Michael I. Jordan from Berkeley.) Derivation is quite straightforward, once we introduce notation $\tau := \frac{1}{\sigma^2}$, $\alpha_0 := \frac{\nu_0}{2}$, $\beta_0 := \alpha_0 \sigma^2_0$, and recognize in the stated prior the following hierarchical model: \begin{align} Y_i &\sim N(\mu, \tau^{-1})\\ \mu &\sim N(\mu_0, (k_0\tau)^{-1})\\ \tau &\sim Gamma(\alpha_0,\beta_0)\\ \end{align} where $Gamma$ stands for Gamma distribution with the probability density function $$p(\tau|\alpha_0,\beta_0) = \frac{\beta_0^{\alpha_0}}{\Gamma(\alpha_0)} \tau^{\alpha_0-1}\exp(-\tau \beta_0).$$ We are looking for the posterior $\mu| \mathbf{Y}$ and $\tau | \mathbf{Y}$, where $\mathbf{Y}:= (Y_1,...,Y_n) $. Obtaining posterior $\mu|\mathbf{Y}$ is a matter of taking an expectation of pdf of the interim posterior $(\star)$ with respect to the posterior $\tau|\mathbf{Y}$: \begin{equation} p(\mu|\mathbf{Y}) = \int_0^\infty p(\mu|\tau, \mathbf{Y}) p(\tau|\mathbf{Y})d \tau \quad (*) \end{equation} So the first step would be to obtain the posterior $\tau| \mathbf{Y}$, which is just the marginal of the joint posterior $\mu,\tau |\mathbf{Y}$: \begin{align} p(\tau,\mu|\mathbf{Y}) \propto & \prod_i p(Y_i|\mu,\tau)\cdot p(\mu|\tau)\cdot p(\tau) \\ \propto & \tau^{n/2} \exp\left(-\frac{\tau}{2}\sum_i(Y_i-\mu + \bar Y - \bar Y)^2\right) \cdot \tau^{1/2} \exp\left( -\frac{k_0 \tau}{2}(\mu-\mu_0)^2 \right) \cdot \tau^{\alpha_0-1} \exp(-\beta_0\tau) \\ \propto & \tau^{\alpha_0 + \frac{n}{2}-1}\exp\left(-\tau(\beta_0 + \frac{1}{2}\sum(Y_i-\bar Y)^2) \right) \tau^{1/2} \cdot \exp\left(-\frac{\tau}{2}(k_0(\mu-\mu_0)^2+n(\bar Y - \mu)^2)\right) \end{align} In the last expression we can factorize a kernel of a normal out of the second term (on the right of $\cdot$): \begin{align} &\exp\left(-\frac{\tau}{2}(k_0(\mu-\mu_0)^2+n(\bar Y - \mu)^2)\right) =\\ &= \exp\left(-\frac{\tau}{2}((k_0+n)\mu^2-2(k_0\mu_0 + n\bar Y) \mu + k_0 \mu_0^2+n\bar Y^2)\right)\\ &= \exp\left(-\frac{\tau}{2}((k_0+n)(\mu^2-2\frac{k_0\mu_0 + n\bar Y}{k_0+n}\mu + {\mu'}^2) - (k_0+n){\mu'}^2 + k_0 \mu_0^2+n\bar Y^2)\right)\\ &= \exp(-\frac{\tau}{2}(k_0+n)(\mu - \mu')^2) \cdot \exp\left(\frac{\tau}{2}( \frac{k_0^2 \mu_0^2 + 2 n k_0 \mu_0 \bar Y + n^2 \bar Y^2}{n+k_0} - k_0 \mu_0^2 -n \bar Y^2)\right)\\ &= \tau^{1/2} \exp(-\frac{\tau}{2}(k_0+n)(\mu - \mu')^2) \cdot \tau^{-1/2}\exp\left(-\frac{n k_0 \tau}{2(n+k_0)} (\bar Y -\mu_0)^2\right) \end{align} The first term in the above product is going to integrate to $\sqrt{\frac{2\pi}{k_0+n}}$ (pdf of $N(\mu', \frac{1}{(n+k_0)\tau})$) and may be neglected, whereas the second term will be factorized leaving us with the following posterior for $\tau| \mathbf{Y}$: \begin{equation} p(\tau|\mathbf{Y}) \propto \tau^{\alpha_0 + \frac{n}{2}-1} \exp(-\tau \left(\beta_0 + \frac{1}{2}\sum_i(Y_i-\bar Y)^2 + \frac{n k_0}{2(n+k_0)}(\bar Y -\mu_0)^2\right)) \end{equation} in which the kernel of a Gamma distribution is easily recognizable, i.e. $$\tau|\mathbf{Y} \sim Gamma(\alpha,\beta)$$ where $\alpha := \alpha_0 + \frac{n}{2}$ and $\beta := \beta_0 + \frac{1}{2}\sum_i(Y_i-\bar Y)^2 + \frac{n k_0}{2(n+k_0)}(\bar Y -\mu_0)^2$. Finally compute the expectation $(*)$: \begin{align} p(\mu|\mathbf{Y}) = & \int_0^\infty \frac{{\beta}^{\alpha}}{\Gamma(\alpha)}\tau^{\alpha-1} \exp(-\tau \beta) \cdot \frac{(n+k_0)^{1/2}\tau^{1/2}}{\sqrt{2 \pi}} \exp\left(-\frac{n+k_0}{2}\tau (\mu - \mu')^2 \right) d\tau \\ \propto & \int_0^\infty \tau^{\alpha+\frac{1}{2}-1} \exp\left(-\tau \beta - \tau \frac{n+k_0}{2}(\mu - \mu')^2 \right) d\tau \quad (**)\\ \propto & \Gamma(\alpha + \frac{1}{2}) \left(\beta + \frac{n+k_0}{2}(\mu-\mu')^2\right)^{-\alpha-\frac{1}{2}} \\ \propto & (1 + \frac{1}{2\alpha}\frac{(\mu-\mu')^2}{\frac{\beta}{(n+k_0)\alpha}})^{-\frac{2\alpha+1}{2}} \end{align} In the integrand in expression $(**)$ we see the kernel of $Gamma(\alpha+\frac{1}{2}, \beta + \frac{n+k_0}{2}(\mu - \mu')^2)$ which integrates to the expression in which one can easily recognize the kernel of a Student's t-distribution with mean $\mu'$, scale parameter $\frac{\beta}{(n+k_0)\alpha}$ and $2\alpha$ degrees of freedom.
exact form for the marginal posterior
Answer: Posterior of $\sigma^2|Y_1,..., Y_n$ is an instance of inverse gamma distribution with the probability density $$ p(\sigma^2|Y_1,...,Y_n) = \frac{\beta^\alpha}{\Gamma(\alpha)} (\sigma^2)^{-\a
exact form for the marginal posterior Answer: Posterior of $\sigma^2|Y_1,..., Y_n$ is an instance of inverse gamma distribution with the probability density $$ p(\sigma^2|Y_1,...,Y_n) = \frac{\beta^\alpha}{\Gamma(\alpha)} (\sigma^2)^{-\alpha+1}\exp(-\frac{\beta}{\sigma^2}), $$ where \begin{align} \alpha:=\frac{\nu_0+n}{2}, \quad& \beta:=\frac{\nu_0\sigma_0^2+n(\hat \sigma^2 + \frac{k_0}{k_0+n}(\bar Y - \mu_0)^2)}{2},\\ \bar Y := \frac{1}{n}\sum_i Y_i, \quad &\hat \sigma^2 := \frac{1}{n}\sum_i(Y_i-\bar Y)^2. \end{align} The posterior of $\mu|Y_1,...,Y_n$ is a shifted and scaled Student's t-distribution. It's probability density function can be written down as $$ p(\mu|Y_1,...,Y_n) = \frac{\Gamma \left(\frac{\nu+1}{2} \right)} {\sqrt{\nu\pi\gamma}\,\Gamma \left(\frac{\nu}{2} \right)} \left(1+\frac{(\mu-\mu')^2}{\nu \gamma} \right)^{-\frac{\nu+1}{2}},$$ where $\Gamma(x)$ is the Gamma function, $\nu:=\nu_0+n$ is the number of degrees of freedom, $\gamma:=\frac{\beta}{\alpha(n+k_0)}$ is the scale parameter $\mu' := \frac{n}{n+k_0}\bar Y + \frac{k_0}{n+k_0}\mu_0 $ is the mean of the interim posterior $\mu|\tau,\mathbf{Y}$: \begin{equation} \mu|\tau,\mathbf{Y} \sim N(\mu', ((n+k_0)\tau)^{-1}). \qquad\qquad (\star) \end{equation} Detailed steps: (There is a great variety of sources online, one of which I am reproducing almost without changes: lectures of Michael I. Jordan from Berkeley.) Derivation is quite straightforward, once we introduce notation $\tau := \frac{1}{\sigma^2}$, $\alpha_0 := \frac{\nu_0}{2}$, $\beta_0 := \alpha_0 \sigma^2_0$, and recognize in the stated prior the following hierarchical model: \begin{align} Y_i &\sim N(\mu, \tau^{-1})\\ \mu &\sim N(\mu_0, (k_0\tau)^{-1})\\ \tau &\sim Gamma(\alpha_0,\beta_0)\\ \end{align} where $Gamma$ stands for Gamma distribution with the probability density function $$p(\tau|\alpha_0,\beta_0) = \frac{\beta_0^{\alpha_0}}{\Gamma(\alpha_0)} \tau^{\alpha_0-1}\exp(-\tau \beta_0).$$ We are looking for the posterior $\mu| \mathbf{Y}$ and $\tau | \mathbf{Y}$, where $\mathbf{Y}:= (Y_1,...,Y_n) $. Obtaining posterior $\mu|\mathbf{Y}$ is a matter of taking an expectation of pdf of the interim posterior $(\star)$ with respect to the posterior $\tau|\mathbf{Y}$: \begin{equation} p(\mu|\mathbf{Y}) = \int_0^\infty p(\mu|\tau, \mathbf{Y}) p(\tau|\mathbf{Y})d \tau \quad (*) \end{equation} So the first step would be to obtain the posterior $\tau| \mathbf{Y}$, which is just the marginal of the joint posterior $\mu,\tau |\mathbf{Y}$: \begin{align} p(\tau,\mu|\mathbf{Y}) \propto & \prod_i p(Y_i|\mu,\tau)\cdot p(\mu|\tau)\cdot p(\tau) \\ \propto & \tau^{n/2} \exp\left(-\frac{\tau}{2}\sum_i(Y_i-\mu + \bar Y - \bar Y)^2\right) \cdot \tau^{1/2} \exp\left( -\frac{k_0 \tau}{2}(\mu-\mu_0)^2 \right) \cdot \tau^{\alpha_0-1} \exp(-\beta_0\tau) \\ \propto & \tau^{\alpha_0 + \frac{n}{2}-1}\exp\left(-\tau(\beta_0 + \frac{1}{2}\sum(Y_i-\bar Y)^2) \right) \tau^{1/2} \cdot \exp\left(-\frac{\tau}{2}(k_0(\mu-\mu_0)^2+n(\bar Y - \mu)^2)\right) \end{align} In the last expression we can factorize a kernel of a normal out of the second term (on the right of $\cdot$): \begin{align} &\exp\left(-\frac{\tau}{2}(k_0(\mu-\mu_0)^2+n(\bar Y - \mu)^2)\right) =\\ &= \exp\left(-\frac{\tau}{2}((k_0+n)\mu^2-2(k_0\mu_0 + n\bar Y) \mu + k_0 \mu_0^2+n\bar Y^2)\right)\\ &= \exp\left(-\frac{\tau}{2}((k_0+n)(\mu^2-2\frac{k_0\mu_0 + n\bar Y}{k_0+n}\mu + {\mu'}^2) - (k_0+n){\mu'}^2 + k_0 \mu_0^2+n\bar Y^2)\right)\\ &= \exp(-\frac{\tau}{2}(k_0+n)(\mu - \mu')^2) \cdot \exp\left(\frac{\tau}{2}( \frac{k_0^2 \mu_0^2 + 2 n k_0 \mu_0 \bar Y + n^2 \bar Y^2}{n+k_0} - k_0 \mu_0^2 -n \bar Y^2)\right)\\ &= \tau^{1/2} \exp(-\frac{\tau}{2}(k_0+n)(\mu - \mu')^2) \cdot \tau^{-1/2}\exp\left(-\frac{n k_0 \tau}{2(n+k_0)} (\bar Y -\mu_0)^2\right) \end{align} The first term in the above product is going to integrate to $\sqrt{\frac{2\pi}{k_0+n}}$ (pdf of $N(\mu', \frac{1}{(n+k_0)\tau})$) and may be neglected, whereas the second term will be factorized leaving us with the following posterior for $\tau| \mathbf{Y}$: \begin{equation} p(\tau|\mathbf{Y}) \propto \tau^{\alpha_0 + \frac{n}{2}-1} \exp(-\tau \left(\beta_0 + \frac{1}{2}\sum_i(Y_i-\bar Y)^2 + \frac{n k_0}{2(n+k_0)}(\bar Y -\mu_0)^2\right)) \end{equation} in which the kernel of a Gamma distribution is easily recognizable, i.e. $$\tau|\mathbf{Y} \sim Gamma(\alpha,\beta)$$ where $\alpha := \alpha_0 + \frac{n}{2}$ and $\beta := \beta_0 + \frac{1}{2}\sum_i(Y_i-\bar Y)^2 + \frac{n k_0}{2(n+k_0)}(\bar Y -\mu_0)^2$. Finally compute the expectation $(*)$: \begin{align} p(\mu|\mathbf{Y}) = & \int_0^\infty \frac{{\beta}^{\alpha}}{\Gamma(\alpha)}\tau^{\alpha-1} \exp(-\tau \beta) \cdot \frac{(n+k_0)^{1/2}\tau^{1/2}}{\sqrt{2 \pi}} \exp\left(-\frac{n+k_0}{2}\tau (\mu - \mu')^2 \right) d\tau \\ \propto & \int_0^\infty \tau^{\alpha+\frac{1}{2}-1} \exp\left(-\tau \beta - \tau \frac{n+k_0}{2}(\mu - \mu')^2 \right) d\tau \quad (**)\\ \propto & \Gamma(\alpha + \frac{1}{2}) \left(\beta + \frac{n+k_0}{2}(\mu-\mu')^2\right)^{-\alpha-\frac{1}{2}} \\ \propto & (1 + \frac{1}{2\alpha}\frac{(\mu-\mu')^2}{\frac{\beta}{(n+k_0)\alpha}})^{-\frac{2\alpha+1}{2}} \end{align} In the integrand in expression $(**)$ we see the kernel of $Gamma(\alpha+\frac{1}{2}, \beta + \frac{n+k_0}{2}(\mu - \mu')^2)$ which integrates to the expression in which one can easily recognize the kernel of a Student's t-distribution with mean $\mu'$, scale parameter $\frac{\beta}{(n+k_0)\alpha}$ and $2\alpha$ degrees of freedom.
exact form for the marginal posterior Answer: Posterior of $\sigma^2|Y_1,..., Y_n$ is an instance of inverse gamma distribution with the probability density $$ p(\sigma^2|Y_1,...,Y_n) = \frac{\beta^\alpha}{\Gamma(\alpha)} (\sigma^2)^{-\a
47,654
exact form for the marginal posterior
For this type of analysis, it is often possible to decompose the posterior density into a part representing the marginal posterior of one of the parameters, and another part representing the conditional posterior of the other parameter. It turns out to be possible to do this in the present case. To facilitate our analysis, let us define the useful posterior quantities: $$\mu_* \equiv \frac{n \bar{y} + k_0 \mu_0}{n + k_0} \quad \quad \quad \quad \quad \beta_* \equiv \frac{||\mathbf{y}||^2 + v_0 \sigma_0^2 + k_0 \mu_0^2 - (n+k_0) \mu_*}{2}.$$ Now, we can solve this problem by writing out the posterior kernel, and then collect all terms involving $\mu$ and simplify this into the kernel of a known density function (in this case the normal density). Using the method of completing the square, we obtain: $$\begin{equation} \begin{aligned} p(\mu, \sigma^2 | \mathbf{y}) &\propto L_\mathbf{y}(\mu, \sigma^2) \cdot p(\mu, \sigma^2) \\[6pt] &\propto \sigma^{-n} \exp \Bigg( - \frac{1}{2 \sigma^2} \cdot \sum_{i=1}^n ( y_i-\mu)^2 \Bigg) \cdot \sigma^{-v_0 -3} \exp \Bigg( -\frac{1}{2\sigma^2} [v_0 \sigma_0^2+ k_0(\mu_0 - \mu)^2] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{1}{2 \sigma^2} \Bigg[ \sum_{i=1}^n ( y_i-\mu)^2 +v_0 \sigma_0^2+ k_0(\mu_0 - \mu)^2 \Bigg] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{1}{2 \sigma^2} \Bigg[ (||\mathbf{y}||^2 -2 n \bar{y} \mu + n \mu^2) + v_0 \sigma_0^2 + (k_0 \mu_0^2 - 2 k_0 \mu_0 \mu + k_0 \mu^2) \Bigg] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{1}{2 \sigma^2} \Bigg[ -2 (n \bar{y} + k_0 \mu_0 ) \mu + (n + k_0) \mu^2 + ||\mathbf{y}||^2 + v_0 \sigma_0^2 + k_0 \mu_0^2 \Bigg] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} \Bigg[ -2 \mu_* \mu + \mu^2 \Bigg] - \frac{||\mathbf{y}||^2 + v_0 \sigma_0^2 + k_0 \mu_0^2}{2 \sigma^2} \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} \Bigg[ \mu_*^2 -2 \mu_* \mu + \mu^2 \Bigg] - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} ( \mu - \mu_* )^2 - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &= \sigma^{-1} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} ( \mu - \mu_* )^2 \Bigg) \cdot \sigma^{-n-v_0 -2} \exp \Bigg( - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &= \sigma^{-1} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} ( \mu - \mu_* )^2 \Bigg) \cdot (\sigma^2)^{-(n+v_0)/2 -1} \exp \Bigg( - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &\propto \text{N} \Big( \mu \Big| \mu_*, \frac{\sigma^2}{n + k_0} \Big) \cdot \text{InvGa} \Big( \sigma^2 \Big| \frac{n+v_0}{2}, \beta_* \Big). \\[6pt] \end{aligned} \end{equation}$$ Since the joint density is a probability density, we then have: $$p(\mu, \sigma^2 | \mathbf{y}) = \text{N} \Big( \mu \Big| \mu_*, \frac{\sigma^2}{n + k_0} \Big) \cdot \text{InvGa} \Big( \sigma^2 \Big| \frac{n+v_0}{2}, \beta_* \Big). $$ From this equation we obtain the marginal distribution: $$\sigma^2 | \mathbf{y} \sim \text{InvGa} \Big( \frac{n+v_0}{2}, \beta_* \Big). $$
exact form for the marginal posterior
For this type of analysis, it is often possible to decompose the posterior density into a part representing the marginal posterior of one of the parameters, and another part representing the condition
exact form for the marginal posterior For this type of analysis, it is often possible to decompose the posterior density into a part representing the marginal posterior of one of the parameters, and another part representing the conditional posterior of the other parameter. It turns out to be possible to do this in the present case. To facilitate our analysis, let us define the useful posterior quantities: $$\mu_* \equiv \frac{n \bar{y} + k_0 \mu_0}{n + k_0} \quad \quad \quad \quad \quad \beta_* \equiv \frac{||\mathbf{y}||^2 + v_0 \sigma_0^2 + k_0 \mu_0^2 - (n+k_0) \mu_*}{2}.$$ Now, we can solve this problem by writing out the posterior kernel, and then collect all terms involving $\mu$ and simplify this into the kernel of a known density function (in this case the normal density). Using the method of completing the square, we obtain: $$\begin{equation} \begin{aligned} p(\mu, \sigma^2 | \mathbf{y}) &\propto L_\mathbf{y}(\mu, \sigma^2) \cdot p(\mu, \sigma^2) \\[6pt] &\propto \sigma^{-n} \exp \Bigg( - \frac{1}{2 \sigma^2} \cdot \sum_{i=1}^n ( y_i-\mu)^2 \Bigg) \cdot \sigma^{-v_0 -3} \exp \Bigg( -\frac{1}{2\sigma^2} [v_0 \sigma_0^2+ k_0(\mu_0 - \mu)^2] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{1}{2 \sigma^2} \Bigg[ \sum_{i=1}^n ( y_i-\mu)^2 +v_0 \sigma_0^2+ k_0(\mu_0 - \mu)^2 \Bigg] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{1}{2 \sigma^2} \Bigg[ (||\mathbf{y}||^2 -2 n \bar{y} \mu + n \mu^2) + v_0 \sigma_0^2 + (k_0 \mu_0^2 - 2 k_0 \mu_0 \mu + k_0 \mu^2) \Bigg] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{1}{2 \sigma^2} \Bigg[ -2 (n \bar{y} + k_0 \mu_0 ) \mu + (n + k_0) \mu^2 + ||\mathbf{y}||^2 + v_0 \sigma_0^2 + k_0 \mu_0^2 \Bigg] \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} \Bigg[ -2 \mu_* \mu + \mu^2 \Bigg] - \frac{||\mathbf{y}||^2 + v_0 \sigma_0^2 + k_0 \mu_0^2}{2 \sigma^2} \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} \Bigg[ \mu_*^2 -2 \mu_* \mu + \mu^2 \Bigg] - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &= \sigma^{-n-v_0 -3} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} ( \mu - \mu_* )^2 - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &= \sigma^{-1} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} ( \mu - \mu_* )^2 \Bigg) \cdot \sigma^{-n-v_0 -2} \exp \Bigg( - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &= \sigma^{-1} \exp \Bigg( - \frac{n + k_0}{2 \sigma^2} ( \mu - \mu_* )^2 \Bigg) \cdot (\sigma^2)^{-(n+v_0)/2 -1} \exp \Bigg( - \frac{\beta_*}{\sigma^2} \Bigg) \\[6pt] &\propto \text{N} \Big( \mu \Big| \mu_*, \frac{\sigma^2}{n + k_0} \Big) \cdot \text{InvGa} \Big( \sigma^2 \Big| \frac{n+v_0}{2}, \beta_* \Big). \\[6pt] \end{aligned} \end{equation}$$ Since the joint density is a probability density, we then have: $$p(\mu, \sigma^2 | \mathbf{y}) = \text{N} \Big( \mu \Big| \mu_*, \frac{\sigma^2}{n + k_0} \Big) \cdot \text{InvGa} \Big( \sigma^2 \Big| \frac{n+v_0}{2}, \beta_* \Big). $$ From this equation we obtain the marginal distribution: $$\sigma^2 | \mathbf{y} \sim \text{InvGa} \Big( \frac{n+v_0}{2}, \beta_* \Big). $$
exact form for the marginal posterior For this type of analysis, it is often possible to decompose the posterior density into a part representing the marginal posterior of one of the parameters, and another part representing the condition
47,655
Interpreting the intercept of a Linear Mixed Model Results in Python - Statsmodel Package
The intercept estimate of 15.724 is the global intercept, around which the (72) random intercepts vary. The random intercepts are estimated as samples from a normal distribution with a variance of 40.384 and mean of zero - hence the need for a global (fixed) intercept.
Interpreting the intercept of a Linear Mixed Model Results in Python - Statsmodel Package
The intercept estimate of 15.724 is the global intercept, around which the (72) random intercepts vary. The random intercepts are estimated as samples from a normal distribution with a variance of 40.
Interpreting the intercept of a Linear Mixed Model Results in Python - Statsmodel Package The intercept estimate of 15.724 is the global intercept, around which the (72) random intercepts vary. The random intercepts are estimated as samples from a normal distribution with a variance of 40.384 and mean of zero - hence the need for a global (fixed) intercept.
Interpreting the intercept of a Linear Mixed Model Results in Python - Statsmodel Package The intercept estimate of 15.724 is the global intercept, around which the (72) random intercepts vary. The random intercepts are estimated as samples from a normal distribution with a variance of 40.
47,656
How to optimise waterfall questions of purchase value
Short answer: Indeed, when the same customer may be approached at most $n$ times, it is optimal to start with offer $y_1=\frac{n-1}{n}x$ and decrease the price by $\frac{x}{n}$ with every refusal. The above result only holds for the uniform distribution of the customer's valuation $v$. Under the normal distribution, closed form answer is feasible only numerically. When $n$ customer may be approached, each at most once, the optimization problem assumes a double layer structure: inner smooth optimization problem is wrapped in outer combinatorial optimization task. Coupled with non-trivial covariance structure in valuations, this makes the analytical (and/or tractable) closed form solution infeasible. A promising approach for the latter case would be to assume that valuations $v_1,...,v_n$ are uniformly distributed over a parallelotope and leverage the polyhedral computation methods to speed up computations. Detailed answer Approaching the same customer at most $n$ times When we are dealing with asingle customer and may try up to $n$ times until he walks away, the problem solution is straightforward and and follows the logic presented in the other answer to this post. The expected profit can be written down as follows: \begin{align} \mathbb{E}\pi =& y_1 \cdot \mathbb{P}(v > y_1) + y_2 \cdot \mathbb{P}(v < y_1 \cap v < y_2 )+ ... + y_n \cdot \mathbb{P}(v < y_n \cap (\cap_{j=1}^{n-1} v < y_j )) =\\ = & \sum_{i=1}^n y_i \mathbb{P}(v < y_n \cap (\cap_{j=1}^{i-1} v < y_j )) = \\ = & \sum_{i=1}^n y_i \mathbb{P}(y_i < v < y_{i-1}) \end{align} where the implicit convention is that $y_0$ is some upper bound of the support of $v$ so that $\mathbb{P}( v < y_0) = 1$. The solution to the problem is thus a sequence $\mathbf{y}:=(y_1,...,y_n)$ maximizing the expected profit. In the case of uniform distribution, $v \sim U[0, x]$ the first order conditions with respect to $y_i$ represent a system of linear equations: \begin{equation} \frac{\partial}{\partial y_i} \mathbb{E} \pi = 0 \iff \begin{cases} \frac{x-y_1}{x} - y_1 \frac{1}{x} + y_2 \frac{1}{x} = 0 \\ \frac{y_{i-1}-y_{i}}{x} - y_i \frac{1}{x} + y_{i+1} \frac{1}{x} = 0 \quad \forall i=2,..n-1 \\ \frac{y_{n-1}-y_{n}}{x} - y_n \frac{1}{x} = 0 \end{cases} \end{equation} It is immediate from the second equality that there exists an increment $\delta$ such that $\forall i=2,..n$ holds $y_{i} = y_{i-1} - \delta$, implying that $y_i = y_1 - (i-1)\delta$. This is consistent with the first and the last equality iff $\delta = \frac{x}{n}$ and $y_1 = \frac{n-1}{n}x$ as per intuition described in the OP. Remark: Once we switch to a more contrived assumption about the distribution of the customer valuation, explicit answer becomes impossible to obtain analytically. E.g. in the case of a normal distribution truncated to the interval $[0,x]$ the system of first order conditions becomes \begin{equation} \begin{cases} \frac{\Phi(x)-\Phi(y_1)}{\Phi(x)-1/2} - y_1 \frac{\phi(y_1)}{\Phi(x)-1/2} + y_2 \frac{\phi(y_1)}{\Phi(x)-1/2} = 0 \\ \frac{\Phi(y_{i-1})-\Phi(y_{i})}{\Phi(x)-1/2} - y_i \frac{\phi(y_i)}{\Phi(x)-1/2} + y_{i+1} \frac{\phi(y_i)}{\Phi(x)-1/2} = 0 \quad \forall i=2,..n-1 \\ \frac{\Phi(y_{n-1})-\Phi(y_{n})}{\Phi(x)-1/2} - y_n \frac{\phi(y_n)}{\Phi(x)-1/2} = 0 \end{cases} \end{equation} where $\phi(z) = (2\pi)^{-1/2}\exp(-\frac{z^2}{2})$ is the pdf of the standart normal and $\Phi(z) = \int_{-\infty}^{z} \phi(\xi)d\xi$ is its cdf. One can clearly see that the analytical closed form solution is infeasible in this case. Approaching at most $n$ different customers no more than once each First take a look at a 2-customer problem: for a sequence of offers $y_1, y_2$ and the ordering (permutation) of clients $\sigma(1),\sigma(2)$ the expected revenue looks as follows: \begin{align} \mathbb{E}\pi = &y_1 \mathbb{P}(v_{\sigma(1)} > y_1) + \mathbb{P}(v_{\sigma(1)} < y_1) \cdot y_2 \mathbb{P}(v_{\sigma(2)}>y_2 | y_1 > v_{\sigma(1)}) =\\ = & y_1 \mathbb{P}(v_{\sigma(1)} > y_1) + y_2 \mathbb{P}(v_{\sigma(1)} < y_1 \cap v_{\sigma(2)}>y_2). \end{align} Now, it is not hard to write down the formula for $n$ clients: \begin{align} \mathbb{E}\pi =& \sum_{i=1}^n y_i \cdot \mathbb{P}\left(v_{\sigma(i)} > y_i \cap ( \cap_{j=1}^{i-1} v_{\sigma(j)}<y_j)\right) = \\ = & \sum_{i=1}^n y_i \cdot (\mathbb{P}\left(\cap_{j=1}^{i-1} v_{\sigma(j)}<y_j\right) - \mathbb{P}\left(\cap_{j=1}^i v_{\sigma(j)}<y_j\right) )= \\ = & y_1 + \sum_{i=1}^{n} (y_{i+1} - y_i) \mathbb{P}\left(\cap_{j=1}^{i} v_{\sigma(j)}<y_j\right), \end{align} where the last equality holds true if we posit $y_{n+1}\equiv 0$. Here just as in the remark above, one can see that analytical closed form solution of the inner smooth optimization problem is impossible to obtain under the joint normality assumption as the first order conditions will certainly be non-polynomial. This and given that the outer problem is combinatorial makes the numerical (algorithmical) solution of the problem the most promising way forward. An idea for a way forward: Computation of probabilities $\mathbb{P}\left(\cap_{j=1}^{i} v_{\sigma(j)}<y_j\right)$ might turn out to be easier if we assume a distorted uniform distribution (uniform over a [parallelotope][3]). I haven't seen anything like this in the litterature myself, but it might be the good compromise between the simplicity of operations with the uniform distribution and the capacity of the normal to capture non-trivial covariance structure. More precisely, one may assume that $\mathbf{v}=(v_1,...,v_n)$ is distributed uniformly over an $n$-parallelotope. In this case the parameter of the distribution would be the matrix of $n$ stacked vectors $a_1,...,a_n$ in the frame of the parallelotope, and the unconditional density would be the inverse of its volume, whereas conditional probabilities may be computed as volumes of straightforwardly formulated convex polytopes. Given a reasonably fast oracle for computing optimal $\mathbf{y}$, the combinatorial optimization for moderate $n$ may then be performed by a simple comparison of expected profits of different permutations.
How to optimise waterfall questions of purchase value
Short answer: Indeed, when the same customer may be approached at most $n$ times, it is optimal to start with offer $y_1=\frac{n-1}{n}x$ and decrease the price by $\frac{x}{n}$ with every refusal. Th
How to optimise waterfall questions of purchase value Short answer: Indeed, when the same customer may be approached at most $n$ times, it is optimal to start with offer $y_1=\frac{n-1}{n}x$ and decrease the price by $\frac{x}{n}$ with every refusal. The above result only holds for the uniform distribution of the customer's valuation $v$. Under the normal distribution, closed form answer is feasible only numerically. When $n$ customer may be approached, each at most once, the optimization problem assumes a double layer structure: inner smooth optimization problem is wrapped in outer combinatorial optimization task. Coupled with non-trivial covariance structure in valuations, this makes the analytical (and/or tractable) closed form solution infeasible. A promising approach for the latter case would be to assume that valuations $v_1,...,v_n$ are uniformly distributed over a parallelotope and leverage the polyhedral computation methods to speed up computations. Detailed answer Approaching the same customer at most $n$ times When we are dealing with asingle customer and may try up to $n$ times until he walks away, the problem solution is straightforward and and follows the logic presented in the other answer to this post. The expected profit can be written down as follows: \begin{align} \mathbb{E}\pi =& y_1 \cdot \mathbb{P}(v > y_1) + y_2 \cdot \mathbb{P}(v < y_1 \cap v < y_2 )+ ... + y_n \cdot \mathbb{P}(v < y_n \cap (\cap_{j=1}^{n-1} v < y_j )) =\\ = & \sum_{i=1}^n y_i \mathbb{P}(v < y_n \cap (\cap_{j=1}^{i-1} v < y_j )) = \\ = & \sum_{i=1}^n y_i \mathbb{P}(y_i < v < y_{i-1}) \end{align} where the implicit convention is that $y_0$ is some upper bound of the support of $v$ so that $\mathbb{P}( v < y_0) = 1$. The solution to the problem is thus a sequence $\mathbf{y}:=(y_1,...,y_n)$ maximizing the expected profit. In the case of uniform distribution, $v \sim U[0, x]$ the first order conditions with respect to $y_i$ represent a system of linear equations: \begin{equation} \frac{\partial}{\partial y_i} \mathbb{E} \pi = 0 \iff \begin{cases} \frac{x-y_1}{x} - y_1 \frac{1}{x} + y_2 \frac{1}{x} = 0 \\ \frac{y_{i-1}-y_{i}}{x} - y_i \frac{1}{x} + y_{i+1} \frac{1}{x} = 0 \quad \forall i=2,..n-1 \\ \frac{y_{n-1}-y_{n}}{x} - y_n \frac{1}{x} = 0 \end{cases} \end{equation} It is immediate from the second equality that there exists an increment $\delta$ such that $\forall i=2,..n$ holds $y_{i} = y_{i-1} - \delta$, implying that $y_i = y_1 - (i-1)\delta$. This is consistent with the first and the last equality iff $\delta = \frac{x}{n}$ and $y_1 = \frac{n-1}{n}x$ as per intuition described in the OP. Remark: Once we switch to a more contrived assumption about the distribution of the customer valuation, explicit answer becomes impossible to obtain analytically. E.g. in the case of a normal distribution truncated to the interval $[0,x]$ the system of first order conditions becomes \begin{equation} \begin{cases} \frac{\Phi(x)-\Phi(y_1)}{\Phi(x)-1/2} - y_1 \frac{\phi(y_1)}{\Phi(x)-1/2} + y_2 \frac{\phi(y_1)}{\Phi(x)-1/2} = 0 \\ \frac{\Phi(y_{i-1})-\Phi(y_{i})}{\Phi(x)-1/2} - y_i \frac{\phi(y_i)}{\Phi(x)-1/2} + y_{i+1} \frac{\phi(y_i)}{\Phi(x)-1/2} = 0 \quad \forall i=2,..n-1 \\ \frac{\Phi(y_{n-1})-\Phi(y_{n})}{\Phi(x)-1/2} - y_n \frac{\phi(y_n)}{\Phi(x)-1/2} = 0 \end{cases} \end{equation} where $\phi(z) = (2\pi)^{-1/2}\exp(-\frac{z^2}{2})$ is the pdf of the standart normal and $\Phi(z) = \int_{-\infty}^{z} \phi(\xi)d\xi$ is its cdf. One can clearly see that the analytical closed form solution is infeasible in this case. Approaching at most $n$ different customers no more than once each First take a look at a 2-customer problem: for a sequence of offers $y_1, y_2$ and the ordering (permutation) of clients $\sigma(1),\sigma(2)$ the expected revenue looks as follows: \begin{align} \mathbb{E}\pi = &y_1 \mathbb{P}(v_{\sigma(1)} > y_1) + \mathbb{P}(v_{\sigma(1)} < y_1) \cdot y_2 \mathbb{P}(v_{\sigma(2)}>y_2 | y_1 > v_{\sigma(1)}) =\\ = & y_1 \mathbb{P}(v_{\sigma(1)} > y_1) + y_2 \mathbb{P}(v_{\sigma(1)} < y_1 \cap v_{\sigma(2)}>y_2). \end{align} Now, it is not hard to write down the formula for $n$ clients: \begin{align} \mathbb{E}\pi =& \sum_{i=1}^n y_i \cdot \mathbb{P}\left(v_{\sigma(i)} > y_i \cap ( \cap_{j=1}^{i-1} v_{\sigma(j)}<y_j)\right) = \\ = & \sum_{i=1}^n y_i \cdot (\mathbb{P}\left(\cap_{j=1}^{i-1} v_{\sigma(j)}<y_j\right) - \mathbb{P}\left(\cap_{j=1}^i v_{\sigma(j)}<y_j\right) )= \\ = & y_1 + \sum_{i=1}^{n} (y_{i+1} - y_i) \mathbb{P}\left(\cap_{j=1}^{i} v_{\sigma(j)}<y_j\right), \end{align} where the last equality holds true if we posit $y_{n+1}\equiv 0$. Here just as in the remark above, one can see that analytical closed form solution of the inner smooth optimization problem is impossible to obtain under the joint normality assumption as the first order conditions will certainly be non-polynomial. This and given that the outer problem is combinatorial makes the numerical (algorithmical) solution of the problem the most promising way forward. An idea for a way forward: Computation of probabilities $\mathbb{P}\left(\cap_{j=1}^{i} v_{\sigma(j)}<y_j\right)$ might turn out to be easier if we assume a distorted uniform distribution (uniform over a [parallelotope][3]). I haven't seen anything like this in the litterature myself, but it might be the good compromise between the simplicity of operations with the uniform distribution and the capacity of the normal to capture non-trivial covariance structure. More precisely, one may assume that $\mathbf{v}=(v_1,...,v_n)$ is distributed uniformly over an $n$-parallelotope. In this case the parameter of the distribution would be the matrix of $n$ stacked vectors $a_1,...,a_n$ in the frame of the parallelotope, and the unconditional density would be the inverse of its volume, whereas conditional probabilities may be computed as volumes of straightforwardly formulated convex polytopes. Given a reasonably fast oracle for computing optimal $\mathbf{y}$, the combinatorial optimization for moderate $n$ may then be performed by a simple comparison of expected profits of different permutations.
How to optimise waterfall questions of purchase value Short answer: Indeed, when the same customer may be approached at most $n$ times, it is optimal to start with offer $y_1=\frac{n-1}{n}x$ and decrease the price by $\frac{x}{n}$ with every refusal. Th
47,657
How to optimise waterfall questions of purchase value
This kind of problem is an optimisation problem that can either be solved directly from the profit function, or in two-steps using backward induction. To show you how to uses either of these methods, I will first write the optimisation problem out in a helpful mathematical form. I will show the solution by both methods. In this particular case, direct optimisation is much simpler, but if you have more difficult cases then the method of backward induction can be simpler. The optimisation problem: You have a continuous random variable $V \sim \text{U}(0, x)$ and you will choose two offers $y_1$ and $y_2$. Your profit is the random variable: $$\pi_V(y_1,y_2) = y_1 \cdot \mathbb{I}(y_1 \leqslant V) + y_2 \cdot \mathbb{I}(y_2 \leqslant V < y_1).$$ Your goal is to choose a first and second offer to maximise your expected profit, which is the expected value of the above function. Direct optimisation: With direct optimisation we write out the expected profit as a bivariate function of your two decision variables, and we then conduct multivariate optimisation using standard calculus techniques. We can restrict attention to the cases $0 \leqslant y_2 < y_1 \leqslant x$, since both offers must be within the support of $V$, and your second offer should be lower than your first. (The second offer only matters if the first is rejected, so it makes no sense to make a second offer that is equal or greater to the first.) Restricting attention to this case, the expected profit function can be written as the bivariate function: $$\begin{equation} \begin{aligned} \bar{\pi}(y_1,y_2) &\equiv \mathbb{E}(\pi_V(y_1,y_2)) \\[6pt] &= y_1 \cdot \mathbb{P}(y_1 \leqslant V) + y_2 \cdot \mathbb{P}(y_2 \leqslant V < y_1) \\[6pt] &= y_1 \cdot \frac{x-y_1}{x} + y_2 \cdot \frac{y_1-y_2}{x} \\[6pt] &= \frac{1}{x} \big( y_1 (x-y_1) + y_2 (y_1-y_2) \big) \\[6pt] &= \frac{1}{x} \big( y_1 x -y_1^2 + y_2 y_1 - y_2^2 \big). \\[6pt] \end{aligned} \end{equation}$$ The gradient vector and Hessian matrix of this function are given respectively by: $$\nabla \bar{\pi}(y_1,y_2) = \frac{1}{x} \begin{bmatrix} x - 2y_1 + y_2 \\ y_1 - 2 y_2 \end{bmatrix} \quad \quad \quad \quad \quad \nabla^2 \bar{\pi}(y_1,y_2) = \frac{1}{x} \begin{bmatrix} - 2 & 1 \\ 1 & - 2 \ \end{bmatrix}.$$ It is simple to show that the Hessian is negative definite (eigenvalues are $\lambda_1 = -3$ and $\lambda_2 = -1$), so the function is strictly concave. This means that it has a unique critical point that is the global maximising value of the function. This point satisfies the first-order condition (FOC): $$\mathbf{0} = \nabla \bar{\pi}(\hat{y}_1,\hat{y}_2) = \frac{1}{x} \begin{bmatrix} x - 2\hat{y}_1 + \hat{y}_2 \\ \hat{y}_1 - 2 \hat{y}_2 \end{bmatrix}.$$ Solving these two equations in two unknowns yields the optimising prices: $$\hat{y}_1 = \frac{2}{3} \cdot x \quad \quad \quad \hat{y}_2 = \frac{1}{3} \cdot x.$$ Optimisation by backwards induction: With backward induction we begin by optimising the later decision, and then work backwards to optimise the earlier decision, assuming optimisation of the later decision. So, let's imagine that you have already made some first offer of $0 \leqslant y_1 \leqslant x$ and it has been rejected, so now you are going to make your second offer. Conditional on the rejection of the first offer, we have the posterior distribution $V | V < y_1 \sim \text{U}(0, y_1)$, so the expected profit from a new offer of $0 \leqslant y_2 \leqslant x$ is: $$\begin{equation} \begin{aligned} \bar{\pi}(y_2) &= \mathbb{E}(\pi_V(y_1,y_2) | V \sim \text{U}(0, y_1)) \\[6pt] &= \mathbb{E}(y_2 \cdot \mathbb{I}(y_2 \leqslant V) | V \sim \text{U}(0, y_1)) \\[6pt] &= y_2 \cdot \frac{y_1-y_2}{y_1} \cdot \mathbb{I}(y_2 < y_1) \\[6pt] &= \frac{1}{y_1} \cdot (y_2 y_1 - y_2^2) \cdot \mathbb{I}(y_2 < y_1) \\[6pt] \end{aligned} \end{equation}$$ Univariate optimisation (omitting the calculus steps) yields the optimising value: $$\hat{y}_2 = \frac{1}{2} \cdot y_1.$$ Having obtained this optimising value, we proceed backward to the first offer. Assuming that the second offer is optimal, the expected profit as a function of the first offer $y_1$ is: $$\begin{equation} \begin{aligned} \bar{\pi}(y_1|\hat{y}_2) &= \mathbb{E}(\pi_V(y_1,\hat{y}_2) | V \sim \text{U}(0, x)) \\[6pt] &= \mathbb{E}(\pi_V(y_1,y_1/2) | V \sim \text{U}(0, x)) \\[6pt] &= \mathbb{E}(y_1 \cdot \mathbb{I}(y_1 \leqslant V) + \frac{y_1}{2} \cdot \mathbb{I}(y_1/2 \leqslant V < y_1) | V \sim \text{U}(0, x)) \\[6pt] &= y_1 \cdot \mathbb{P}(y_1 \leqslant V) + \frac{y_1}{2} \cdot \mathbb{P}(y_1/2 \leqslant V < y_1) \\[6pt] &= y_1 \cdot \frac{x-y_1}{x} + \frac{y_1}{2} \cdot \frac{y_1/2}{x} \\[6pt] &= \frac{1}{x} \big( x y_1 - y_1^2 + \frac{y_1^2}{4} \big) \\[6pt] &= \frac{1}{x} \big( x y_1 - \frac{3 y_1^2}{4} \big). \\[6pt] \end{aligned} \end{equation}$$ Univariate optimisation (omitting the calculus steps) yields the optimising value: $$\hat{y}_1 = \frac{2}{3} \cdot x.$$ Substitution of this optimum offer to the second optimising offer then gives: $$\hat{y}_2 = \frac{1}{3} \cdot x.$$ This is the same answer that is obtained via direct optimisation. The above methods can easily be extended to the more general case where you have more than two opportunities for offers. As in the above case, the simplest method is the direct method ---i.e., you form a multivariate function for the expected profit conditional on a vector of offers, and then optimise this function using standard calculus techniques.
How to optimise waterfall questions of purchase value
This kind of problem is an optimisation problem that can either be solved directly from the profit function, or in two-steps using backward induction. To show you how to uses either of these methods,
How to optimise waterfall questions of purchase value This kind of problem is an optimisation problem that can either be solved directly from the profit function, or in two-steps using backward induction. To show you how to uses either of these methods, I will first write the optimisation problem out in a helpful mathematical form. I will show the solution by both methods. In this particular case, direct optimisation is much simpler, but if you have more difficult cases then the method of backward induction can be simpler. The optimisation problem: You have a continuous random variable $V \sim \text{U}(0, x)$ and you will choose two offers $y_1$ and $y_2$. Your profit is the random variable: $$\pi_V(y_1,y_2) = y_1 \cdot \mathbb{I}(y_1 \leqslant V) + y_2 \cdot \mathbb{I}(y_2 \leqslant V < y_1).$$ Your goal is to choose a first and second offer to maximise your expected profit, which is the expected value of the above function. Direct optimisation: With direct optimisation we write out the expected profit as a bivariate function of your two decision variables, and we then conduct multivariate optimisation using standard calculus techniques. We can restrict attention to the cases $0 \leqslant y_2 < y_1 \leqslant x$, since both offers must be within the support of $V$, and your second offer should be lower than your first. (The second offer only matters if the first is rejected, so it makes no sense to make a second offer that is equal or greater to the first.) Restricting attention to this case, the expected profit function can be written as the bivariate function: $$\begin{equation} \begin{aligned} \bar{\pi}(y_1,y_2) &\equiv \mathbb{E}(\pi_V(y_1,y_2)) \\[6pt] &= y_1 \cdot \mathbb{P}(y_1 \leqslant V) + y_2 \cdot \mathbb{P}(y_2 \leqslant V < y_1) \\[6pt] &= y_1 \cdot \frac{x-y_1}{x} + y_2 \cdot \frac{y_1-y_2}{x} \\[6pt] &= \frac{1}{x} \big( y_1 (x-y_1) + y_2 (y_1-y_2) \big) \\[6pt] &= \frac{1}{x} \big( y_1 x -y_1^2 + y_2 y_1 - y_2^2 \big). \\[6pt] \end{aligned} \end{equation}$$ The gradient vector and Hessian matrix of this function are given respectively by: $$\nabla \bar{\pi}(y_1,y_2) = \frac{1}{x} \begin{bmatrix} x - 2y_1 + y_2 \\ y_1 - 2 y_2 \end{bmatrix} \quad \quad \quad \quad \quad \nabla^2 \bar{\pi}(y_1,y_2) = \frac{1}{x} \begin{bmatrix} - 2 & 1 \\ 1 & - 2 \ \end{bmatrix}.$$ It is simple to show that the Hessian is negative definite (eigenvalues are $\lambda_1 = -3$ and $\lambda_2 = -1$), so the function is strictly concave. This means that it has a unique critical point that is the global maximising value of the function. This point satisfies the first-order condition (FOC): $$\mathbf{0} = \nabla \bar{\pi}(\hat{y}_1,\hat{y}_2) = \frac{1}{x} \begin{bmatrix} x - 2\hat{y}_1 + \hat{y}_2 \\ \hat{y}_1 - 2 \hat{y}_2 \end{bmatrix}.$$ Solving these two equations in two unknowns yields the optimising prices: $$\hat{y}_1 = \frac{2}{3} \cdot x \quad \quad \quad \hat{y}_2 = \frac{1}{3} \cdot x.$$ Optimisation by backwards induction: With backward induction we begin by optimising the later decision, and then work backwards to optimise the earlier decision, assuming optimisation of the later decision. So, let's imagine that you have already made some first offer of $0 \leqslant y_1 \leqslant x$ and it has been rejected, so now you are going to make your second offer. Conditional on the rejection of the first offer, we have the posterior distribution $V | V < y_1 \sim \text{U}(0, y_1)$, so the expected profit from a new offer of $0 \leqslant y_2 \leqslant x$ is: $$\begin{equation} \begin{aligned} \bar{\pi}(y_2) &= \mathbb{E}(\pi_V(y_1,y_2) | V \sim \text{U}(0, y_1)) \\[6pt] &= \mathbb{E}(y_2 \cdot \mathbb{I}(y_2 \leqslant V) | V \sim \text{U}(0, y_1)) \\[6pt] &= y_2 \cdot \frac{y_1-y_2}{y_1} \cdot \mathbb{I}(y_2 < y_1) \\[6pt] &= \frac{1}{y_1} \cdot (y_2 y_1 - y_2^2) \cdot \mathbb{I}(y_2 < y_1) \\[6pt] \end{aligned} \end{equation}$$ Univariate optimisation (omitting the calculus steps) yields the optimising value: $$\hat{y}_2 = \frac{1}{2} \cdot y_1.$$ Having obtained this optimising value, we proceed backward to the first offer. Assuming that the second offer is optimal, the expected profit as a function of the first offer $y_1$ is: $$\begin{equation} \begin{aligned} \bar{\pi}(y_1|\hat{y}_2) &= \mathbb{E}(\pi_V(y_1,\hat{y}_2) | V \sim \text{U}(0, x)) \\[6pt] &= \mathbb{E}(\pi_V(y_1,y_1/2) | V \sim \text{U}(0, x)) \\[6pt] &= \mathbb{E}(y_1 \cdot \mathbb{I}(y_1 \leqslant V) + \frac{y_1}{2} \cdot \mathbb{I}(y_1/2 \leqslant V < y_1) | V \sim \text{U}(0, x)) \\[6pt] &= y_1 \cdot \mathbb{P}(y_1 \leqslant V) + \frac{y_1}{2} \cdot \mathbb{P}(y_1/2 \leqslant V < y_1) \\[6pt] &= y_1 \cdot \frac{x-y_1}{x} + \frac{y_1}{2} \cdot \frac{y_1/2}{x} \\[6pt] &= \frac{1}{x} \big( x y_1 - y_1^2 + \frac{y_1^2}{4} \big) \\[6pt] &= \frac{1}{x} \big( x y_1 - \frac{3 y_1^2}{4} \big). \\[6pt] \end{aligned} \end{equation}$$ Univariate optimisation (omitting the calculus steps) yields the optimising value: $$\hat{y}_1 = \frac{2}{3} \cdot x.$$ Substitution of this optimum offer to the second optimising offer then gives: $$\hat{y}_2 = \frac{1}{3} \cdot x.$$ This is the same answer that is obtained via direct optimisation. The above methods can easily be extended to the more general case where you have more than two opportunities for offers. As in the above case, the simplest method is the direct method ---i.e., you form a multivariate function for the expected profit conditional on a vector of offers, and then optimise this function using standard calculus techniques.
How to optimise waterfall questions of purchase value This kind of problem is an optimisation problem that can either be solved directly from the profit function, or in two-steps using backward induction. To show you how to uses either of these methods,
47,658
Multinomial distribution: probability that one outcome is greater than another
There is a closed form for this probability, but it is not particularly concise. To obtain the formula, start with the probability of the event of interest, conditional on the event $X_1+X_2=r$. It can easily be shown that: $$X_1 | X_1 + X_2 = r, n, \mathbf{p} \sim \text{Bin} \Big( r, \frac{p_1}{p_1+p_2} \Big).$$ Under the stated conditioning event, the event $X_1 \geqslant X_2$ is equivalent to the event $X_1 \geqslant r/2$. We therefore have the conditional probability: $$\begin{equation} \begin{aligned} \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) &= \mathbb{P}(X_1 \geqslant r-X_1 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \mathbb{P}(X_1 \geqslant r/2 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \mathbb{P}(X_1 \geqslant \lceil r/2 \rceil | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &=\sum_{x = \lceil r/2 \rceil}^r {r \choose x} \cdot \Big(\frac{p_1}{p_1+p_2}\Big)^x \cdot \Big(\frac{p_2}{p_1+p_2}\Big)^{r-x}\\[6pt] &= \frac{1}{(p_1+p_2)^r} \sum_{x = \lceil r/2 \rceil}^r {r \choose x} \cdot p_1^x \cdot p_2^{r-x}. \\[6pt] \end{aligned} \end{equation}$$ In practice, the upper tail of the binomial distribution is usually computed using the regularised incomplete beta function, rather than by summing the mass function. In this latter form, we have: $$\begin{equation} \begin{aligned} \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) &= 1-\mathbb{P}(X_1 \leqslant \lceil r/2 \rceil - 1 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= 1-I_{p_2/(p_1+p_2)}(r - \lceil r/2 \rceil + 1, \lceil r/2 \rceil). \\[6pt] \end{aligned} \end{equation}$$ Applying the law of total probability gives the marginal probability of interest: $$\begin{equation} \begin{aligned} \mathbb{P}(X_1 \geqslant X_2 | n, \mathbf{p}) &= \sum_{r=0}^n \mathbb{P}(X_1 + X_2 = r | n) \cdot \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \sum_{r=0}^n \text{Bin}(r|n, p_1+p_2) \cdot \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \sum_{r=0}^n {n \choose r} \cdot (1-(p_1+p_2))^{n-r} \sum_{x = \lceil r/2 \rceil}^r {r \choose x} \cdot p_1^x \cdot p_2^{r-x} \\[6pt] &= \sum_{r=0}^n {n \choose r} \cdot (p_1+p_2)^{r} \cdot (1-(p_1+p_2))^{n-r} \\[6pt] &\quad \quad \quad \times (1-I_{p_2/(p_1+p_2)}(r - \lceil r/2 \rceil + 1, \lceil r/2 \rceil)). \\[6pt] \end{aligned} \end{equation}$$ Either of the last two lines give a closed form solution to the problem. (The first is a sum over relevant values of the mass function of the binomial. The second uses the regularised incomplete beta function for the distribution. The latter is closer to what you would use when implementing the function in statistical computing.) Either expression is somewhat cumbersome for large $n$. Computing the probability: We can construct a function in R to compute this probability using the standard statistical distribution functions. (Since this computation involves adding very small probabilities we work in log-space for the computation, and then convert back to a standard probability at the end.) PROB <- function(n, p, log = FALSE) { #Normalise probability vector p <- p/sum(p) #Computeprobability LOGTERMS <- rep(0, n+1) LOGTERMS[1] <- dbinom(0, size = n, prob = p[1]+p[2], log = TRUE) CLOGPROB <- rep(0, n+1) for (r in 1:n) { CLOGPROB[r+1] <- pbinom(ceiling(r/2)-1, size = r, prob = p[1]/(p[1]+p[2]), lower.tail = FALSE, log.p = TRUE) LOGTERMS[r+1] <- dbinom(r, size = n, prob = p[1]+p[2], log = TRUE) + CLOGPROB[r+1] } LOGPROB <- matrixStats::logSumExp(LOGTERMS) if (log) { LOGPROB } else { exp(LOGPROB) } } This function is sufficiently efficient to compute the probability of interest up to quite large values of $n$. Basic tests show that it will compute for $n = 10^7$ in a few seconds. Below are some examples of use of this function for various values of $n$. As can be seen, even when the probability gets too small to see on the standard scale, we can still compute it on the log-probability scale. p <- c(0.20, 0.25, 0.55) PROB(1, p) [1] 0.75 PROB(2, p) [1] 0.6625 PROB(10, p) [1] 0.4987803 PROB(100, p) [1] 0.2503806 PROB(10^5, p) [1] 1.174474e-123 PROB(10^6, p) [1] 0 PROB(10^6, p, log = TRUE) [1] -2795.471 PROB(10^7, p, log = TRUE) [1] -27909.27 This function can be used to obtain the probability of interest up to large values of $n$. For values that are so large that they are computationally infeasible with this algorithm, we can then fall back on the normal approximation to the multinomial distribution.
Multinomial distribution: probability that one outcome is greater than another
There is a closed form for this probability, but it is not particularly concise. To obtain the formula, start with the probability of the event of interest, conditional on the event $X_1+X_2=r$. It
Multinomial distribution: probability that one outcome is greater than another There is a closed form for this probability, but it is not particularly concise. To obtain the formula, start with the probability of the event of interest, conditional on the event $X_1+X_2=r$. It can easily be shown that: $$X_1 | X_1 + X_2 = r, n, \mathbf{p} \sim \text{Bin} \Big( r, \frac{p_1}{p_1+p_2} \Big).$$ Under the stated conditioning event, the event $X_1 \geqslant X_2$ is equivalent to the event $X_1 \geqslant r/2$. We therefore have the conditional probability: $$\begin{equation} \begin{aligned} \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) &= \mathbb{P}(X_1 \geqslant r-X_1 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \mathbb{P}(X_1 \geqslant r/2 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \mathbb{P}(X_1 \geqslant \lceil r/2 \rceil | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &=\sum_{x = \lceil r/2 \rceil}^r {r \choose x} \cdot \Big(\frac{p_1}{p_1+p_2}\Big)^x \cdot \Big(\frac{p_2}{p_1+p_2}\Big)^{r-x}\\[6pt] &= \frac{1}{(p_1+p_2)^r} \sum_{x = \lceil r/2 \rceil}^r {r \choose x} \cdot p_1^x \cdot p_2^{r-x}. \\[6pt] \end{aligned} \end{equation}$$ In practice, the upper tail of the binomial distribution is usually computed using the regularised incomplete beta function, rather than by summing the mass function. In this latter form, we have: $$\begin{equation} \begin{aligned} \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) &= 1-\mathbb{P}(X_1 \leqslant \lceil r/2 \rceil - 1 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= 1-I_{p_2/(p_1+p_2)}(r - \lceil r/2 \rceil + 1, \lceil r/2 \rceil). \\[6pt] \end{aligned} \end{equation}$$ Applying the law of total probability gives the marginal probability of interest: $$\begin{equation} \begin{aligned} \mathbb{P}(X_1 \geqslant X_2 | n, \mathbf{p}) &= \sum_{r=0}^n \mathbb{P}(X_1 + X_2 = r | n) \cdot \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \sum_{r=0}^n \text{Bin}(r|n, p_1+p_2) \cdot \mathbb{P}(X_1 \geqslant X_2 | X_1 + X_2 = r, n, \mathbf{p}) \\[6pt] &= \sum_{r=0}^n {n \choose r} \cdot (1-(p_1+p_2))^{n-r} \sum_{x = \lceil r/2 \rceil}^r {r \choose x} \cdot p_1^x \cdot p_2^{r-x} \\[6pt] &= \sum_{r=0}^n {n \choose r} \cdot (p_1+p_2)^{r} \cdot (1-(p_1+p_2))^{n-r} \\[6pt] &\quad \quad \quad \times (1-I_{p_2/(p_1+p_2)}(r - \lceil r/2 \rceil + 1, \lceil r/2 \rceil)). \\[6pt] \end{aligned} \end{equation}$$ Either of the last two lines give a closed form solution to the problem. (The first is a sum over relevant values of the mass function of the binomial. The second uses the regularised incomplete beta function for the distribution. The latter is closer to what you would use when implementing the function in statistical computing.) Either expression is somewhat cumbersome for large $n$. Computing the probability: We can construct a function in R to compute this probability using the standard statistical distribution functions. (Since this computation involves adding very small probabilities we work in log-space for the computation, and then convert back to a standard probability at the end.) PROB <- function(n, p, log = FALSE) { #Normalise probability vector p <- p/sum(p) #Computeprobability LOGTERMS <- rep(0, n+1) LOGTERMS[1] <- dbinom(0, size = n, prob = p[1]+p[2], log = TRUE) CLOGPROB <- rep(0, n+1) for (r in 1:n) { CLOGPROB[r+1] <- pbinom(ceiling(r/2)-1, size = r, prob = p[1]/(p[1]+p[2]), lower.tail = FALSE, log.p = TRUE) LOGTERMS[r+1] <- dbinom(r, size = n, prob = p[1]+p[2], log = TRUE) + CLOGPROB[r+1] } LOGPROB <- matrixStats::logSumExp(LOGTERMS) if (log) { LOGPROB } else { exp(LOGPROB) } } This function is sufficiently efficient to compute the probability of interest up to quite large values of $n$. Basic tests show that it will compute for $n = 10^7$ in a few seconds. Below are some examples of use of this function for various values of $n$. As can be seen, even when the probability gets too small to see on the standard scale, we can still compute it on the log-probability scale. p <- c(0.20, 0.25, 0.55) PROB(1, p) [1] 0.75 PROB(2, p) [1] 0.6625 PROB(10, p) [1] 0.4987803 PROB(100, p) [1] 0.2503806 PROB(10^5, p) [1] 1.174474e-123 PROB(10^6, p) [1] 0 PROB(10^6, p, log = TRUE) [1] -2795.471 PROB(10^7, p, log = TRUE) [1] -27909.27 This function can be used to obtain the probability of interest up to large values of $n$. For values that are so large that they are computationally infeasible with this algorithm, we can then fall back on the normal approximation to the multinomial distribution.
Multinomial distribution: probability that one outcome is greater than another There is a closed form for this probability, but it is not particularly concise. To obtain the formula, start with the probability of the event of interest, conditional on the event $X_1+X_2=r$. It
47,659
Multinomial distribution: probability that one outcome is greater than another
Let $Z_i$ be independent draws from a categorical variable take takes values 1,2 and 3 with probability $p_1,p_2$ and $1-p_1-p_2$. Then, $X_k = \sum_{i=1}^n 1\{Z_i = k\}$ has the desired multinomial distribution. Let $Y_i = \{Z_i = 1\} - 1\{Z_i = 2\}$ and let $W_n = \sum_{i=1}^n Y_i$. The desired probability is $P(W_n \ge 0)$. Note that $Y_i$ takes values $1, -1$ and zero with probabilities $p_1, p_2$ and $1-p_1-p_2$. $W_n$ is a nonsymmetric lazy random walk. I am going to only consider the asymptotics. We have $E[Y_i] = p_1 - p_2$ and $var(Y_i) = p_1 + p_2 - (p_1-p_2)^2 =: v^2$. By CLT, $$ U_n := \frac{W_n - n(p_1-p_2)}{\sqrt{n} v} \to N(0,1) $$ Thus, $$P(W_n \ge 0) = P( U_n \ge -\sqrt{n}(p_1-p_2)/v) $$ which is going to go to $1$ or $0$ depneding on whether $p_1 > p_2$ or $p_1 < p_2$, respectively. A good approximation for large $n$ is $$ P(W_n \ge 0) \approx \Phi(\sqrt{n}(p_1-p_2)/v) $$ where $\Phi$ is the CDF of the normal distribution.
Multinomial distribution: probability that one outcome is greater than another
Let $Z_i$ be independent draws from a categorical variable take takes values 1,2 and 3 with probability $p_1,p_2$ and $1-p_1-p_2$. Then, $X_k = \sum_{i=1}^n 1\{Z_i = k\}$ has the desired multinomial d
Multinomial distribution: probability that one outcome is greater than another Let $Z_i$ be independent draws from a categorical variable take takes values 1,2 and 3 with probability $p_1,p_2$ and $1-p_1-p_2$. Then, $X_k = \sum_{i=1}^n 1\{Z_i = k\}$ has the desired multinomial distribution. Let $Y_i = \{Z_i = 1\} - 1\{Z_i = 2\}$ and let $W_n = \sum_{i=1}^n Y_i$. The desired probability is $P(W_n \ge 0)$. Note that $Y_i$ takes values $1, -1$ and zero with probabilities $p_1, p_2$ and $1-p_1-p_2$. $W_n$ is a nonsymmetric lazy random walk. I am going to only consider the asymptotics. We have $E[Y_i] = p_1 - p_2$ and $var(Y_i) = p_1 + p_2 - (p_1-p_2)^2 =: v^2$. By CLT, $$ U_n := \frac{W_n - n(p_1-p_2)}{\sqrt{n} v} \to N(0,1) $$ Thus, $$P(W_n \ge 0) = P( U_n \ge -\sqrt{n}(p_1-p_2)/v) $$ which is going to go to $1$ or $0$ depneding on whether $p_1 > p_2$ or $p_1 < p_2$, respectively. A good approximation for large $n$ is $$ P(W_n \ge 0) \approx \Phi(\sqrt{n}(p_1-p_2)/v) $$ where $\Phi$ is the CDF of the normal distribution.
Multinomial distribution: probability that one outcome is greater than another Let $Z_i$ be independent draws from a categorical variable take takes values 1,2 and 3 with probability $p_1,p_2$ and $1-p_1-p_2$. Then, $X_k = \sum_{i=1}^n 1\{Z_i = k\}$ has the desired multinomial d
47,660
What test can I use to compare intercepts from two or more regression models when slopes might differ?
I will answer the technical question, then try to talk you out of doing this. The intercept is the predicted value when the abscissa is equal to zero. Hence, the intercepts in the example are obtained via: > mod = lm(Sepal.Length ~ Petal.Width*Species, data = iris) > library("emmeans") > (emm = emmeans(mod, "Species", at = list(Petal.Width = 0))) NOTE: Results may be misleading due to involvement in interactions Species emmean SE df lower.CL upper.CL setosa 4.78 0.173 144 4.43 5.12 versicolor 4.04 0.464 144 3.13 4.96 virginica 5.27 0.509 144 4.26 6.28 Confidence level used: 0.95 ... and the comparisons thereof can be tested this way: > pairs(emm) contrast estimate SE df t.ratio p.value setosa - versicolor 0.733 0.495 144 1.480 0.3037 setosa - virginica -0.492 0.538 144 -0.915 0.6316 versicolor - virginica -1.225 0.689 144 -1.779 0.1804 P value adjustment: tukey method for comparing a family of 3 estimates That said, it is an unusual instance that the intercept is an interesting or meaningful quantity to want to do inferences about. In many datasets, the intercept is a severe extrapolation because a predictor value of zero is distant from its observed values. Models are only approximations to the truth, and it is highly questionable that one should believe that the straight line you have fitted actually represents the trend at a distant point. Thus, I urge you to re-think what you are trying to do and decide on what meaningful question you are really trying to answer.
What test can I use to compare intercepts from two or more regression models when slopes might diffe
I will answer the technical question, then try to talk you out of doing this. The intercept is the predicted value when the abscissa is equal to zero. Hence, the intercepts in the example are obtained
What test can I use to compare intercepts from two or more regression models when slopes might differ? I will answer the technical question, then try to talk you out of doing this. The intercept is the predicted value when the abscissa is equal to zero. Hence, the intercepts in the example are obtained via: > mod = lm(Sepal.Length ~ Petal.Width*Species, data = iris) > library("emmeans") > (emm = emmeans(mod, "Species", at = list(Petal.Width = 0))) NOTE: Results may be misleading due to involvement in interactions Species emmean SE df lower.CL upper.CL setosa 4.78 0.173 144 4.43 5.12 versicolor 4.04 0.464 144 3.13 4.96 virginica 5.27 0.509 144 4.26 6.28 Confidence level used: 0.95 ... and the comparisons thereof can be tested this way: > pairs(emm) contrast estimate SE df t.ratio p.value setosa - versicolor 0.733 0.495 144 1.480 0.3037 setosa - virginica -0.492 0.538 144 -0.915 0.6316 versicolor - virginica -1.225 0.689 144 -1.779 0.1804 P value adjustment: tukey method for comparing a family of 3 estimates That said, it is an unusual instance that the intercept is an interesting or meaningful quantity to want to do inferences about. In many datasets, the intercept is a severe extrapolation because a predictor value of zero is distant from its observed values. Models are only approximations to the truth, and it is highly questionable that one should believe that the straight line you have fitted actually represents the trend at a distant point. Thus, I urge you to re-think what you are trying to do and decide on what meaningful question you are really trying to answer.
What test can I use to compare intercepts from two or more regression models when slopes might diffe I will answer the technical question, then try to talk you out of doing this. The intercept is the predicted value when the abscissa is equal to zero. Hence, the intercepts in the example are obtained
47,661
What test can I use to compare intercepts from two or more regression models when slopes might differ?
In principle, once you have the linear regression object generated by lm(), you can test for significant differences between any desired linear combinations of predictor values that you wish by applying the formula for the variance of a sum to the covariance matrix for the linear regression, the matrix provided provided by vcov(lm()). You should correct, of course, for the multiple comparisons. The emmeans package provides one convenient way to perform such tests. That said, you need to be very careful about comparing intercepts when interaction terms are involved, particularly when one of the predictors is continuous with values far from 0. In your example, the intercept represents the Sepal.Length for each Species when the Petal.Width is exactly 0. Is that really a comparison you care about? In the iris dataset, the average Petal.Width values are 0.246, 1.326, and 2.026 for the Species setosa, versicolor, and virginica respectively. With such a range of Petal.Width values, what would be the point of examining the intercepts for Sepal.Lengthin the fictitious case when the Petal.Width is 0? I understand that you are using this dataset only as an example of a more general question, but the same cautions apply broadly to evaluations of intercepts when interactions are involved.
What test can I use to compare intercepts from two or more regression models when slopes might diffe
In principle, once you have the linear regression object generated by lm(), you can test for significant differences between any desired linear combinations of predictor values that you wish by applyi
What test can I use to compare intercepts from two or more regression models when slopes might differ? In principle, once you have the linear regression object generated by lm(), you can test for significant differences between any desired linear combinations of predictor values that you wish by applying the formula for the variance of a sum to the covariance matrix for the linear regression, the matrix provided provided by vcov(lm()). You should correct, of course, for the multiple comparisons. The emmeans package provides one convenient way to perform such tests. That said, you need to be very careful about comparing intercepts when interaction terms are involved, particularly when one of the predictors is continuous with values far from 0. In your example, the intercept represents the Sepal.Length for each Species when the Petal.Width is exactly 0. Is that really a comparison you care about? In the iris dataset, the average Petal.Width values are 0.246, 1.326, and 2.026 for the Species setosa, versicolor, and virginica respectively. With such a range of Petal.Width values, what would be the point of examining the intercepts for Sepal.Lengthin the fictitious case when the Petal.Width is 0? I understand that you are using this dataset only as an example of a more general question, but the same cautions apply broadly to evaluations of intercepts when interactions are involved.
What test can I use to compare intercepts from two or more regression models when slopes might diffe In principle, once you have the linear regression object generated by lm(), you can test for significant differences between any desired linear combinations of predictor values that you wish by applyi
47,662
How i add uniformly distributed noisy attributes to data set?
One way would be to train a model that learns the distribution of each feature separately; it could be a KDE for each feature. Then you could use this model to generate outliers for the data. I'd suggest producing the outliers by generating values at 4 std from the mean for a few of the features and generate realistic values for the rest. This will prevent the outliers to be too easily detectable.
How i add uniformly distributed noisy attributes to data set?
One way would be to train a model that learns the distribution of each feature separately; it could be a KDE for each feature. Then you could use this model to generate outliers for the data. I'd sugg
How i add uniformly distributed noisy attributes to data set? One way would be to train a model that learns the distribution of each feature separately; it could be a KDE for each feature. Then you could use this model to generate outliers for the data. I'd suggest producing the outliers by generating values at 4 std from the mean for a few of the features and generate realistic values for the rest. This will prevent the outliers to be too easily detectable.
How i add uniformly distributed noisy attributes to data set? One way would be to train a model that learns the distribution of each feature separately; it could be a KDE for each feature. Then you could use this model to generate outliers for the data. I'd sugg
47,663
ARIMAX vs. Regression With ARIMA Errors
Assuming you are fitting the regression with ARIMA error model using arima(), Arima() or auto.arima(), the estimation is done in one step, not two as you describe. That is, the regression coefficients are estimated simultaneously with the ARMA coefficients. If you are studying the effect of the exogenous variables, you are much better off using a regression with ARIMA errors than an ARIMAX model. In the ARIMAX model, the effect of the exogenous variables tends to get muddled up with the effect of the autoregression parts of the model as I explain in my blog post. On the other hand, the regression with ARIMA errors allows the regression coefficients to be interpreted in the usual way.
ARIMAX vs. Regression With ARIMA Errors
Assuming you are fitting the regression with ARIMA error model using arima(), Arima() or auto.arima(), the estimation is done in one step, not two as you describe. That is, the regression coefficients
ARIMAX vs. Regression With ARIMA Errors Assuming you are fitting the regression with ARIMA error model using arima(), Arima() or auto.arima(), the estimation is done in one step, not two as you describe. That is, the regression coefficients are estimated simultaneously with the ARMA coefficients. If you are studying the effect of the exogenous variables, you are much better off using a regression with ARIMA errors than an ARIMAX model. In the ARIMAX model, the effect of the exogenous variables tends to get muddled up with the effect of the autoregression parts of the model as I explain in my blog post. On the other hand, the regression with ARIMA errors allows the regression coefficients to be interpreted in the usual way.
ARIMAX vs. Regression With ARIMA Errors Assuming you are fitting the regression with ARIMA error model using arima(), Arima() or auto.arima(), the estimation is done in one step, not two as you describe. That is, the regression coefficients
47,664
Combining regression estimates by summing
Based on your clarification in the comments, and your amended notation, you want to use a Gaussian linear model where the parameters and error terms in each of the initial regressions are different. You therefore have the model: $$\begin{matrix} Y_{it}^{(1)} = \alpha_i^{(1)} + \gamma_t^{(1)} + X_{it}\beta^{(1)} + \epsilon_{it}^{(1)} & & & \epsilon_{it}^{(1)} \sim \text{N}(0, \sigma_1^2), \\[6pt] Y_{it}^{(2)} = \alpha_i^{(2)} + \gamma_t^{(2)} + X_{it}\beta^{(2)} + \epsilon_{it}^{(2)} & & & \epsilon_{it}^{(2)} \sim \text{N}(0, \sigma_1^2). \\[6pt] \end{matrix}$$ Taking the sum of the response variables gives the linear regression model: $$\begin{equation} \begin{aligned} Y_{it}^\text{sum} &\equiv Y_{it}^{(1)} + Y_{it}^{(2)} \\[6pt] &= \alpha_i^{(1)} + \gamma_t^{(1)} + X_{it} \beta^{(1)} + \epsilon_{it}^{(1)} + \alpha_i^{(2)} + \gamma_t^{(2)} + X_{it} \beta^{(2)} + \epsilon_{it}^{(2)} \\[6pt] &= (\alpha_i^{(1)} + \alpha_i^{(2)}) + (\gamma_t^{(1)} + \gamma_t^{(2)}) + X_{it} (\beta^{(1)} + \beta^{(2)}) + (\epsilon_{it}^{(1)} + \epsilon_{it}^{(2)}) \\[6pt] &= \alpha_i^\text{sum} + \gamma_t^\text{sum} + X_{it} \beta^\text{sum} + \epsilon_{it}^\text{sum}, \\[6pt] \end{aligned} \end{equation}$$ where we have the parameters and error terms given by: $$\begin{matrix} \alpha_i^\text{sum} = \alpha_i^{(1)} + \alpha_i^{(2)} & & & \gamma_t^\text{sum} + \gamma_t^{(2)} = \gamma_t^{(1)} + \gamma_t^{(2)} \\[6pt] \beta_\text{sum} = \beta_1 + \beta_2 \ \quad & & & \epsilon_{it}^\text{sum} \sim \text{N}(0,\sigma_1^2+\sigma_2^2). \\[6pt] \end{matrix}$$ This shows you that the true parameters in the regression model for the summed response are equal to the sums of the parameters in the individual regressions. Note that this does not imply that the parameters estimates will obey this relationship, and in general, they will not. If you use OLS estimation to estimate each of the underlying parameters, and you do the same for the summed model, you will find that the the sum of the estimated parameters for the smaller models will not be equal to the estimated parameter for the summed model.
Combining regression estimates by summing
Based on your clarification in the comments, and your amended notation, you want to use a Gaussian linear model where the parameters and error terms in each of the initial regressions are different.
Combining regression estimates by summing Based on your clarification in the comments, and your amended notation, you want to use a Gaussian linear model where the parameters and error terms in each of the initial regressions are different. You therefore have the model: $$\begin{matrix} Y_{it}^{(1)} = \alpha_i^{(1)} + \gamma_t^{(1)} + X_{it}\beta^{(1)} + \epsilon_{it}^{(1)} & & & \epsilon_{it}^{(1)} \sim \text{N}(0, \sigma_1^2), \\[6pt] Y_{it}^{(2)} = \alpha_i^{(2)} + \gamma_t^{(2)} + X_{it}\beta^{(2)} + \epsilon_{it}^{(2)} & & & \epsilon_{it}^{(2)} \sim \text{N}(0, \sigma_1^2). \\[6pt] \end{matrix}$$ Taking the sum of the response variables gives the linear regression model: $$\begin{equation} \begin{aligned} Y_{it}^\text{sum} &\equiv Y_{it}^{(1)} + Y_{it}^{(2)} \\[6pt] &= \alpha_i^{(1)} + \gamma_t^{(1)} + X_{it} \beta^{(1)} + \epsilon_{it}^{(1)} + \alpha_i^{(2)} + \gamma_t^{(2)} + X_{it} \beta^{(2)} + \epsilon_{it}^{(2)} \\[6pt] &= (\alpha_i^{(1)} + \alpha_i^{(2)}) + (\gamma_t^{(1)} + \gamma_t^{(2)}) + X_{it} (\beta^{(1)} + \beta^{(2)}) + (\epsilon_{it}^{(1)} + \epsilon_{it}^{(2)}) \\[6pt] &= \alpha_i^\text{sum} + \gamma_t^\text{sum} + X_{it} \beta^\text{sum} + \epsilon_{it}^\text{sum}, \\[6pt] \end{aligned} \end{equation}$$ where we have the parameters and error terms given by: $$\begin{matrix} \alpha_i^\text{sum} = \alpha_i^{(1)} + \alpha_i^{(2)} & & & \gamma_t^\text{sum} + \gamma_t^{(2)} = \gamma_t^{(1)} + \gamma_t^{(2)} \\[6pt] \beta_\text{sum} = \beta_1 + \beta_2 \ \quad & & & \epsilon_{it}^\text{sum} \sim \text{N}(0,\sigma_1^2+\sigma_2^2). \\[6pt] \end{matrix}$$ This shows you that the true parameters in the regression model for the summed response are equal to the sums of the parameters in the individual regressions. Note that this does not imply that the parameters estimates will obey this relationship, and in general, they will not. If you use OLS estimation to estimate each of the underlying parameters, and you do the same for the summed model, you will find that the the sum of the estimated parameters for the smaller models will not be equal to the estimated parameter for the summed model.
Combining regression estimates by summing Based on your clarification in the comments, and your amended notation, you want to use a Gaussian linear model where the parameters and error terms in each of the initial regressions are different.
47,665
Combining regression estimates by summing
$Y_1 \sim \mathcal{N}(X\beta_1,\sigma_1^2)$ ==> $Y_1=X\beta_1+\epsilon_1$ and $\epsilon_1\sim \mathcal{N}(0,\sigma_1^2) $ $Y_2 \sim \mathcal{N}(X\beta_2,\sigma_2^2)$ ==> $Y_2=X\beta_2+\epsilon_2$ and $\epsilon_2\sim \mathcal{N}(0,\sigma_2^2) $ Assume $\epsilon_1$ and $\epsilon_2$ are independent, then $Y_1 + Y_2 \sim \mathcal{N}(X(\beta_1+\beta_2),\sigma_1^2 + \sigma_2^2)$ or $Y_1+ Y_2=X(\beta_1+\beta_2)+\epsilon_3$ and $\epsilon_3 = \epsilon_1 + \epsilon_2 \sim \mathcal{N}(0,\sigma_1^2+\sigma_2^2) $ Now let check the estimate. $\hat \beta_1 = (X'X)^{-1}Y_1$ $\hat \beta_2 = (X'X)^{-1}Y_2$ $\widehat {\beta_1 + \beta_2}= (X'X)^{-1}(Y_1+Y_2) = (X'X)^{-1}Y_1 + (X'X)^{-1}Y_2 = \hat \beta_1 + \hat \beta_2$ About "The empirical results don't agree with that", the real data and model are needed for further discussion. This conclusion is not correct for Poisson regression, because log link function is used in Poisson regression.
Combining regression estimates by summing
$Y_1 \sim \mathcal{N}(X\beta_1,\sigma_1^2)$ ==> $Y_1=X\beta_1+\epsilon_1$ and $\epsilon_1\sim \mathcal{N}(0,\sigma_1^2) $ $Y_2 \sim \mathcal{N}(X\beta_2,\sigma_2^2)$ ==> $Y_2=X\beta_2+\epsilon_2$ an
Combining regression estimates by summing $Y_1 \sim \mathcal{N}(X\beta_1,\sigma_1^2)$ ==> $Y_1=X\beta_1+\epsilon_1$ and $\epsilon_1\sim \mathcal{N}(0,\sigma_1^2) $ $Y_2 \sim \mathcal{N}(X\beta_2,\sigma_2^2)$ ==> $Y_2=X\beta_2+\epsilon_2$ and $\epsilon_2\sim \mathcal{N}(0,\sigma_2^2) $ Assume $\epsilon_1$ and $\epsilon_2$ are independent, then $Y_1 + Y_2 \sim \mathcal{N}(X(\beta_1+\beta_2),\sigma_1^2 + \sigma_2^2)$ or $Y_1+ Y_2=X(\beta_1+\beta_2)+\epsilon_3$ and $\epsilon_3 = \epsilon_1 + \epsilon_2 \sim \mathcal{N}(0,\sigma_1^2+\sigma_2^2) $ Now let check the estimate. $\hat \beta_1 = (X'X)^{-1}Y_1$ $\hat \beta_2 = (X'X)^{-1}Y_2$ $\widehat {\beta_1 + \beta_2}= (X'X)^{-1}(Y_1+Y_2) = (X'X)^{-1}Y_1 + (X'X)^{-1}Y_2 = \hat \beta_1 + \hat \beta_2$ About "The empirical results don't agree with that", the real data and model are needed for further discussion. This conclusion is not correct for Poisson regression, because log link function is used in Poisson regression.
Combining regression estimates by summing $Y_1 \sim \mathcal{N}(X\beta_1,\sigma_1^2)$ ==> $Y_1=X\beta_1+\epsilon_1$ and $\epsilon_1\sim \mathcal{N}(0,\sigma_1^2) $ $Y_2 \sim \mathcal{N}(X\beta_2,\sigma_2^2)$ ==> $Y_2=X\beta_2+\epsilon_2$ an
47,666
Combining regression estimates by summing
Short answer: In the described theoretical setting, you are right to expect $\beta_3 = \beta_1+\beta_2$ in the linear setting. The time- and individual- FE does not change it. In the linear setting, $\beta_3$ can differ from $\beta_1+\beta_2$ for instance due to data limitations. (please look at the bottom of the posted answer) In a Poisson setting, there is no reason that the first two coefficients would sum to the third one. This is also not due to the time- and individual- FE. Longer answer: Some (Stata) code showing it for illustrative purposes is available here: https://sites.google.com/view/acazenave-lacroutz/stack_ansa 1 & 3/**Note that on this dataset (without any missig value) I get that $\beta_3$ is **exactly the sum of $\beta1+\beta_2$ when using linear fixed-effects equations, but are far from being equal when using fixed-effect Poisson equations. Fixed-effects are a distraction here. Consider here they are just dummy variables. I rewrite the linear equations: $$(Reg1): Y_1 = X\beta_1 + \epsilon_1 $$ $$(Reg2): Y_2 = X\beta_2 + \epsilon_2 $$ $$(Reg3): Y_3 = X\beta_3 + \epsilon_3 $$ There are explicit solutions/estimates for the various $\beta$: $$\beta_1 = (X'X)^{-1}X'Y_1 $$ $$\beta_2 = (X'X)^{-1}X'Y_2 $$ $$\beta_3 = (X'X)^{-1}X'Y_3 $$ One indeed gets: $\beta_3 = \beta_1+\beta_2$ when using $Y_3=Y_1+Y_2$ No assumption is needed regarding independence between $\epsilon_1$ and $\epsilon_2$. Save random numerical approximations when computing inverse of the matrix (X'X), the equality should perfectly hold in the linear case (just try it). What about the Poisson case ? Here, your model writes (I index your explanatory variables with letters): $$E(Y_i|X) = e^{X\beta_i}=e^{x_a\beta_{i,a}+...+x_p\beta_{i,p}} $$ How to interpret the $\beta$ coefficients ? A increase by $dx_a$ will turn: $E(Y_1|X)$ into $e^{dx_a \times \beta_{1,a}} E(Y_1|X)$ $E(Y_2|X)$ into $e^{dx_a \times \beta_{2,a}} E(Y_2|X)$ $E(Y_3|X)$ into $e^{dx_a \times \beta_{3,a}} E(Y_3|X)$ In order to have $Y_3=Y_1+Y_2$, you expect: $$(1): e^{dx_a \times \beta_{3,a}} (E(Y_1|X)+E(Y_2|X)) = e^{dx_a \times \beta_{1,a}} E(Y_1|X) +e^{dx_a \times \beta_{2,a}} E(Y_2|X)$$ I do not know a more general relationship between $\beta_1$ and $\beta_2$ but this clearly shows that in general you do not have: $\beta_{3,a} = \beta_{1,a}+\beta_{2,a}$ . (To do so, consider the trivial case where $\beta_{1,a}=\beta_{2,a}$. In this case, equation (1) becomes: $$(1_{trivial}): e^{dx_a \times \beta_{3,a}} (E(Y_1|X)+E(Y_2|X)) = e^{dx_a \times \beta_{1,a}} (E(Y_1|X)+E(Y_2|X))$$ Save $E(Y_1|X)+E(Y_2|X)=0$, this implies: $\beta_3 = \beta_1 =\beta_2 $. Hence, when it is different from zero, it is different from $ \beta_1+\beta_2$ ) 2/ But there are probably some missing values in your dataset. More precisely, perhaps some observations are missing for some individual $i$ (or time $t$) for $Y_{1,i,t}$, while some other observations are missing for some individual $j$ (or time $u$) for $Y_{1,j,u}. Hence, your are: Estimating $\beta_1$ on the individuals for which $Y_1$ is not lacking. Estimating $\beta_2$ on the individuals for which $Y_2$ is not lacking. Estimating $\beta_3$ on the individuals for which $Y_1$ and $Y_2$ are not lacking. This implies you are comparing estimates fom three different datasets. In this case, it is possible that you do not have $\beta_3 = \beta_1+\beta_2$, even in the linear setting.
Combining regression estimates by summing
Short answer: In the described theoretical setting, you are right to expect $\beta_3 = \beta_1+\beta_2$ in the linear setting. The time- and individual- FE does not change it. In the linear setting,
Combining regression estimates by summing Short answer: In the described theoretical setting, you are right to expect $\beta_3 = \beta_1+\beta_2$ in the linear setting. The time- and individual- FE does not change it. In the linear setting, $\beta_3$ can differ from $\beta_1+\beta_2$ for instance due to data limitations. (please look at the bottom of the posted answer) In a Poisson setting, there is no reason that the first two coefficients would sum to the third one. This is also not due to the time- and individual- FE. Longer answer: Some (Stata) code showing it for illustrative purposes is available here: https://sites.google.com/view/acazenave-lacroutz/stack_ansa 1 & 3/**Note that on this dataset (without any missig value) I get that $\beta_3$ is **exactly the sum of $\beta1+\beta_2$ when using linear fixed-effects equations, but are far from being equal when using fixed-effect Poisson equations. Fixed-effects are a distraction here. Consider here they are just dummy variables. I rewrite the linear equations: $$(Reg1): Y_1 = X\beta_1 + \epsilon_1 $$ $$(Reg2): Y_2 = X\beta_2 + \epsilon_2 $$ $$(Reg3): Y_3 = X\beta_3 + \epsilon_3 $$ There are explicit solutions/estimates for the various $\beta$: $$\beta_1 = (X'X)^{-1}X'Y_1 $$ $$\beta_2 = (X'X)^{-1}X'Y_2 $$ $$\beta_3 = (X'X)^{-1}X'Y_3 $$ One indeed gets: $\beta_3 = \beta_1+\beta_2$ when using $Y_3=Y_1+Y_2$ No assumption is needed regarding independence between $\epsilon_1$ and $\epsilon_2$. Save random numerical approximations when computing inverse of the matrix (X'X), the equality should perfectly hold in the linear case (just try it). What about the Poisson case ? Here, your model writes (I index your explanatory variables with letters): $$E(Y_i|X) = e^{X\beta_i}=e^{x_a\beta_{i,a}+...+x_p\beta_{i,p}} $$ How to interpret the $\beta$ coefficients ? A increase by $dx_a$ will turn: $E(Y_1|X)$ into $e^{dx_a \times \beta_{1,a}} E(Y_1|X)$ $E(Y_2|X)$ into $e^{dx_a \times \beta_{2,a}} E(Y_2|X)$ $E(Y_3|X)$ into $e^{dx_a \times \beta_{3,a}} E(Y_3|X)$ In order to have $Y_3=Y_1+Y_2$, you expect: $$(1): e^{dx_a \times \beta_{3,a}} (E(Y_1|X)+E(Y_2|X)) = e^{dx_a \times \beta_{1,a}} E(Y_1|X) +e^{dx_a \times \beta_{2,a}} E(Y_2|X)$$ I do not know a more general relationship between $\beta_1$ and $\beta_2$ but this clearly shows that in general you do not have: $\beta_{3,a} = \beta_{1,a}+\beta_{2,a}$ . (To do so, consider the trivial case where $\beta_{1,a}=\beta_{2,a}$. In this case, equation (1) becomes: $$(1_{trivial}): e^{dx_a \times \beta_{3,a}} (E(Y_1|X)+E(Y_2|X)) = e^{dx_a \times \beta_{1,a}} (E(Y_1|X)+E(Y_2|X))$$ Save $E(Y_1|X)+E(Y_2|X)=0$, this implies: $\beta_3 = \beta_1 =\beta_2 $. Hence, when it is different from zero, it is different from $ \beta_1+\beta_2$ ) 2/ But there are probably some missing values in your dataset. More precisely, perhaps some observations are missing for some individual $i$ (or time $t$) for $Y_{1,i,t}$, while some other observations are missing for some individual $j$ (or time $u$) for $Y_{1,j,u}. Hence, your are: Estimating $\beta_1$ on the individuals for which $Y_1$ is not lacking. Estimating $\beta_2$ on the individuals for which $Y_2$ is not lacking. Estimating $\beta_3$ on the individuals for which $Y_1$ and $Y_2$ are not lacking. This implies you are comparing estimates fom three different datasets. In this case, it is possible that you do not have $\beta_3 = \beta_1+\beta_2$, even in the linear setting.
Combining regression estimates by summing Short answer: In the described theoretical setting, you are right to expect $\beta_3 = \beta_1+\beta_2$ in the linear setting. The time- and individual- FE does not change it. In the linear setting,
47,667
Combining regression estimates by summing
**** Edits to the question made this answer obsolete **** I'm no expert, so interpret with caution. Isn't the model that you fit for the sum supposed to be $$ Y^{sum} = 2 \alpha_i + 2\gamma_t + \beta_3 X + 2\epsilon_{it}, $$ thus changing what you should expect. This assumes that your parameters $\alpha_i$ and $\gamma_t$ are the same for the two models, which I think is what you meant. Correct me if I'm wrong. Also, concerning the claim: $\mathbb{Var}(Y^1 + Y^2) = \mathbb{Var}(Y^1) + \mathbb{Var}(Y^2) = \sigma_1^2 + \sigma_2^2$. It seems to me that you rather have the following: $$ \mathbb{Var}(Y^1 + Y^2) = \sigma_1^2 + \sigma_2^2 + 2 \mathbb{Cov}(Y^1,Y^2) $$ where $\mathbb{Cov}(Y^1,Y^2) \neq 0$, since both variables depend on $X$.
Combining regression estimates by summing
**** Edits to the question made this answer obsolete **** I'm no expert, so interpret with caution. Isn't the model that you fit for the sum supposed to be $$ Y^{sum} = 2 \alpha_i + 2\gamma_t + \beta_
Combining regression estimates by summing **** Edits to the question made this answer obsolete **** I'm no expert, so interpret with caution. Isn't the model that you fit for the sum supposed to be $$ Y^{sum} = 2 \alpha_i + 2\gamma_t + \beta_3 X + 2\epsilon_{it}, $$ thus changing what you should expect. This assumes that your parameters $\alpha_i$ and $\gamma_t$ are the same for the two models, which I think is what you meant. Correct me if I'm wrong. Also, concerning the claim: $\mathbb{Var}(Y^1 + Y^2) = \mathbb{Var}(Y^1) + \mathbb{Var}(Y^2) = \sigma_1^2 + \sigma_2^2$. It seems to me that you rather have the following: $$ \mathbb{Var}(Y^1 + Y^2) = \sigma_1^2 + \sigma_2^2 + 2 \mathbb{Cov}(Y^1,Y^2) $$ where $\mathbb{Cov}(Y^1,Y^2) \neq 0$, since both variables depend on $X$.
Combining regression estimates by summing **** Edits to the question made this answer obsolete **** I'm no expert, so interpret with caution. Isn't the model that you fit for the sum supposed to be $$ Y^{sum} = 2 \alpha_i + 2\gamma_t + \beta_
47,668
Non-uniform distribution of p-values
As whuber has commented: the Kolmogorov-Smirnov test is only valid as a comparison against a fully specified distribution. You cannot use it to compare an observed distribution against a distribution whose parameters have been estimated based on your observed sample. If you do so, your p-values will not be uniformly distributed under the null hypothesis, but show the exact pattern you have observed. This is unfortunately an extremely common error, which you can very often find in online tutorials. As a little illustration, let us simulate $x_1, \dots, x_{20}\sim N(0,1)$, then run a K-S test first against a fully specified $N(0,1)$ distribution, then against an estimated $N(\hat{\mu},\hat{\sigma}^2)$ distribution, where $\hat{\mu}$ and $\hat{\sigma}^2$ are estimated based on $x_1, \dots, x_{20}$. Record the $p$ value. Do this 10,000 times. Here are histograms of the $p$ values: As you see, the $p$ values of the tests against a fully specified distribution are uniformly distributed, as they should be, but the ones from a fitted distribution are anything but. n_sims <- 1e4 nn <- 20 pp_estimated <- pp_specified <- rep(NA,n_sims) pb <- winProgressBar(max=n_sims) for ( ii in 1:n_sims ) { setWinProgressBar(pb,ii,paste(ii,"of",n_sims)) set.seed(ii) sim <- rnorm(nn) pp_specified[ii] <- ks.test(sim,y="pnorm",mean=0,sd=1)$p pp_estimated[ii] <- ks.test(sim,y="pnorm",mean=mean(sim),sd=sd(sim))$p } close(pb) opar <- par(mfrow=c(1,2)) hist(pp_specified,main="Parameters specified",xlab="",col="lightgray") hist(pp_estimated,main="Parameters estimated",xlab="",col="lightgray") par(opar) If your hypothesized reference distribution is normal, but you need to estimate the mean and variance, then the Lilliefors test would be appropriate. Other approaches may work for other distribution types. You may want to ask a specific question for the distribution type you are interested in. I do not know of general framework for goodness-of-fit tests for fitted distributions. (As an extreme example, you could always use the empirical distribution of the data you observe. Of course, the fit would be perfect. But this would also likely not be very informative.) EDIT - I just asked the general question here: Goodness of fit to a fitted distribution.
Non-uniform distribution of p-values
As whuber has commented: the Kolmogorov-Smirnov test is only valid as a comparison against a fully specified distribution. You cannot use it to compare an observed distribution against a distribution
Non-uniform distribution of p-values As whuber has commented: the Kolmogorov-Smirnov test is only valid as a comparison against a fully specified distribution. You cannot use it to compare an observed distribution against a distribution whose parameters have been estimated based on your observed sample. If you do so, your p-values will not be uniformly distributed under the null hypothesis, but show the exact pattern you have observed. This is unfortunately an extremely common error, which you can very often find in online tutorials. As a little illustration, let us simulate $x_1, \dots, x_{20}\sim N(0,1)$, then run a K-S test first against a fully specified $N(0,1)$ distribution, then against an estimated $N(\hat{\mu},\hat{\sigma}^2)$ distribution, where $\hat{\mu}$ and $\hat{\sigma}^2$ are estimated based on $x_1, \dots, x_{20}$. Record the $p$ value. Do this 10,000 times. Here are histograms of the $p$ values: As you see, the $p$ values of the tests against a fully specified distribution are uniformly distributed, as they should be, but the ones from a fitted distribution are anything but. n_sims <- 1e4 nn <- 20 pp_estimated <- pp_specified <- rep(NA,n_sims) pb <- winProgressBar(max=n_sims) for ( ii in 1:n_sims ) { setWinProgressBar(pb,ii,paste(ii,"of",n_sims)) set.seed(ii) sim <- rnorm(nn) pp_specified[ii] <- ks.test(sim,y="pnorm",mean=0,sd=1)$p pp_estimated[ii] <- ks.test(sim,y="pnorm",mean=mean(sim),sd=sd(sim))$p } close(pb) opar <- par(mfrow=c(1,2)) hist(pp_specified,main="Parameters specified",xlab="",col="lightgray") hist(pp_estimated,main="Parameters estimated",xlab="",col="lightgray") par(opar) If your hypothesized reference distribution is normal, but you need to estimate the mean and variance, then the Lilliefors test would be appropriate. Other approaches may work for other distribution types. You may want to ask a specific question for the distribution type you are interested in. I do not know of general framework for goodness-of-fit tests for fitted distributions. (As an extreme example, you could always use the empirical distribution of the data you observe. Of course, the fit would be perfect. But this would also likely not be very informative.) EDIT - I just asked the general question here: Goodness of fit to a fitted distribution.
Non-uniform distribution of p-values As whuber has commented: the Kolmogorov-Smirnov test is only valid as a comparison against a fully specified distribution. You cannot use it to compare an observed distribution against a distribution
47,669
Why is bagging stable classifiers not a good idea?
Summary: bagging is a bias-variance tradeoff for the model, accepting some bias to reduce variance. If there's nothing to gain by reducing variance, there can still be losses due to bias compared to training on $\mathcal L$. We can check whether variance reduction leads to substantial improvements (also in situations where we cannot measure the corresponding bias) and thus restrict the use of aggregation to cases where we see substantial reduction in loss due to model instability. Let's look at this in two steps: bootstrapping as resampling and aggregation. Aggregation reduces variance. More precisely, the variance in the predictions that is due to the models being unstable wrt. exchanging a few training cases. If the variance is negligible, aggregation doesn't help overall. But it also doesn't hurt: if all surrogate models yield equal predictions (as they do when stable), the aggregate prediction is always the same as the predicitons of each of the surrogate models. So at this level, the predictive ability is the same whether you aggregate stable surrogate models or not. Things may be different wrt. to step 1, though. Consider training models $\phi (\mathbf x, \mathcal L)$ on the full dataset at hand $\mathcal L$ vsr. training models $\phi_b (\mathbf x, \mathcal L_B)$ on bootstrap samples of $\mathcal L$ ($\mathcal L_B$). The bootstrap models $\phi_b$ can on average be worse than the models $\phi$ trained on the full dataset $\mathcal L$, i.e. they may be biased. I'm not aware of papers that study this bias of the bootstrap models $\phi_b$, but: Excursion: out-of-bootstrap estimation of generalization error The same mechanism, namely that (non-aggregated) models $\phi_b (\mathbf x, \mathcal L_B)$ trained on bootstrap subsamples $\mathcal L_B$ are on average worse than models $\phi (\mathbf x, \mathcal L)$ trained on the full learning set $\mathcal L$, is also the source of bias for out-of-bootstrap estimates of generalization error (oob error). The bias and variance properties of oob erros have been extensively studied (e.g. Kohavi, R.: A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection, Mellish, C. S. (ed.) Artificial Intelligence Proceedings 14$^th$ International Joint Conference, 20 -- 25. August 1995, Montréal, Québec, Canada, Morgan Kaufmann, USA, , 1137 - 1145 (1995). is a famous paper on the topic. We also observed substantial bias for oob estimates for classification of spectroscopic data: Beleites, C.; Baumgartner, R.; Bowman, C.; Somorjai, R.; Steiner, G.; Salzer, R. & Sowa, M. G.: Variance reduction in estimating classification error using sparse datasets, Chemom Intell Lab Syst, 79, 91 - 100 (2005). ). For generalization error, we can nicely and unambiguously refer to this bias as a pessimistic bias because out-of-bootstrap on average yields too high error compared to the true error of the model trained on the whole data set $\phi (\mathbf x, \mathcal L)$. This bias for generalization error is actually caused by an unbiased estimate of generalization error of biased predictions by the surrogate models $\phi_b(\mathbf x, \mathcal L_B)$ (which are the very same models that are aggregated in bagging). We may also call the models themselves biased, but how such a model bias looks inside the model depends a lot on what model we are talking about. But this can take the form of the model's internal parameters (e.g. coefficients) being on average off of the parameters corresponding to the true underlying relationship. Back to bagging: Intuitively, the underlying reason for the worse (average) performance of $\phi_b (\mathbf x, \mathcal L_B)$ compared to the performance of $\phi (\mathbf x, \mathcal L)$ is that subsampling $\mathcal L \mapsto \mathcal L_B$ looses a bit of information by substituting some data points by copies of other cases. A copy of an already known case usually doesn't add a "full case's worth of information". The consequence of that is that the models trained on $\mathcal L_B$ are on average a bit worse than those trained on $\mathcal L$. I'd argue this bias is tied to the learning curve of the algorithm/application combination, i.e. to whether adding more (real) data points to $\mathcal L$ leads to substantial improvement of the model (on average/expectation). So, aggregating helps to stabilize models. But to get the models to aggregate, bootstrap resampling accepts a bias for each single model. Thus, bagging helps iff the stabilization (reduction in performance loss due to model variance) is larger than the loss in performance due to the bias of the models based on bootstrap resampled variants of the whole data set at hand. bagging hurts iff the bias is larger than the reduction in variance for out-of-bag or out-of-bootstrap, the bias will not show here. The resulting heuristic is to go for bagging only if the out-of-bootstrap predictions are in fact unstable. This is easy to assess: compare the out-of-bag error to the out-of-bootstrap error - the calculations for this are of negligible additional effort. Out-of-bag and out-of-bootstrap error estimates are subject to exactly the same bias compared to the true performance of $\phi (\mathbf x, \mathcal L)$, though. That bias will in practice be more difficult to measure: considering that model instability is a concern in small sample size situations, a sufficiently precise estimate of the performance of $\phi (\mathbf x, \mathcal L)$ may not be available. Note: if in the first place you do cross validation instead of out-of-bootstrap and find model instability, you can also aggregate cross validation surrogate models instead of bagging (and calculate aggregatedd cross validation error in analogy to out-of-bag error).
Why is bagging stable classifiers not a good idea?
Summary: bagging is a bias-variance tradeoff for the model, accepting some bias to reduce variance. If there's nothing to gain by reducing variance, there can still be losses due to bias compared to
Why is bagging stable classifiers not a good idea? Summary: bagging is a bias-variance tradeoff for the model, accepting some bias to reduce variance. If there's nothing to gain by reducing variance, there can still be losses due to bias compared to training on $\mathcal L$. We can check whether variance reduction leads to substantial improvements (also in situations where we cannot measure the corresponding bias) and thus restrict the use of aggregation to cases where we see substantial reduction in loss due to model instability. Let's look at this in two steps: bootstrapping as resampling and aggregation. Aggregation reduces variance. More precisely, the variance in the predictions that is due to the models being unstable wrt. exchanging a few training cases. If the variance is negligible, aggregation doesn't help overall. But it also doesn't hurt: if all surrogate models yield equal predictions (as they do when stable), the aggregate prediction is always the same as the predicitons of each of the surrogate models. So at this level, the predictive ability is the same whether you aggregate stable surrogate models or not. Things may be different wrt. to step 1, though. Consider training models $\phi (\mathbf x, \mathcal L)$ on the full dataset at hand $\mathcal L$ vsr. training models $\phi_b (\mathbf x, \mathcal L_B)$ on bootstrap samples of $\mathcal L$ ($\mathcal L_B$). The bootstrap models $\phi_b$ can on average be worse than the models $\phi$ trained on the full dataset $\mathcal L$, i.e. they may be biased. I'm not aware of papers that study this bias of the bootstrap models $\phi_b$, but: Excursion: out-of-bootstrap estimation of generalization error The same mechanism, namely that (non-aggregated) models $\phi_b (\mathbf x, \mathcal L_B)$ trained on bootstrap subsamples $\mathcal L_B$ are on average worse than models $\phi (\mathbf x, \mathcal L)$ trained on the full learning set $\mathcal L$, is also the source of bias for out-of-bootstrap estimates of generalization error (oob error). The bias and variance properties of oob erros have been extensively studied (e.g. Kohavi, R.: A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection, Mellish, C. S. (ed.) Artificial Intelligence Proceedings 14$^th$ International Joint Conference, 20 -- 25. August 1995, Montréal, Québec, Canada, Morgan Kaufmann, USA, , 1137 - 1145 (1995). is a famous paper on the topic. We also observed substantial bias for oob estimates for classification of spectroscopic data: Beleites, C.; Baumgartner, R.; Bowman, C.; Somorjai, R.; Steiner, G.; Salzer, R. & Sowa, M. G.: Variance reduction in estimating classification error using sparse datasets, Chemom Intell Lab Syst, 79, 91 - 100 (2005). ). For generalization error, we can nicely and unambiguously refer to this bias as a pessimistic bias because out-of-bootstrap on average yields too high error compared to the true error of the model trained on the whole data set $\phi (\mathbf x, \mathcal L)$. This bias for generalization error is actually caused by an unbiased estimate of generalization error of biased predictions by the surrogate models $\phi_b(\mathbf x, \mathcal L_B)$ (which are the very same models that are aggregated in bagging). We may also call the models themselves biased, but how such a model bias looks inside the model depends a lot on what model we are talking about. But this can take the form of the model's internal parameters (e.g. coefficients) being on average off of the parameters corresponding to the true underlying relationship. Back to bagging: Intuitively, the underlying reason for the worse (average) performance of $\phi_b (\mathbf x, \mathcal L_B)$ compared to the performance of $\phi (\mathbf x, \mathcal L)$ is that subsampling $\mathcal L \mapsto \mathcal L_B$ looses a bit of information by substituting some data points by copies of other cases. A copy of an already known case usually doesn't add a "full case's worth of information". The consequence of that is that the models trained on $\mathcal L_B$ are on average a bit worse than those trained on $\mathcal L$. I'd argue this bias is tied to the learning curve of the algorithm/application combination, i.e. to whether adding more (real) data points to $\mathcal L$ leads to substantial improvement of the model (on average/expectation). So, aggregating helps to stabilize models. But to get the models to aggregate, bootstrap resampling accepts a bias for each single model. Thus, bagging helps iff the stabilization (reduction in performance loss due to model variance) is larger than the loss in performance due to the bias of the models based on bootstrap resampled variants of the whole data set at hand. bagging hurts iff the bias is larger than the reduction in variance for out-of-bag or out-of-bootstrap, the bias will not show here. The resulting heuristic is to go for bagging only if the out-of-bootstrap predictions are in fact unstable. This is easy to assess: compare the out-of-bag error to the out-of-bootstrap error - the calculations for this are of negligible additional effort. Out-of-bag and out-of-bootstrap error estimates are subject to exactly the same bias compared to the true performance of $\phi (\mathbf x, \mathcal L)$, though. That bias will in practice be more difficult to measure: considering that model instability is a concern in small sample size situations, a sufficiently precise estimate of the performance of $\phi (\mathbf x, \mathcal L)$ may not be available. Note: if in the first place you do cross validation instead of out-of-bootstrap and find model instability, you can also aggregate cross validation surrogate models instead of bagging (and calculate aggregatedd cross validation error in analogy to out-of-bag error).
Why is bagging stable classifiers not a good idea? Summary: bagging is a bias-variance tradeoff for the model, accepting some bias to reduce variance. If there's nothing to gain by reducing variance, there can still be losses due to bias compared to
47,670
What is the correct definition of the root mean square percentage error (RMSPE)?
There are several alternative sources (Swanson et al., Fomby, Shcherbakov et al.), which agree that the RMSPE is defined as: \begin{equation} \text{RMSPE} = \sqrt{\frac{1}{n} \cdot \sum_{i=1}^n \Delta X^2_{\text{rel},i}} \cdot 100\% \end{equation}
What is the correct definition of the root mean square percentage error (RMSPE)?
There are several alternative sources (Swanson et al., Fomby, Shcherbakov et al.), which agree that the RMSPE is defined as: \begin{equation} \text{RMSPE} = \sqrt{\frac{1}{n} \cdot \sum_{i=1}^n \Delta
What is the correct definition of the root mean square percentage error (RMSPE)? There are several alternative sources (Swanson et al., Fomby, Shcherbakov et al.), which agree that the RMSPE is defined as: \begin{equation} \text{RMSPE} = \sqrt{\frac{1}{n} \cdot \sum_{i=1}^n \Delta X^2_{\text{rel},i}} \cdot 100\% \end{equation}
What is the correct definition of the root mean square percentage error (RMSPE)? There are several alternative sources (Swanson et al., Fomby, Shcherbakov et al.), which agree that the RMSPE is defined as: \begin{equation} \text{RMSPE} = \sqrt{\frac{1}{n} \cdot \sum_{i=1}^n \Delta
47,671
Camera trapping and the Poisson distribution
It is almost never a good idea to use a Poisson distribution (or any other single parameter distribution) for modelling --- this distribution fixes the variance in relation to the mean, which means that the model does not allow the estimated variability to conform to the data. For this type of data, you should use a negative binomial model instead. This is a generalisation of the Poisson distribution (coming from mixtures of the Poisson) that has an additional parameter affecting the variance. It is also worth noting that, in cases like this, some analysts use "over-dispersion tests", but even these are unnecessary unless there is a strong a priori theoretical reason to prefer a Poisson model. There is no strong a priori reason to prefer the Poisson in this case, so I would recommend starting with a negative binomial model. This model will estimate the variance from the data, and so the estimated variability will conform to the data.
Camera trapping and the Poisson distribution
It is almost never a good idea to use a Poisson distribution (or any other single parameter distribution) for modelling --- this distribution fixes the variance in relation to the mean, which means th
Camera trapping and the Poisson distribution It is almost never a good idea to use a Poisson distribution (or any other single parameter distribution) for modelling --- this distribution fixes the variance in relation to the mean, which means that the model does not allow the estimated variability to conform to the data. For this type of data, you should use a negative binomial model instead. This is a generalisation of the Poisson distribution (coming from mixtures of the Poisson) that has an additional parameter affecting the variance. It is also worth noting that, in cases like this, some analysts use "over-dispersion tests", but even these are unnecessary unless there is a strong a priori theoretical reason to prefer a Poisson model. There is no strong a priori reason to prefer the Poisson in this case, so I would recommend starting with a negative binomial model. This model will estimate the variance from the data, and so the estimated variability will conform to the data.
Camera trapping and the Poisson distribution It is almost never a good idea to use a Poisson distribution (or any other single parameter distribution) for modelling --- this distribution fixes the variance in relation to the mean, which means th
47,672
Camera trapping and the Poisson distribution
Consider $n$ counts having the same covariate pattern (replicates). Suppose the $i$th count $X_i$ were to follow a Poisson distribution with its own mean $\mu_i$; the joint mass function of $n$ independent counts is then $$\begin{align} f_{\vec{X}}(\vec{x};\mu_1,\ldots,\mu_n) &= \prod_{i=1}^n\frac{\mu_i^{x_i}\exp(-\mu_i)}{x_i!}\\ &= \prod_{i=1}^n \frac{1}{x_i!}\cdot\prod_{i=1}^n \mu_i^{x_i}\cdot \exp\left(-\sum_{i=1}^n\mu_i\right) \end{align}$$ Reparametrize with $\phi=\sum_{i=1}^n \mu_i$ & $\pi_i=\frac{\mu_i}{\sum_{i=1}^n \mu_i}$, & let $t=\sum_{i=1}^n x_i$: $$\begin{align} f_{\vec{X},T}(\vec{x},t;\pi_1,\ldots,\pi_n,\phi)&=\prod_{i=1}^n\frac{1}{x_i!}\cdot\prod_{i=1}^n\pi_i^{x_i}\cdot\phi^{t}\exp(-\phi) \end{align}$$ The statistic $t$ is sufficient for $\phi$ (& ancillary for $\pi_1,\ldots,\pi_n$), with a marginal Poisson distribution having the mass function $$f_T(t;\phi)= \frac{\phi^t\exp(-\phi)}{t!}$$ So the conditional distribution of $X$ given $T=t$ is multinomial, free of the nuisance parameter $\phi$, having the mass function $$ f_{X|T}(x;t,\pi_1,\ldots,\pi_n)=\frac{f_{\vec{X},T}(\vec{x},t;\pi_,\ldots,\pi_n,\phi)}{f_{T}(t;\phi)}={\prod_{i=1}^n \frac{t!}{x_i!}}\cdot\prod_{i=1}^n\pi_i^{x_i} $$ With the null hypothesis $\pi_1=\ldots=\pi_n=\frac{1}{n}$, the log likelihood ratio test statistic is $$2\sum_{i=1}^n X_i \log \frac{X_i}{t/n}$$ & Rao's score test statistic is $$\sum_{i=1}^n \frac{(X_i-t/n)^2}{t/n}$$ Under the null, both follow, asymptotically, a chi-squared distribution with $n-1$ degrees of freedom ; the resulting tests of goodness of fit are known as the G-test (I don't know why) & Pearson's chi-squared test respectively. Exact distributions of either statistic under the null can be of course be obtained by exhaustive calculation or simulation. The extension to an omnibus test across $m$ covariate patterns is straightforward, & gives as test statistics $$2\sum_{j=1}^m\sum_{i=1}^{n_j} X_{ij} \log \frac{X_{ij}}{t_j / n_j}$$ & $$\sum_{j=1}^m \sum_{i=1}^{n_j} \frac{(X_{ij}-t_j/n_j)^2}{t_j /n_j}$$ both, under the null, asymptotically, following a chi-squared distribution with $\sum_{j=1}^m (n_j-1)$ degrees of freedom. The score test is, I think, the most popular—the ratio of the sample variance to the sample mean has an intuitive appeal as a measure of extra-Poisson dispersion. Low values may be taken as evidence for under-dispersion. A variance of counts exceeding their mean may also indicate zero inflation. See Van den Broeck (1995), Biometrics, 51, pp 738–743, "A Score Test for Zero Inflation in a Poisson Distribution" & How to test for Zero-Inflation in a dataset?.
Camera trapping and the Poisson distribution
Consider $n$ counts having the same covariate pattern (replicates). Suppose the $i$th count $X_i$ were to follow a Poisson distribution with its own mean $\mu_i$; the joint mass function of $n$ indepe
Camera trapping and the Poisson distribution Consider $n$ counts having the same covariate pattern (replicates). Suppose the $i$th count $X_i$ were to follow a Poisson distribution with its own mean $\mu_i$; the joint mass function of $n$ independent counts is then $$\begin{align} f_{\vec{X}}(\vec{x};\mu_1,\ldots,\mu_n) &= \prod_{i=1}^n\frac{\mu_i^{x_i}\exp(-\mu_i)}{x_i!}\\ &= \prod_{i=1}^n \frac{1}{x_i!}\cdot\prod_{i=1}^n \mu_i^{x_i}\cdot \exp\left(-\sum_{i=1}^n\mu_i\right) \end{align}$$ Reparametrize with $\phi=\sum_{i=1}^n \mu_i$ & $\pi_i=\frac{\mu_i}{\sum_{i=1}^n \mu_i}$, & let $t=\sum_{i=1}^n x_i$: $$\begin{align} f_{\vec{X},T}(\vec{x},t;\pi_1,\ldots,\pi_n,\phi)&=\prod_{i=1}^n\frac{1}{x_i!}\cdot\prod_{i=1}^n\pi_i^{x_i}\cdot\phi^{t}\exp(-\phi) \end{align}$$ The statistic $t$ is sufficient for $\phi$ (& ancillary for $\pi_1,\ldots,\pi_n$), with a marginal Poisson distribution having the mass function $$f_T(t;\phi)= \frac{\phi^t\exp(-\phi)}{t!}$$ So the conditional distribution of $X$ given $T=t$ is multinomial, free of the nuisance parameter $\phi$, having the mass function $$ f_{X|T}(x;t,\pi_1,\ldots,\pi_n)=\frac{f_{\vec{X},T}(\vec{x},t;\pi_,\ldots,\pi_n,\phi)}{f_{T}(t;\phi)}={\prod_{i=1}^n \frac{t!}{x_i!}}\cdot\prod_{i=1}^n\pi_i^{x_i} $$ With the null hypothesis $\pi_1=\ldots=\pi_n=\frac{1}{n}$, the log likelihood ratio test statistic is $$2\sum_{i=1}^n X_i \log \frac{X_i}{t/n}$$ & Rao's score test statistic is $$\sum_{i=1}^n \frac{(X_i-t/n)^2}{t/n}$$ Under the null, both follow, asymptotically, a chi-squared distribution with $n-1$ degrees of freedom ; the resulting tests of goodness of fit are known as the G-test (I don't know why) & Pearson's chi-squared test respectively. Exact distributions of either statistic under the null can be of course be obtained by exhaustive calculation or simulation. The extension to an omnibus test across $m$ covariate patterns is straightforward, & gives as test statistics $$2\sum_{j=1}^m\sum_{i=1}^{n_j} X_{ij} \log \frac{X_{ij}}{t_j / n_j}$$ & $$\sum_{j=1}^m \sum_{i=1}^{n_j} \frac{(X_{ij}-t_j/n_j)^2}{t_j /n_j}$$ both, under the null, asymptotically, following a chi-squared distribution with $\sum_{j=1}^m (n_j-1)$ degrees of freedom. The score test is, I think, the most popular—the ratio of the sample variance to the sample mean has an intuitive appeal as a measure of extra-Poisson dispersion. Low values may be taken as evidence for under-dispersion. A variance of counts exceeding their mean may also indicate zero inflation. See Van den Broeck (1995), Biometrics, 51, pp 738–743, "A Score Test for Zero Inflation in a Poisson Distribution" & How to test for Zero-Inflation in a dataset?.
Camera trapping and the Poisson distribution Consider $n$ counts having the same covariate pattern (replicates). Suppose the $i$th count $X_i$ were to follow a Poisson distribution with its own mean $\mu_i$; the joint mass function of $n$ indepe
47,673
How would someone use curves as an input to a supervised learning model?
The response was idiotic, my condolences. What you suggested is not unreasonable. It will probably not work, but how would you know in advance? Both your options were good starting points. Although the simple polynomial approach is probably not a good idea in a literal sense, but in principle, it's not much different from Nelson-Siegel curves, e.g. see widely used Diebold Li approach. Nelson-Siegel parametrization is based on orthogonal Laguerre polynomials. Hence, your answer was not off the mark, in my opinion. Treating yield curves as time series is also not wrong in principle. There's a bunch of paper where people do something along this line, e.g. this arxiv paper. In fact they compare performance vs. PCA. The PCA is probably the best approach if you want to reduce number of inputs. You get first three component scores, and use them as your inputs instead of the original yield curve. First three PC usually cover more than 90% of variance. However, I wouldn't say that it's universally best approach. For instance, if you're modeling markets some entities may specifically be sensitive to 10 year US treasury rate, then maybe it's good to have it as a distinct input etc.
How would someone use curves as an input to a supervised learning model?
The response was idiotic, my condolences. What you suggested is not unreasonable. It will probably not work, but how would you know in advance? Both your options were good starting points. Although th
How would someone use curves as an input to a supervised learning model? The response was idiotic, my condolences. What you suggested is not unreasonable. It will probably not work, but how would you know in advance? Both your options were good starting points. Although the simple polynomial approach is probably not a good idea in a literal sense, but in principle, it's not much different from Nelson-Siegel curves, e.g. see widely used Diebold Li approach. Nelson-Siegel parametrization is based on orthogonal Laguerre polynomials. Hence, your answer was not off the mark, in my opinion. Treating yield curves as time series is also not wrong in principle. There's a bunch of paper where people do something along this line, e.g. this arxiv paper. In fact they compare performance vs. PCA. The PCA is probably the best approach if you want to reduce number of inputs. You get first three component scores, and use them as your inputs instead of the original yield curve. First three PC usually cover more than 90% of variance. However, I wouldn't say that it's universally best approach. For instance, if you're modeling markets some entities may specifically be sensitive to 10 year US treasury rate, then maybe it's good to have it as a distinct input etc.
How would someone use curves as an input to a supervised learning model? The response was idiotic, my condolences. What you suggested is not unreasonable. It will probably not work, but how would you know in advance? Both your options were good starting points. Although th
47,674
What is the difference between BLUE and MVUE?
BLUE means an estimator is Best among the class of Linear and Unbiased Estimators. By best we mean that it is the most efficient estimator in the class of the estimators that are Unbiased plus Linear. MVUE is the Minimum Variance estimator in the class of Unbiased Estimators. They need not be linear. But yes if any Linear estimator is MVUE then it Certainly is BLUE.
What is the difference between BLUE and MVUE?
BLUE means an estimator is Best among the class of Linear and Unbiased Estimators. By best we mean that it is the most efficient estimator in the class of the estimators that are Unbiased plus Linear.
What is the difference between BLUE and MVUE? BLUE means an estimator is Best among the class of Linear and Unbiased Estimators. By best we mean that it is the most efficient estimator in the class of the estimators that are Unbiased plus Linear. MVUE is the Minimum Variance estimator in the class of Unbiased Estimators. They need not be linear. But yes if any Linear estimator is MVUE then it Certainly is BLUE.
What is the difference between BLUE and MVUE? BLUE means an estimator is Best among the class of Linear and Unbiased Estimators. By best we mean that it is the most efficient estimator in the class of the estimators that are Unbiased plus Linear.
47,675
Why does discrete data distribution has differential entropy of negative infinity?
The differential entropy is defined as: $$h=-\int_{-\infty}^\infty f(x)\ln(f(x))dx$$ vwhere $f(x)$ is the PDf of the function. For the discrete distribution, there is not PDF, but there is a probability mass function. However, we could represent the PDF with Dirac delta function $\delta(x)$: $$f(x)=\sum_ip_i\delta(x-x_i)$$ where $p_i$ is the probability of outcome $x_i$. For instance, Benroulli distribution psudo PDF would be: $$f(x)=\frac{\delta(x)+\delta(x-1)}{2}$$ You can see that this sort of behaves like PDF: $$\int_{-\infty}^\infty f(x)dx=\sum_ip_i\equiv 1$$ etc. Now, if you plug this PDF like creature into the differential entropy you get the following: $$\begin{align} h&=-\int_{-\infty}^\infty f(x)\ln(f(x))dx \\ &= -\int_{-\infty}^\infty \left(\sum_ip_i\delta(x-x_i)\right)\ln\left(\sum_kp_k\delta(x-x_k)\right)dx \\ &= -\sum_ip_i\ln\left(\sum_kp_k\delta(x_i-x_k)\right) \\ &=-\infty \end{align}$$ You can see why this doesn't converge: for any $k= i$ you get $\delta(0)$, which can be interpreted as infinity. Hence, the conclusion that differential entropy for discrete distributions is negative infinity. However, you should not be normally dealing with this, because for discrete distribution you would usually apply a conventional entropy formula : $h=-\sum_i p_i\ln p_i$.
Why does discrete data distribution has differential entropy of negative infinity?
The differential entropy is defined as: $$h=-\int_{-\infty}^\infty f(x)\ln(f(x))dx$$ vwhere $f(x)$ is the PDf of the function. For the discrete distribution, there is not PDF, but there is a probabili
Why does discrete data distribution has differential entropy of negative infinity? The differential entropy is defined as: $$h=-\int_{-\infty}^\infty f(x)\ln(f(x))dx$$ vwhere $f(x)$ is the PDf of the function. For the discrete distribution, there is not PDF, but there is a probability mass function. However, we could represent the PDF with Dirac delta function $\delta(x)$: $$f(x)=\sum_ip_i\delta(x-x_i)$$ where $p_i$ is the probability of outcome $x_i$. For instance, Benroulli distribution psudo PDF would be: $$f(x)=\frac{\delta(x)+\delta(x-1)}{2}$$ You can see that this sort of behaves like PDF: $$\int_{-\infty}^\infty f(x)dx=\sum_ip_i\equiv 1$$ etc. Now, if you plug this PDF like creature into the differential entropy you get the following: $$\begin{align} h&=-\int_{-\infty}^\infty f(x)\ln(f(x))dx \\ &= -\int_{-\infty}^\infty \left(\sum_ip_i\delta(x-x_i)\right)\ln\left(\sum_kp_k\delta(x-x_k)\right)dx \\ &= -\sum_ip_i\ln\left(\sum_kp_k\delta(x_i-x_k)\right) \\ &=-\infty \end{align}$$ You can see why this doesn't converge: for any $k= i$ you get $\delta(0)$, which can be interpreted as infinity. Hence, the conclusion that differential entropy for discrete distributions is negative infinity. However, you should not be normally dealing with this, because for discrete distribution you would usually apply a conventional entropy formula : $h=-\sum_i p_i\ln p_i$.
Why does discrete data distribution has differential entropy of negative infinity? The differential entropy is defined as: $$h=-\int_{-\infty}^\infty f(x)\ln(f(x))dx$$ vwhere $f(x)$ is the PDf of the function. For the discrete distribution, there is not PDF, but there is a probabili
47,676
Why does discrete data distribution has differential entropy of negative infinity?
The next sentence in that paper has a citation that clears it up: To avoid this case, it is becoming best practice to add real-valued noise to the integer pixel values to dequantize the data (e.g., Uria et al., 2013; van den Oord & Schrauwen, 2014; Theis & Bethge, 2015)) The Uria et al. 2013 paper on RNADE explains it well: Pixels in this dataset can take a finite number of brightness values ranging from 0 to 255. Modeling discretized data using a real-valued distribution can lead to arbitrarily high density values, by locating narrow high density spike on each of the possible discrete values. In order to avoid this "cheating" solution, we added noise uniformly distributed between 0 and 1 to the value of each pixel.
Why does discrete data distribution has differential entropy of negative infinity?
The next sentence in that paper has a citation that clears it up: To avoid this case, it is becoming best practice to add real-valued noise to the integer pixel values to dequantize the data (e.g., U
Why does discrete data distribution has differential entropy of negative infinity? The next sentence in that paper has a citation that clears it up: To avoid this case, it is becoming best practice to add real-valued noise to the integer pixel values to dequantize the data (e.g., Uria et al., 2013; van den Oord & Schrauwen, 2014; Theis & Bethge, 2015)) The Uria et al. 2013 paper on RNADE explains it well: Pixels in this dataset can take a finite number of brightness values ranging from 0 to 255. Modeling discretized data using a real-valued distribution can lead to arbitrarily high density values, by locating narrow high density spike on each of the possible discrete values. In order to avoid this "cheating" solution, we added noise uniformly distributed between 0 and 1 to the value of each pixel.
Why does discrete data distribution has differential entropy of negative infinity? The next sentence in that paper has a citation that clears it up: To avoid this case, it is becoming best practice to add real-valued noise to the integer pixel values to dequantize the data (e.g., U
47,677
Uniform(0,$\theta$) ratio UMVUE?
Your working looks entirely correct to me. We can also confirm this result by an alternative method. Let us posit that the UMVUE is likely to be some scaled version of the ratio statistic: $$R_n \equiv \frac{X_{(n)}}{Y_{(n)}}.$$ For all $r > 0$ we have: $$\begin{equation} \begin{aligned} F_{R_n}(r) \equiv \mathbb{P}(R_n \leqslant r) &= \mathbb{P}( X_{(n)} \leqslant r Y_{(n)} ) \\[6pt] &= \int \mathbb{P}(X_{(n)} \leqslant r y) f_Y(y) \ dy \\[6pt] &= \int \limits_0^\lambda \min \Big(1, \frac{ry}{\theta} \Big)^n \cdot \frac{n y^{n-1}}{\lambda^n} \ dy \\[6pt] &= \begin{cases} \frac{1}{2} \big( \frac{\lambda r}{\theta} \big)^n & & & \text{if } r \leqslant \tfrac{\theta}{\lambda}, \\[6pt] 1 - \frac{1}{2} \big( \frac{\theta}{\lambda r} \big)^n & & & \text{if } r > \tfrac{\theta}{\lambda}. \\ \end{cases} \end{aligned} \end{equation}$$ Thus, for $n>1$ we have the expectation: $$\begin{equation} \begin{aligned} \mathbb{E}(R_n) &= \int \limits_0^\infty (1-F_{R_n}(r)) \ dr \\[6pt] &= \int \limits_0^{\theta / \lambda} \Big( 1-\frac{1}{2} \Big( \frac{\lambda r}{\theta} \Big)^n \Big) \ dr + \int \limits_{\theta / \lambda}^\infty \frac{1}{2} \Big( \frac{\theta}{\lambda r} \Big)^n \ dr \\[6pt] &= \frac{\theta}{\lambda} \bigg( 1-\frac{1}{2(n+1)} \bigg) + \frac{\theta}{\lambda} \frac{1}{2(n-1)} \\[6pt] &= \frac{\theta}{\lambda} \bigg( 1-\frac{1}{2(n+1)} + \frac{1}{2(n-1)} \bigg) \\[6pt] &= \frac{\theta}{\lambda} \cdot \frac{2(n-1)(n+1) - (n-1) + (n+1)}{2(n-1)(n+1)} \\[6pt] &= \frac{\theta}{\lambda} \cdot \frac{n^2}{n^2-1}. \\[6pt] \end{aligned} \end{equation}$$ Thus, for all $n>1$ we have the unbiased estimator: $$\widehat{\theta / \lambda} = \frac{n^2-1}{n^2} \cdot R_n,$$ which is what you have derived in your own working.
Uniform(0,$\theta$) ratio UMVUE?
Your working looks entirely correct to me. We can also confirm this result by an alternative method. Let us posit that the UMVUE is likely to be some scaled version of the ratio statistic: $$R_n \eq
Uniform(0,$\theta$) ratio UMVUE? Your working looks entirely correct to me. We can also confirm this result by an alternative method. Let us posit that the UMVUE is likely to be some scaled version of the ratio statistic: $$R_n \equiv \frac{X_{(n)}}{Y_{(n)}}.$$ For all $r > 0$ we have: $$\begin{equation} \begin{aligned} F_{R_n}(r) \equiv \mathbb{P}(R_n \leqslant r) &= \mathbb{P}( X_{(n)} \leqslant r Y_{(n)} ) \\[6pt] &= \int \mathbb{P}(X_{(n)} \leqslant r y) f_Y(y) \ dy \\[6pt] &= \int \limits_0^\lambda \min \Big(1, \frac{ry}{\theta} \Big)^n \cdot \frac{n y^{n-1}}{\lambda^n} \ dy \\[6pt] &= \begin{cases} \frac{1}{2} \big( \frac{\lambda r}{\theta} \big)^n & & & \text{if } r \leqslant \tfrac{\theta}{\lambda}, \\[6pt] 1 - \frac{1}{2} \big( \frac{\theta}{\lambda r} \big)^n & & & \text{if } r > \tfrac{\theta}{\lambda}. \\ \end{cases} \end{aligned} \end{equation}$$ Thus, for $n>1$ we have the expectation: $$\begin{equation} \begin{aligned} \mathbb{E}(R_n) &= \int \limits_0^\infty (1-F_{R_n}(r)) \ dr \\[6pt] &= \int \limits_0^{\theta / \lambda} \Big( 1-\frac{1}{2} \Big( \frac{\lambda r}{\theta} \Big)^n \Big) \ dr + \int \limits_{\theta / \lambda}^\infty \frac{1}{2} \Big( \frac{\theta}{\lambda r} \Big)^n \ dr \\[6pt] &= \frac{\theta}{\lambda} \bigg( 1-\frac{1}{2(n+1)} \bigg) + \frac{\theta}{\lambda} \frac{1}{2(n-1)} \\[6pt] &= \frac{\theta}{\lambda} \bigg( 1-\frac{1}{2(n+1)} + \frac{1}{2(n-1)} \bigg) \\[6pt] &= \frac{\theta}{\lambda} \cdot \frac{2(n-1)(n+1) - (n-1) + (n+1)}{2(n-1)(n+1)} \\[6pt] &= \frac{\theta}{\lambda} \cdot \frac{n^2}{n^2-1}. \\[6pt] \end{aligned} \end{equation}$$ Thus, for all $n>1$ we have the unbiased estimator: $$\widehat{\theta / \lambda} = \frac{n^2-1}{n^2} \cdot R_n,$$ which is what you have derived in your own working.
Uniform(0,$\theta$) ratio UMVUE? Your working looks entirely correct to me. We can also confirm this result by an alternative method. Let us posit that the UMVUE is likely to be some scaled version of the ratio statistic: $$R_n \eq
47,678
What are disadvantages of "Sequential analysis"
From a frequentist perspective, there are some clear disadvantages of a sequential analyses. That is, if we are concerned with preserving type I errors, we need to recognize that we are doing multiple comparisons: if I do 3 analyses of the data, then I have three non-independent chances to make a type I error and need to adjust my inference as such. There's a variety of methods for accounting for this, but in short, for a fixed sample size and significance level, all of them end up reducing power compared to waiting until all the data comes in. So if you're looking at the power/subjects ratio, you can't beat a fixed analysis, although as you point out, often that's not necessarily the most important metric. Theoretically, from a Bayesian perspective, there's nothing wrong with using a sequential analysis. Since Bayesian decision theory generally does not worry about type I errors, there's nothing wrong with multiple peeks. However, in practice, it's a lot more of a gray area. Derived prior distributions don't really capture our knowledge before seeing the data, but we can hand wave this issue away by saying that the likelihood will typically dominate the prior, so this isn't an issue. But if we do a sequential analysis, we may be analyzing the data when we have very little data. Suddenly, miss-specification of the prior becomes a really big issue! EDIT: @FrankHarell brings up the point that if you have a valid prior, you should do a sequential analysis. The point I would like to make is that "Valid" priors (i.e. a distribution that perfectly matches the desired uncertainty) are extremely hard to come by. Pragmatic priors (i.e. a distribution that improves the performance of our model) are much easier to find. Despite the fact that priors are typically not "valid", we still have some faith in our Bayesian analyses, since the likelihood usually swamps the prior anyways. With a sequential analysis, early on in a study the likelihood may not swamp the prior, so we need to handle with extra care! As a toy example, suppose we had a sequential analysis where we wanted to compare $\mu_1$ and $\mu_2$ and we (mistakenly) put a prior on $\sigma$ (shared between both groups) that puts almost all the probability below 1. If we observe a single pair of data points where $x_1 = 0$ and $x_2 = 4$, we should now be very convinced that $\mu_1 < \mu_2$ and stop the sequential analysis. Note that our inference on $\sigma$ is only from the prior! On the other hand, if we had waited until we had 100 data pairs, we at least have the chance to let the data tell us that our strong prior on $\sigma$ was not justified. To be clear, I think sequential analyses are a very good idea. But there are downsides.
What are disadvantages of "Sequential analysis"
From a frequentist perspective, there are some clear disadvantages of a sequential analyses. That is, if we are concerned with preserving type I errors, we need to recognize that we are doing multiple
What are disadvantages of "Sequential analysis" From a frequentist perspective, there are some clear disadvantages of a sequential analyses. That is, if we are concerned with preserving type I errors, we need to recognize that we are doing multiple comparisons: if I do 3 analyses of the data, then I have three non-independent chances to make a type I error and need to adjust my inference as such. There's a variety of methods for accounting for this, but in short, for a fixed sample size and significance level, all of them end up reducing power compared to waiting until all the data comes in. So if you're looking at the power/subjects ratio, you can't beat a fixed analysis, although as you point out, often that's not necessarily the most important metric. Theoretically, from a Bayesian perspective, there's nothing wrong with using a sequential analysis. Since Bayesian decision theory generally does not worry about type I errors, there's nothing wrong with multiple peeks. However, in practice, it's a lot more of a gray area. Derived prior distributions don't really capture our knowledge before seeing the data, but we can hand wave this issue away by saying that the likelihood will typically dominate the prior, so this isn't an issue. But if we do a sequential analysis, we may be analyzing the data when we have very little data. Suddenly, miss-specification of the prior becomes a really big issue! EDIT: @FrankHarell brings up the point that if you have a valid prior, you should do a sequential analysis. The point I would like to make is that "Valid" priors (i.e. a distribution that perfectly matches the desired uncertainty) are extremely hard to come by. Pragmatic priors (i.e. a distribution that improves the performance of our model) are much easier to find. Despite the fact that priors are typically not "valid", we still have some faith in our Bayesian analyses, since the likelihood usually swamps the prior anyways. With a sequential analysis, early on in a study the likelihood may not swamp the prior, so we need to handle with extra care! As a toy example, suppose we had a sequential analysis where we wanted to compare $\mu_1$ and $\mu_2$ and we (mistakenly) put a prior on $\sigma$ (shared between both groups) that puts almost all the probability below 1. If we observe a single pair of data points where $x_1 = 0$ and $x_2 = 4$, we should now be very convinced that $\mu_1 < \mu_2$ and stop the sequential analysis. Note that our inference on $\sigma$ is only from the prior! On the other hand, if we had waited until we had 100 data pairs, we at least have the chance to let the data tell us that our strong prior on $\sigma$ was not justified. To be clear, I think sequential analyses are a very good idea. But there are downsides.
What are disadvantages of "Sequential analysis" From a frequentist perspective, there are some clear disadvantages of a sequential analyses. That is, if we are concerned with preserving type I errors, we need to recognize that we are doing multiple
47,679
"Appropriate conditions" for method of moments estimator to exist, be consistent, and asymptotically normal?
Almost all arguments to asymptotic normality of a sequence of statistics hinge on arguments using Taylor series, and thus, the "appropriate conditions" are generally smoothness conditions required to write the Taylor series, eliminate some of the terms, and then infer vanishing of the higher-order terms. Thus, the "appropriate conditions" usually consist of the existence of derivatives (to a desired order) for the function of interest, and the existence of higher-order moments. Below I will give a heuristic explanation of the derivation of the asymptotic distribution for the method-of-moments estimator. Formal proof would require some greater technicality in presenting the various limiting distributions and establishing vanishing of the higher-order terms, but this heuristic demonstration ought to give you an idea of the required conditions for the result, and why these are required. Method of moments estimation: Suppose we observe IID data from some distribution $\{ p_\theta | \theta \in \Theta \}$ with parameter $\theta = (\theta_1,...,\theta_m)$, and suppose that the first $m$ moments of this distribution exist, and can be written as functions of the parameters: $$\mu_k \equiv \int \limits_\mathscr{X} x^k dP_\theta(x) = g_k(\theta) \quad \quad \quad \quad \quad \text{for all } k = 1,...,m.$$ For $n$ sample values, the method of moments estimator $\hat{\theta}: \mathscr{X}^n \rightarrow \Theta$ is defined by equating the first $m$ parametric moments and sample moments: $$\hat{\mu}_k \equiv\frac{1}{n} \sum_{i=1}^n x_i^k = g_k(\hat{\theta}) \quad \quad \quad \quad \quad \quad \text{for all } k = 1,...,m.$$ Whether or not this estimator exists, and is unique, depends on how many solutions there are to this set of equations. The simplest case is where the function $g = (g_1,...,g_m)$ is invertible, with inverse denoted as $h = (h_1,...,h_m)$. This gives a unique estimator and a corresponding expression for the true parameter: $$\theta = h (\boldsymbol{\mu}) = h (\mu_1, ..., \mu_m) \quad \quad \quad \quad \quad \hat{\theta} = h (\hat{\boldsymbol{\mu}}) = h (\hat{\mu}_1, ..., \hat{\mu}_m).$$ Asymptotic properties: For simplicity, we will assume that the function $g$ in the above setup is invertible, so we have a unique method of moments estimator. Since we are now looking at asymptotic properties we will use a subscript $n$ on the estimator. Since the data is IID, the strong law of large numbers means that the sample moments converge to the true moments almost surely: $$\quad \quad \quad \quad \quad \quad \mathbb{E}(|X|^{2m}) < \infty \quad \quad \quad \implies \quad \quad \quad \mathbb{P} \Big( \lim_{n \rightarrow \infty} \hat{\mu}_n = \mu \Big) = 1. \text{ }$$ Thus, if $h$ is continuous and the relevant moments exist then the estimator will be strongly consistent: $$\quad h \text{ is continuous and } \mathbb{E}(|X|^{2m}) < \infty \quad \quad \quad \implies \quad \quad \quad \mathbb{P} \Big( \lim_{n \rightarrow \infty} \hat{\theta}_n = \theta \Big) = 1. \quad \quad \quad \quad$$ If $h$ is differentiable then we can expand the function $\hat{\theta} = h (\hat{\boldsymbol{\mu}})$ using a Taylor expansion around the true moment vector $\boldsymbol{\mu}$, yielding: $$\begin{equation} \begin{aligned} \hat{\theta}_n - \theta &= \nabla h (\boldsymbol{\mu}) (\hat{\boldsymbol{\mu}}_n - \boldsymbol{\mu}) + \mathcal{O}((\hat{\boldsymbol{\mu}}_n - \boldsymbol{\mu})^2). \\[6pt] \end{aligned} \end{equation}$$ As $n \rightarrow \infty$, the higher-order terms vanish relative to the first term. For the first term, we can invoke the central limit theorem to obtain the asymptotic distribution: $$\quad \hat{\boldsymbol{\mu}}_n \sim \text{N} \bigg( \boldsymbol{\mu}, \frac{1}{n} \boldsymbol{\Sigma}_\boldsymbol{\mu} \bigg). \text{ }$$ Thus, by the delta method, we have the asymptotic distribution: $$\begin{equation} \begin{aligned} \sqrt{n} (\hat{\theta}_n - \theta) &\rightarrow \sqrt{n} \cdot \nabla h (\boldsymbol{\mu}) (\hat{\boldsymbol{\mu}}_n - \boldsymbol{\mu}) \sim \text{N} \bigg( \mathbf{0}, (\nabla h (\boldsymbol{\mu}))^\text{T} \boldsymbol{\Sigma}_\boldsymbol{\mu} (\nabla h (\boldsymbol{\mu})) \bigg). \quad \quad \\[6pt] \end{aligned} \end{equation}$$
"Appropriate conditions" for method of moments estimator to exist, be consistent, and asymptotically
Almost all arguments to asymptotic normality of a sequence of statistics hinge on arguments using Taylor series, and thus, the "appropriate conditions" are generally smoothness conditions required to
"Appropriate conditions" for method of moments estimator to exist, be consistent, and asymptotically normal? Almost all arguments to asymptotic normality of a sequence of statistics hinge on arguments using Taylor series, and thus, the "appropriate conditions" are generally smoothness conditions required to write the Taylor series, eliminate some of the terms, and then infer vanishing of the higher-order terms. Thus, the "appropriate conditions" usually consist of the existence of derivatives (to a desired order) for the function of interest, and the existence of higher-order moments. Below I will give a heuristic explanation of the derivation of the asymptotic distribution for the method-of-moments estimator. Formal proof would require some greater technicality in presenting the various limiting distributions and establishing vanishing of the higher-order terms, but this heuristic demonstration ought to give you an idea of the required conditions for the result, and why these are required. Method of moments estimation: Suppose we observe IID data from some distribution $\{ p_\theta | \theta \in \Theta \}$ with parameter $\theta = (\theta_1,...,\theta_m)$, and suppose that the first $m$ moments of this distribution exist, and can be written as functions of the parameters: $$\mu_k \equiv \int \limits_\mathscr{X} x^k dP_\theta(x) = g_k(\theta) \quad \quad \quad \quad \quad \text{for all } k = 1,...,m.$$ For $n$ sample values, the method of moments estimator $\hat{\theta}: \mathscr{X}^n \rightarrow \Theta$ is defined by equating the first $m$ parametric moments and sample moments: $$\hat{\mu}_k \equiv\frac{1}{n} \sum_{i=1}^n x_i^k = g_k(\hat{\theta}) \quad \quad \quad \quad \quad \quad \text{for all } k = 1,...,m.$$ Whether or not this estimator exists, and is unique, depends on how many solutions there are to this set of equations. The simplest case is where the function $g = (g_1,...,g_m)$ is invertible, with inverse denoted as $h = (h_1,...,h_m)$. This gives a unique estimator and a corresponding expression for the true parameter: $$\theta = h (\boldsymbol{\mu}) = h (\mu_1, ..., \mu_m) \quad \quad \quad \quad \quad \hat{\theta} = h (\hat{\boldsymbol{\mu}}) = h (\hat{\mu}_1, ..., \hat{\mu}_m).$$ Asymptotic properties: For simplicity, we will assume that the function $g$ in the above setup is invertible, so we have a unique method of moments estimator. Since we are now looking at asymptotic properties we will use a subscript $n$ on the estimator. Since the data is IID, the strong law of large numbers means that the sample moments converge to the true moments almost surely: $$\quad \quad \quad \quad \quad \quad \mathbb{E}(|X|^{2m}) < \infty \quad \quad \quad \implies \quad \quad \quad \mathbb{P} \Big( \lim_{n \rightarrow \infty} \hat{\mu}_n = \mu \Big) = 1. \text{ }$$ Thus, if $h$ is continuous and the relevant moments exist then the estimator will be strongly consistent: $$\quad h \text{ is continuous and } \mathbb{E}(|X|^{2m}) < \infty \quad \quad \quad \implies \quad \quad \quad \mathbb{P} \Big( \lim_{n \rightarrow \infty} \hat{\theta}_n = \theta \Big) = 1. \quad \quad \quad \quad$$ If $h$ is differentiable then we can expand the function $\hat{\theta} = h (\hat{\boldsymbol{\mu}})$ using a Taylor expansion around the true moment vector $\boldsymbol{\mu}$, yielding: $$\begin{equation} \begin{aligned} \hat{\theta}_n - \theta &= \nabla h (\boldsymbol{\mu}) (\hat{\boldsymbol{\mu}}_n - \boldsymbol{\mu}) + \mathcal{O}((\hat{\boldsymbol{\mu}}_n - \boldsymbol{\mu})^2). \\[6pt] \end{aligned} \end{equation}$$ As $n \rightarrow \infty$, the higher-order terms vanish relative to the first term. For the first term, we can invoke the central limit theorem to obtain the asymptotic distribution: $$\quad \hat{\boldsymbol{\mu}}_n \sim \text{N} \bigg( \boldsymbol{\mu}, \frac{1}{n} \boldsymbol{\Sigma}_\boldsymbol{\mu} \bigg). \text{ }$$ Thus, by the delta method, we have the asymptotic distribution: $$\begin{equation} \begin{aligned} \sqrt{n} (\hat{\theta}_n - \theta) &\rightarrow \sqrt{n} \cdot \nabla h (\boldsymbol{\mu}) (\hat{\boldsymbol{\mu}}_n - \boldsymbol{\mu}) \sim \text{N} \bigg( \mathbf{0}, (\nabla h (\boldsymbol{\mu}))^\text{T} \boldsymbol{\Sigma}_\boldsymbol{\mu} (\nabla h (\boldsymbol{\mu})) \bigg). \quad \quad \\[6pt] \end{aligned} \end{equation}$$
"Appropriate conditions" for method of moments estimator to exist, be consistent, and asymptotically Almost all arguments to asymptotic normality of a sequence of statistics hinge on arguments using Taylor series, and thus, the "appropriate conditions" are generally smoothness conditions required to
47,680
Correlation: If $Z^2$s are correlated, it doesnt imply that $Z$s are correlated?
Let $X$ be a standard normal random variable with distribution $\mathcal N(0,1)$, $Y$ be independently another standard normal random variable and $Z=\text{sign}(Y) \, |X|$, also a standard normal random variable Then $X^2=Z^2$, so with correlation of $1$ between them, but $X$ and $Z$ are uncorrelated with correlation of $0$ between them (though they are not independent since $|X|=|Z|$) while $Y^2$ and $Z^2$ are independent, so uncorrelated with correlation of $0$ between them, but $Y$ and $Z$ are correlated with correlation of $\frac{2}{\pi} \approx 0.6366$ between them
Correlation: If $Z^2$s are correlated, it doesnt imply that $Z$s are correlated?
Let $X$ be a standard normal random variable with distribution $\mathcal N(0,1)$, $Y$ be independently another standard normal random variable and $Z=\text{sign}(Y) \, |X|$, also a standard normal
Correlation: If $Z^2$s are correlated, it doesnt imply that $Z$s are correlated? Let $X$ be a standard normal random variable with distribution $\mathcal N(0,1)$, $Y$ be independently another standard normal random variable and $Z=\text{sign}(Y) \, |X|$, also a standard normal random variable Then $X^2=Z^2$, so with correlation of $1$ between them, but $X$ and $Z$ are uncorrelated with correlation of $0$ between them (though they are not independent since $|X|=|Z|$) while $Y^2$ and $Z^2$ are independent, so uncorrelated with correlation of $0$ between them, but $Y$ and $Z$ are correlated with correlation of $\frac{2}{\pi} \approx 0.6366$ between them
Correlation: If $Z^2$s are correlated, it doesnt imply that $Z$s are correlated? Let $X$ be a standard normal random variable with distribution $\mathcal N(0,1)$, $Y$ be independently another standard normal random variable and $Z=\text{sign}(Y) \, |X|$, also a standard normal
47,681
10% rule for sample sizes
In statistical models that use parameters for the underlying distributions, these parameters correspond to aspects of the empirical distribution of an infinite population (called a "superpopulation"). Thus, for statistical tests and confidence intervals that deal with model parameters, we are implicitly making inferences about a quantity relating to an infinite population. If we instead wish to make inferences about quantities relating to a finite population this is usually done by imposing an adjustment to the standard tests and confidence intervals called a finite population correction (FPC). When we have a finite population of $N \in \mathbb{N}$ units, the FPC term "disappears" as $N \rightarrow \infty$, reflecting the fact that this term is an "adjustment" from the case where $N = \infty$. Moreover, in most applications, the FPC term tends to be determined by the proportion of sampled values --- as this approaches zero the term "disappears" from the relevant equations. The author of the book you are reading probably takes the view that when the proportion of sampled values in the population is less than 10%, the FPC adjustment is small enough that it can be safely ignored, whereas when it is larger than 10% it is large enough that it should not be ignored. This is an arbitrary demarcation, and I don't really see any sense in it. In my view, it is much better just to use the FPC when you are making inferences about a finite population, irrespective of its magnitude. An applied example: Suppose you observe $n$ data points and want to obtain a confidence interval for the mean of a population. If you use the standard confidence interval for the mean parameter of the underlying distribution (implicitly the mean of an infinite superpopulation) then your interval has the form: $$\text{CI}(1-\alpha) = \Bigg[ \bar{x} \pm \frac{t_{n-1,\alpha/2}}{\sqrt{n}} \cdot s \Bigg].$$ However, we can add a "finite population correction" term to this formula to obtain a confidence interval for the mean of a finite population of $N$ units: $$\text{CI}(1-\alpha) = \Bigg[ \bar{x} \pm \sqrt{\frac{N-n}{N}} \cdot \frac{t_{n-1,\alpha/2}}{\sqrt{n}} \cdot s \Bigg].$$ You can see that the FPC term is a multiplicative term equal to the square-root of the unsampled proportion of values in the population. As $N \rightarrow \infty$ the unsampled proportion approaches one (and the sampled proportion approaches zero) so the FPC term "disappears". You can also see that this latter formula gives you a confidence interval that will allow for any sampling proportion, so it is not necessary to come up with a "rule of thumb" for how low the sampling proportion should be. Now, when we sample 10% of the population, the FPC term is $\sqrt{0.9} \approx 0.9487$, and evidently the author of your book thinks that this is close enough to one that it can be safely ignored (but if the sample proportion is higher than 10% then the adjustment should not be ignored). The author of your book is essentially asserting a "rule-of-thumb" --- if $n/N \leqslant 0.9$ then $FPC \geqslant 0.9487$, which means you can take $FPC=1$ without serious error. As I said above, my preference would be to avoid any such rule and simply use the FPC term when making an inference for a finite population.
10% rule for sample sizes
In statistical models that use parameters for the underlying distributions, these parameters correspond to aspects of the empirical distribution of an infinite population (called a "superpopulation").
10% rule for sample sizes In statistical models that use parameters for the underlying distributions, these parameters correspond to aspects of the empirical distribution of an infinite population (called a "superpopulation"). Thus, for statistical tests and confidence intervals that deal with model parameters, we are implicitly making inferences about a quantity relating to an infinite population. If we instead wish to make inferences about quantities relating to a finite population this is usually done by imposing an adjustment to the standard tests and confidence intervals called a finite population correction (FPC). When we have a finite population of $N \in \mathbb{N}$ units, the FPC term "disappears" as $N \rightarrow \infty$, reflecting the fact that this term is an "adjustment" from the case where $N = \infty$. Moreover, in most applications, the FPC term tends to be determined by the proportion of sampled values --- as this approaches zero the term "disappears" from the relevant equations. The author of the book you are reading probably takes the view that when the proportion of sampled values in the population is less than 10%, the FPC adjustment is small enough that it can be safely ignored, whereas when it is larger than 10% it is large enough that it should not be ignored. This is an arbitrary demarcation, and I don't really see any sense in it. In my view, it is much better just to use the FPC when you are making inferences about a finite population, irrespective of its magnitude. An applied example: Suppose you observe $n$ data points and want to obtain a confidence interval for the mean of a population. If you use the standard confidence interval for the mean parameter of the underlying distribution (implicitly the mean of an infinite superpopulation) then your interval has the form: $$\text{CI}(1-\alpha) = \Bigg[ \bar{x} \pm \frac{t_{n-1,\alpha/2}}{\sqrt{n}} \cdot s \Bigg].$$ However, we can add a "finite population correction" term to this formula to obtain a confidence interval for the mean of a finite population of $N$ units: $$\text{CI}(1-\alpha) = \Bigg[ \bar{x} \pm \sqrt{\frac{N-n}{N}} \cdot \frac{t_{n-1,\alpha/2}}{\sqrt{n}} \cdot s \Bigg].$$ You can see that the FPC term is a multiplicative term equal to the square-root of the unsampled proportion of values in the population. As $N \rightarrow \infty$ the unsampled proportion approaches one (and the sampled proportion approaches zero) so the FPC term "disappears". You can also see that this latter formula gives you a confidence interval that will allow for any sampling proportion, so it is not necessary to come up with a "rule of thumb" for how low the sampling proportion should be. Now, when we sample 10% of the population, the FPC term is $\sqrt{0.9} \approx 0.9487$, and evidently the author of your book thinks that this is close enough to one that it can be safely ignored (but if the sample proportion is higher than 10% then the adjustment should not be ignored). The author of your book is essentially asserting a "rule-of-thumb" --- if $n/N \leqslant 0.9$ then $FPC \geqslant 0.9487$, which means you can take $FPC=1$ without serious error. As I said above, my preference would be to avoid any such rule and simply use the FPC term when making an inference for a finite population.
10% rule for sample sizes In statistical models that use parameters for the underlying distributions, these parameters correspond to aspects of the empirical distribution of an infinite population (called a "superpopulation").
47,682
10% rule for sample sizes
If you're sampling a finite population without replacement, you're not sampling independently; your new observations in the sample avoid previously sampled cases. This is generally a good thing! However if you're using calculations based on assuming independence you will overestimate variances (instead of the formulas for the sampling you're doing) this will impact properties of CIs and tests. On the other hand if your sample is a very small fraction of the population this barely makes a difference. A common rule of thumb that people use is to ignore it if the standard deviation is overestimated by less than:about 5%. This corresponds to the 10% rule you mention. Also see finite population correction.
10% rule for sample sizes
If you're sampling a finite population without replacement, you're not sampling independently; your new observations in the sample avoid previously sampled cases. This is generally a good thing! Howev
10% rule for sample sizes If you're sampling a finite population without replacement, you're not sampling independently; your new observations in the sample avoid previously sampled cases. This is generally a good thing! However if you're using calculations based on assuming independence you will overestimate variances (instead of the formulas for the sampling you're doing) this will impact properties of CIs and tests. On the other hand if your sample is a very small fraction of the population this barely makes a difference. A common rule of thumb that people use is to ignore it if the standard deviation is overestimated by less than:about 5%. This corresponds to the 10% rule you mention. Also see finite population correction.
10% rule for sample sizes If you're sampling a finite population without replacement, you're not sampling independently; your new observations in the sample avoid previously sampled cases. This is generally a good thing! Howev
47,683
How to derive the formula of the t-test of the correlation coefficient
A t-test is a test on a statistic that has a t-distribution under the null hypothesis. A variable $Z$ has a t-distribution if it is obtained by dividing a Normally-distributed variable $X$ by a $\chi^2$-distributed variable $Y$. For the familiar t-test, $X$ is the sample mean of some IID data, which by the central limit theorem is Normally distributed, while $Y$ is the standard error of the mean, which has a $\chi^2$-distribution, and thus $X/Y$ follows a t-distribution. For correlation coefficients, under the null-hypothesis that the population correlation coefficient equals 0, the sample correlation is approximately Normally distributed with standard error $SE(r)=\sqrt{\frac{1-r^2}{n-2}}$, and the standard error is again $\chi^2$-distributed. Thus, the t-statistic is obtained by dividing the sample correlation coefficient $r$ by this standard error: $$ t=\frac{r}{SE(r)}=\frac{r}{\sqrt{\frac{1-r^2}{n-2}}} =\frac{r\sqrt{n-2}}{\sqrt{1-r^2}} $$ Note that in both cases we get the t-statistic by dividing a Normally-distributed variable by its $\chi^2$-distributed standard error, and so they're actually really not that different.
How to derive the formula of the t-test of the correlation coefficient
A t-test is a test on a statistic that has a t-distribution under the null hypothesis. A variable $Z$ has a t-distribution if it is obtained by dividing a Normally-distributed variable $X$ by a $\chi^
How to derive the formula of the t-test of the correlation coefficient A t-test is a test on a statistic that has a t-distribution under the null hypothesis. A variable $Z$ has a t-distribution if it is obtained by dividing a Normally-distributed variable $X$ by a $\chi^2$-distributed variable $Y$. For the familiar t-test, $X$ is the sample mean of some IID data, which by the central limit theorem is Normally distributed, while $Y$ is the standard error of the mean, which has a $\chi^2$-distribution, and thus $X/Y$ follows a t-distribution. For correlation coefficients, under the null-hypothesis that the population correlation coefficient equals 0, the sample correlation is approximately Normally distributed with standard error $SE(r)=\sqrt{\frac{1-r^2}{n-2}}$, and the standard error is again $\chi^2$-distributed. Thus, the t-statistic is obtained by dividing the sample correlation coefficient $r$ by this standard error: $$ t=\frac{r}{SE(r)}=\frac{r}{\sqrt{\frac{1-r^2}{n-2}}} =\frac{r\sqrt{n-2}}{\sqrt{1-r^2}} $$ Note that in both cases we get the t-statistic by dividing a Normally-distributed variable by its $\chi^2$-distributed standard error, and so they're actually really not that different.
How to derive the formula of the t-test of the correlation coefficient A t-test is a test on a statistic that has a t-distribution under the null hypothesis. A variable $Z$ has a t-distribution if it is obtained by dividing a Normally-distributed variable $X$ by a $\chi^
47,684
Why are Generative Adversarial Networks classed as unsupervised
There are many different flavors of GANs, so in this answer, I will refer to the original GAN. It's regarded as unsupervised because you don't assume that you have a target variable in your dataset -- and if you have one, you don't use it. All you need is some features (e.g., images) -- you don't need class label information for these images etc. Your goal is to sample from the distribution generating these images (via the generator). You are right though that there is some supervised learning going on inside a GAN via the discriminator. I.e., the discriminator is a binary classifier. The labels are not describing the content of the images, they are not part of the training set. It's merely an indicator whether the image is form the training set or from the generator. So, in that sense, GANs are for unsupervervised problems where you don't have label information, yet it also incorporates techniques from supervised learning. To call it an "unsupervised learning" technique is hence just a convention and in that case it's up for interpretation (I mean, DL technical language is broken anyway with lots of inconsistent terminology, so we shouldn't take it too seriously or literally I guess :))
Why are Generative Adversarial Networks classed as unsupervised
There are many different flavors of GANs, so in this answer, I will refer to the original GAN. It's regarded as unsupervised because you don't assume that you have a target variable in your dataset --
Why are Generative Adversarial Networks classed as unsupervised There are many different flavors of GANs, so in this answer, I will refer to the original GAN. It's regarded as unsupervised because you don't assume that you have a target variable in your dataset -- and if you have one, you don't use it. All you need is some features (e.g., images) -- you don't need class label information for these images etc. Your goal is to sample from the distribution generating these images (via the generator). You are right though that there is some supervised learning going on inside a GAN via the discriminator. I.e., the discriminator is a binary classifier. The labels are not describing the content of the images, they are not part of the training set. It's merely an indicator whether the image is form the training set or from the generator. So, in that sense, GANs are for unsupervervised problems where you don't have label information, yet it also incorporates techniques from supervised learning. To call it an "unsupervised learning" technique is hence just a convention and in that case it's up for interpretation (I mean, DL technical language is broken anyway with lots of inconsistent terminology, so we shouldn't take it too seriously or literally I guess :))
Why are Generative Adversarial Networks classed as unsupervised There are many different flavors of GANs, so in this answer, I will refer to the original GAN. It's regarded as unsupervised because you don't assume that you have a target variable in your dataset --
47,685
Why are Generative Adversarial Networks classed as unsupervised
I think the following perspective might further clarify the confusion. Generative Adversarial Networks attempt to solve an unsupervised learning problem by jointly solving a supervised learning problems, an optimization problem. Suppose we have training data that takes the form x1,...,xN without labels. Since there are no labels, this problem is unsupervised. Suppose we train a generator to produce fake samples, while simultaneously training a discriminator to tell real samples from fake. Training the discriminator is a supervised learning problem. Training the generator to fool the discriminator is an optimization problem. In summary: It is possible to train a GAN on data without labels, unsupervised learning. Doing this require us to jointly solve a supervised learning problem and an optimization problem.
Why are Generative Adversarial Networks classed as unsupervised
I think the following perspective might further clarify the confusion. Generative Adversarial Networks attempt to solve an unsupervised learning problem by jointly solving a supervised learning pro
Why are Generative Adversarial Networks classed as unsupervised I think the following perspective might further clarify the confusion. Generative Adversarial Networks attempt to solve an unsupervised learning problem by jointly solving a supervised learning problems, an optimization problem. Suppose we have training data that takes the form x1,...,xN without labels. Since there are no labels, this problem is unsupervised. Suppose we train a generator to produce fake samples, while simultaneously training a discriminator to tell real samples from fake. Training the discriminator is a supervised learning problem. Training the generator to fool the discriminator is an optimization problem. In summary: It is possible to train a GAN on data without labels, unsupervised learning. Doing this require us to jointly solve a supervised learning problem and an optimization problem.
Why are Generative Adversarial Networks classed as unsupervised I think the following perspective might further clarify the confusion. Generative Adversarial Networks attempt to solve an unsupervised learning problem by jointly solving a supervised learning pro
47,686
Why do you set 1 as intercept in linear regression model in python?
I don't know the python function/method you are referring to. But you may be confusing that the 1 you add is to your variables/feature such that it is multiplied by the intercept parameter in your parameter vector. In other words, 1 is rather added to your features and is NOT the value of your intercept.
Why do you set 1 as intercept in linear regression model in python?
I don't know the python function/method you are referring to. But you may be confusing that the 1 you add is to your variables/feature such that it is multiplied by the intercept parameter in your par
Why do you set 1 as intercept in linear regression model in python? I don't know the python function/method you are referring to. But you may be confusing that the 1 you add is to your variables/feature such that it is multiplied by the intercept parameter in your parameter vector. In other words, 1 is rather added to your features and is NOT the value of your intercept.
Why do you set 1 as intercept in linear regression model in python? I don't know the python function/method you are referring to. But you may be confusing that the 1 you add is to your variables/feature such that it is multiplied by the intercept parameter in your par
47,687
Why do you set 1 as intercept in linear regression model in python?
I do not know Python, but as you can readily illustrate in R, setting the value of the intercept to 1 is really just a convention (a useful one, though, of course, allowing us to interpret the intercept as the expected effect when $x=0$). n <- 10 y <- rnorm(n) # some random data x <- rnorm(n) intercept <- rep(1,n) # a "hand-made" intercept lm(y~x) # the default in R which includes an intercept lm(y~intercept+x-1) # removing the default intercept with -1 and re-adding it manually as another regressor lm(y~I(2*intercept)+x-1) # removing the default intercept with -1 and re-adding 2 as a constant term Output: > lm(y~x) Call: lm(formula = y ~ x) Coefficients: (Intercept) x -0.07813 0.55086 > lm(y~intercept+x-1) Call: lm(formula = y ~ intercept + x - 1) Coefficients: intercept x -0.07813 0.55086 > lm(y~I(2*intercept)+x-1) Call: lm(formula = y ~ I(2 * intercept) + x - 1) Coefficients: I(2 * intercept) x -0.03907 0.55086 As you can see, the first two regressions are exactly the same (as fully expected), and the third has the same coefficient on x, and exactly half the coefficient on the constant term, to account for the effect that we have multiplied that by two.
Why do you set 1 as intercept in linear regression model in python?
I do not know Python, but as you can readily illustrate in R, setting the value of the intercept to 1 is really just a convention (a useful one, though, of course, allowing us to interpret the interce
Why do you set 1 as intercept in linear regression model in python? I do not know Python, but as you can readily illustrate in R, setting the value of the intercept to 1 is really just a convention (a useful one, though, of course, allowing us to interpret the intercept as the expected effect when $x=0$). n <- 10 y <- rnorm(n) # some random data x <- rnorm(n) intercept <- rep(1,n) # a "hand-made" intercept lm(y~x) # the default in R which includes an intercept lm(y~intercept+x-1) # removing the default intercept with -1 and re-adding it manually as another regressor lm(y~I(2*intercept)+x-1) # removing the default intercept with -1 and re-adding 2 as a constant term Output: > lm(y~x) Call: lm(formula = y ~ x) Coefficients: (Intercept) x -0.07813 0.55086 > lm(y~intercept+x-1) Call: lm(formula = y ~ intercept + x - 1) Coefficients: intercept x -0.07813 0.55086 > lm(y~I(2*intercept)+x-1) Call: lm(formula = y ~ I(2 * intercept) + x - 1) Coefficients: I(2 * intercept) x -0.03907 0.55086 As you can see, the first two regressions are exactly the same (as fully expected), and the third has the same coefficient on x, and exactly half the coefficient on the constant term, to account for the effect that we have multiplied that by two.
Why do you set 1 as intercept in linear regression model in python? I do not know Python, but as you can readily illustrate in R, setting the value of the intercept to 1 is really just a convention (a useful one, though, of course, allowing us to interpret the interce
47,688
Least Squares Estimator Vs Ordinary Least Squares Estimator
Dropping out the Estimator keyword, Least Squares and Ordinary Least Squares, referred as LS and OLS respectively, are not the same. LS is much more general. It consist of linear and non-linear LS. And, linear LS consist of OLS, and some other types (e.g. GLS: Generalized LS, WLS: Weighted LS). The nonlinear part is itself a different world. In LS methods, the key thing is minimizing the sum of squared residuals. So, any one of the above listed method having this objective functions is a LS estimator. So, LS estimator is not that much definitive. When you make assumptions about the model and the error, it'll boil down to some of the listed alternatives. But, sometimes (and maybe commonly), it is being used for referring to OLS. The author of any article/note saying just LS estimator is probably referring to some sort of special case of it, by making related assumptions, probably somewhere in the article/notes. In your link, Page 9, Section 4.4, it is referring to OLS, in which he actually refers to it in the beginning of the second paragraph.
Least Squares Estimator Vs Ordinary Least Squares Estimator
Dropping out the Estimator keyword, Least Squares and Ordinary Least Squares, referred as LS and OLS respectively, are not the same. LS is much more general. It consist of linear and non-linear LS. An
Least Squares Estimator Vs Ordinary Least Squares Estimator Dropping out the Estimator keyword, Least Squares and Ordinary Least Squares, referred as LS and OLS respectively, are not the same. LS is much more general. It consist of linear and non-linear LS. And, linear LS consist of OLS, and some other types (e.g. GLS: Generalized LS, WLS: Weighted LS). The nonlinear part is itself a different world. In LS methods, the key thing is minimizing the sum of squared residuals. So, any one of the above listed method having this objective functions is a LS estimator. So, LS estimator is not that much definitive. When you make assumptions about the model and the error, it'll boil down to some of the listed alternatives. But, sometimes (and maybe commonly), it is being used for referring to OLS. The author of any article/note saying just LS estimator is probably referring to some sort of special case of it, by making related assumptions, probably somewhere in the article/notes. In your link, Page 9, Section 4.4, it is referring to OLS, in which he actually refers to it in the beginning of the second paragraph.
Least Squares Estimator Vs Ordinary Least Squares Estimator Dropping out the Estimator keyword, Least Squares and Ordinary Least Squares, referred as LS and OLS respectively, are not the same. LS is much more general. It consist of linear and non-linear LS. An
47,689
Gaussian-to-gaussian transformations
The thread at Normal Distribution Existence Non-affine Invariant Transformation? exhibits many non-affine transformations that map normally distributed variables into normally distributed variables, so the answer is in the negative. (For the record, an affine transformation $f:\mathbb R\to \mathbb R$ is one of the form $f(x) = \mu + \sigma x$ for numbers $\mu$ and $\sigma.$ That is, its graph is a line. I will restrict this definition to positive $\sigma$ (positively sloping graphs) in order to obtain an easily stated result.) We can, however, point to a simple condition that assures a positive answer, as suggested in the question. I will state it rather generally because that reveals its nature and it is no harder to prove the generalization. Let $X$ be a continuous random variable supported on all the real numbers. (This implies its distribution function $F_X$ given by $F_X(x)=\Pr(X\le x)$ is a strictly increasing continuous function from $\mathbb R$ onto the interval $(0,1).$) Denote by $\mathcal{F}[F_X]$ the set of distributions of all invertible affine transformations of $X$ (the "location-scale family" of $X$). Thus $$\mathcal{F}[F_X] = \{F_{\mu+\sigma X}\mid \mu\in\mathbb{R},\,\sigma\gt 0\}.$$ Proposition Let $f:\mathbb R\to\mathbb R$ be a continuous, increasing, one-to-one, measurable function for which $F_{f(X)}\in\mathcal{F}[F_X].$ Then $f$ is affine. Proof The measurability of $f$ is required to assure $Y=f(X)$ is a random variable. By applying a preliminary affine transformation to $f(X)$ we may, without any loss of generality, assume $F_X=F_Y=F_{f(X)}.$ Let $y$ be any real number and compute $$F_X(y) = F_Y(y) = F_{f(X)}(y) = \color{red}{\Pr(f(X) \le y) = \Pr\left(X\le f^{-1}(y)\right)} = F_X\left(f^{-1}(y)\right).$$ The first three and last equalities are all definitions. The remaining (penultimate) equality, shown in red, is justified because $f$ is one-to-one and increasing, whence its inverse $f^{-1}$ exists, is unique, and preserves inequalities. Finally, comparing the left and right sides of the foregoing, observe that because $F_X$ is strictly increasing and continuous, equality can hold only when the arguments are equal: that is, $$F_X(y) = F_X\left(f^{-1}(y)\right)\text{ implies } y = f^{-1}(y)$$ for all real $y.$ That means $f^{-1}$ (and therefore $f$) is the identity function. Accounting for the preliminary affine transformation that was applied, we conclude that the original transformation was affine, QED. Readers might enjoy constructing counterexamples to the proposition when any of the conditions on $f$ are relaxed. To answer the question: This applies to Normally distributed variables because they are a location-scale family of absolutely continuous variables with distributions supported on the entire real line.
Gaussian-to-gaussian transformations
The thread at Normal Distribution Existence Non-affine Invariant Transformation? exhibits many non-affine transformations that map normally distributed variables into normally distributed variables, s
Gaussian-to-gaussian transformations The thread at Normal Distribution Existence Non-affine Invariant Transformation? exhibits many non-affine transformations that map normally distributed variables into normally distributed variables, so the answer is in the negative. (For the record, an affine transformation $f:\mathbb R\to \mathbb R$ is one of the form $f(x) = \mu + \sigma x$ for numbers $\mu$ and $\sigma.$ That is, its graph is a line. I will restrict this definition to positive $\sigma$ (positively sloping graphs) in order to obtain an easily stated result.) We can, however, point to a simple condition that assures a positive answer, as suggested in the question. I will state it rather generally because that reveals its nature and it is no harder to prove the generalization. Let $X$ be a continuous random variable supported on all the real numbers. (This implies its distribution function $F_X$ given by $F_X(x)=\Pr(X\le x)$ is a strictly increasing continuous function from $\mathbb R$ onto the interval $(0,1).$) Denote by $\mathcal{F}[F_X]$ the set of distributions of all invertible affine transformations of $X$ (the "location-scale family" of $X$). Thus $$\mathcal{F}[F_X] = \{F_{\mu+\sigma X}\mid \mu\in\mathbb{R},\,\sigma\gt 0\}.$$ Proposition Let $f:\mathbb R\to\mathbb R$ be a continuous, increasing, one-to-one, measurable function for which $F_{f(X)}\in\mathcal{F}[F_X].$ Then $f$ is affine. Proof The measurability of $f$ is required to assure $Y=f(X)$ is a random variable. By applying a preliminary affine transformation to $f(X)$ we may, without any loss of generality, assume $F_X=F_Y=F_{f(X)}.$ Let $y$ be any real number and compute $$F_X(y) = F_Y(y) = F_{f(X)}(y) = \color{red}{\Pr(f(X) \le y) = \Pr\left(X\le f^{-1}(y)\right)} = F_X\left(f^{-1}(y)\right).$$ The first three and last equalities are all definitions. The remaining (penultimate) equality, shown in red, is justified because $f$ is one-to-one and increasing, whence its inverse $f^{-1}$ exists, is unique, and preserves inequalities. Finally, comparing the left and right sides of the foregoing, observe that because $F_X$ is strictly increasing and continuous, equality can hold only when the arguments are equal: that is, $$F_X(y) = F_X\left(f^{-1}(y)\right)\text{ implies } y = f^{-1}(y)$$ for all real $y.$ That means $f^{-1}$ (and therefore $f$) is the identity function. Accounting for the preliminary affine transformation that was applied, we conclude that the original transformation was affine, QED. Readers might enjoy constructing counterexamples to the proposition when any of the conditions on $f$ are relaxed. To answer the question: This applies to Normally distributed variables because they are a location-scale family of absolutely continuous variables with distributions supported on the entire real line.
Gaussian-to-gaussian transformations The thread at Normal Distribution Existence Non-affine Invariant Transformation? exhibits many non-affine transformations that map normally distributed variables into normally distributed variables, s
47,690
Gaussian-to-gaussian transformations
If $y=f(x), x,y\in\mathbb{R}^m$, then the condition that $x$ and $y$ are normally distributed is that the Jacobian of the transformation $f$ exists and is constant everywhere, with thanks to @henry for improvements. Please see the comment by @whuber in the OP’s question, viz., Normal Distribution Existence Non-affine Invariant Transformation?”, for his detailed discussion of non-affine transformations that preserve normality.
Gaussian-to-gaussian transformations
If $y=f(x), x,y\in\mathbb{R}^m$, then the condition that $x$ and $y$ are normally distributed is that the Jacobian of the transformation $f$ exists and is constant everywhere, with thanks to @henry fo
Gaussian-to-gaussian transformations If $y=f(x), x,y\in\mathbb{R}^m$, then the condition that $x$ and $y$ are normally distributed is that the Jacobian of the transformation $f$ exists and is constant everywhere, with thanks to @henry for improvements. Please see the comment by @whuber in the OP’s question, viz., Normal Distribution Existence Non-affine Invariant Transformation?”, for his detailed discussion of non-affine transformations that preserve normality.
Gaussian-to-gaussian transformations If $y=f(x), x,y\in\mathbb{R}^m$, then the condition that $x$ and $y$ are normally distributed is that the Jacobian of the transformation $f$ exists and is constant everywhere, with thanks to @henry fo
47,691
Interpretation of fixed effect coefficients from GLMs and GLMMs
Indeed in GLMs and because you have no random effects, the inverse-link transformed regression coefficients have an interpretation for the for the mean of the outcome. However, in GLMMs and because there you do have random effects, the inverse-link transformed regression coefficients have an interpretation for the for the mean of the outcome conditional on the random effects. Most often you are interested in the marginal mean of the outcome averaged over the random effects distribution, but the coefficients you obtained from the GLMMs do not have this interpretation.
Interpretation of fixed effect coefficients from GLMs and GLMMs
Indeed in GLMs and because you have no random effects, the inverse-link transformed regression coefficients have an interpretation for the for the mean of the outcome. However, in GLMMs and because th
Interpretation of fixed effect coefficients from GLMs and GLMMs Indeed in GLMs and because you have no random effects, the inverse-link transformed regression coefficients have an interpretation for the for the mean of the outcome. However, in GLMMs and because there you do have random effects, the inverse-link transformed regression coefficients have an interpretation for the for the mean of the outcome conditional on the random effects. Most often you are interested in the marginal mean of the outcome averaged over the random effects distribution, but the coefficients you obtained from the GLMMs do not have this interpretation.
Interpretation of fixed effect coefficients from GLMs and GLMMs Indeed in GLMs and because you have no random effects, the inverse-link transformed regression coefficients have an interpretation for the for the mean of the outcome. However, in GLMMs and because th
47,692
Non-monotone hazard functions
What you search for is called a U-formed hazard function or bathtub function (and references in those links). One specific case is the Gompertz-Makeham law from demography. An example is the hazard function of humans, high but falling hazard first few years of life, a minimum around 9-10 years of life, then slowly increasing. Googling with those terms will lead to much information. Much of interest here EDIT Some more information. This paper is a good starting point. They discuss a new extension of the Weibull, which they call EMWE (Exponentiated Modified Weibull Extension distribution) with four parameters, which permits bathtube shaped hazard with form close to hazard functions seen in practice. A plot from that paper is with pdf's on the left and corresponding hazard rates on the right. For reference I will give the cdf and pdf functions: $$ f(x;\alpha,\beta,\lambda,\gamma)=\lambda\beta\gamma(x/\alpha)^{\beta-1}\exp\left\{(x/\alpha)^\beta+\lambda\alpha(1-e^{(x/\alpha)^\beta} \right\}\cdot \left\{1-e^{\lambda\alpha(1-e^{(x/\alpha)^\beta}}\right\}^{\gamma-1}\\ F(x;\alpha,\beta,\lambda,\gamma)=\left\{1-\exp[\lambda\alpha(1-e^{(x/\alpha)^\beta}]\right\}^\gamma $$ and the hazard rate is $$ h(x;\alpha,\beta,\lambda,\gamma)=\frac{\lambda\beta\gamma(x/\alpha)^{\beta-1}\exp[(x/\alpha)^\beta+\lambda\alpha(1-e^{(x/\alpha)^\beta})]}{[1-\exp[\lambda\alpha(1-e^{(x/\alpha)^\beta})]]^{1-\gamma}+\exp\left\{ \lambda\alpha(1-e^{(x/\alpha)^\beta})\right\} -1} $$ Estimation can be done with maximum likelihood.
Non-monotone hazard functions
What you search for is called a U-formed hazard function or bathtub function (and references in those links). One specific case is the Gompertz-Makeham law from demography. An example is the hazard fu
Non-monotone hazard functions What you search for is called a U-formed hazard function or bathtub function (and references in those links). One specific case is the Gompertz-Makeham law from demography. An example is the hazard function of humans, high but falling hazard first few years of life, a minimum around 9-10 years of life, then slowly increasing. Googling with those terms will lead to much information. Much of interest here EDIT Some more information. This paper is a good starting point. They discuss a new extension of the Weibull, which they call EMWE (Exponentiated Modified Weibull Extension distribution) with four parameters, which permits bathtube shaped hazard with form close to hazard functions seen in practice. A plot from that paper is with pdf's on the left and corresponding hazard rates on the right. For reference I will give the cdf and pdf functions: $$ f(x;\alpha,\beta,\lambda,\gamma)=\lambda\beta\gamma(x/\alpha)^{\beta-1}\exp\left\{(x/\alpha)^\beta+\lambda\alpha(1-e^{(x/\alpha)^\beta} \right\}\cdot \left\{1-e^{\lambda\alpha(1-e^{(x/\alpha)^\beta}}\right\}^{\gamma-1}\\ F(x;\alpha,\beta,\lambda,\gamma)=\left\{1-\exp[\lambda\alpha(1-e^{(x/\alpha)^\beta}]\right\}^\gamma $$ and the hazard rate is $$ h(x;\alpha,\beta,\lambda,\gamma)=\frac{\lambda\beta\gamma(x/\alpha)^{\beta-1}\exp[(x/\alpha)^\beta+\lambda\alpha(1-e^{(x/\alpha)^\beta})]}{[1-\exp[\lambda\alpha(1-e^{(x/\alpha)^\beta})]]^{1-\gamma}+\exp\left\{ \lambda\alpha(1-e^{(x/\alpha)^\beta})\right\} -1} $$ Estimation can be done with maximum likelihood.
Non-monotone hazard functions What you search for is called a U-formed hazard function or bathtub function (and references in those links). One specific case is the Gompertz-Makeham law from demography. An example is the hazard fu
47,693
Are all symmetric matrices with diagonal elements 1 and other values between -1 and 1 correlation matrices?
I thought this must be asked & answered before, but cannot find it, so here it goes ... Let $S$ be a covariance matrix (for the algebra that follows it does not matter if it is theoretical or empirical). Let $D$ be a diagonal matrix with the diagonal of $S$. Then the correlation matrix $R$ is given by $$ R= D^{-1/2} S D^{-1/2} $$ (how you can see this directly is explained here.) To see that $S$ must be positive (semi)-definite (abbreviated posdef), let $X$ be a random variable with covariance amtrix $S$, and $c$ a vector. Then $$ \DeclareMathOperator{\var}{\mathbb{V}ar} \var(c^T X)= c^T S c \ge 0 $$ since variance is always nonnegative. Then this transfers to the correlation matrix: $$ c^T R c = c^T D^{-1/2} S D^{-1/2} c = (D^{-1/2} c)^T S (D^{-1/2} c) \ge 0 $$ Armed with this it is easy to make an counterexample, the following is not a correlation matrix: $$ \begin{pmatrix} 1 & -0.9 & -0.9 \\ -0.9& 1 & -0.9 \\ -0.9 & -0.9 & 1 \end{pmatrix} $$
Are all symmetric matrices with diagonal elements 1 and other values between -1 and 1 correlation ma
I thought this must be asked & answered before, but cannot find it, so here it goes ... Let $S$ be a covariance matrix (for the algebra that follows it does not matter if it is theoretical or empiric
Are all symmetric matrices with diagonal elements 1 and other values between -1 and 1 correlation matrices? I thought this must be asked & answered before, but cannot find it, so here it goes ... Let $S$ be a covariance matrix (for the algebra that follows it does not matter if it is theoretical or empirical). Let $D$ be a diagonal matrix with the diagonal of $S$. Then the correlation matrix $R$ is given by $$ R= D^{-1/2} S D^{-1/2} $$ (how you can see this directly is explained here.) To see that $S$ must be positive (semi)-definite (abbreviated posdef), let $X$ be a random variable with covariance amtrix $S$, and $c$ a vector. Then $$ \DeclareMathOperator{\var}{\mathbb{V}ar} \var(c^T X)= c^T S c \ge 0 $$ since variance is always nonnegative. Then this transfers to the correlation matrix: $$ c^T R c = c^T D^{-1/2} S D^{-1/2} c = (D^{-1/2} c)^T S (D^{-1/2} c) \ge 0 $$ Armed with this it is easy to make an counterexample, the following is not a correlation matrix: $$ \begin{pmatrix} 1 & -0.9 & -0.9 \\ -0.9& 1 & -0.9 \\ -0.9 & -0.9 & 1 \end{pmatrix} $$
Are all symmetric matrices with diagonal elements 1 and other values between -1 and 1 correlation ma I thought this must be asked & answered before, but cannot find it, so here it goes ... Let $S$ be a covariance matrix (for the algebra that follows it does not matter if it is theoretical or empiric
47,694
Interpreting Regression Diagnostic Plots
As mentioned above there are a fair few answers to assessing these kind of plots but it can't hurt to have all the answers in one place. I have created some data and code in R to illustrate my answer: #Data creation df <- data.frame(y = c(rep(1:100, 10))) df$x <- df$y + rnorm(1000, sd = 5) To begin with it is always good to plot your variables against one another. If you have just one predictor then something like: plot(y ~ x, data = df) works well. If you have multiple predictors then you can use pairs(df). In this case the data looks like it has a positive linear association suggesting that an appropriate model is: fit <- lm(y ~ x, data = df) The residual v.s. fitted plot is usually used to determine if the residuals meet the equality of variance assumption that is implicit in linear models which is what I assume you have fitted. There are a few things we look for here - if you have a continuous predictor then we want to see that the residuals are equally and randomly distributed around 0, with essentially no pattern - i.e. white noise. If it looks like white noise it means that your linear model is capturing any pattern in your data. If you have significant curvature (which your plot shows) it means that you have not captured some pattern, this commonly happens when you fit a straight line to data which has a curve in it suggesting that you might need to add a quadratic term to your model - this allows your fitted line to curve. Sometimes this can also be fixed by log transforming your response variable. The importance of this is that your error term will not be accurate otherwise; it will be underestimating the errors at low and high values of your predictor and over-estimating at the mid-range, which in turn means your predictions and coefficients will not be accurate. The second thing we look for in this plot (when assessing linear models - i.e. your response is normally distributed) is that the residuals are have roughly equal variance across the range of fitted values - I.e. the overall spread of the residuals is roughly equal across the range of fitted values. Put another way you don't have something like a trumpet or rugby ball shape, although there are other inappropriate shapes. This again means that the errors across your fitted line are not equal - some are underestimating while others are over-estimating which will throw out predictions and alters estimates/p-values. The plot should look something like this: plot(fit, which = 1) In my case the plot has some funny edges which are a result of how I created the data but it should serve to give an indication of what we are after. The second plot (Normal Q-Q) checks that the errors are roughly normally distributed meaning that most of the residuals lie close to the line and a few far away. This has important implications for predictions again, but if you are only interested in p-values then it is less important as we can invoke the central limit theorem in most cases - some more reading on this here. Essentially we want the points to lie on the fitted line. If they don't it could be for any number of reasons. In your case it is likely due to the curvature that your model has missed but could also be fixed by a log-transformation of your response. The plot should look something like this: plot(fit, which = 2) Another way you can see this is using the normcheck function in the s20x library, which give a bit more intuitive output. #install.packages("s20x") library(s20x) normcheck(fit) The third plot (Scale-Location plot) shows much the same as the residual v.s. fitted plot but on a standardised scale. The residual v.s. fitted and scale-location plots can be used to assess heteroscedasticity (variance changing with fitted values) as well. The plot should look something like this: plot(fit, which = 3) This is also a better example of the kind of pattern we want to see in the first plot as it has lost the odd edges. The final plot (residuals v.s. leverage) is a way of checking if any points are having undue influence over the line. The ordinary least squares equation, which is what linear models employ, tries to minimise the distance of the line from all the points. Points which are further from the line can sometimes have a greater influence over the plot - it's kind of like a sitting on the far end of a seesaw compared to sitting near the fulcrum. Typically the rule of thumb is that if a point has a cook's distance > 0.4 it has a large influence over the line and sometimes this might be criteria to remove it but this should never be done lightly. Your plot shows at least two points (22 and 50 - which corresponds to rows 22 and 50), along with their respective indexes, are having a large influence over your line. The indexes allow one to easily subset the points to have a look at them to see if they are wonky - sometimes it just comes down to an entry error. In your case I suspect that it is because the model is inappropriate rather than the data having anomalies. The plot should look something like this: plot(fit, which = 4) You can see in that last one that there are no red boundary lines like in the top right corner of yours - this is because non of my points come close to having high leverage. This can also be assessed using the s20x package in a more intuitive (I feel) way using the cooks20x function: cooks20x(fit) Just look for points that are above 0.4 on the y-axis. The number displayed above each column is the row of the observation in the data frame. I hope this helps!
Interpreting Regression Diagnostic Plots
As mentioned above there are a fair few answers to assessing these kind of plots but it can't hurt to have all the answers in one place. I have created some data and code in R to illustrate my answer:
Interpreting Regression Diagnostic Plots As mentioned above there are a fair few answers to assessing these kind of plots but it can't hurt to have all the answers in one place. I have created some data and code in R to illustrate my answer: #Data creation df <- data.frame(y = c(rep(1:100, 10))) df$x <- df$y + rnorm(1000, sd = 5) To begin with it is always good to plot your variables against one another. If you have just one predictor then something like: plot(y ~ x, data = df) works well. If you have multiple predictors then you can use pairs(df). In this case the data looks like it has a positive linear association suggesting that an appropriate model is: fit <- lm(y ~ x, data = df) The residual v.s. fitted plot is usually used to determine if the residuals meet the equality of variance assumption that is implicit in linear models which is what I assume you have fitted. There are a few things we look for here - if you have a continuous predictor then we want to see that the residuals are equally and randomly distributed around 0, with essentially no pattern - i.e. white noise. If it looks like white noise it means that your linear model is capturing any pattern in your data. If you have significant curvature (which your plot shows) it means that you have not captured some pattern, this commonly happens when you fit a straight line to data which has a curve in it suggesting that you might need to add a quadratic term to your model - this allows your fitted line to curve. Sometimes this can also be fixed by log transforming your response variable. The importance of this is that your error term will not be accurate otherwise; it will be underestimating the errors at low and high values of your predictor and over-estimating at the mid-range, which in turn means your predictions and coefficients will not be accurate. The second thing we look for in this plot (when assessing linear models - i.e. your response is normally distributed) is that the residuals are have roughly equal variance across the range of fitted values - I.e. the overall spread of the residuals is roughly equal across the range of fitted values. Put another way you don't have something like a trumpet or rugby ball shape, although there are other inappropriate shapes. This again means that the errors across your fitted line are not equal - some are underestimating while others are over-estimating which will throw out predictions and alters estimates/p-values. The plot should look something like this: plot(fit, which = 1) In my case the plot has some funny edges which are a result of how I created the data but it should serve to give an indication of what we are after. The second plot (Normal Q-Q) checks that the errors are roughly normally distributed meaning that most of the residuals lie close to the line and a few far away. This has important implications for predictions again, but if you are only interested in p-values then it is less important as we can invoke the central limit theorem in most cases - some more reading on this here. Essentially we want the points to lie on the fitted line. If they don't it could be for any number of reasons. In your case it is likely due to the curvature that your model has missed but could also be fixed by a log-transformation of your response. The plot should look something like this: plot(fit, which = 2) Another way you can see this is using the normcheck function in the s20x library, which give a bit more intuitive output. #install.packages("s20x") library(s20x) normcheck(fit) The third plot (Scale-Location plot) shows much the same as the residual v.s. fitted plot but on a standardised scale. The residual v.s. fitted and scale-location plots can be used to assess heteroscedasticity (variance changing with fitted values) as well. The plot should look something like this: plot(fit, which = 3) This is also a better example of the kind of pattern we want to see in the first plot as it has lost the odd edges. The final plot (residuals v.s. leverage) is a way of checking if any points are having undue influence over the line. The ordinary least squares equation, which is what linear models employ, tries to minimise the distance of the line from all the points. Points which are further from the line can sometimes have a greater influence over the plot - it's kind of like a sitting on the far end of a seesaw compared to sitting near the fulcrum. Typically the rule of thumb is that if a point has a cook's distance > 0.4 it has a large influence over the line and sometimes this might be criteria to remove it but this should never be done lightly. Your plot shows at least two points (22 and 50 - which corresponds to rows 22 and 50), along with their respective indexes, are having a large influence over your line. The indexes allow one to easily subset the points to have a look at them to see if they are wonky - sometimes it just comes down to an entry error. In your case I suspect that it is because the model is inappropriate rather than the data having anomalies. The plot should look something like this: plot(fit, which = 4) You can see in that last one that there are no red boundary lines like in the top right corner of yours - this is because non of my points come close to having high leverage. This can also be assessed using the s20x package in a more intuitive (I feel) way using the cooks20x function: cooks20x(fit) Just look for points that are above 0.4 on the y-axis. The number displayed above each column is the row of the observation in the data frame. I hope this helps!
Interpreting Regression Diagnostic Plots As mentioned above there are a fair few answers to assessing these kind of plots but it can't hurt to have all the answers in one place. I have created some data and code in R to illustrate my answer:
47,695
What, if anything, is wrong with the SE welcome wagon blog post's statistical analysis?
This is a great question, and it is nice to see the analysis conducted by StackExchange subjected to the rigour of its own contributing experts! Nevertheless, it is a bit difficult to assess a blog post "from an academic perspective" since the level of rigour in blog posts differs substantially from those of published scholarly work in academia. As a general opinion, I will first note that the analysis presented in the blog post is less rigorous than what I would expect in an academic paper, and there are many aspects of the study and analysis that are not specified. That is not necessarily unreasonable, since a blog post is generally not aiming at the level of detail and rigour of an academic paper on the subject. Blog posts are usually targeted to a lay audience that cannot be assumed to have any statistical knowledge or training, so it is not necessarily unreasonable that the kinds of information in a detailed statistical analysis would be stripped away for brevity. The data they have collected looks to me to be a large and impressive project, so my overall impressions are favourable. Another important thing to note is that it is important to distinguish exploratory data analysis and confirmatory data analysis. This project appears to be in the former category, since it does not seek to test a pre-existing hypothesis. In view of this, one must be careful with presenting formal statistical tests for hypotheses. In particular, if hypotheses are formed by looking at the exploratory data then formal tests of these hypotheses using that same data will be biased towards acceptance of the hypotheses. In EDA it is generally best to avoid formal hypothesis tests, except for general tests of differences that were reasonable to ask for prior to seeing the data. Having said this, it would certainly be nice if the authors were able to back up this blog post with a more detailed exposition of the mechanics of their study and their modelling (e.g., in a published paper, or even just a more detailed post aimed at statisticians). To get this up to a level that would be convincing to a statistician they would need to gave a bit more detail in some areas, particularly in regard to their sampling mechanisms and their modelling. It would be even nicer if they shared the underlying data ---suitably anonymised--- so that others can model the data! In terms of the drawbacks of the present post, I see a few main issues that would need to be tightened up to make this a more rigorous presentation. Unclear sampling mechanisms: The mechanism by which comments were sampled and presented to the participants is not clear from the post. Were all comments in a given time period presented for review, or was it just a sample? If the latter, was it a randomised sample, or was it chosen in the discretion of the study researchers? Unclear demarcation of group effect vs question effect: The metrics shown in the blog post are all measures per user, that do not have any adjustment to account for the comments rated by that user. It is unclear whether there are systematic differences in the types of comments rated by different users, and if this can be filtered out via statistical methods. We are told that the overall group differences are "...robust to comparing groups who were shown the same comments, who rated the same number of comments, and other analytical approaches." Nevertheless, this latter analysis is not shown or described. Measures of uncertainty: The post shows the median ratings of each group, and the graphs give a visual presentation of spread in the median ratings of each participant. Nevertheless, aside from those presented graphically, there are no statistical metrics (e.g., confidence intervals, etc.) that estimate the "true" group means/medians. There is also no presentation of the relative size of the variance in ratings for an individual participant, versus the spread in median ratings for different participants. Hypothesis testing: The omission of formal testing in this analysis is probably a positive, since it appears to be an exploratory study rather than a confirmatory analysis of a pre-existing hypothesis. From their observed data the authors state that "[o]ur project showed that the more deeply an individual is connected to Stack Overflow (as an employee, or a moderator), the more they are likely to see problems in comments like these." For reasons elaborated at length by Tukey in his analysis of EDA and CDA (see e.g., Behrens 1997), I think this "conclusion" should actually be treated as an exploratory hypothesis formed by observation of the data, and so it should be tested with new data in a later study. As a final comment, I would like to reiterate that the above issues are things that are drawbacks only from the point of view of trying to present a more rigorous analysis - in terms of a blog post for a lay audience, their omission may be perfectly reasonable. The authors of the blog post are both data scientists with some background in statistical analysis, so I'm sure they're aware of these issues, and would deal with them accordingly if they decide to write their blog post up into a more rigorous paper.
What, if anything, is wrong with the SE welcome wagon blog post's statistical analysis?
This is a great question, and it is nice to see the analysis conducted by StackExchange subjected to the rigour of its own contributing experts! Nevertheless, it is a bit difficult to assess a blog p
What, if anything, is wrong with the SE welcome wagon blog post's statistical analysis? This is a great question, and it is nice to see the analysis conducted by StackExchange subjected to the rigour of its own contributing experts! Nevertheless, it is a bit difficult to assess a blog post "from an academic perspective" since the level of rigour in blog posts differs substantially from those of published scholarly work in academia. As a general opinion, I will first note that the analysis presented in the blog post is less rigorous than what I would expect in an academic paper, and there are many aspects of the study and analysis that are not specified. That is not necessarily unreasonable, since a blog post is generally not aiming at the level of detail and rigour of an academic paper on the subject. Blog posts are usually targeted to a lay audience that cannot be assumed to have any statistical knowledge or training, so it is not necessarily unreasonable that the kinds of information in a detailed statistical analysis would be stripped away for brevity. The data they have collected looks to me to be a large and impressive project, so my overall impressions are favourable. Another important thing to note is that it is important to distinguish exploratory data analysis and confirmatory data analysis. This project appears to be in the former category, since it does not seek to test a pre-existing hypothesis. In view of this, one must be careful with presenting formal statistical tests for hypotheses. In particular, if hypotheses are formed by looking at the exploratory data then formal tests of these hypotheses using that same data will be biased towards acceptance of the hypotheses. In EDA it is generally best to avoid formal hypothesis tests, except for general tests of differences that were reasonable to ask for prior to seeing the data. Having said this, it would certainly be nice if the authors were able to back up this blog post with a more detailed exposition of the mechanics of their study and their modelling (e.g., in a published paper, or even just a more detailed post aimed at statisticians). To get this up to a level that would be convincing to a statistician they would need to gave a bit more detail in some areas, particularly in regard to their sampling mechanisms and their modelling. It would be even nicer if they shared the underlying data ---suitably anonymised--- so that others can model the data! In terms of the drawbacks of the present post, I see a few main issues that would need to be tightened up to make this a more rigorous presentation. Unclear sampling mechanisms: The mechanism by which comments were sampled and presented to the participants is not clear from the post. Were all comments in a given time period presented for review, or was it just a sample? If the latter, was it a randomised sample, or was it chosen in the discretion of the study researchers? Unclear demarcation of group effect vs question effect: The metrics shown in the blog post are all measures per user, that do not have any adjustment to account for the comments rated by that user. It is unclear whether there are systematic differences in the types of comments rated by different users, and if this can be filtered out via statistical methods. We are told that the overall group differences are "...robust to comparing groups who were shown the same comments, who rated the same number of comments, and other analytical approaches." Nevertheless, this latter analysis is not shown or described. Measures of uncertainty: The post shows the median ratings of each group, and the graphs give a visual presentation of spread in the median ratings of each participant. Nevertheless, aside from those presented graphically, there are no statistical metrics (e.g., confidence intervals, etc.) that estimate the "true" group means/medians. There is also no presentation of the relative size of the variance in ratings for an individual participant, versus the spread in median ratings for different participants. Hypothesis testing: The omission of formal testing in this analysis is probably a positive, since it appears to be an exploratory study rather than a confirmatory analysis of a pre-existing hypothesis. From their observed data the authors state that "[o]ur project showed that the more deeply an individual is connected to Stack Overflow (as an employee, or a moderator), the more they are likely to see problems in comments like these." For reasons elaborated at length by Tukey in his analysis of EDA and CDA (see e.g., Behrens 1997), I think this "conclusion" should actually be treated as an exploratory hypothesis formed by observation of the data, and so it should be tested with new data in a later study. As a final comment, I would like to reiterate that the above issues are things that are drawbacks only from the point of view of trying to present a more rigorous analysis - in terms of a blog post for a lay audience, their omission may be perfectly reasonable. The authors of the blog post are both data scientists with some background in statistical analysis, so I'm sure they're aware of these issues, and would deal with them accordingly if they decide to write their blog post up into a more rigorous paper.
What, if anything, is wrong with the SE welcome wagon blog post's statistical analysis? This is a great question, and it is nice to see the analysis conducted by StackExchange subjected to the rigour of its own contributing experts! Nevertheless, it is a bit difficult to assess a blog p
47,696
Why does dropout increase the training time per epoch in a neural network?
but I thought that the training time per epoch would decrease by dropping out units. That's not the case. I understand your rationale though. You thought that zeroing out components would make for less computation. That would be the case for sparse matrices, but not for dense matrices. TensorFlow, and any deep learning framework for that matter, uses vectorized operations on dense vector*. This means that number of zeros makes no difference, since you're going to calculate matrix operations using all entries. In reality, the opposite is true, because dropout requires additional matrices for dropout masks drawing random numbers for each entry of these matrices multiplying the masks and corresponding weights * They also support sparse matrices, but they don't make sense for most weights because they're useful mostly if you have far less than half of entries equal to zero.
Why does dropout increase the training time per epoch in a neural network?
but I thought that the training time per epoch would decrease by dropping out units. That's not the case. I understand your rationale though. You thought that zeroing out components would make for
Why does dropout increase the training time per epoch in a neural network? but I thought that the training time per epoch would decrease by dropping out units. That's not the case. I understand your rationale though. You thought that zeroing out components would make for less computation. That would be the case for sparse matrices, but not for dense matrices. TensorFlow, and any deep learning framework for that matter, uses vectorized operations on dense vector*. This means that number of zeros makes no difference, since you're going to calculate matrix operations using all entries. In reality, the opposite is true, because dropout requires additional matrices for dropout masks drawing random numbers for each entry of these matrices multiplying the masks and corresponding weights * They also support sparse matrices, but they don't make sense for most weights because they're useful mostly if you have far less than half of entries equal to zero.
Why does dropout increase the training time per epoch in a neural network? but I thought that the training time per epoch would decrease by dropping out units. That's not the case. I understand your rationale though. You thought that zeroing out components would make for
47,697
The meaning of Bayesian update
Posteriors and priors are all distributions on the parameter space, so they can be compared as such, even if they are not of the same shape. If you are interested in performing multiple updates, i.e. to go from a posterior p(theta|Y1) to a second posterior p(theta|Y1,Y2), etc, then you can absolutely use p(theta|Y1) as a prior, and p(Y2|Y1,theta) as a likelihood. In fact some methods called sequential Monte Carlo can be used to recursively approximate a sequence of such posteriors, see for instance Chopin 2002, A sequential particle filter method for static models , https://academic.oup.com/biomet/article-abstract/89/3/539/251804?redirectedFrom=PDF
The meaning of Bayesian update
Posteriors and priors are all distributions on the parameter space, so they can be compared as such, even if they are not of the same shape. If you are interested in performing multiple updates, i.e.
The meaning of Bayesian update Posteriors and priors are all distributions on the parameter space, so they can be compared as such, even if they are not of the same shape. If you are interested in performing multiple updates, i.e. to go from a posterior p(theta|Y1) to a second posterior p(theta|Y1,Y2), etc, then you can absolutely use p(theta|Y1) as a prior, and p(Y2|Y1,theta) as a likelihood. In fact some methods called sequential Monte Carlo can be used to recursively approximate a sequence of such posteriors, see for instance Chopin 2002, A sequential particle filter method for static models , https://academic.oup.com/biomet/article-abstract/89/3/539/251804?redirectedFrom=PDF
The meaning of Bayesian update Posteriors and priors are all distributions on the parameter space, so they can be compared as such, even if they are not of the same shape. If you are interested in performing multiple updates, i.e.
47,698
The meaning of Bayesian update
Pierrot's answer is correct, but as this seems to be a question about intuition, I wanted to give what might be a more intuitive approach to thinking about the question. I (+1)'d this question because it is in a way insightful; you are taking seriously that you need to understand what a method really means. However, when you take a higher-level view to the meaning behind the MCMC method, you also need to take a higher-level view to what it means to update the prior. If your prior belief can be described as a gamma distribution and your posterior belief can't, you have certainly updated your prior beliefs, and this does not bring any problems of "compar[ing] apples and oranges" (with respect to saying whether or not you've updated your prior). If you assign a different probability to various events in your posterior belief to the probabilities you assign in your prior belief, you have updated your beliefs, and this has nothing to do with whether your prior and posterior are the same type of probability distribution with just different parameters, or are represented by different types of distribution entirely. In other words, a Bayesian update does not require the posterior distribution to be of the same form of the prior. This fact does not mean that only a "one-shot" update is possible either. Let me give a simple example. Suppose your prior belief is that it is just as likely on any particular day that it will rain (call this event $B$) than that it will not. Then your prior is a discrete uniform distribution assigning probability $0.5$ to $B$ and $0.5$ to $\neg B$. However, suppose you have also observe that it is April (call this event $A$) and you know both that the probability that a day is in April is $\frac{1}{12}$ and that the joint probability that it will rain on a day and that the day is a day in April is $\frac{3}{48}$. Then $$ \Pr(B|A) = \frac{\Pr(A \cap B)}{\Pr(A)} = \frac{3/48}{1/12} = 0.75 $$ Now your posterior belief assigns probability $0.75$ to $B$ and $0.25$ to $\neg B$, which is not a uniform distribution, but we would still validly call this a Bayesian update. Moreover, this need not be a one-shot update, because you could easily further update your belief about $B$ if, for example, you observed dark clouds in the sky, etc. This answer does not address another question that might be lurking within the question you asked -- how you use the posterior approximation from MCMC as a prior in another update. Perhaps Pierrot's answer can give you some insight there.
The meaning of Bayesian update
Pierrot's answer is correct, but as this seems to be a question about intuition, I wanted to give what might be a more intuitive approach to thinking about the question. I (+1)'d this question because
The meaning of Bayesian update Pierrot's answer is correct, but as this seems to be a question about intuition, I wanted to give what might be a more intuitive approach to thinking about the question. I (+1)'d this question because it is in a way insightful; you are taking seriously that you need to understand what a method really means. However, when you take a higher-level view to the meaning behind the MCMC method, you also need to take a higher-level view to what it means to update the prior. If your prior belief can be described as a gamma distribution and your posterior belief can't, you have certainly updated your prior beliefs, and this does not bring any problems of "compar[ing] apples and oranges" (with respect to saying whether or not you've updated your prior). If you assign a different probability to various events in your posterior belief to the probabilities you assign in your prior belief, you have updated your beliefs, and this has nothing to do with whether your prior and posterior are the same type of probability distribution with just different parameters, or are represented by different types of distribution entirely. In other words, a Bayesian update does not require the posterior distribution to be of the same form of the prior. This fact does not mean that only a "one-shot" update is possible either. Let me give a simple example. Suppose your prior belief is that it is just as likely on any particular day that it will rain (call this event $B$) than that it will not. Then your prior is a discrete uniform distribution assigning probability $0.5$ to $B$ and $0.5$ to $\neg B$. However, suppose you have also observe that it is April (call this event $A$) and you know both that the probability that a day is in April is $\frac{1}{12}$ and that the joint probability that it will rain on a day and that the day is a day in April is $\frac{3}{48}$. Then $$ \Pr(B|A) = \frac{\Pr(A \cap B)}{\Pr(A)} = \frac{3/48}{1/12} = 0.75 $$ Now your posterior belief assigns probability $0.75$ to $B$ and $0.25$ to $\neg B$, which is not a uniform distribution, but we would still validly call this a Bayesian update. Moreover, this need not be a one-shot update, because you could easily further update your belief about $B$ if, for example, you observed dark clouds in the sky, etc. This answer does not address another question that might be lurking within the question you asked -- how you use the posterior approximation from MCMC as a prior in another update. Perhaps Pierrot's answer can give you some insight there.
The meaning of Bayesian update Pierrot's answer is correct, but as this seems to be a question about intuition, I wanted to give what might be a more intuitive approach to thinking about the question. I (+1)'d this question because
47,699
Principled understanding of why AlphaZero's algorithm works?
First a small note: AlphaGo Zero actually does only use a single network, it no longer has separate value and policy networks like the original AlphaGo did. That single network does still have separate value and policy heads though (two separate outputs)... so I suppose you can intuitively still view it as having two networks (which happen to share a large number of parameters between them). With that technicality out of the way, it is first important to have a good understanding of what the different roles are that are fulfilled by learning (regardless of whether it is a policy or a value network) on one hand, and search (MCTS) on the other hand: The networks (both value and policy) obtained through learning can informally be viewed as providing a strong level of intuition to the program. These components look at a current state, and instantly make a "snap decision" for an action to play (in the case of policy network) or a "snap evaluation" to estimate the value of a state (in the case of value network). They can be trained to perform at an admirable level on their own already, but are always going to be constrained in some sense. When not combined with an element of search (like MCTS), they do not perform any additional "reasoning" or "thinking". The search component (MCTS) provides "reasoning" / "thinking" / "deliberation" to the program. It does not make any instant "snap" decisions, but happily uses as much thinking time as it can get to continue reasoning and gradually improve the decision it would make during the specific turn it is "thinking" about. It really focuses on that one particular turn, rather than then learning components which focus on the complete game simultaneously. Given an infinite amount of thinking time, it would play optimally. Why does AlphaZero use both a policy network and a value network? It could also have used only a policy net with MCTS, or only a value net with MCTS. Is there a principled understanding of why this works well? (apart from "it turns out to work well in experiments"). Note that: Given a state $s$, the value network gives an estimate of the value $V(s)$ of that state $s$. Given a state $s$, the policy network gives a recommendation of an action $a = \pi(s)$ to take (or a probability distribution $\pi(s, a)$ over the different possible actions $a$). These are quite different kinds of outputs, and this means there are different parts in the MCTS algorithm where they can be used: The output $V(s)$ of a value network is an evaluation "in hindsight". You first have to actually reach a state $s$, and then the value network can be used to evaluate it. This is useful, for example, if you want to terminate a Play-out / rollout of MCTS early (before it has been rolled out all the way to a truly terminal state), and return a reasonable evaluation for that rollout. However, it can not be used (efficiently) for action selection during a rollout for example; if you want to use a $V(s')$ estimate to determine which action to pick in a rollout, you have to first generate all possible successor states $s'$ for all possible actions, evaluate all of them, and then you can finally pick the best action accordingly. This is computationally expensive. The output $\pi(s, a)$ of a policy network is a "proactive action selection". You can use it, for example, during a Play-out/rollout to immediately select an action for a current state $s$, no need to first generate and evaluate all possible successors $s'$. However, when you wish to terminate a rollout, evaluate the resulting state, and backpropagate that evaluation... the policy network does not provide the information required to do that, it doesn't give you a state-value estimate. In practice, it is indeed desirable to be able to do both of the things that were described above as being easy to do for one network and difficult for the other. It is important to use a strong "intuition" (obtained throuhg learning) for action selection in MCTS, because this leads to more realistic rollouts and therefore also often better evaluations. This cannot be done using a value network (well, it can in the Selection phase / tree traversal of MCTS, but not once a node is reached that hasn't been fully expanded). It is also desirable to terminate rollouts early and backpropagate high-quality evaluations, rather than rolling them out all the way (which takes more time and introduces more variance due to greater likelihood of selecting unrealistic actions along the trajectory). This functionality can only be provided by a value network. Why does AlphaZero use both the value function AND an "upper confidence bound" to guide its search? When the search process starts, when we have not yet run through a large number of MCTS simulations, the evaluations based purely on MCTS itself (which are typically used in the UCB equation) are unreliable. So, initially it is useful to have a strong "intuition" for value estimates, as provided by the value network. As the number of MCTS simulations performed increases (in particular as it tends to infinity, but of course also earlier than that in practice), we expect the MCTS-based evaluations to gradually become more reliable, eventually even potentially becoming more accurate than the learned value network. Note that the value network was trained to provide reasonable value estimates instantly for any game state. The MCTS search process dedicates all of its time just to computing reliable value estimates for the current game state, it is allowed to "specialize" to the current game state. So, as time moves on, we'll want to start relying a bit more on the MCTS-based evaluations, and a bit less on the initial "intuition" from the value network.
Principled understanding of why AlphaZero's algorithm works?
First a small note: AlphaGo Zero actually does only use a single network, it no longer has separate value and policy networks like the original AlphaGo did. That single network does still have separat
Principled understanding of why AlphaZero's algorithm works? First a small note: AlphaGo Zero actually does only use a single network, it no longer has separate value and policy networks like the original AlphaGo did. That single network does still have separate value and policy heads though (two separate outputs)... so I suppose you can intuitively still view it as having two networks (which happen to share a large number of parameters between them). With that technicality out of the way, it is first important to have a good understanding of what the different roles are that are fulfilled by learning (regardless of whether it is a policy or a value network) on one hand, and search (MCTS) on the other hand: The networks (both value and policy) obtained through learning can informally be viewed as providing a strong level of intuition to the program. These components look at a current state, and instantly make a "snap decision" for an action to play (in the case of policy network) or a "snap evaluation" to estimate the value of a state (in the case of value network). They can be trained to perform at an admirable level on their own already, but are always going to be constrained in some sense. When not combined with an element of search (like MCTS), they do not perform any additional "reasoning" or "thinking". The search component (MCTS) provides "reasoning" / "thinking" / "deliberation" to the program. It does not make any instant "snap" decisions, but happily uses as much thinking time as it can get to continue reasoning and gradually improve the decision it would make during the specific turn it is "thinking" about. It really focuses on that one particular turn, rather than then learning components which focus on the complete game simultaneously. Given an infinite amount of thinking time, it would play optimally. Why does AlphaZero use both a policy network and a value network? It could also have used only a policy net with MCTS, or only a value net with MCTS. Is there a principled understanding of why this works well? (apart from "it turns out to work well in experiments"). Note that: Given a state $s$, the value network gives an estimate of the value $V(s)$ of that state $s$. Given a state $s$, the policy network gives a recommendation of an action $a = \pi(s)$ to take (or a probability distribution $\pi(s, a)$ over the different possible actions $a$). These are quite different kinds of outputs, and this means there are different parts in the MCTS algorithm where they can be used: The output $V(s)$ of a value network is an evaluation "in hindsight". You first have to actually reach a state $s$, and then the value network can be used to evaluate it. This is useful, for example, if you want to terminate a Play-out / rollout of MCTS early (before it has been rolled out all the way to a truly terminal state), and return a reasonable evaluation for that rollout. However, it can not be used (efficiently) for action selection during a rollout for example; if you want to use a $V(s')$ estimate to determine which action to pick in a rollout, you have to first generate all possible successor states $s'$ for all possible actions, evaluate all of them, and then you can finally pick the best action accordingly. This is computationally expensive. The output $\pi(s, a)$ of a policy network is a "proactive action selection". You can use it, for example, during a Play-out/rollout to immediately select an action for a current state $s$, no need to first generate and evaluate all possible successors $s'$. However, when you wish to terminate a rollout, evaluate the resulting state, and backpropagate that evaluation... the policy network does not provide the information required to do that, it doesn't give you a state-value estimate. In practice, it is indeed desirable to be able to do both of the things that were described above as being easy to do for one network and difficult for the other. It is important to use a strong "intuition" (obtained throuhg learning) for action selection in MCTS, because this leads to more realistic rollouts and therefore also often better evaluations. This cannot be done using a value network (well, it can in the Selection phase / tree traversal of MCTS, but not once a node is reached that hasn't been fully expanded). It is also desirable to terminate rollouts early and backpropagate high-quality evaluations, rather than rolling them out all the way (which takes more time and introduces more variance due to greater likelihood of selecting unrealistic actions along the trajectory). This functionality can only be provided by a value network. Why does AlphaZero use both the value function AND an "upper confidence bound" to guide its search? When the search process starts, when we have not yet run through a large number of MCTS simulations, the evaluations based purely on MCTS itself (which are typically used in the UCB equation) are unreliable. So, initially it is useful to have a strong "intuition" for value estimates, as provided by the value network. As the number of MCTS simulations performed increases (in particular as it tends to infinity, but of course also earlier than that in practice), we expect the MCTS-based evaluations to gradually become more reliable, eventually even potentially becoming more accurate than the learned value network. Note that the value network was trained to provide reasonable value estimates instantly for any game state. The MCTS search process dedicates all of its time just to computing reliable value estimates for the current game state, it is allowed to "specialize" to the current game state. So, as time moves on, we'll want to start relying a bit more on the MCTS-based evaluations, and a bit less on the initial "intuition" from the value network.
Principled understanding of why AlphaZero's algorithm works? First a small note: AlphaGo Zero actually does only use a single network, it no longer has separate value and policy networks like the original AlphaGo did. That single network does still have separat
47,700
Principled understanding of why AlphaZero's algorithm works?
Using a policy network and a value network seems related to the trick that dueling DQNs use. The simplest dueling DQN is a single network that "branches" near the final layers to compute advantage values $A(s,a)$ for each action, as well as value $V(s)$ for the current state. Explicitly separating the advantage for each action from the values for the current state has better training stability, faster convergence and better performance on the Atari benchmark (Dueling Network Architectures for Deep Reinforcement Learning, Wang et al. 2015). This is because it makes explicit the two components of the $Q$ values: $$ Q(s,a) = V(s) + A(s,a) $$ The difference between AlphaZero and a dueling DQN appears to be that instead of using the same network with different branches to approximate $V(s)$ and $A(s,a)$, a distinct value and policy network are used instead. This is just a parallel, but I think it gives a sense of why distinguishing different components of the problem can make learning a complex problem easier.
Principled understanding of why AlphaZero's algorithm works?
Using a policy network and a value network seems related to the trick that dueling DQNs use. The simplest dueling DQN is a single network that "branches" near the final layers to compute advantage val
Principled understanding of why AlphaZero's algorithm works? Using a policy network and a value network seems related to the trick that dueling DQNs use. The simplest dueling DQN is a single network that "branches" near the final layers to compute advantage values $A(s,a)$ for each action, as well as value $V(s)$ for the current state. Explicitly separating the advantage for each action from the values for the current state has better training stability, faster convergence and better performance on the Atari benchmark (Dueling Network Architectures for Deep Reinforcement Learning, Wang et al. 2015). This is because it makes explicit the two components of the $Q$ values: $$ Q(s,a) = V(s) + A(s,a) $$ The difference between AlphaZero and a dueling DQN appears to be that instead of using the same network with different branches to approximate $V(s)$ and $A(s,a)$, a distinct value and policy network are used instead. This is just a parallel, but I think it gives a sense of why distinguishing different components of the problem can make learning a complex problem easier.
Principled understanding of why AlphaZero's algorithm works? Using a policy network and a value network seems related to the trick that dueling DQNs use. The simplest dueling DQN is a single network that "branches" near the final layers to compute advantage val