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
8,901
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$?
Consider what PCA does. Put simply, PCA (as most typically run) creates a new coordinate system by: shifting the origin to the centroid of your data, squeezes and/or stretches the axes to make them equal in length, and rotates your axes into a new orientation. (For more details, see this excellent CV thread: Making sense of principal component analysis, eigenvectors & eigenvalues.) However, it doesn't just rotate your axes any old way. Your new $X_1$ (the first principal component) is oriented in your data's direction of maximal variation. The second principal component is oriented in the direction of the next greatest amount of variation that is orthogonal to the first principal component. The remaining principal components are formed likewise. With this in mind, let's examine @amoeba's example. Here is a data matrix with two points in a three dimensional space: $$ X = \bigg[ \begin{array}{ccc} 1 &1 &1 \\ 2 &2 &2 \end{array} \bigg] $$ Let's view these points in a (pseudo) three dimensional scatterplot: So let's follow the steps listed above. (1) The origin of the new coordinate system will be located at $(1.5, 1.5, 1.5)$. (2) The axes are already equal. (3) The first principal component will go diagonally from $(0,0,0)$ to $(3,3,3)$, which is the direction of greatest variation for these data. Now, the second principal component must be orthogonal to the first, and should go in the direction of the greatest remaining variation. But what direction is that? Is it from $(0,0,3)$ to $(3,3,0)$, or from $(0,3,0)$ to $(3,0,3)$, or something else? There is no remaining variation, so there cannot be any more principal components. With $N=2$ data, we can fit (at most) $N-1 = 1$ principal components.
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$?
Consider what PCA does. Put simply, PCA (as most typically run) creates a new coordinate system by: shifting the origin to the centroid of your data, squeezes and/or stretches the axes to make them
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$? Consider what PCA does. Put simply, PCA (as most typically run) creates a new coordinate system by: shifting the origin to the centroid of your data, squeezes and/or stretches the axes to make them equal in length, and rotates your axes into a new orientation. (For more details, see this excellent CV thread: Making sense of principal component analysis, eigenvectors & eigenvalues.) However, it doesn't just rotate your axes any old way. Your new $X_1$ (the first principal component) is oriented in your data's direction of maximal variation. The second principal component is oriented in the direction of the next greatest amount of variation that is orthogonal to the first principal component. The remaining principal components are formed likewise. With this in mind, let's examine @amoeba's example. Here is a data matrix with two points in a three dimensional space: $$ X = \bigg[ \begin{array}{ccc} 1 &1 &1 \\ 2 &2 &2 \end{array} \bigg] $$ Let's view these points in a (pseudo) three dimensional scatterplot: So let's follow the steps listed above. (1) The origin of the new coordinate system will be located at $(1.5, 1.5, 1.5)$. (2) The axes are already equal. (3) The first principal component will go diagonally from $(0,0,0)$ to $(3,3,3)$, which is the direction of greatest variation for these data. Now, the second principal component must be orthogonal to the first, and should go in the direction of the greatest remaining variation. But what direction is that? Is it from $(0,0,3)$ to $(3,3,0)$, or from $(0,3,0)$ to $(3,0,3)$, or something else? There is no remaining variation, so there cannot be any more principal components. With $N=2$ data, we can fit (at most) $N-1 = 1$ principal components.
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$? Consider what PCA does. Put simply, PCA (as most typically run) creates a new coordinate system by: shifting the origin to the centroid of your data, squeezes and/or stretches the axes to make them
8,902
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$?
Let's say we have a matrix $X=[x_1, x_2, \cdots, x_n]$ , where each $x_i$ is an obervation (sample) from $d$ dimension space, so $X$ is a $d$ by $n$ matrix, and $d > n$. If we first centered the dataset , we have $\sum\limits_{i=1}^n x_i = 0$, which means: $x_1=-\sum\limits_{i=2}^n x_i$, so the column rank of $X \leq n-1$ , then $rank(X)\leq n-1$. We know that $rank(XX^T)=rank(X)\leq n-1$ , so $XX^T$ has at most $n-1$ non-zero eigenvalues.
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$?
Let's say we have a matrix $X=[x_1, x_2, \cdots, x_n]$ , where each $x_i$ is an obervation (sample) from $d$ dimension space, so $X$ is a $d$ by $n$ matrix, and $d > n$. If we first centered the data
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$? Let's say we have a matrix $X=[x_1, x_2, \cdots, x_n]$ , where each $x_i$ is an obervation (sample) from $d$ dimension space, so $X$ is a $d$ by $n$ matrix, and $d > n$. If we first centered the dataset , we have $\sum\limits_{i=1}^n x_i = 0$, which means: $x_1=-\sum\limits_{i=2}^n x_i$, so the column rank of $X \leq n-1$ , then $rank(X)\leq n-1$. We know that $rank(XX^T)=rank(X)\leq n-1$ , so $XX^T$ has at most $n-1$ non-zero eigenvalues.
Why are there only $n-1$ principal components for $n$ data if the number of dimensions is $\ge n$? Let's say we have a matrix $X=[x_1, x_2, \cdots, x_n]$ , where each $x_i$ is an obervation (sample) from $d$ dimension space, so $X$ is a $d$ by $n$ matrix, and $d > n$. If we first centered the data
8,903
Difference between rungs two and three in the Ladder of Causation
There is no contradiction between the factual world and the action of interest in the interventional level. For example, smoking until today and being forced to quit smoking starting tomorrow are not in contradiction with each other, even though you could say one “negates” the other. But now imagine the following scenario. You know Joe, a lifetime smoker who has lung cancer, and you wonder: what if Joe had not smoked for thirty years, would he be healthy today? In this case we are dealing with the same person, in the same time, imagining a scenario where action and outcome are in direct contradiction with known facts. Thus, the main difference of interventions and counterfactuals is that, whereas in interventions you are asking what will happen on average if you perform an action, in counterfactuals you are asking what would have happened had you taken a different course of action in a specific situation, given that you have information about what actually happened. Note that, since you already know what happened in the actual world, you need to update your information about the past in light of the evidence you have observed. These two types of queries are mathematically distinct because they require different levels of information to be answered (counterfactuals need more information to be answered) and even more elaborate language to be articulated!. With the information needed to answer Rung 3 questions you can answer Rung 2 questions, but not the other way around. More precisely, you cannot answer counterfactual questions with just interventional information. Examples where the clash of interventions and counterfactuals happens were already given here in CV, see this post and this post. However, for the sake of completeness, I will include an example here as well. The example below can be found in Causality, section 1.4.4. Consider that you have performed a randomized experiment where patients were randomly assigned (50% / 50%) to treatment ($x =1$) and control conditions ($x=0$), and in both treatment and control groups 50% recovered ($y=0$) and 50% died ($y=1$). That is $P(y|x) = 0.5~~~\forall x,y$. The result of the experiment tells you that the average causal effect of the intervention is zero. This is a rung 2 question, $P(Y = 1|do(X = 1)) - P(Y=1|do(X =0) = 0$. But now let us ask the following question: what percentage of those patients who died under treatment would have recovered had they not taken the treatment? Mathematically, you want to compute $P(Y_{0} = 0|X =1, Y = 1)$. This question cannot be answered just with the interventional data you have. The proof is simple: I can create two different causal models that will have the same interventional distributions, yet different counterfactual distributions. The two are provided below: Here, $U$ amounts to unobserved factors that explain how the patient reacts to the treatment. You can think of factors that explain treatment heterogeneity, for instance. Note the marginal distribution $P(y, x)$ of both models agree. Note that, in the first model, no one is affected by the treatment, thus the percentage of those patients who died under treatment that would have recovered had they not taken the treatment is zero. However, in the second model, every patient is affected by the treatment, and we have a mixture of two populations in which the average causal effect turns out to be zero. In this example, the counterfactual quantity now goes to 100% --- in Model 2, all patients who died under treatment would have recovered had they not taken the treatment. Thus, there's a clear distinction of rung 2 and rung 3. As the example shows, you can't answer counterfactual questions with just information and assumptions about interventions. This is made clear with the three steps for computing a counterfactual: Step 1 (abduction): update the probability of unobserved factors $P(u)$ in light of the observed evidence $P(u|e)$ Step 2 (action): perform the action in the model (for instance $do(x))$. Step 3 (prediction): predict $Y$ in the modified model. This will not be possible to compute without some functional information about the causal model, or without some information about latent variables.
Difference between rungs two and three in the Ladder of Causation
There is no contradiction between the factual world and the action of interest in the interventional level. For example, smoking until today and being forced to quit smoking starting tomorrow are not
Difference between rungs two and three in the Ladder of Causation There is no contradiction between the factual world and the action of interest in the interventional level. For example, smoking until today and being forced to quit smoking starting tomorrow are not in contradiction with each other, even though you could say one “negates” the other. But now imagine the following scenario. You know Joe, a lifetime smoker who has lung cancer, and you wonder: what if Joe had not smoked for thirty years, would he be healthy today? In this case we are dealing with the same person, in the same time, imagining a scenario where action and outcome are in direct contradiction with known facts. Thus, the main difference of interventions and counterfactuals is that, whereas in interventions you are asking what will happen on average if you perform an action, in counterfactuals you are asking what would have happened had you taken a different course of action in a specific situation, given that you have information about what actually happened. Note that, since you already know what happened in the actual world, you need to update your information about the past in light of the evidence you have observed. These two types of queries are mathematically distinct because they require different levels of information to be answered (counterfactuals need more information to be answered) and even more elaborate language to be articulated!. With the information needed to answer Rung 3 questions you can answer Rung 2 questions, but not the other way around. More precisely, you cannot answer counterfactual questions with just interventional information. Examples where the clash of interventions and counterfactuals happens were already given here in CV, see this post and this post. However, for the sake of completeness, I will include an example here as well. The example below can be found in Causality, section 1.4.4. Consider that you have performed a randomized experiment where patients were randomly assigned (50% / 50%) to treatment ($x =1$) and control conditions ($x=0$), and in both treatment and control groups 50% recovered ($y=0$) and 50% died ($y=1$). That is $P(y|x) = 0.5~~~\forall x,y$. The result of the experiment tells you that the average causal effect of the intervention is zero. This is a rung 2 question, $P(Y = 1|do(X = 1)) - P(Y=1|do(X =0) = 0$. But now let us ask the following question: what percentage of those patients who died under treatment would have recovered had they not taken the treatment? Mathematically, you want to compute $P(Y_{0} = 0|X =1, Y = 1)$. This question cannot be answered just with the interventional data you have. The proof is simple: I can create two different causal models that will have the same interventional distributions, yet different counterfactual distributions. The two are provided below: Here, $U$ amounts to unobserved factors that explain how the patient reacts to the treatment. You can think of factors that explain treatment heterogeneity, for instance. Note the marginal distribution $P(y, x)$ of both models agree. Note that, in the first model, no one is affected by the treatment, thus the percentage of those patients who died under treatment that would have recovered had they not taken the treatment is zero. However, in the second model, every patient is affected by the treatment, and we have a mixture of two populations in which the average causal effect turns out to be zero. In this example, the counterfactual quantity now goes to 100% --- in Model 2, all patients who died under treatment would have recovered had they not taken the treatment. Thus, there's a clear distinction of rung 2 and rung 3. As the example shows, you can't answer counterfactual questions with just information and assumptions about interventions. This is made clear with the three steps for computing a counterfactual: Step 1 (abduction): update the probability of unobserved factors $P(u)$ in light of the observed evidence $P(u|e)$ Step 2 (action): perform the action in the model (for instance $do(x))$. Step 3 (prediction): predict $Y$ in the modified model. This will not be possible to compute without some functional information about the causal model, or without some information about latent variables.
Difference between rungs two and three in the Ladder of Causation There is no contradiction between the factual world and the action of interest in the interventional level. For example, smoking until today and being forced to quit smoking starting tomorrow are not
8,904
Difference between rungs two and three in the Ladder of Causation
Here is the answer Judea Pearl gave on twitter: Readers ask: Why is intervention (Rung-2) different from counterfactual (Rung-3)? Doesn't intervening negate some aspects of the observed world? Ans. Interventions change but do not contradict the observed world, because the world before and after the intervention entails time-distinct variables. In contrast, "Had I been dead" contradicts known facts. For a recent discussion, see this discussion. Remark: Both Harvard's #causalinference group and Rubin's potential outcome framework do not distinguish Rung-2 from Rung-3. This, I believe, is a culturally rooted resistance that will be rectified in the future. It stems from the origin of both frameworks in the "as if randomized" metaphor, as opposed to the physical "listening" metaphor of #Bookofwhy
Difference between rungs two and three in the Ladder of Causation
Here is the answer Judea Pearl gave on twitter: Readers ask: Why is intervention (Rung-2) different from counterfactual (Rung-3)? Doesn't intervening negate some aspects of the observed world? Ans. I
Difference between rungs two and three in the Ladder of Causation Here is the answer Judea Pearl gave on twitter: Readers ask: Why is intervention (Rung-2) different from counterfactual (Rung-3)? Doesn't intervening negate some aspects of the observed world? Ans. Interventions change but do not contradict the observed world, because the world before and after the intervention entails time-distinct variables. In contrast, "Had I been dead" contradicts known facts. For a recent discussion, see this discussion. Remark: Both Harvard's #causalinference group and Rubin's potential outcome framework do not distinguish Rung-2 from Rung-3. This, I believe, is a culturally rooted resistance that will be rectified in the future. It stems from the origin of both frameworks in the "as if randomized" metaphor, as opposed to the physical "listening" metaphor of #Bookofwhy
Difference between rungs two and three in the Ladder of Causation Here is the answer Judea Pearl gave on twitter: Readers ask: Why is intervention (Rung-2) different from counterfactual (Rung-3)? Doesn't intervening negate some aspects of the observed world? Ans. I
8,905
Difference between rungs two and three in the Ladder of Causation
Counterfactual questions are also questions about intervening. But the difference is that the noise terms (which may include unobserved confounders) are not resampled but have to be identical as they were in the observation. Counterfactuals are computed in SCMs through the following procedure: Update the noise distribution to its posterior given the observed evidence (“abduction”). Manipulate the structural equations to capture the hypothetical intervention (“action”). Use the modified SCM to infer the quantity of interest (“prediction”). Example 4.11 of this paper explains this intuitively with simple numbers.
Difference between rungs two and three in the Ladder of Causation
Counterfactual questions are also questions about intervening. But the difference is that the noise terms (which may include unobserved confounders) are not resampled but have to be identical as they
Difference between rungs two and three in the Ladder of Causation Counterfactual questions are also questions about intervening. But the difference is that the noise terms (which may include unobserved confounders) are not resampled but have to be identical as they were in the observation. Counterfactuals are computed in SCMs through the following procedure: Update the noise distribution to its posterior given the observed evidence (“abduction”). Manipulate the structural equations to capture the hypothetical intervention (“action”). Use the modified SCM to infer the quantity of interest (“prediction”). Example 4.11 of this paper explains this intuitively with simple numbers.
Difference between rungs two and three in the Ladder of Causation Counterfactual questions are also questions about intervening. But the difference is that the noise terms (which may include unobserved confounders) are not resampled but have to be identical as they
8,906
Difference between rungs two and three in the Ladder of Causation
To add more insight to this question and the other answers: Intervention: We want to answer/predict what will happen to variable $Z$, if we intervene on a variable $X$ in the present. Counterfactual: We want to answer/predict what would happen to variable $Z$, had we intervened on a variable $X$ in the past. But the world has moved on and many other variables of the system have changed. Thus, we can't use intervention in the present to answer such a scenario. Finally, an example to make the difference between intervention (rung 2) and counterfactual (rung 3) clear. Assuming there are 3 variables $X, Y, Z$ with $Z$ being a common effect of $X$ and $Y$ as shown in the graph below: Now, in rung 2 (intervention), if we perform an action/intervention on $X$, the value of $Y$ might change/adapt. However, rung 3 (counterfactual), can be thought of as an imaginary intervention on the graph, whereas all variables that are not affected by the imaginary intervention, here $Y$, have to stay fixed at the levels/values we observed prior to the action. Therefore, the value of $Y$ does not change/adapt.
Difference between rungs two and three in the Ladder of Causation
To add more insight to this question and the other answers: Intervention: We want to answer/predict what will happen to variable $Z$, if we intervene on a variable $X$ in the present. Counterfactual:
Difference between rungs two and three in the Ladder of Causation To add more insight to this question and the other answers: Intervention: We want to answer/predict what will happen to variable $Z$, if we intervene on a variable $X$ in the present. Counterfactual: We want to answer/predict what would happen to variable $Z$, had we intervened on a variable $X$ in the past. But the world has moved on and many other variables of the system have changed. Thus, we can't use intervention in the present to answer such a scenario. Finally, an example to make the difference between intervention (rung 2) and counterfactual (rung 3) clear. Assuming there are 3 variables $X, Y, Z$ with $Z$ being a common effect of $X$ and $Y$ as shown in the graph below: Now, in rung 2 (intervention), if we perform an action/intervention on $X$, the value of $Y$ might change/adapt. However, rung 3 (counterfactual), can be thought of as an imaginary intervention on the graph, whereas all variables that are not affected by the imaginary intervention, here $Y$, have to stay fixed at the levels/values we observed prior to the action. Therefore, the value of $Y$ does not change/adapt.
Difference between rungs two and three in the Ladder of Causation To add more insight to this question and the other answers: Intervention: We want to answer/predict what will happen to variable $Z$, if we intervene on a variable $X$ in the present. Counterfactual:
8,907
Why are probability distributions denoted with a tilde?
The ~ (tilde) used in that way means "is distributed as". Why? To ask why doesn't make much sense to me, its just a convention. To cite Brian Ripley: Mathematical conventions are just that, conventions. They differ by field of mathematics. Don't ask us why matrix rows are numbered down but graphs are numbered up the y axis, nor why x comes before y but row before column. But the matrix layout has always seemed illogical to me. -- Brian D. Ripley (answering a question why print(x) and image(x) are layouted differently) R-help (August 2004)
Why are probability distributions denoted with a tilde?
The ~ (tilde) used in that way means "is distributed as". Why? To ask why doesn't make much sense to me, its just a convention. To cite Brian Ripley: Mathematical conventions are just that, conventio
Why are probability distributions denoted with a tilde? The ~ (tilde) used in that way means "is distributed as". Why? To ask why doesn't make much sense to me, its just a convention. To cite Brian Ripley: Mathematical conventions are just that, conventions. They differ by field of mathematics. Don't ask us why matrix rows are numbered down but graphs are numbered up the y axis, nor why x comes before y but row before column. But the matrix layout has always seemed illogical to me. -- Brian D. Ripley (answering a question why print(x) and image(x) are layouted differently) R-help (August 2004)
Why are probability distributions denoted with a tilde? The ~ (tilde) used in that way means "is distributed as". Why? To ask why doesn't make much sense to me, its just a convention. To cite Brian Ripley: Mathematical conventions are just that, conventio
8,908
Why are probability distributions denoted with a tilde?
I can't comment on the history, but I believe it might be the following. The ~ symbol is commonly used in mathematics to denote an equivalence relation. In the context of probability theory it is used to denote equivalance in (marginal) distribution. So when we say, Z ~ N(0,1), what we mean is that the random variable Z has the same marginal distribution as the random variable N(0,1). (The latter being a standard normal random variable, by definition.) This interpretation requires that you interpret the right-hand-side of the equation as referring to a random variable, not a distribution function. Under this interpretation, the ~ sign means "has the same distribution as". Since this is reflexive, symmetric and transitive, it is an equivalence relation.
Why are probability distributions denoted with a tilde?
I can't comment on the history, but I believe it might be the following. The ~ symbol is commonly used in mathematics to denote an equivalence relation. In the context of probability theory it is us
Why are probability distributions denoted with a tilde? I can't comment on the history, but I believe it might be the following. The ~ symbol is commonly used in mathematics to denote an equivalence relation. In the context of probability theory it is used to denote equivalance in (marginal) distribution. So when we say, Z ~ N(0,1), what we mean is that the random variable Z has the same marginal distribution as the random variable N(0,1). (The latter being a standard normal random variable, by definition.) This interpretation requires that you interpret the right-hand-side of the equation as referring to a random variable, not a distribution function. Under this interpretation, the ~ sign means "has the same distribution as". Since this is reflexive, symmetric and transitive, it is an equivalence relation.
Why are probability distributions denoted with a tilde? I can't comment on the history, but I believe it might be the following. The ~ symbol is commonly used in mathematics to denote an equivalence relation. In the context of probability theory it is us
8,909
Why would anyone use KNN for regression?
Local methods like K-NN make sense in some situations. One example that I did in school work had to do with predicting the compressive strength of various mixtures of cement ingredients. All of these ingredients were relatively non-volatile with respect to the response or each other and KNN made reliable predictions on it. In other words none of the independent variables had disproportionately large variance to confer to the model either individually or possibly by mutual interaction. Take this with a grain of salt because I don't know of a data investigation technique that conclusively shows this but intuitively it seems reasonable that if your features have some proportionate degree of variances, I don't know what proportion, you might have a KNN candidate. I'd certainly like to know if there were some studies and resulting techniques developed to this effect. If you think about it from a generalized domain perspective there is a broad class of applications where similar 'recipes' yield similar outcomes. This certainly seemed to describe the situation of predicting outcomes of mixing cement. I would say if you had data that behaved according to this description and in addition your distance measure was also natural to the domain at hand and lastly that you had sufficient data, I would imagine that you should get useful results from KNN or another local method. You are also getting the benefit of extremely low bias when you use local methods. Sometimes generalized additive models (GAM) balance bias and variance by fitting each individual variable using KNN such that: $$\hat{y}=f_1(x_1) + f_2(x_2) + \dots + f_n(x_n) + \epsilon$$ The additive portion (the plus symbols) protect against high variance while the use of KNN in place of $f_n(x_n)$ protects against high bias. I wouldn't write off KNN so quickly. It has its place.
Why would anyone use KNN for regression?
Local methods like K-NN make sense in some situations. One example that I did in school work had to do with predicting the compressive strength of various mixtures of cement ingredients. All of these
Why would anyone use KNN for regression? Local methods like K-NN make sense in some situations. One example that I did in school work had to do with predicting the compressive strength of various mixtures of cement ingredients. All of these ingredients were relatively non-volatile with respect to the response or each other and KNN made reliable predictions on it. In other words none of the independent variables had disproportionately large variance to confer to the model either individually or possibly by mutual interaction. Take this with a grain of salt because I don't know of a data investigation technique that conclusively shows this but intuitively it seems reasonable that if your features have some proportionate degree of variances, I don't know what proportion, you might have a KNN candidate. I'd certainly like to know if there were some studies and resulting techniques developed to this effect. If you think about it from a generalized domain perspective there is a broad class of applications where similar 'recipes' yield similar outcomes. This certainly seemed to describe the situation of predicting outcomes of mixing cement. I would say if you had data that behaved according to this description and in addition your distance measure was also natural to the domain at hand and lastly that you had sufficient data, I would imagine that you should get useful results from KNN or another local method. You are also getting the benefit of extremely low bias when you use local methods. Sometimes generalized additive models (GAM) balance bias and variance by fitting each individual variable using KNN such that: $$\hat{y}=f_1(x_1) + f_2(x_2) + \dots + f_n(x_n) + \epsilon$$ The additive portion (the plus symbols) protect against high variance while the use of KNN in place of $f_n(x_n)$ protects against high bias. I wouldn't write off KNN so quickly. It has its place.
Why would anyone use KNN for regression? Local methods like K-NN make sense in some situations. One example that I did in school work had to do with predicting the compressive strength of various mixtures of cement ingredients. All of these
8,910
Why would anyone use KNN for regression?
I don't like to say it but actually the short answer is, that "predicting into the future" is not really possible not with a knn nor with any other currently existing classifier or regressor. Sure you can extrapolate the line of a linear regression or the hyper plane of an SVM but in the end you don't know what the future will be, for all we know, the line might just be a small part of a curvy reality. This becomes apparent when you look at Bayesian methods like Gaussian processes for instance, you will notice a big uncertainty in the predictive distribution, as soon as you leave the "known input domain". Of course you can try to generalize from what happened today to what likely happens tomorrow, which can easily be done with a knn regressor (e.g. last year's customer numbers during Christmas time can give you a good hint about this year's numbers). Sure other methods may incorporate trends and so on but in the end you can see how well that works when it comes to the stock market or long-term weather predictions.
Why would anyone use KNN for regression?
I don't like to say it but actually the short answer is, that "predicting into the future" is not really possible not with a knn nor with any other currently existing classifier or regressor. Sure yo
Why would anyone use KNN for regression? I don't like to say it but actually the short answer is, that "predicting into the future" is not really possible not with a knn nor with any other currently existing classifier or regressor. Sure you can extrapolate the line of a linear regression or the hyper plane of an SVM but in the end you don't know what the future will be, for all we know, the line might just be a small part of a curvy reality. This becomes apparent when you look at Bayesian methods like Gaussian processes for instance, you will notice a big uncertainty in the predictive distribution, as soon as you leave the "known input domain". Of course you can try to generalize from what happened today to what likely happens tomorrow, which can easily be done with a knn regressor (e.g. last year's customer numbers during Christmas time can give you a good hint about this year's numbers). Sure other methods may incorporate trends and so on but in the end you can see how well that works when it comes to the stock market or long-term weather predictions.
Why would anyone use KNN for regression? I don't like to say it but actually the short answer is, that "predicting into the future" is not really possible not with a knn nor with any other currently existing classifier or regressor. Sure yo
8,911
Why would anyone use KNN for regression?
First an example for "How would I predict into the future using a KNN regressor ?". Problem: predict hours of sunlight tomorrow $sun_{t+1}$ from $sun_t .. sun_{t-6}$ over the last week. Training data: $sun_t$ (in one city) over the last 10 years, 3650 numbers. Denote $week_t \equiv sun_t .. sun_{t-6}$ and $tomorrow( week_t )) \equiv sun_{t+1} $ . Method: put the 3650-odd $week_t$ curves in a k-d tree with k=7. Given a new $week$, look up its say 10 nearest-neighbor weeks with their $tomorrow_0 .. tomorrow_9$ and calculate $\qquad predict( week ) \equiv $ weighted average of $tomorrow_0 .. tomorrow_9$ Tune the weights, see e.g. inverse-distance-weighted-idw-interpolation-with-python, and the distance metric for "Nearest neighbor" in 7d. "What are the advantages of using a KNN regressor ?" To others' good comments I'd add easy to code and understand, and scales up to big data. Disadvantages: sensitive to data and tuning, not much understanding. (Longish footnote on terminology: "regression" is used as a fancy word for "fitting a model to data". Most common is fitting data $X$ to a target $Y$ with a linear model: $\qquad Y_t = b_0 X_t + b_1 X_{t-1} + ... $ Also common is predicting tomorrow's say stock price $Y_{t+1}$ from prices over the last week or year: $\qquad Y_{t+1} = a_0 Y_t + a_1 Y_{t-1} + ... $ Forecasters call this an ARMA, Autoregressive moving-average_model or Autoregressive model . See also Regression analysis . So your first line "we can only build a regression function that lies within the interval of the training data" seems to be about the confusing word "regression".)
Why would anyone use KNN for regression?
First an example for "How would I predict into the future using a KNN regressor ?". Problem: predict hours of sunlight tomorrow $sun_{t+1}$ from $sun_t .. sun_{t-6}$ over the last week. Training data:
Why would anyone use KNN for regression? First an example for "How would I predict into the future using a KNN regressor ?". Problem: predict hours of sunlight tomorrow $sun_{t+1}$ from $sun_t .. sun_{t-6}$ over the last week. Training data: $sun_t$ (in one city) over the last 10 years, 3650 numbers. Denote $week_t \equiv sun_t .. sun_{t-6}$ and $tomorrow( week_t )) \equiv sun_{t+1} $ . Method: put the 3650-odd $week_t$ curves in a k-d tree with k=7. Given a new $week$, look up its say 10 nearest-neighbor weeks with their $tomorrow_0 .. tomorrow_9$ and calculate $\qquad predict( week ) \equiv $ weighted average of $tomorrow_0 .. tomorrow_9$ Tune the weights, see e.g. inverse-distance-weighted-idw-interpolation-with-python, and the distance metric for "Nearest neighbor" in 7d. "What are the advantages of using a KNN regressor ?" To others' good comments I'd add easy to code and understand, and scales up to big data. Disadvantages: sensitive to data and tuning, not much understanding. (Longish footnote on terminology: "regression" is used as a fancy word for "fitting a model to data". Most common is fitting data $X$ to a target $Y$ with a linear model: $\qquad Y_t = b_0 X_t + b_1 X_{t-1} + ... $ Also common is predicting tomorrow's say stock price $Y_{t+1}$ from prices over the last week or year: $\qquad Y_{t+1} = a_0 Y_t + a_1 Y_{t-1} + ... $ Forecasters call this an ARMA, Autoregressive moving-average_model or Autoregressive model . See also Regression analysis . So your first line "we can only build a regression function that lies within the interval of the training data" seems to be about the confusing word "regression".)
Why would anyone use KNN for regression? First an example for "How would I predict into the future using a KNN regressor ?". Problem: predict hours of sunlight tomorrow $sun_{t+1}$ from $sun_t .. sun_{t-6}$ over the last week. Training data:
8,912
Why would anyone use KNN for regression?
From An Introduction to Statistical Learning, section 3.5: In a real-life situation in which the true relationship is unknown, one might draw the conclusion that KNN should be favored over linear regression because it will at worst be slightly inferior than linear regression if the true relationship is linear, and may give substantially better results if the true relationship is non-linear. But there are constraints (not from the textbook, just what I concluded): a sufficient number of observations per predictor. the number of predictors should not be too big.
Why would anyone use KNN for regression?
From An Introduction to Statistical Learning, section 3.5: In a real-life situation in which the true relationship is unknown, one might draw the conclusion that KNN should be favored over linear r
Why would anyone use KNN for regression? From An Introduction to Statistical Learning, section 3.5: In a real-life situation in which the true relationship is unknown, one might draw the conclusion that KNN should be favored over linear regression because it will at worst be slightly inferior than linear regression if the true relationship is linear, and may give substantially better results if the true relationship is non-linear. But there are constraints (not from the textbook, just what I concluded): a sufficient number of observations per predictor. the number of predictors should not be too big.
Why would anyone use KNN for regression? From An Introduction to Statistical Learning, section 3.5: In a real-life situation in which the true relationship is unknown, one might draw the conclusion that KNN should be favored over linear r
8,913
Why would anyone use KNN for regression?
Hangyu Tian makes a great point that k-NN regression will not do well when there isn't enough data and method like linear regression that make stronger assumptions may outperform k-NN. However, the amazing thing about k-NN is that you can encode all sorts of interesting assumptions by using different weights. For example, if you normalize the data and then use $k(x, x')=x \cdot x'$ as the weight between $x$ and $x'$ for all $x, x'$ in your data, that will actually approximate good old fashioned linear regression! Of course, it would be unnecessarily slow compared to other methods for linear regression but the point is that you actually have a lot of flexibility. For reference this is called the linear kernel. I played around with the notebook that generated the photos you attached. I don't see much reason to do k-NN regression with uniform or distance weights as that example shows. So I changed it to use RBF weights. This means that it will be like scipy.interpolate.Rbf except that we are only looking at the nearest neighbors. Obviously looking at k nearest neighbors doesn't improve accuracy but it can be essential for performance when you have a large dataset. I also upped the number of neighbors to 10. Also, I think you should be comparing to the true function rather than the noisy data. Our goal here is to approximate the true function and ignore all that noise. Also, to have a baseline I compared to CubicSpline. I also am using 80 examples rather than just 40. I played around with different axis bound on the time axis because that affects the density which is an important factor for the performance of any k-NN method. The k-NN interpolation works pretty well even as I change the bounds on the axis. It usually gets close to the original function than the original data was. So I that this particular example just needed a bit of work done on it. Anyways, the reason in general for using k-NN anything is that it's faster than looking at the entire dataset. So k-NN based regression will be more scalable than a Gaussian process. It is also just very simple, intuitive and predictable. You can see in the attached picture that cubic spline is showing some strange behavior in certain areas. Neural networks are also relatively unpredictable. Another huge difference between k-NN interpolation and methods like cubic spline is that k-NN interpolation doesn't try to fit the data perfectly because we know the data is noisy. We can also see that k-NN gets better with more data. Meanwhile cubic spline gets starts acting crazy and gaussian processes start getting too slow. Here we use twice the amount of data. I think the moral of the story is that k-NN can do very different things depending on how you define your distances and weights. Actually, you could even use k-NN with polynomial kernel to interpolate polynomials as we did with cubic spline. Or since the underlying function here is sin it would make the most sense to use the periodic kernel. For more info see the kernel cookbook https://www.cs.toronto.edu/~duvenaud/cookbook/
Why would anyone use KNN for regression?
Hangyu Tian makes a great point that k-NN regression will not do well when there isn't enough data and method like linear regression that make stronger assumptions may outperform k-NN. However, the am
Why would anyone use KNN for regression? Hangyu Tian makes a great point that k-NN regression will not do well when there isn't enough data and method like linear regression that make stronger assumptions may outperform k-NN. However, the amazing thing about k-NN is that you can encode all sorts of interesting assumptions by using different weights. For example, if you normalize the data and then use $k(x, x')=x \cdot x'$ as the weight between $x$ and $x'$ for all $x, x'$ in your data, that will actually approximate good old fashioned linear regression! Of course, it would be unnecessarily slow compared to other methods for linear regression but the point is that you actually have a lot of flexibility. For reference this is called the linear kernel. I played around with the notebook that generated the photos you attached. I don't see much reason to do k-NN regression with uniform or distance weights as that example shows. So I changed it to use RBF weights. This means that it will be like scipy.interpolate.Rbf except that we are only looking at the nearest neighbors. Obviously looking at k nearest neighbors doesn't improve accuracy but it can be essential for performance when you have a large dataset. I also upped the number of neighbors to 10. Also, I think you should be comparing to the true function rather than the noisy data. Our goal here is to approximate the true function and ignore all that noise. Also, to have a baseline I compared to CubicSpline. I also am using 80 examples rather than just 40. I played around with different axis bound on the time axis because that affects the density which is an important factor for the performance of any k-NN method. The k-NN interpolation works pretty well even as I change the bounds on the axis. It usually gets close to the original function than the original data was. So I that this particular example just needed a bit of work done on it. Anyways, the reason in general for using k-NN anything is that it's faster than looking at the entire dataset. So k-NN based regression will be more scalable than a Gaussian process. It is also just very simple, intuitive and predictable. You can see in the attached picture that cubic spline is showing some strange behavior in certain areas. Neural networks are also relatively unpredictable. Another huge difference between k-NN interpolation and methods like cubic spline is that k-NN interpolation doesn't try to fit the data perfectly because we know the data is noisy. We can also see that k-NN gets better with more data. Meanwhile cubic spline gets starts acting crazy and gaussian processes start getting too slow. Here we use twice the amount of data. I think the moral of the story is that k-NN can do very different things depending on how you define your distances and weights. Actually, you could even use k-NN with polynomial kernel to interpolate polynomials as we did with cubic spline. Or since the underlying function here is sin it would make the most sense to use the periodic kernel. For more info see the kernel cookbook https://www.cs.toronto.edu/~duvenaud/cookbook/
Why would anyone use KNN for regression? Hangyu Tian makes a great point that k-NN regression will not do well when there isn't enough data and method like linear regression that make stronger assumptions may outperform k-NN. However, the am
8,914
What is the loss function of hard margin SVM?
The hinge loss term $\sum_i\max(0,1-y_i(\mathbf{w}^\intercal \mathbf{x}_i+b))$ in soft margin SVM penalizes misclassifications. In hard margin SVM there are, by definition, no misclassifications. This indeed means that hard margin SVM tries to minimize $\|\mathbf{w}\|^2$. Due to the formulation of the SVM problem, the margin is $2/\|\mathbf{w}\|$. As such, minimizing the norm of $\mathbf{w}$ is geometrically equivalent to maximizing the margin. Exactly what we want! Regularization is a technique to avoid overfitting by penalizing large coefficients in the solution vector. In hard margin SVM $\|\mathbf{w}\|^2$ is both the loss function and an $L_2$ regularizer. In soft-margin SVM, the hinge loss term also acts like a regularizer but on the slack variables instead of $\mathbf{w}$ and in $L_1$ rather than $L_2$. $L_1$ regularization induces sparsity, which is why standard SVM is sparse in terms of support vectors (in contrast to least-squares SVM).
What is the loss function of hard margin SVM?
The hinge loss term $\sum_i\max(0,1-y_i(\mathbf{w}^\intercal \mathbf{x}_i+b))$ in soft margin SVM penalizes misclassifications. In hard margin SVM there are, by definition, no misclassifications. This
What is the loss function of hard margin SVM? The hinge loss term $\sum_i\max(0,1-y_i(\mathbf{w}^\intercal \mathbf{x}_i+b))$ in soft margin SVM penalizes misclassifications. In hard margin SVM there are, by definition, no misclassifications. This indeed means that hard margin SVM tries to minimize $\|\mathbf{w}\|^2$. Due to the formulation of the SVM problem, the margin is $2/\|\mathbf{w}\|$. As such, minimizing the norm of $\mathbf{w}$ is geometrically equivalent to maximizing the margin. Exactly what we want! Regularization is a technique to avoid overfitting by penalizing large coefficients in the solution vector. In hard margin SVM $\|\mathbf{w}\|^2$ is both the loss function and an $L_2$ regularizer. In soft-margin SVM, the hinge loss term also acts like a regularizer but on the slack variables instead of $\mathbf{w}$ and in $L_1$ rather than $L_2$. $L_1$ regularization induces sparsity, which is why standard SVM is sparse in terms of support vectors (in contrast to least-squares SVM).
What is the loss function of hard margin SVM? The hinge loss term $\sum_i\max(0,1-y_i(\mathbf{w}^\intercal \mathbf{x}_i+b))$ in soft margin SVM penalizes misclassifications. In hard margin SVM there are, by definition, no misclassifications. This
8,915
What is the loss function of hard margin SVM?
There's no "loss function" for hard-margin SVMs, but when we're solving soft-margin SVMs, it turns out the loss exists. Now is the detailed explanation: When we talk about loss function, what we really mean is a training objective that we want to minimize. In hard-margin SVM setting, the "objective" is to maximize the geometric margin s.t each training example lies outside the separating hyperplane, i.e. $$\begin{aligned} & \max_{\gamma, w, b}\frac{1}{\Vert w \Vert} \\ &s.t\quad y(w^Tx+b) \ge 1 \end{aligned} $$ Note that this is a quadratic programming problem, so we cannot solve it numerically using direct gradient descent approach, that is, there is no analytic "loss function" for hard-margin SVMs. However, in soft-margin SVM setting, we add a slack variable to allow our SVM to made mistakes. We now try to solve $$\begin{aligned} & \min_{w,b,\boldsymbol{\xi}}\frac{1}{2}\Vert w \Vert_2^2 + C\sum \xi_i \\ s.t\quad &y_i(w^Tx_i+b) \ge 1-\xi_i \\ & \boldsymbol{\xi} \succeq \mathbf{0} \end{aligned} $$ This is the same as we try to penalize the misclassified training example $x_i$ by adding $C\xi_i$ to our objective to be minimized. Recall hinge loss: $$ \ell_{\mbox{hinge}}(z) = \max\{0, 1-z\}, $$ since if the training example lies outside the margin $\xi_i$ will be zero and it will only be nonzero when training example falls into margin region, and since hinge loss is always nonnegative, it happens we can rephrase our problem as $$ \min \frac{1}{2}\Vert w \Vert_2^2 + C\sum\ell_{\mbox{hinge}}(y_i(w^Tx_i)). $$ We know that hinge loss is convex and its derivative is known, thus we can solve for soft-margin SVM directly by gradient descent. So the slack variable is just hinge loss in disguise, and the property of hinge loss happens to wrap up our optimization constraints (i.e. nonnegativity and activates input when it's less than 1).
What is the loss function of hard margin SVM?
There's no "loss function" for hard-margin SVMs, but when we're solving soft-margin SVMs, it turns out the loss exists. Now is the detailed explanation: When we talk about loss function, what we reall
What is the loss function of hard margin SVM? There's no "loss function" for hard-margin SVMs, but when we're solving soft-margin SVMs, it turns out the loss exists. Now is the detailed explanation: When we talk about loss function, what we really mean is a training objective that we want to minimize. In hard-margin SVM setting, the "objective" is to maximize the geometric margin s.t each training example lies outside the separating hyperplane, i.e. $$\begin{aligned} & \max_{\gamma, w, b}\frac{1}{\Vert w \Vert} \\ &s.t\quad y(w^Tx+b) \ge 1 \end{aligned} $$ Note that this is a quadratic programming problem, so we cannot solve it numerically using direct gradient descent approach, that is, there is no analytic "loss function" for hard-margin SVMs. However, in soft-margin SVM setting, we add a slack variable to allow our SVM to made mistakes. We now try to solve $$\begin{aligned} & \min_{w,b,\boldsymbol{\xi}}\frac{1}{2}\Vert w \Vert_2^2 + C\sum \xi_i \\ s.t\quad &y_i(w^Tx_i+b) \ge 1-\xi_i \\ & \boldsymbol{\xi} \succeq \mathbf{0} \end{aligned} $$ This is the same as we try to penalize the misclassified training example $x_i$ by adding $C\xi_i$ to our objective to be minimized. Recall hinge loss: $$ \ell_{\mbox{hinge}}(z) = \max\{0, 1-z\}, $$ since if the training example lies outside the margin $\xi_i$ will be zero and it will only be nonzero when training example falls into margin region, and since hinge loss is always nonnegative, it happens we can rephrase our problem as $$ \min \frac{1}{2}\Vert w \Vert_2^2 + C\sum\ell_{\mbox{hinge}}(y_i(w^Tx_i)). $$ We know that hinge loss is convex and its derivative is known, thus we can solve for soft-margin SVM directly by gradient descent. So the slack variable is just hinge loss in disguise, and the property of hinge loss happens to wrap up our optimization constraints (i.e. nonnegativity and activates input when it's less than 1).
What is the loss function of hard margin SVM? There's no "loss function" for hard-margin SVMs, but when we're solving soft-margin SVMs, it turns out the loss exists. Now is the detailed explanation: When we talk about loss function, what we reall
8,916
What is the loss function of hard margin SVM?
Just to clarify, $$ \frac{1}{2}\|w\|^2 $$ is minimized subject to the constraint that the points are linearly separable (I.e. one can draw a hyperplane that perfectly separates the two). In other words, the only allowed values of w that we can consider as solutions are those that separate the two sets of points. Now, it is thought that hard margin SVM "overfits" more readily than soft margin. This is easier to imagine with a RBF SVM with high enough of a $\gamma$, which can create (overly) complicated and (potentially) over-fit decision boundaries. The harder the margin (emulated imprecisely with a higher "C"), the harder the search will try to find decision boundaries that perfectly classify the two sets of points. When we move to "soft margin", the constraints are relaxed and replaced with a restraint through the introduction of "slack". This slack variable is defined with a "hinge loss" term. After simplification, one arrives at the hinge + l2 like loss term everyone associates with SVMs. FWIW, I like to frame SVMs as more of an optimization problem instead of the omnipresent "follow the gradients" problem.
What is the loss function of hard margin SVM?
Just to clarify, $$ \frac{1}{2}\|w\|^2 $$ is minimized subject to the constraint that the points are linearly separable (I.e. one can draw a hyperplane that perfectly separates the two). In other wo
What is the loss function of hard margin SVM? Just to clarify, $$ \frac{1}{2}\|w\|^2 $$ is minimized subject to the constraint that the points are linearly separable (I.e. one can draw a hyperplane that perfectly separates the two). In other words, the only allowed values of w that we can consider as solutions are those that separate the two sets of points. Now, it is thought that hard margin SVM "overfits" more readily than soft margin. This is easier to imagine with a RBF SVM with high enough of a $\gamma$, which can create (overly) complicated and (potentially) over-fit decision boundaries. The harder the margin (emulated imprecisely with a higher "C"), the harder the search will try to find decision boundaries that perfectly classify the two sets of points. When we move to "soft margin", the constraints are relaxed and replaced with a restraint through the introduction of "slack". This slack variable is defined with a "hinge loss" term. After simplification, one arrives at the hinge + l2 like loss term everyone associates with SVMs. FWIW, I like to frame SVMs as more of an optimization problem instead of the omnipresent "follow the gradients" problem.
What is the loss function of hard margin SVM? Just to clarify, $$ \frac{1}{2}\|w\|^2 $$ is minimized subject to the constraint that the points are linearly separable (I.e. one can draw a hyperplane that perfectly separates the two). In other wo
8,917
For which distributions are the parameterizations in BUGS and R different?
I don't know of a canned list. update: this list (plus additional information) is now published as Translating Probability Density Functions: From R to BUGS and Back Again (2013), DS LeBauer, MC Dietze, BM Bolker R Journal 5 (1), 207-209. Here is my list (edits provided by original questioner): Normal and log-normal are parameterized in terms of $\tau$ (precision) rather than $\sigma$ or $\sigma^2$ (std. dev. or variance); $\tau = 1/\sigma^2 = 1/\mbox{var}$ Beta, Poisson, Exponential, Uniform are all the same Negative binomial in BUGS has only the discrete parameterization (size,prob), not the "ecological" (size,mu, where size can be non-integer) parameterization. edit: Weibull in BUGS is ($\nu$=shape,$\lambda$=lambda), in R is ($a$=shape,$b$=scale) [the math notation is consistent with the notation used in the respective documentation] As pointed out at How do I parameterize a Weibull distribution in JAGS / BUGS? , $\lambda= (1/b)^a$ Gamma in BUGS is (shape,rate). This is the default in R, but R also allows (shape,scale) [if the scale argument is named]; rate = 1/scale Order matters, especially in BUGS (which doesn't have named arguments), e.g. R dbinom(x,size,prob) vs BUGS dbin(p,n) [same parameters, opposite order]. Name differences: Binomial: R=dbinom,BUGS=dbin Chi-squared: R=dchisq,BUGS=dchisqr Weibull: R=dweibull,BUGS=dweib Negative binomial: R=dnbinom, BUGS=dnegbin edit: for truncated distributions BUGS uses I(), JAGS uses dinterval() [it's worth looking in the JAGS documentation if you're going to use this, there may be other subtle differences]
For which distributions are the parameterizations in BUGS and R different?
I don't know of a canned list. update: this list (plus additional information) is now published as Translating Probability Density Functions: From R to BUGS and Back Again (2013), DS LeBauer, MC Diet
For which distributions are the parameterizations in BUGS and R different? I don't know of a canned list. update: this list (plus additional information) is now published as Translating Probability Density Functions: From R to BUGS and Back Again (2013), DS LeBauer, MC Dietze, BM Bolker R Journal 5 (1), 207-209. Here is my list (edits provided by original questioner): Normal and log-normal are parameterized in terms of $\tau$ (precision) rather than $\sigma$ or $\sigma^2$ (std. dev. or variance); $\tau = 1/\sigma^2 = 1/\mbox{var}$ Beta, Poisson, Exponential, Uniform are all the same Negative binomial in BUGS has only the discrete parameterization (size,prob), not the "ecological" (size,mu, where size can be non-integer) parameterization. edit: Weibull in BUGS is ($\nu$=shape,$\lambda$=lambda), in R is ($a$=shape,$b$=scale) [the math notation is consistent with the notation used in the respective documentation] As pointed out at How do I parameterize a Weibull distribution in JAGS / BUGS? , $\lambda= (1/b)^a$ Gamma in BUGS is (shape,rate). This is the default in R, but R also allows (shape,scale) [if the scale argument is named]; rate = 1/scale Order matters, especially in BUGS (which doesn't have named arguments), e.g. R dbinom(x,size,prob) vs BUGS dbin(p,n) [same parameters, opposite order]. Name differences: Binomial: R=dbinom,BUGS=dbin Chi-squared: R=dchisq,BUGS=dchisqr Weibull: R=dweibull,BUGS=dweib Negative binomial: R=dnbinom, BUGS=dnegbin edit: for truncated distributions BUGS uses I(), JAGS uses dinterval() [it's worth looking in the JAGS documentation if you're going to use this, there may be other subtle differences]
For which distributions are the parameterizations in BUGS and R different? I don't know of a canned list. update: this list (plus additional information) is now published as Translating Probability Density Functions: From R to BUGS and Back Again (2013), DS LeBauer, MC Diet
8,918
2D analog of standard deviation?
One thing you could use is a distance measure from a central point, ${\bf c}=(c_{1},c_{2})$, such as the sample mean of the points $(\overline{x}, \overline{y})$, or perhaps the centroid of the observed points. Then a measure of dispersion would be the average distance from that central point: $$ \frac{1}{n} \sum_{i=1}^{n} || {\bf z}_{i} - {\bf c} || $$ where ${\bf z}_{i} = \{ x_{i}, y_{i} \}$. There are many potential choices for a distance measure but the $L_{2}$ norm (e.g. euclidean distance) may be a reasonable choice: $$ || {\bf z}_{i} - {\bf c} || = \sqrt{ (x_{i}-c_{1})^{2} + (y_{i}-c_{2})^{2} } $$ There are lots of other potential choices, though. See http://en.wikipedia.org/wiki/Norm_%28mathematics%29
2D analog of standard deviation?
One thing you could use is a distance measure from a central point, ${\bf c}=(c_{1},c_{2})$, such as the sample mean of the points $(\overline{x}, \overline{y})$, or perhaps the centroid of the observ
2D analog of standard deviation? One thing you could use is a distance measure from a central point, ${\bf c}=(c_{1},c_{2})$, such as the sample mean of the points $(\overline{x}, \overline{y})$, or perhaps the centroid of the observed points. Then a measure of dispersion would be the average distance from that central point: $$ \frac{1}{n} \sum_{i=1}^{n} || {\bf z}_{i} - {\bf c} || $$ where ${\bf z}_{i} = \{ x_{i}, y_{i} \}$. There are many potential choices for a distance measure but the $L_{2}$ norm (e.g. euclidean distance) may be a reasonable choice: $$ || {\bf z}_{i} - {\bf c} || = \sqrt{ (x_{i}-c_{1})^{2} + (y_{i}-c_{2})^{2} } $$ There are lots of other potential choices, though. See http://en.wikipedia.org/wiki/Norm_%28mathematics%29
2D analog of standard deviation? One thing you could use is a distance measure from a central point, ${\bf c}=(c_{1},c_{2})$, such as the sample mean of the points $(\overline{x}, \overline{y})$, or perhaps the centroid of the observ
8,919
2D analog of standard deviation?
A good reference on metrics for the spatial distribution of point patterns is the CrimeStat manual (in particular for this question, Chapter 4 will be of interest). Similar to the metric Macro suggested, the Standard Distance Deviation is similar to a 2D standard deviation (the only difference is that you would divide by "n-2" not "n" in the first formula Macro gave). Your example experiment actually reminds me a bit of how studies evaluate Geographic Offender Profiling, and hence the metrics used in those works may be of interest. In particular the terms precision and accuracy are used quite a bit and would be pertinent to the study. Guesses could have a small standard deviation (i.e. precise) but still have a very low accuracy.
2D analog of standard deviation?
A good reference on metrics for the spatial distribution of point patterns is the CrimeStat manual (in particular for this question, Chapter 4 will be of interest). Similar to the metric Macro suggest
2D analog of standard deviation? A good reference on metrics for the spatial distribution of point patterns is the CrimeStat manual (in particular for this question, Chapter 4 will be of interest). Similar to the metric Macro suggested, the Standard Distance Deviation is similar to a 2D standard deviation (the only difference is that you would divide by "n-2" not "n" in the first formula Macro gave). Your example experiment actually reminds me a bit of how studies evaluate Geographic Offender Profiling, and hence the metrics used in those works may be of interest. In particular the terms precision and accuracy are used quite a bit and would be pertinent to the study. Guesses could have a small standard deviation (i.e. precise) but still have a very low accuracy.
2D analog of standard deviation? A good reference on metrics for the spatial distribution of point patterns is the CrimeStat manual (in particular for this question, Chapter 4 will be of interest). Similar to the metric Macro suggest
8,920
2D analog of standard deviation?
I actually ran into a similar problem recently. It sounds like you want a way to measure how well the points are scattered area-wise. Of course, for a given measurement, you’d have to realize that if all the points are in a straight line, the answer is zero, since there’s no 2 dimensional variety. From the calculations I did, this is what I came up with: $$ \sqrt{S_{xx}S_{yy}-S_{xy}²} $$ In this case, Sxx and Syy are the variances of x and of y respectively, whereas Sxy is kinda like the mixed variance of x and y. To elaborate, assuming there are n elements, and $x_μ$ represents the mean value of x and $y_μ$ represents the mean of y: $$ S_{xx}=\frac{1}{n} \sum_{i=1}^{n} (x-x_μ)² $$ $$ S_{yy}=\frac{1}{n} \sum_{i=1}^{n} (y-y_μ)² $$ $$ S_{xy}=\frac{1}{n} \sum_{i=1}^{n} (x-x_μ)(y-y_μ) $$ Hopefully this should work for you. Also, if you’re wondering how to do it in higher dimensions, like measuring volume spread or surteron bulk in 4 dimensions, you have to form a matrix like such: Sxx Sxy Sxz ... Syx Syy Syz ... Szx Szy Szz ... ... ... ... ... And continue for however many dimensions you need. You should be able to figure out the S values given the provided definitions above, but for different variables. Once the matrix is formed, take the determinant, find the square root, and you’re done.
2D analog of standard deviation?
I actually ran into a similar problem recently. It sounds like you want a way to measure how well the points are scattered area-wise. Of course, for a given measurement, you’d have to realize that i
2D analog of standard deviation? I actually ran into a similar problem recently. It sounds like you want a way to measure how well the points are scattered area-wise. Of course, for a given measurement, you’d have to realize that if all the points are in a straight line, the answer is zero, since there’s no 2 dimensional variety. From the calculations I did, this is what I came up with: $$ \sqrt{S_{xx}S_{yy}-S_{xy}²} $$ In this case, Sxx and Syy are the variances of x and of y respectively, whereas Sxy is kinda like the mixed variance of x and y. To elaborate, assuming there are n elements, and $x_μ$ represents the mean value of x and $y_μ$ represents the mean of y: $$ S_{xx}=\frac{1}{n} \sum_{i=1}^{n} (x-x_μ)² $$ $$ S_{yy}=\frac{1}{n} \sum_{i=1}^{n} (y-y_μ)² $$ $$ S_{xy}=\frac{1}{n} \sum_{i=1}^{n} (x-x_μ)(y-y_μ) $$ Hopefully this should work for you. Also, if you’re wondering how to do it in higher dimensions, like measuring volume spread or surteron bulk in 4 dimensions, you have to form a matrix like such: Sxx Sxy Sxz ... Syx Syy Syz ... Szx Szy Szz ... ... ... ... ... And continue for however many dimensions you need. You should be able to figure out the S values given the provided definitions above, but for different variables. Once the matrix is formed, take the determinant, find the square root, and you’re done.
2D analog of standard deviation? I actually ran into a similar problem recently. It sounds like you want a way to measure how well the points are scattered area-wise. Of course, for a given measurement, you’d have to realize that i
8,921
2D analog of standard deviation?
I think you should use 'Mahalanobis Distance' rather than Euclidean distance norms, as it takes into account the correlation of the data set and is 'scale-invariant'. Here is the link: http://en.wikipedia.org/wiki/Mahalanobis_distance You could also use 'Half-Space Depth'. It is a bit more complicated but shares many attractive properties. The Half space Depth (also known as Location depth) of a given point a relative to a data set P is the minimum number of points of P lying in any closed halfplane determined by a line through a. Here are the links: http://www.cs.unb.ca/~bremner/research/talks/depth-survey.pdf http://depth.johnhugg.com/DepthExplorerALENEXslides.pdf
2D analog of standard deviation?
I think you should use 'Mahalanobis Distance' rather than Euclidean distance norms, as it takes into account the correlation of the data set and is 'scale-invariant'. Here is the link: http://en.wikip
2D analog of standard deviation? I think you should use 'Mahalanobis Distance' rather than Euclidean distance norms, as it takes into account the correlation of the data set and is 'scale-invariant'. Here is the link: http://en.wikipedia.org/wiki/Mahalanobis_distance You could also use 'Half-Space Depth'. It is a bit more complicated but shares many attractive properties. The Half space Depth (also known as Location depth) of a given point a relative to a data set P is the minimum number of points of P lying in any closed halfplane determined by a line through a. Here are the links: http://www.cs.unb.ca/~bremner/research/talks/depth-survey.pdf http://depth.johnhugg.com/DepthExplorerALENEXslides.pdf
2D analog of standard deviation? I think you should use 'Mahalanobis Distance' rather than Euclidean distance norms, as it takes into account the correlation of the data set and is 'scale-invariant'. Here is the link: http://en.wikip
8,922
2D analog of standard deviation?
For this specific example - where there is a predetermined "correct" answer - I would re-work the x/y cooridnates to be polar coordinates around the city they were being asked to mark on the map. The accuracy is then measured agains the radial component (mean, sd, etc.). An "average angle" could also be used to measure bias. For myself, I'm still looking for a a good solution to when there is no pre-determined centre point, and don't like the idea of a pre-pass over the data to create a centroid.
2D analog of standard deviation?
For this specific example - where there is a predetermined "correct" answer - I would re-work the x/y cooridnates to be polar coordinates around the city they were being asked to mark on the map. The
2D analog of standard deviation? For this specific example - where there is a predetermined "correct" answer - I would re-work the x/y cooridnates to be polar coordinates around the city they were being asked to mark on the map. The accuracy is then measured agains the radial component (mean, sd, etc.). An "average angle" could also be used to measure bias. For myself, I'm still looking for a a good solution to when there is no pre-determined centre point, and don't like the idea of a pre-pass over the data to create a centroid.
2D analog of standard deviation? For this specific example - where there is a predetermined "correct" answer - I would re-work the x/y cooridnates to be polar coordinates around the city they were being asked to mark on the map. The
8,923
Is the result of an exam a binomial?
I would agree with your answer. Usually this kind of data would nowadays be modeled with some kind of Item Response Theory model. For example, if you used the Rasch model, then the binary answer $X_{ni}$ would be modeled as $$ \Pr \{X_{ni}=1\} =\frac{e^{{\beta_n} - {\delta_i}}}{1 + e^{{\beta_n} - {\delta_i}}} $$ where $\beta_n$ can be thought as $n$-th persons ability and $\delta_i$ as $i$-th question difficulty. So the model enables you to catch the fact that different persons vary in abilities and questions vary in difficulty, and this is the simplest of the IRT models. Your professors answer assumes that all questions have same probability of "success" and are independent, since binomial is a distribution of a sum of $n$ i.i.d. Bernoulli trials. It ignores the two kinds of dependencies described above. As noticed in the comments, if you looked at the distribution of answers of a particular person (so you don't have to care about between-person variability), or answers of different people on the same item (so there is no between-item variability), then the distribution would be Poisson-binomial, i.e. the distribution of the sum of $n$ non-i.i.d. Bernoulli trials. The distribution could be approximated with binomial, or Poisson, but that's all. Otherwise you're making the i.i.d. assumption. Even under "null" assumption about guessing, this assumes that there is no guessing patterns, so people do not differ in how they guess and items do not differ in how they are guessed--so the guessing is purely random.
Is the result of an exam a binomial?
I would agree with your answer. Usually this kind of data would nowadays be modeled with some kind of Item Response Theory model. For example, if you used the Rasch model, then the binary answer $X_{n
Is the result of an exam a binomial? I would agree with your answer. Usually this kind of data would nowadays be modeled with some kind of Item Response Theory model. For example, if you used the Rasch model, then the binary answer $X_{ni}$ would be modeled as $$ \Pr \{X_{ni}=1\} =\frac{e^{{\beta_n} - {\delta_i}}}{1 + e^{{\beta_n} - {\delta_i}}} $$ where $\beta_n$ can be thought as $n$-th persons ability and $\delta_i$ as $i$-th question difficulty. So the model enables you to catch the fact that different persons vary in abilities and questions vary in difficulty, and this is the simplest of the IRT models. Your professors answer assumes that all questions have same probability of "success" and are independent, since binomial is a distribution of a sum of $n$ i.i.d. Bernoulli trials. It ignores the two kinds of dependencies described above. As noticed in the comments, if you looked at the distribution of answers of a particular person (so you don't have to care about between-person variability), or answers of different people on the same item (so there is no between-item variability), then the distribution would be Poisson-binomial, i.e. the distribution of the sum of $n$ non-i.i.d. Bernoulli trials. The distribution could be approximated with binomial, or Poisson, but that's all. Otherwise you're making the i.i.d. assumption. Even under "null" assumption about guessing, this assumes that there is no guessing patterns, so people do not differ in how they guess and items do not differ in how they are guessed--so the guessing is purely random.
Is the result of an exam a binomial? I would agree with your answer. Usually this kind of data would nowadays be modeled with some kind of Item Response Theory model. For example, if you used the Rasch model, then the binary answer $X_{n
8,924
Is the result of an exam a binomial?
The answer to this problem depends on the framing of the question and when information is gained. Overall, I tend to agree with the professor but think the explanation of his/her answer is poor and the professor's question should include more information up front. If you consider an infinite number of potential exam questions, and you draw one at random for question 1, draw one at random for question 2, etc. Then going into the exam: Each question has two outcomes (right or wrong) There are a fixed number of trials (questions) Each trial could be considered independent (going into question two, your probability $p$ of getting it right is the same as when going into question one) Under this framework, the assumptions of a binomial experiment are met. Alas, ill-proposed statistical problems are very common in practice, not just on exams. I wouldn't hesitate to defend your rationale to your professor.
Is the result of an exam a binomial?
The answer to this problem depends on the framing of the question and when information is gained. Overall, I tend to agree with the professor but think the explanation of his/her answer is poor and t
Is the result of an exam a binomial? The answer to this problem depends on the framing of the question and when information is gained. Overall, I tend to agree with the professor but think the explanation of his/her answer is poor and the professor's question should include more information up front. If you consider an infinite number of potential exam questions, and you draw one at random for question 1, draw one at random for question 2, etc. Then going into the exam: Each question has two outcomes (right or wrong) There are a fixed number of trials (questions) Each trial could be considered independent (going into question two, your probability $p$ of getting it right is the same as when going into question one) Under this framework, the assumptions of a binomial experiment are met. Alas, ill-proposed statistical problems are very common in practice, not just on exams. I wouldn't hesitate to defend your rationale to your professor.
Is the result of an exam a binomial? The answer to this problem depends on the framing of the question and when information is gained. Overall, I tend to agree with the professor but think the explanation of his/her answer is poor and t
8,925
Is the result of an exam a binomial?
If there are n questions, and I can answer any one question correctly with probability p, and there is enough time to attempt answering all questions, and I did 100 of these tests, then my scores would be normal distributed with a mean of np. But it's not me repeating the test 100 times, it's 100 different candidates doing one test, each with his own probability p. The distribution of these p's will be the overriding factor. You might have a test where p = 0.9 if you studied the subject well, p = 0.1 if you didn't, with very few people between 0.1 and 0.9. The distribution of points will have very strong maxima at 0.1n and 0.9 n and will be nowhere near normal distribution. On the other hand, there are tests where everybody can answer any question, but take different amounts of time, so some will answer all n questions, and others will answer fewer because they run out of time. If we can assume that the speed of the candidates is normal distributed, then the points will be close to normal distributed. But many tests will contain some very hard and some very easy questions, intentionally so that we can distinguish between the best candidates (who will answer all questions up to some degree of difficulty) and the worst candidates (who will only be able to answer very simple questions). This would change the distribution of points quite strongly.
Is the result of an exam a binomial?
If there are n questions, and I can answer any one question correctly with probability p, and there is enough time to attempt answering all questions, and I did 100 of these tests, then my scores woul
Is the result of an exam a binomial? If there are n questions, and I can answer any one question correctly with probability p, and there is enough time to attempt answering all questions, and I did 100 of these tests, then my scores would be normal distributed with a mean of np. But it's not me repeating the test 100 times, it's 100 different candidates doing one test, each with his own probability p. The distribution of these p's will be the overriding factor. You might have a test where p = 0.9 if you studied the subject well, p = 0.1 if you didn't, with very few people between 0.1 and 0.9. The distribution of points will have very strong maxima at 0.1n and 0.9 n and will be nowhere near normal distribution. On the other hand, there are tests where everybody can answer any question, but take different amounts of time, so some will answer all n questions, and others will answer fewer because they run out of time. If we can assume that the speed of the candidates is normal distributed, then the points will be close to normal distributed. But many tests will contain some very hard and some very easy questions, intentionally so that we can distinguish between the best candidates (who will answer all questions up to some degree of difficulty) and the worst candidates (who will only be able to answer very simple questions). This would change the distribution of points quite strongly.
Is the result of an exam a binomial? If there are n questions, and I can answer any one question correctly with probability p, and there is enough time to attempt answering all questions, and I did 100 of these tests, then my scores woul
8,926
Is the result of an exam a binomial?
By definition, a binomial distribution is a set of $n$ independent and identically distributed Bernoulli trials. In the case of a multiple choice exam, each of the $n$ questions would be one of the Bernoulli trials. The issue here arises because we can't reasonably assume that the $n$ questions: Are identically distributed. As you said, the probability a student knows the answer to question $1$ is almost certainly not going to be the same as the probability they know the answer question $2$, and so on. Are independent. Many exams ask questions that are built upon the answers to the previous question(s). Who's to say for sure that that wouldn't happen on the exam in this question? There are other factors that could make answers to exam questions not independent of one another, but I think this one is the most intuitively obvious. I have seen questions in Statistics classes that model exam questions as binomials, but they are framed something along the lines of: What probability distribution would model the number of questions answered correctly on a multiple choice exam where every question has four choices, and the student taking the exam is guessing every answer at random? In this scenario, of course it would be represented as a binomial distribution with $p= \frac{1}{4}$ .
Is the result of an exam a binomial?
By definition, a binomial distribution is a set of $n$ independent and identically distributed Bernoulli trials. In the case of a multiple choice exam, each of the $n$ questions would be one of the Be
Is the result of an exam a binomial? By definition, a binomial distribution is a set of $n$ independent and identically distributed Bernoulli trials. In the case of a multiple choice exam, each of the $n$ questions would be one of the Bernoulli trials. The issue here arises because we can't reasonably assume that the $n$ questions: Are identically distributed. As you said, the probability a student knows the answer to question $1$ is almost certainly not going to be the same as the probability they know the answer question $2$, and so on. Are independent. Many exams ask questions that are built upon the answers to the previous question(s). Who's to say for sure that that wouldn't happen on the exam in this question? There are other factors that could make answers to exam questions not independent of one another, but I think this one is the most intuitively obvious. I have seen questions in Statistics classes that model exam questions as binomials, but they are framed something along the lines of: What probability distribution would model the number of questions answered correctly on a multiple choice exam where every question has four choices, and the student taking the exam is guessing every answer at random? In this scenario, of course it would be represented as a binomial distribution with $p= \frac{1}{4}$ .
Is the result of an exam a binomial? By definition, a binomial distribution is a set of $n$ independent and identically distributed Bernoulli trials. In the case of a multiple choice exam, each of the $n$ questions would be one of the Be
8,927
How can stochastic gradient descent avoid the problem of a local minimum?
The stochastic gradient (SG) algorithm behaves like a simulated annealing (SA) algorithm, where the learning rate of the SG is related to the temperature of SA. The randomness or noise introduced by SG allows to escape from local minima to reach a better minimum. Of course, it depends on how fast you decrease the learning rate. Read section 4.2, of Stochastic Gradient Learning in Neural Networks (pdf), where it is explained in more detail.
How can stochastic gradient descent avoid the problem of a local minimum?
The stochastic gradient (SG) algorithm behaves like a simulated annealing (SA) algorithm, where the learning rate of the SG is related to the temperature of SA. The randomness or noise introduced by S
How can stochastic gradient descent avoid the problem of a local minimum? The stochastic gradient (SG) algorithm behaves like a simulated annealing (SA) algorithm, where the learning rate of the SG is related to the temperature of SA. The randomness or noise introduced by SG allows to escape from local minima to reach a better minimum. Of course, it depends on how fast you decrease the learning rate. Read section 4.2, of Stochastic Gradient Learning in Neural Networks (pdf), where it is explained in more detail.
How can stochastic gradient descent avoid the problem of a local minimum? The stochastic gradient (SG) algorithm behaves like a simulated annealing (SA) algorithm, where the learning rate of the SG is related to the temperature of SA. The randomness or noise introduced by S
8,928
How can stochastic gradient descent avoid the problem of a local minimum?
In stochastic gradient descent the parameters are estimated for every observation, as opposed the whole sample in regular gradient descent (batch gradient descent). This is what gives it a lot of randomness. The path of stochastic gradient descent wanders over more places, and thus is more likely to "jump out" of a local minimum, and find a global minimum (Note*). However, stochastic gradient descent can still get stuck in local minimum. Note: It is common to keep the learning rate constant, in this case stochastic gradient descent does not converge; it just wanders around the same point. However, if the learning rate decreases over time, say, it is inversely related to number of iterations then stochastic gradient descent would converge.
How can stochastic gradient descent avoid the problem of a local minimum?
In stochastic gradient descent the parameters are estimated for every observation, as opposed the whole sample in regular gradient descent (batch gradient descent). This is what gives it a lot of rand
How can stochastic gradient descent avoid the problem of a local minimum? In stochastic gradient descent the parameters are estimated for every observation, as opposed the whole sample in regular gradient descent (batch gradient descent). This is what gives it a lot of randomness. The path of stochastic gradient descent wanders over more places, and thus is more likely to "jump out" of a local minimum, and find a global minimum (Note*). However, stochastic gradient descent can still get stuck in local minimum. Note: It is common to keep the learning rate constant, in this case stochastic gradient descent does not converge; it just wanders around the same point. However, if the learning rate decreases over time, say, it is inversely related to number of iterations then stochastic gradient descent would converge.
How can stochastic gradient descent avoid the problem of a local minimum? In stochastic gradient descent the parameters are estimated for every observation, as opposed the whole sample in regular gradient descent (batch gradient descent). This is what gives it a lot of rand
8,929
How can stochastic gradient descent avoid the problem of a local minimum?
As it was already mentioned in the previous answers, stochastic gradient descent has a much noisier error surface since you are evaluating each sample iteratively. While you are taking a step towards the global minimum in batch gradient descent at every epoch (pass over the training set), the individual steps of your stochastic gradient descent gradient must not always point towards the global minimum depending on the evaluated sample. To visualize this using a two-dimensional example, here are some figures and drawings from Andrew Ng's machine learning class. First gradient descent: Second, stochastic gradient descent: The red circle in the lower figure shall illustrate that stochastic gradient descent will "keep updating" somewhere in the area around the global minimum if you are using a constant learning rate. So, here are some practical tips if you are using stochastic gradient descent: 1) shuffle the training set before each epoch (or iteration in the "standard" variant) 2) use an adaptive learning rate to "anneal" closer to the global minimum
How can stochastic gradient descent avoid the problem of a local minimum?
As it was already mentioned in the previous answers, stochastic gradient descent has a much noisier error surface since you are evaluating each sample iteratively. While you are taking a step towards
How can stochastic gradient descent avoid the problem of a local minimum? As it was already mentioned in the previous answers, stochastic gradient descent has a much noisier error surface since you are evaluating each sample iteratively. While you are taking a step towards the global minimum in batch gradient descent at every epoch (pass over the training set), the individual steps of your stochastic gradient descent gradient must not always point towards the global minimum depending on the evaluated sample. To visualize this using a two-dimensional example, here are some figures and drawings from Andrew Ng's machine learning class. First gradient descent: Second, stochastic gradient descent: The red circle in the lower figure shall illustrate that stochastic gradient descent will "keep updating" somewhere in the area around the global minimum if you are using a constant learning rate. So, here are some practical tips if you are using stochastic gradient descent: 1) shuffle the training set before each epoch (or iteration in the "standard" variant) 2) use an adaptive learning rate to "anneal" closer to the global minimum
How can stochastic gradient descent avoid the problem of a local minimum? As it was already mentioned in the previous answers, stochastic gradient descent has a much noisier error surface since you are evaluating each sample iteratively. While you are taking a step towards
8,930
What is the appropriate model for underdispersed count data?
The best --- and standard ways to handle underdispersed Poisson data is by using a generalized Poisson, or perhaps a hurdle model. Three parameter count models can also be used for underdispersed data; eg Faddy-Smith, Waring, Famoye, Conway-Maxwell and other generalized count models. The only drawback with these is interpretability. But for general underdispersed data the generalized Poisson should be used. It is like negative binomial for overdispersed data. I discuss this in some detail in two of my books, Modeling Count Data (2014) and Negative Binomial Regression, 2nd edition, (2011) both by Cambridge University Press. In R the VGAM package allows for generalized Poisson (GP) regression. Negative values of the dispersion parameter indicate adjustment for underdispersion. You can use the GP model for overdispersed data as well, but generally the NB model is better. When it comes down to it, its best to determine the cause for underdispersion and then select the most appropriate model to deal with it.
What is the appropriate model for underdispersed count data?
The best --- and standard ways to handle underdispersed Poisson data is by using a generalized Poisson, or perhaps a hurdle model. Three parameter count models can also be used for underdispersed data
What is the appropriate model for underdispersed count data? The best --- and standard ways to handle underdispersed Poisson data is by using a generalized Poisson, or perhaps a hurdle model. Three parameter count models can also be used for underdispersed data; eg Faddy-Smith, Waring, Famoye, Conway-Maxwell and other generalized count models. The only drawback with these is interpretability. But for general underdispersed data the generalized Poisson should be used. It is like negative binomial for overdispersed data. I discuss this in some detail in two of my books, Modeling Count Data (2014) and Negative Binomial Regression, 2nd edition, (2011) both by Cambridge University Press. In R the VGAM package allows for generalized Poisson (GP) regression. Negative values of the dispersion parameter indicate adjustment for underdispersion. You can use the GP model for overdispersed data as well, but generally the NB model is better. When it comes down to it, its best to determine the cause for underdispersion and then select the most appropriate model to deal with it.
What is the appropriate model for underdispersed count data? The best --- and standard ways to handle underdispersed Poisson data is by using a generalized Poisson, or perhaps a hurdle model. Three parameter count models can also be used for underdispersed data
8,931
What is the appropriate model for underdispersed count data?
I encountered an under dispersed Poisson once that had to do with frequency at which people would play a social game. It turned out this was due to the extreme regularity with which people would play on Fridays. Removing Friday data gave me the expected overdispersed Poisson. Perhaps you have the option to similarly edit your data.
What is the appropriate model for underdispersed count data?
I encountered an under dispersed Poisson once that had to do with frequency at which people would play a social game. It turned out this was due to the extreme regularity with which people would play
What is the appropriate model for underdispersed count data? I encountered an under dispersed Poisson once that had to do with frequency at which people would play a social game. It turned out this was due to the extreme regularity with which people would play on Fridays. Removing Friday data gave me the expected overdispersed Poisson. Perhaps you have the option to similarly edit your data.
What is the appropriate model for underdispersed count data? I encountered an under dispersed Poisson once that had to do with frequency at which people would play a social game. It turned out this was due to the extreme regularity with which people would play
8,932
What is the appropriate model for underdispersed count data?
It seems that the solution provided by Joseph Hilbe within the vgam package is no longer available. From the manual of the package: The genpoisson() has been simplified to genpoisson0 by only handling positive parameters, hence only overdispersion relative to the Poisson is accommodated. Some of the reasons for this are described in Scollnik (1998), e.g., the probabilities do not sum to unity when lambda is negative. To simply things, VGAM 1.1-4 and later will only handle positive lambda.
What is the appropriate model for underdispersed count data?
It seems that the solution provided by Joseph Hilbe within the vgam package is no longer available. From the manual of the package: The genpoisson() has been simplified to genpoisson0 by only handlin
What is the appropriate model for underdispersed count data? It seems that the solution provided by Joseph Hilbe within the vgam package is no longer available. From the manual of the package: The genpoisson() has been simplified to genpoisson0 by only handling positive parameters, hence only overdispersion relative to the Poisson is accommodated. Some of the reasons for this are described in Scollnik (1998), e.g., the probabilities do not sum to unity when lambda is negative. To simply things, VGAM 1.1-4 and later will only handle positive lambda.
What is the appropriate model for underdispersed count data? It seems that the solution provided by Joseph Hilbe within the vgam package is no longer available. From the manual of the package: The genpoisson() has been simplified to genpoisson0 by only handlin
8,933
What is the appropriate model for underdispersed count data?
There are situations where underdispersion coalesces with zero-inflation which is typical for preferred children counts by individuals of both sexes. I haven't found a way to capture this to date
What is the appropriate model for underdispersed count data?
There are situations where underdispersion coalesces with zero-inflation which is typical for preferred children counts by individuals of both sexes. I haven't found a way to capture this to date
What is the appropriate model for underdispersed count data? There are situations where underdispersion coalesces with zero-inflation which is typical for preferred children counts by individuals of both sexes. I haven't found a way to capture this to date
What is the appropriate model for underdispersed count data? There are situations where underdispersion coalesces with zero-inflation which is typical for preferred children counts by individuals of both sexes. I haven't found a way to capture this to date
8,934
Nonlinear vs. generalized linear model: How do you refer to logistic, Poisson, etc. regression?
This is a great question. We know models such as logistic, Poisson, etc. fall under the umbrella of generalized linear models. Well, yes and no. Given the context of the question, we must be quite careful to specify what we're talking about -- and "logistic" and "Poisson" alone are insufficient to describe what is intended. (i) "Poisson" is a distribution. As a description of a conditional distribution, it's not linear (and hence not a GLM) unless you specify a linear (in parameters) model to describe the conditional mean (i.e. it's not sufficient merely to say "Poisson"). When people specify "Poisson regression", they nearly always intend to a model that is linear in parameters, and is therefore a GLM. But "Poisson" alone could be any number of things*. (ii) "Logistic" on the other hand refers to the description of a mean (that the mean is logistic in predictors). It's not a GLM unless you combine it with a conditional distribution that's in the exponential family. When people say "logistic regression" on the other hand, they almost always mean a binomial model with logit link - that does have mean that's logistic in predictors, the model is linear in parameters and is in the exponential family, so is a GLM. The model includes nonlinear functions of the parameters, Well, again, yes and no. The linear in "generalized linear model" says the parameters enter the model linearly. Specifically, what's meant is that on the scale of the linear predictor $\eta=g(\mu)$, the model is of the form $\eta=X\beta$. which may in turn be modeled using the linear model framework by using the appropriate link function. Correct I'm wondering if you consider (teach?) situations such as logistic regression as a: (I am changing the order of your question here) Linear model, since the link transforms us to the linear model framework It's conventional to call a GLM "linear", for precisely this reason. Indeed, it's pretty clear that this is the convention, because it's right there in the name. Nonlinear model, given the form of the parameters We must be very careful here, because "nonlinear" generally refers to a model that is nonlinear in parameters. Contrast nonlinear regression with generalized linear models. So if you want to use the term "nonlinear" to describe a GLM, it's important to carefully specify what you mean - generally, that the mean is non linearly related to the predictors. Indeed, if you do use "nonlinear" to refer to GLMs, you will get into difficulty not just with convention (and so be likely to be misunderstood), but also when trying to talk about generalized nonlinear models. It's a bit hard to explain the distinction if you already characterized GLMs as "nonlinear models"! * Consider a Poisson nonlinear regression model, one where there is no $g(\mu)$ for which the parameters enter linearly, so we still have: $$ Y\sim \text{Poisson}(\mu_x)$$ but for example, where $x$ is age, $Y$ at a given $x$ is observed deaths, and $\mu_x$ is a model for population annual mortality at age $x$: $$\mu_x = \alpha + \exp(\beta x)\,.$$ (Normally we'd have an offset here for the population at age $x$ which would shift the $\alpha$ term, but we can posit a situation where we observe a constant exposure. Note that both Poisson and binomial models are used for modelling mortality.) Here the first term represents a constant death rate due to (say) accidents (or other effects not much related to age) while the second term has an increasing death rate due to age. Such a model may perhaps sometimes be feasible over short ranges of later-adult-but-not-senescent-ages; it's essentially Makeham's law (there presented as a hazard function, but for which an annualized rate would be a reasonable approximation). That's a generalized nonlinear model.
Nonlinear vs. generalized linear model: How do you refer to logistic, Poisson, etc. regression?
This is a great question. We know models such as logistic, Poisson, etc. fall under the umbrella of generalized linear models. Well, yes and no. Given the context of the question, we must be quite
Nonlinear vs. generalized linear model: How do you refer to logistic, Poisson, etc. regression? This is a great question. We know models such as logistic, Poisson, etc. fall under the umbrella of generalized linear models. Well, yes and no. Given the context of the question, we must be quite careful to specify what we're talking about -- and "logistic" and "Poisson" alone are insufficient to describe what is intended. (i) "Poisson" is a distribution. As a description of a conditional distribution, it's not linear (and hence not a GLM) unless you specify a linear (in parameters) model to describe the conditional mean (i.e. it's not sufficient merely to say "Poisson"). When people specify "Poisson regression", they nearly always intend to a model that is linear in parameters, and is therefore a GLM. But "Poisson" alone could be any number of things*. (ii) "Logistic" on the other hand refers to the description of a mean (that the mean is logistic in predictors). It's not a GLM unless you combine it with a conditional distribution that's in the exponential family. When people say "logistic regression" on the other hand, they almost always mean a binomial model with logit link - that does have mean that's logistic in predictors, the model is linear in parameters and is in the exponential family, so is a GLM. The model includes nonlinear functions of the parameters, Well, again, yes and no. The linear in "generalized linear model" says the parameters enter the model linearly. Specifically, what's meant is that on the scale of the linear predictor $\eta=g(\mu)$, the model is of the form $\eta=X\beta$. which may in turn be modeled using the linear model framework by using the appropriate link function. Correct I'm wondering if you consider (teach?) situations such as logistic regression as a: (I am changing the order of your question here) Linear model, since the link transforms us to the linear model framework It's conventional to call a GLM "linear", for precisely this reason. Indeed, it's pretty clear that this is the convention, because it's right there in the name. Nonlinear model, given the form of the parameters We must be very careful here, because "nonlinear" generally refers to a model that is nonlinear in parameters. Contrast nonlinear regression with generalized linear models. So if you want to use the term "nonlinear" to describe a GLM, it's important to carefully specify what you mean - generally, that the mean is non linearly related to the predictors. Indeed, if you do use "nonlinear" to refer to GLMs, you will get into difficulty not just with convention (and so be likely to be misunderstood), but also when trying to talk about generalized nonlinear models. It's a bit hard to explain the distinction if you already characterized GLMs as "nonlinear models"! * Consider a Poisson nonlinear regression model, one where there is no $g(\mu)$ for which the parameters enter linearly, so we still have: $$ Y\sim \text{Poisson}(\mu_x)$$ but for example, where $x$ is age, $Y$ at a given $x$ is observed deaths, and $\mu_x$ is a model for population annual mortality at age $x$: $$\mu_x = \alpha + \exp(\beta x)\,.$$ (Normally we'd have an offset here for the population at age $x$ which would shift the $\alpha$ term, but we can posit a situation where we observe a constant exposure. Note that both Poisson and binomial models are used for modelling mortality.) Here the first term represents a constant death rate due to (say) accidents (or other effects not much related to age) while the second term has an increasing death rate due to age. Such a model may perhaps sometimes be feasible over short ranges of later-adult-but-not-senescent-ages; it's essentially Makeham's law (there presented as a hazard function, but for which an annualized rate would be a reasonable approximation). That's a generalized nonlinear model.
Nonlinear vs. generalized linear model: How do you refer to logistic, Poisson, etc. regression? This is a great question. We know models such as logistic, Poisson, etc. fall under the umbrella of generalized linear models. Well, yes and no. Given the context of the question, we must be quite
8,935
How to understand output from R's polr function (ordered logistic regression)?
I would suggest you look at books on categorical data analysis (cf. Alan Agresti's Categorical Data Analysis, 2002) for better explanation and understanding of ordered logistic regression. All the questions that you ask are basically answered by a few chapters in such books. If you are only interested in R related examples, Extending Linear Models in R by Julian Faraway (CRC Press, 2008) is a great reference. Before I answer your questions, ordered logistic regression is a case of multinomial logit models in which the categories are ordered. Suppose we have $J$ ordered categories and that for individual $i$, with ordinal response $Y_i$, $p_{ij}=P(Yi=j)$ for $j=1,..., J$. With an ordered response, it is often easier to work with the cumulative probabilities, $\gamma_{ij}=P(Y_i \le j)$. The cumulative probabilities are increasing and invariant to combining adjacent categories. Furthermore, $\gamma_{iJ}=1$, so we need only model $J–1$ probabilities. Now we want to link $\gamma_{ij}$s to covariates $x$. In your case, Sat has 3 ordered levels: low, medium, high. It makes more sense to treat them as ordered rather than unordered. The remaining variables are your covariates. The specific model that you are considering is the proportional odds model and is mathematically equivalent to: $$\mbox{logit } \gamma_j(x_i) = \theta_j - \beta^T x_i, j = 1 \ldots J-1$$ $$\mbox{where }\gamma_j(x_i)=P(Y_i \le j | x_i)$$ It is so called because the relative odds for $Y \le j$ comparing $x_1$ and $x_2$ are: $$\left(\frac {\gamma_j(x_1)}{1-\gamma_j(x_1)}\right) / \left(\frac {\gamma_j(x_2)}{1-\gamma_j(x_2)}\right)=\exp(-\beta^T (x_1-x_2))$$ Notice, the above expression does not depend on $j$. Of course, the assumption of proportional odds does need to be checked for a given dataset. Now, I will answer some (1, 2, 4) questions. How can one understand if the model gave a good fit? summary(house.plr) shows Residual Deviance 3479.149 and AIC (Akaike Information Criterion?) of 3495.149. Is that good? In the case those are only useful as relative measures (i.e. to compare to another model fit), what is a good absolute measure? Is the residual deviance approximately chi-squared distributed? Can one use "% correctly predicted" on the original data or some cross-validation? What is the easiest way to do that? A model fit by polr is a special glm, so all the assumptions that hold for a traditional glm hold here. If you take care of the parameters properly, you can figure out the distribution. Specifically, to test the if the model is good or not you may want to do a goodness of fit test, which test the following null (notice this is subtle, mostly you want to reject the null, but here you don't want to reject it to get a good fit): $$H_o: \mbox{ current model is good enough }$$ You would use the chi-square test for this. The p-value is obtained as: 1-pchisq(deviance(house.plr),df.residual(house.plr)) Most of the time you'd hope to obtain a p-value greater than 0.05 so that you don't reject the null to conclude that the model is good fit (philosophical correctness is ignored here). AIC should be high for a good fit at the same time you don't want to have a large number of parameters. stepAIC is a good way to check this. Yes, you can definitely use cross validation to see if the predictions hold. See predict function (option: type = "probs") in ?polr. All you need to take care of is the covariates. What information does pr contain? The help page on profile is generic, and gives no guidance for polr As pointed by @chl and others, pr contains all the information needed for obtaining CIs and other likelihood related information of the polr fit. All glms are fit using iteratively weighted least square estimation method for the log likelihood. In this optimization you obtain a lot of information (please see the references) which will be needed for calculating Variance Covariance Matrix, CI, t-value etc. It includes all of it. How does one interpret the t values for each coefficient? Unlike some model >fits, there are no P values here. Unlike normal linear model (special glm) other glms are don't have the nice t-distribution for the regression coefficients. Therefore all you can get is the parameter estimates and their asymptotic variance covariance matrix using the max-likelihood theory. Therefore: $$\text{Variance}(\hat \beta) = (X^T W X)^{-1}\hat \phi$$ Estimate divided by its standard error is what BDR and WV call t-value (I am assuming MASS convention here). It is equivalent to t-value from normal linear regression but does not follow a t-distribution. Using CLT, it is asymptotically normally distributed. But they prefer not to use this approx (I guess), hence no p-values. (I hope I am not wrong, and if I am, I hope BDR is not on this forum. I further hope, someone will correct me if I am wrong.)
How to understand output from R's polr function (ordered logistic regression)?
I would suggest you look at books on categorical data analysis (cf. Alan Agresti's Categorical Data Analysis, 2002) for better explanation and understanding of ordered logistic regression. All the que
How to understand output from R's polr function (ordered logistic regression)? I would suggest you look at books on categorical data analysis (cf. Alan Agresti's Categorical Data Analysis, 2002) for better explanation and understanding of ordered logistic regression. All the questions that you ask are basically answered by a few chapters in such books. If you are only interested in R related examples, Extending Linear Models in R by Julian Faraway (CRC Press, 2008) is a great reference. Before I answer your questions, ordered logistic regression is a case of multinomial logit models in which the categories are ordered. Suppose we have $J$ ordered categories and that for individual $i$, with ordinal response $Y_i$, $p_{ij}=P(Yi=j)$ for $j=1,..., J$. With an ordered response, it is often easier to work with the cumulative probabilities, $\gamma_{ij}=P(Y_i \le j)$. The cumulative probabilities are increasing and invariant to combining adjacent categories. Furthermore, $\gamma_{iJ}=1$, so we need only model $J–1$ probabilities. Now we want to link $\gamma_{ij}$s to covariates $x$. In your case, Sat has 3 ordered levels: low, medium, high. It makes more sense to treat them as ordered rather than unordered. The remaining variables are your covariates. The specific model that you are considering is the proportional odds model and is mathematically equivalent to: $$\mbox{logit } \gamma_j(x_i) = \theta_j - \beta^T x_i, j = 1 \ldots J-1$$ $$\mbox{where }\gamma_j(x_i)=P(Y_i \le j | x_i)$$ It is so called because the relative odds for $Y \le j$ comparing $x_1$ and $x_2$ are: $$\left(\frac {\gamma_j(x_1)}{1-\gamma_j(x_1)}\right) / \left(\frac {\gamma_j(x_2)}{1-\gamma_j(x_2)}\right)=\exp(-\beta^T (x_1-x_2))$$ Notice, the above expression does not depend on $j$. Of course, the assumption of proportional odds does need to be checked for a given dataset. Now, I will answer some (1, 2, 4) questions. How can one understand if the model gave a good fit? summary(house.plr) shows Residual Deviance 3479.149 and AIC (Akaike Information Criterion?) of 3495.149. Is that good? In the case those are only useful as relative measures (i.e. to compare to another model fit), what is a good absolute measure? Is the residual deviance approximately chi-squared distributed? Can one use "% correctly predicted" on the original data or some cross-validation? What is the easiest way to do that? A model fit by polr is a special glm, so all the assumptions that hold for a traditional glm hold here. If you take care of the parameters properly, you can figure out the distribution. Specifically, to test the if the model is good or not you may want to do a goodness of fit test, which test the following null (notice this is subtle, mostly you want to reject the null, but here you don't want to reject it to get a good fit): $$H_o: \mbox{ current model is good enough }$$ You would use the chi-square test for this. The p-value is obtained as: 1-pchisq(deviance(house.plr),df.residual(house.plr)) Most of the time you'd hope to obtain a p-value greater than 0.05 so that you don't reject the null to conclude that the model is good fit (philosophical correctness is ignored here). AIC should be high for a good fit at the same time you don't want to have a large number of parameters. stepAIC is a good way to check this. Yes, you can definitely use cross validation to see if the predictions hold. See predict function (option: type = "probs") in ?polr. All you need to take care of is the covariates. What information does pr contain? The help page on profile is generic, and gives no guidance for polr As pointed by @chl and others, pr contains all the information needed for obtaining CIs and other likelihood related information of the polr fit. All glms are fit using iteratively weighted least square estimation method for the log likelihood. In this optimization you obtain a lot of information (please see the references) which will be needed for calculating Variance Covariance Matrix, CI, t-value etc. It includes all of it. How does one interpret the t values for each coefficient? Unlike some model >fits, there are no P values here. Unlike normal linear model (special glm) other glms are don't have the nice t-distribution for the regression coefficients. Therefore all you can get is the parameter estimates and their asymptotic variance covariance matrix using the max-likelihood theory. Therefore: $$\text{Variance}(\hat \beta) = (X^T W X)^{-1}\hat \phi$$ Estimate divided by its standard error is what BDR and WV call t-value (I am assuming MASS convention here). It is equivalent to t-value from normal linear regression but does not follow a t-distribution. Using CLT, it is asymptotically normally distributed. But they prefer not to use this approx (I guess), hence no p-values. (I hope I am not wrong, and if I am, I hope BDR is not on this forum. I further hope, someone will correct me if I am wrong.)
How to understand output from R's polr function (ordered logistic regression)? I would suggest you look at books on categorical data analysis (cf. Alan Agresti's Categorical Data Analysis, 2002) for better explanation and understanding of ordered logistic regression. All the que
8,936
How to understand output from R's polr function (ordered logistic regression)?
I have greatly enjoyed the conversation here, however I feel that the answers did not correctly address all the (very good) components to the question you put forth. The second half of the example page for polr is all about profiling. A good technical reference here is Venerables and Ripley who discuss profiling and what it does. This is a critical technique when you step beyond the comfort zone of fitting exponential family models with full likelihood (regular GLMs). The key departure here is the use of categorical thresholds. You will notice POLR doesn't estimate a usual intercept term. Rather, there are $k-1$ nuisance parameters: thresholds for which the fitted risk tends to fall in a certain cumulative of the $k$ possible categories. Since these thresholds are never jointly estimated, their covariance with model parameters is unknown. Unlike GLMs we cannot "perturb" a coefficient by an amount and be certain of how it might affect other estimates. We use profiling to do this accounting for the nuisance thresholds. Profiling is an immense subject, but basically the goal is robustly measuring the covariance of regression coefficients when the model is maximizing an irregular likelihood, like with lmer, nls, polr, and glm.nb. The help page for ?profile.glm should be of some use as polr objects are essentially GLMs (plus the categorical thresholds). Lastly, you can actually peak at the source code, if it's of any use, using getS3method('profile', 'polr'). I use this getS3method function a lot because, while R seems to insist many methods should be hidden, one can learn surprisingly much about implementation and methods by reviewing code. •What information does pr contain? The help page on profile is generic, and gives no guidance for polr. pr is a profile.polr, profile object (inherited class profile). There's an entry for each covariate. The profiler loops over each covariate, recalculates the optimal model fit with that covariate fixed to some slightly different amount. The output shows the covariate's fixed value measured as a scaled "z-score" difference from its estimated value and the resulting fixed effects in other covariates. For instance, if you look at pr$InflMedium, you'll note that, when "z" is 0, the other fixed effects are the same as are found in the original fit. •What is plot(pr) showing? I see six graphs. Each has an X axis that is numeric, although the label is an indicator variable (looks like an input variable that is an indicator for an ordinal value). Then the Y axis is "tau" which is completely unexplained. Again, ?plot.profile gives the description. The plot roughly shows how the regression coefficients covary. tau is the scaled difference, the z score before, so it's 0 value gives the optimal fit coefficients, depicted with a tick mark. You wouldn't tell for this fit is so well behaved, but those "lines" are actually splines. If the likelihood were very irregularly behaved at the optimal fit, you would observe strange and unpredictable behavior in the plot. This would behoove you to estimate the output using a more robust error estimation (bootstrap/jackknife), to calculate CIs using method='profile', to recode variables, or to perform other diagnostics. •What is pairs(pr) showing? It looks like a plot for each pair of input variables, but again I see no explanation of the X or Y axes. The help file says: "The pairs method shows, for each pair of parameters x and y, two curves intersecting at the maximum likelihood estimate, which give the loci of the points at which the tangents to the contours of the bivariate profile likelihood become vertical and horizontal, respectively. In the case of an exactly bivariate normal profile likelihood, these two curves would be straight lines giving the conditional means of y|x and x|y, and the contours would be exactly elliptical." Basically, they again help you to visualize the confidence ellipses. Non-orthogonal axes indicate highly covariable measures, such as InfMedium and InfHigh which are intuitively very related. Again, irregular likelihoods would lead to images that are quite baffling here. •How can one understand if the model gave a good fit? summary(house.plr) shows Residual Deviance 3479.149 and AIC (Akaike Information Criterion?) of 3495.149. Is that good? In the case those are only useful as relative measures (i.e. to compare to another model fit), what is a good absolute measure? Is the residual deviance approximately chi-squared distributed? Can one use "% correctly predicted" on the original data or some cross-validation? What is the easiest way to do that? One assumption that is good to assess is the proportional odds assumption. This is reflected somewhat in the global test (which assesses polr against a saturated loglinear model). A limitation here is that with large data, global tests always fail. As a result, using graphics and inspecting estimates (betas) and precision (SEs) for the loglinear model and polr fit is a good idea. If they massively disagree, something is perhaps wrong. With ordered outcomes, it is hard to define percent agreement. How will you choose a classifier based on the model, and if you do how will you suss poor performance from a poor classifier. mode is a bad choice. If I have 10 category logits and my prediction is always but one category off, perhaps that is not a bad thing. Further, my model may correctly predict a 40% chance of a 0 response, but also 20% chances of 8, 9, 10. So if I observe 9 is that good or bad? If you must measure agreement use a weighted kappa, or even MSE. The loglinear model will always produce the best agreement. That is not what the POLR does. •How does one apply and interpret anova on this model? The docs say "There are methods for the standard model-fitting functions, including predict, summary, vcov, anova." However, running anova(house.plr) results in anova is not implemented for a single "polr" object You can test nested models with waldtest and lrtest in the lmtest package in R. This is equivalent to ANOVA. The interpretation is exactly the same as with GLMs. •How does one interpret the t values for each coefficient? Unlike some model fits, there are no P values here. Again, unlike linear models, the POLR model is capable of having issues with irregular likelihood so inference based on the Hessian can be very unstable. It is analogous to fitting mixed models, see for instance the helpfile on confint.merMod for the lme4 package. Here, the assessments made with profiling show the covariance is well behaved. The programmers would have done this by default, except that profiling can be computationally very intensive, and thus they leave it to your hands. If you must see the Wald based inference, use coeftest(house.plr) from the lrtest package.
How to understand output from R's polr function (ordered logistic regression)?
I have greatly enjoyed the conversation here, however I feel that the answers did not correctly address all the (very good) components to the question you put forth. The second half of the example pag
How to understand output from R's polr function (ordered logistic regression)? I have greatly enjoyed the conversation here, however I feel that the answers did not correctly address all the (very good) components to the question you put forth. The second half of the example page for polr is all about profiling. A good technical reference here is Venerables and Ripley who discuss profiling and what it does. This is a critical technique when you step beyond the comfort zone of fitting exponential family models with full likelihood (regular GLMs). The key departure here is the use of categorical thresholds. You will notice POLR doesn't estimate a usual intercept term. Rather, there are $k-1$ nuisance parameters: thresholds for which the fitted risk tends to fall in a certain cumulative of the $k$ possible categories. Since these thresholds are never jointly estimated, their covariance with model parameters is unknown. Unlike GLMs we cannot "perturb" a coefficient by an amount and be certain of how it might affect other estimates. We use profiling to do this accounting for the nuisance thresholds. Profiling is an immense subject, but basically the goal is robustly measuring the covariance of regression coefficients when the model is maximizing an irregular likelihood, like with lmer, nls, polr, and glm.nb. The help page for ?profile.glm should be of some use as polr objects are essentially GLMs (plus the categorical thresholds). Lastly, you can actually peak at the source code, if it's of any use, using getS3method('profile', 'polr'). I use this getS3method function a lot because, while R seems to insist many methods should be hidden, one can learn surprisingly much about implementation and methods by reviewing code. •What information does pr contain? The help page on profile is generic, and gives no guidance for polr. pr is a profile.polr, profile object (inherited class profile). There's an entry for each covariate. The profiler loops over each covariate, recalculates the optimal model fit with that covariate fixed to some slightly different amount. The output shows the covariate's fixed value measured as a scaled "z-score" difference from its estimated value and the resulting fixed effects in other covariates. For instance, if you look at pr$InflMedium, you'll note that, when "z" is 0, the other fixed effects are the same as are found in the original fit. •What is plot(pr) showing? I see six graphs. Each has an X axis that is numeric, although the label is an indicator variable (looks like an input variable that is an indicator for an ordinal value). Then the Y axis is "tau" which is completely unexplained. Again, ?plot.profile gives the description. The plot roughly shows how the regression coefficients covary. tau is the scaled difference, the z score before, so it's 0 value gives the optimal fit coefficients, depicted with a tick mark. You wouldn't tell for this fit is so well behaved, but those "lines" are actually splines. If the likelihood were very irregularly behaved at the optimal fit, you would observe strange and unpredictable behavior in the plot. This would behoove you to estimate the output using a more robust error estimation (bootstrap/jackknife), to calculate CIs using method='profile', to recode variables, or to perform other diagnostics. •What is pairs(pr) showing? It looks like a plot for each pair of input variables, but again I see no explanation of the X or Y axes. The help file says: "The pairs method shows, for each pair of parameters x and y, two curves intersecting at the maximum likelihood estimate, which give the loci of the points at which the tangents to the contours of the bivariate profile likelihood become vertical and horizontal, respectively. In the case of an exactly bivariate normal profile likelihood, these two curves would be straight lines giving the conditional means of y|x and x|y, and the contours would be exactly elliptical." Basically, they again help you to visualize the confidence ellipses. Non-orthogonal axes indicate highly covariable measures, such as InfMedium and InfHigh which are intuitively very related. Again, irregular likelihoods would lead to images that are quite baffling here. •How can one understand if the model gave a good fit? summary(house.plr) shows Residual Deviance 3479.149 and AIC (Akaike Information Criterion?) of 3495.149. Is that good? In the case those are only useful as relative measures (i.e. to compare to another model fit), what is a good absolute measure? Is the residual deviance approximately chi-squared distributed? Can one use "% correctly predicted" on the original data or some cross-validation? What is the easiest way to do that? One assumption that is good to assess is the proportional odds assumption. This is reflected somewhat in the global test (which assesses polr against a saturated loglinear model). A limitation here is that with large data, global tests always fail. As a result, using graphics and inspecting estimates (betas) and precision (SEs) for the loglinear model and polr fit is a good idea. If they massively disagree, something is perhaps wrong. With ordered outcomes, it is hard to define percent agreement. How will you choose a classifier based on the model, and if you do how will you suss poor performance from a poor classifier. mode is a bad choice. If I have 10 category logits and my prediction is always but one category off, perhaps that is not a bad thing. Further, my model may correctly predict a 40% chance of a 0 response, but also 20% chances of 8, 9, 10. So if I observe 9 is that good or bad? If you must measure agreement use a weighted kappa, or even MSE. The loglinear model will always produce the best agreement. That is not what the POLR does. •How does one apply and interpret anova on this model? The docs say "There are methods for the standard model-fitting functions, including predict, summary, vcov, anova." However, running anova(house.plr) results in anova is not implemented for a single "polr" object You can test nested models with waldtest and lrtest in the lmtest package in R. This is equivalent to ANOVA. The interpretation is exactly the same as with GLMs. •How does one interpret the t values for each coefficient? Unlike some model fits, there are no P values here. Again, unlike linear models, the POLR model is capable of having issues with irregular likelihood so inference based on the Hessian can be very unstable. It is analogous to fitting mixed models, see for instance the helpfile on confint.merMod for the lme4 package. Here, the assessments made with profiling show the covariance is well behaved. The programmers would have done this by default, except that profiling can be computationally very intensive, and thus they leave it to your hands. If you must see the Wald based inference, use coeftest(house.plr) from the lrtest package.
How to understand output from R's polr function (ordered logistic regression)? I have greatly enjoyed the conversation here, however I feel that the answers did not correctly address all the (very good) components to the question you put forth. The second half of the example pag
8,937
How to understand output from R's polr function (ordered logistic regression)?
To 'test' (i.e., evaluate) the proportional odds assumption in R, you can use residuals.lrm() in Frank Harrell Jr.'s Design package. If you type ?residuals.lrm , there is a quick-to-replicate example of how Frank Harrell recommends evaluating the proportional odds assumption (i.e., visually, rather than by a push-button test). Design estimates ordered logistic regressions using lrm(), which you can substitute for polr() from MASS. For a more formal example of how to visually test the proportional odds assumption in R, see: Paper: Ordinal Response Regression Models in Ecology Author(s): Antoine Guisan and Frank E. Harrell Source: Journal of Vegetation Science, Vol. 11, No. 5 (Oct., 2000), pp. 617-626
How to understand output from R's polr function (ordered logistic regression)?
To 'test' (i.e., evaluate) the proportional odds assumption in R, you can use residuals.lrm() in Frank Harrell Jr.'s Design package. If you type ?residuals.lrm , there is a quick-to-replicate example
How to understand output from R's polr function (ordered logistic regression)? To 'test' (i.e., evaluate) the proportional odds assumption in R, you can use residuals.lrm() in Frank Harrell Jr.'s Design package. If you type ?residuals.lrm , there is a quick-to-replicate example of how Frank Harrell recommends evaluating the proportional odds assumption (i.e., visually, rather than by a push-button test). Design estimates ordered logistic regressions using lrm(), which you can substitute for polr() from MASS. For a more formal example of how to visually test the proportional odds assumption in R, see: Paper: Ordinal Response Regression Models in Ecology Author(s): Antoine Guisan and Frank E. Harrell Source: Journal of Vegetation Science, Vol. 11, No. 5 (Oct., 2000), pp. 617-626
How to understand output from R's polr function (ordered logistic regression)? To 'test' (i.e., evaluate) the proportional odds assumption in R, you can use residuals.lrm() in Frank Harrell Jr.'s Design package. If you type ?residuals.lrm , there is a quick-to-replicate example
8,938
Theoretical motivation for using log-likelihood vs likelihood
It's really just a convenience for loglikelihood, nothing more. I mean the convenience of the sums vs. products: $\ln (\prod_i x_i) =\sum_i\ln x_i$, the sums are easier to deal with in many respects, such as differentialtion or integration. It's not a convenience for only exponential families, I'm trying to say. When you deal with a random sample, the likelihoods are of the form: $\mathrm{L}=\prod_ip_i$, so the loglikelihood would break this product into the sum instead, which is easier to manipulate and analyze. It helps that all we care is the point of the maximum, the value at the maximum is not important, se we can apply any monotonous transformation such as the logarithm. On the curvature intuition. It's basically the same thing in the end as the second derivative of loglikelihood. UPDATE: This is what I meant on the curvature. If you have a function $y=f(x)$, then it's curvature would be (see (14) on Wolfram): $$\kappa=\frac{f''(x)}{(1+f'(x)^2)^{3/2}}$$ The second derivative of the log likelihood: $$A=(\ln f(x))''=\frac{f''(x)}{f(x)}-\left(\frac{f'(x)}{f(x)}\right)^2$$ At the point of the maximum, the first derivative is obviously zero, so we get: $$\kappa_{max}=f''(x_{max})=Af(x_{max})$$ Hence, my quip that the curvature of the likelihood and the second derivative of loglikelihood are the same thing, sort of. On the other hand, if the first derivative of likelihood is small not only at but around the point of maximum, i.e. the likelihood function is flat then we get: $$\kappa\approx f''(x)\approx A f(x)$$ Now the flat likelihood is not a good thing for us, because it makes finding the maximum more difficult numerically, and the maximum likelihood is not that better than other points around it, i.e. the parameter estimation errors are high. And again, we still have the curvature and second derivative relationship. So why didn't Fisher look at the curvature of the likelihood function? I think it's for the same reason of convenience. It's easier to manipulate the loglikelihood because of sums instead of the product. So, he could study the curvature of the likelihood by analyzing the second derivative of the loglikelihood. Although the equation looks very simple for the curvature $\kappa_{max}=f''(x_{max})$, in actuality you're taking a second derivative of the product, which is messier than the sum of second derivatives. UPDATE 2: Here's a demonstration. I draw a (completely made up) likelihood function, its a) curvature and b) the 2nd derivative of its log. On the left side you see the narrow likelihood and on the right side it's wide. You see how at the point of the max likelihood a) and b) converge, as they should. More importantly though, you can study the width (or flatness) of the likelihood function by examining the 2nd derivative of its log-likelihood. As I wrote earlier the latter is technically simpler than the former to analyze. Not surprisingly deeper 2nd derivative of loglikelihood signals flatter likelihood function around its max, which is not desired for it causes bigger parameter estimation error. MATLAB code in case you want to reproduce the plots: f=@(x,a)a.^2./(a.^2+x.^2); c = @(x,a)(-2*a.^2.*(a.^2-3*x.^2)./(a.^2+x.^2).^3/(4*a.^4.*x.^2/(a.^2+x.^2).^4+1).^(3/2)); ll2d = @(x,a)(2*(x.^2-a.^2)./(a.^2+x.^2).^2); h = 0.1; x=-10:h:10; % narrow peak figure subplot(1,2,1) a = 1; y = f(x,a); plot(x,y,'LineWidth',2) %dy = diff(y)/h; hold on %plot(x(2:end),dy) plot(x,c(x,a),'LineWidth',2) plot(x,ll2d(x,a),'LineWidth',2) title 'Narrow Likelihood' ylim([-2 1]) % wide peak subplot(1,2,2) a=2; y = f(x,a); plot(x,y,'LineWidth',2) %dy = diff(y)/h; hold on %plot(x(2:end),dy) plot(x,c(x,a),'LineWidth',2) plot(x,ll2d(x,a),'LineWidth',2) title 'Wide Likelihood' legend('likelihood','curvature','2nd derivative LogL','location','best') ylim([-2 1]) UPDATE 3: In the code above I plugged some arbitrary bell shaped function into the curvature equation, then calculated the second derivative of its log. I didn't re-scale anything, the values are straight from equations to show the equivalence that I mentioned earlier. Here's the very first paper on likelihood that Fisher published while still in the university, "On an Absolute Criterion for Fitting Frequency Curves", Messenger of Mathmatics, 41: 155-160 (1912) As I was insisting all along he doesn't mention any "deeper" connections of log probabilities to entropy and other fancy subjects, neither does he offer his information criterion yet. He simply puts the equation $\log P'=\sum_1^n\log p$ on p.54 then proceeds to talk about maximizing the probabilities. In my opinion, this shows that he was using the logarithm just as a convenient method of analyzing the joint probabilities themselves. It is especially useful in the continuous curve fitting, for which he gives an obvious formula on p.55: $$\log P=\int_{-\infty}^\infty\log fdx$$ Good luck analyzing this likelihood (or probability $P$ as per Fisher) without the log! One thing to note when reading the paper he was only starting with maximum likelihood estimation work, and did more work in subsequent 10 years, so even the term MLE wasn't coined yet, as far as I know.
Theoretical motivation for using log-likelihood vs likelihood
It's really just a convenience for loglikelihood, nothing more. I mean the convenience of the sums vs. products: $\ln (\prod_i x_i) =\sum_i\ln x_i$, the sums are easier to deal with in many respects,
Theoretical motivation for using log-likelihood vs likelihood It's really just a convenience for loglikelihood, nothing more. I mean the convenience of the sums vs. products: $\ln (\prod_i x_i) =\sum_i\ln x_i$, the sums are easier to deal with in many respects, such as differentialtion or integration. It's not a convenience for only exponential families, I'm trying to say. When you deal with a random sample, the likelihoods are of the form: $\mathrm{L}=\prod_ip_i$, so the loglikelihood would break this product into the sum instead, which is easier to manipulate and analyze. It helps that all we care is the point of the maximum, the value at the maximum is not important, se we can apply any monotonous transformation such as the logarithm. On the curvature intuition. It's basically the same thing in the end as the second derivative of loglikelihood. UPDATE: This is what I meant on the curvature. If you have a function $y=f(x)$, then it's curvature would be (see (14) on Wolfram): $$\kappa=\frac{f''(x)}{(1+f'(x)^2)^{3/2}}$$ The second derivative of the log likelihood: $$A=(\ln f(x))''=\frac{f''(x)}{f(x)}-\left(\frac{f'(x)}{f(x)}\right)^2$$ At the point of the maximum, the first derivative is obviously zero, so we get: $$\kappa_{max}=f''(x_{max})=Af(x_{max})$$ Hence, my quip that the curvature of the likelihood and the second derivative of loglikelihood are the same thing, sort of. On the other hand, if the first derivative of likelihood is small not only at but around the point of maximum, i.e. the likelihood function is flat then we get: $$\kappa\approx f''(x)\approx A f(x)$$ Now the flat likelihood is not a good thing for us, because it makes finding the maximum more difficult numerically, and the maximum likelihood is not that better than other points around it, i.e. the parameter estimation errors are high. And again, we still have the curvature and second derivative relationship. So why didn't Fisher look at the curvature of the likelihood function? I think it's for the same reason of convenience. It's easier to manipulate the loglikelihood because of sums instead of the product. So, he could study the curvature of the likelihood by analyzing the second derivative of the loglikelihood. Although the equation looks very simple for the curvature $\kappa_{max}=f''(x_{max})$, in actuality you're taking a second derivative of the product, which is messier than the sum of second derivatives. UPDATE 2: Here's a demonstration. I draw a (completely made up) likelihood function, its a) curvature and b) the 2nd derivative of its log. On the left side you see the narrow likelihood and on the right side it's wide. You see how at the point of the max likelihood a) and b) converge, as they should. More importantly though, you can study the width (or flatness) of the likelihood function by examining the 2nd derivative of its log-likelihood. As I wrote earlier the latter is technically simpler than the former to analyze. Not surprisingly deeper 2nd derivative of loglikelihood signals flatter likelihood function around its max, which is not desired for it causes bigger parameter estimation error. MATLAB code in case you want to reproduce the plots: f=@(x,a)a.^2./(a.^2+x.^2); c = @(x,a)(-2*a.^2.*(a.^2-3*x.^2)./(a.^2+x.^2).^3/(4*a.^4.*x.^2/(a.^2+x.^2).^4+1).^(3/2)); ll2d = @(x,a)(2*(x.^2-a.^2)./(a.^2+x.^2).^2); h = 0.1; x=-10:h:10; % narrow peak figure subplot(1,2,1) a = 1; y = f(x,a); plot(x,y,'LineWidth',2) %dy = diff(y)/h; hold on %plot(x(2:end),dy) plot(x,c(x,a),'LineWidth',2) plot(x,ll2d(x,a),'LineWidth',2) title 'Narrow Likelihood' ylim([-2 1]) % wide peak subplot(1,2,2) a=2; y = f(x,a); plot(x,y,'LineWidth',2) %dy = diff(y)/h; hold on %plot(x(2:end),dy) plot(x,c(x,a),'LineWidth',2) plot(x,ll2d(x,a),'LineWidth',2) title 'Wide Likelihood' legend('likelihood','curvature','2nd derivative LogL','location','best') ylim([-2 1]) UPDATE 3: In the code above I plugged some arbitrary bell shaped function into the curvature equation, then calculated the second derivative of its log. I didn't re-scale anything, the values are straight from equations to show the equivalence that I mentioned earlier. Here's the very first paper on likelihood that Fisher published while still in the university, "On an Absolute Criterion for Fitting Frequency Curves", Messenger of Mathmatics, 41: 155-160 (1912) As I was insisting all along he doesn't mention any "deeper" connections of log probabilities to entropy and other fancy subjects, neither does he offer his information criterion yet. He simply puts the equation $\log P'=\sum_1^n\log p$ on p.54 then proceeds to talk about maximizing the probabilities. In my opinion, this shows that he was using the logarithm just as a convenient method of analyzing the joint probabilities themselves. It is especially useful in the continuous curve fitting, for which he gives an obvious formula on p.55: $$\log P=\int_{-\infty}^\infty\log fdx$$ Good luck analyzing this likelihood (or probability $P$ as per Fisher) without the log! One thing to note when reading the paper he was only starting with maximum likelihood estimation work, and did more work in subsequent 10 years, so even the term MLE wasn't coined yet, as far as I know.
Theoretical motivation for using log-likelihood vs likelihood It's really just a convenience for loglikelihood, nothing more. I mean the convenience of the sums vs. products: $\ln (\prod_i x_i) =\sum_i\ln x_i$, the sums are easier to deal with in many respects,
8,939
Theoretical motivation for using log-likelihood vs likelihood
Log-likelihood's theoretical importance can be seen from (at least) two perspectives: asymptotic likelihood theory and information theory. The earlier of these (I believe) is the asymptotic theory of log-likelihood. I think information theory got underway well after Fisher set maximum likelihood on its course towards 20th century dominance. In likelihood theory, a parabolic log-likelihood has a central place in inference. Lucien Le Cam has played an important role in elucidating the importance of the quadratic log-likelihood in asymptotic theory. When you have a quadratic log-likelihood, not only does the curvature about the MLE tell you qualitatively how precisely you can estimate the parameter, but we also know the error is normally distributed with a variance equal to the reciprocal of the curvature. When the log-likelihood is approximately quadratic, then we say these results hold approximately, or asymptotically. A second reason is the prominence of the log-likelihood (or log-probability) in information theory, where it is the main quantity used to measure the information content. There is a variant of Entropy called the Kullback-Liebler Divergence that is minimized by the maximum likelihood estimate. In particular, if the true data distribution is $g$ then the "closest" distribution (as measured by the Kullback-Liebler divergence) to $g$ in parametric family $f(\theta)$ is given by $f(\hat{\theta})$, where $ \hat{\theta}$ is the maximum likelihood estimate. Finally, log-likelihood is the quantity used in various model selection criteria such as AIC and BIC. Essentially, each of these criteria equates an extra parameter/degree of freedom with some multiple of $\ln \hat{L}$. So, log likelihood, apart from being a useful numerical transformation, has deep ties to inference and information theory.
Theoretical motivation for using log-likelihood vs likelihood
Log-likelihood's theoretical importance can be seen from (at least) two perspectives: asymptotic likelihood theory and information theory. The earlier of these (I believe) is the asymptotic theory of
Theoretical motivation for using log-likelihood vs likelihood Log-likelihood's theoretical importance can be seen from (at least) two perspectives: asymptotic likelihood theory and information theory. The earlier of these (I believe) is the asymptotic theory of log-likelihood. I think information theory got underway well after Fisher set maximum likelihood on its course towards 20th century dominance. In likelihood theory, a parabolic log-likelihood has a central place in inference. Lucien Le Cam has played an important role in elucidating the importance of the quadratic log-likelihood in asymptotic theory. When you have a quadratic log-likelihood, not only does the curvature about the MLE tell you qualitatively how precisely you can estimate the parameter, but we also know the error is normally distributed with a variance equal to the reciprocal of the curvature. When the log-likelihood is approximately quadratic, then we say these results hold approximately, or asymptotically. A second reason is the prominence of the log-likelihood (or log-probability) in information theory, where it is the main quantity used to measure the information content. There is a variant of Entropy called the Kullback-Liebler Divergence that is minimized by the maximum likelihood estimate. In particular, if the true data distribution is $g$ then the "closest" distribution (as measured by the Kullback-Liebler divergence) to $g$ in parametric family $f(\theta)$ is given by $f(\hat{\theta})$, where $ \hat{\theta}$ is the maximum likelihood estimate. Finally, log-likelihood is the quantity used in various model selection criteria such as AIC and BIC. Essentially, each of these criteria equates an extra parameter/degree of freedom with some multiple of $\ln \hat{L}$. So, log likelihood, apart from being a useful numerical transformation, has deep ties to inference and information theory.
Theoretical motivation for using log-likelihood vs likelihood Log-likelihood's theoretical importance can be seen from (at least) two perspectives: asymptotic likelihood theory and information theory. The earlier of these (I believe) is the asymptotic theory of
8,940
Theoretical motivation for using log-likelihood vs likelihood
Additional point. Some of the commonly used probability distributions (including the normal distribution, the exponential distribution, the Laplace distribution, just to name a few) are log-concave. This means that their logarithm is concave. This makes maximising the log-probability much easier than maximising the original probability (which is particularly handy in maximum likelihood or maximum a-posteriori methods). To give an example, using Newton's method to maximise a multivariate Gaussian distribution directly may take a large number of steps while maximising a paraboloid (the log of the multivariate Gaussian distribution) takes exactly one step.
Theoretical motivation for using log-likelihood vs likelihood
Additional point. Some of the commonly used probability distributions (including the normal distribution, the exponential distribution, the Laplace distribution, just to name a few) are log-concave. T
Theoretical motivation for using log-likelihood vs likelihood Additional point. Some of the commonly used probability distributions (including the normal distribution, the exponential distribution, the Laplace distribution, just to name a few) are log-concave. This means that their logarithm is concave. This makes maximising the log-probability much easier than maximising the original probability (which is particularly handy in maximum likelihood or maximum a-posteriori methods). To give an example, using Newton's method to maximise a multivariate Gaussian distribution directly may take a large number of steps while maximising a paraboloid (the log of the multivariate Gaussian distribution) takes exactly one step.
Theoretical motivation for using log-likelihood vs likelihood Additional point. Some of the commonly used probability distributions (including the normal distribution, the exponential distribution, the Laplace distribution, just to name a few) are log-concave. T
8,941
Theoretical motivation for using log-likelihood vs likelihood
TLDR: It is much easier to derive sums than products, because the derivative operator is linear with summation but with product u have to do the product rule. It is linear complexity versus some higher order polynomial complexity
Theoretical motivation for using log-likelihood vs likelihood
TLDR: It is much easier to derive sums than products, because the derivative operator is linear with summation but with product u have to do the product rule. It is linear complexity versus some highe
Theoretical motivation for using log-likelihood vs likelihood TLDR: It is much easier to derive sums than products, because the derivative operator is linear with summation but with product u have to do the product rule. It is linear complexity versus some higher order polynomial complexity
Theoretical motivation for using log-likelihood vs likelihood TLDR: It is much easier to derive sums than products, because the derivative operator is linear with summation but with product u have to do the product rule. It is linear complexity versus some highe
8,942
When to normalize data in regression? [duplicate]
Sometimes standardization helps for numerical issues (not so much these days with modern numerical linear algebra routines) or for interpretation, as mentioned in the other answer. Here is one "rule" that I will use for answering the answer myself: Is the regression method you are using invariant, in that the substantive answer does not change with standardization? Ordinary least squares is invariant, while methods such as lasso or ridge regression are not. So, for invariant methods there is no real need for standardization, while for non-invariant methods you should probably standardize. (Or at least think it through). The following is somewhat related: Dropping one of the columns when using one-hot encoding
When to normalize data in regression? [duplicate]
Sometimes standardization helps for numerical issues (not so much these days with modern numerical linear algebra routines) or for interpretation, as mentioned in the other answer. Here is one "rule"
When to normalize data in regression? [duplicate] Sometimes standardization helps for numerical issues (not so much these days with modern numerical linear algebra routines) or for interpretation, as mentioned in the other answer. Here is one "rule" that I will use for answering the answer myself: Is the regression method you are using invariant, in that the substantive answer does not change with standardization? Ordinary least squares is invariant, while methods such as lasso or ridge regression are not. So, for invariant methods there is no real need for standardization, while for non-invariant methods you should probably standardize. (Or at least think it through). The following is somewhat related: Dropping one of the columns when using one-hot encoding
When to normalize data in regression? [duplicate] Sometimes standardization helps for numerical issues (not so much these days with modern numerical linear algebra routines) or for interpretation, as mentioned in the other answer. Here is one "rule"
8,943
When to normalize data in regression? [duplicate]
It sometimes makes interpretation easier if you subtract the mean or some number within the range of the actual values as this can make the intercept more meaningful. For instance if you have people aged 65 and over subtract 65 and then the intercept is the predicted value for a 65-year old rather than a neonate. If you have non-linear terms like powers this makes them less correlated and so you can see more easily what is going on. It also may make life easier to scale the predictor so as to move the coefficients into a more printable range. For instance converting days into weeks or months. Other than that it should not matter. I suppose some of what I have just written may be what your friend meant by it depends on the data.
When to normalize data in regression? [duplicate]
It sometimes makes interpretation easier if you subtract the mean or some number within the range of the actual values as this can make the intercept more meaningful. For instance if you have people a
When to normalize data in regression? [duplicate] It sometimes makes interpretation easier if you subtract the mean or some number within the range of the actual values as this can make the intercept more meaningful. For instance if you have people aged 65 and over subtract 65 and then the intercept is the predicted value for a 65-year old rather than a neonate. If you have non-linear terms like powers this makes them less correlated and so you can see more easily what is going on. It also may make life easier to scale the predictor so as to move the coefficients into a more printable range. For instance converting days into weeks or months. Other than that it should not matter. I suppose some of what I have just written may be what your friend meant by it depends on the data.
When to normalize data in regression? [duplicate] It sometimes makes interpretation easier if you subtract the mean or some number within the range of the actual values as this can make the intercept more meaningful. For instance if you have people a
8,944
Recommendation for peer-reviewed open-source journal?
A rather lengthy list can be found at the Directory of Open Access Journals. Using the search term statistics yielded a list of 124 open-source journals (updated following the DOAJ's move to a new platform). I have had good experiences and success in the past with the IMS and Bernoulli society co-sponsored open-source journals, particularly Electronic Journal of Statistics Electronic Journal of Probability Electronic Communications in Probability All IMS journals (e.g., AOS, AOAS, AOP, AOAP) now publish production-quality preprints on the arXiv statistics section, including all articles since 2004, as detailed on their website. Forthcoming articles are also available for free; see the Annals of Applied Statistics "Next Issues" page for an example. Some other journals have gone to an online-access model recently, including, e.g., Sankhya.
Recommendation for peer-reviewed open-source journal?
A rather lengthy list can be found at the Directory of Open Access Journals. Using the search term statistics yielded a list of 124 open-source journals (updated following the DOAJ's move to a new pla
Recommendation for peer-reviewed open-source journal? A rather lengthy list can be found at the Directory of Open Access Journals. Using the search term statistics yielded a list of 124 open-source journals (updated following the DOAJ's move to a new platform). I have had good experiences and success in the past with the IMS and Bernoulli society co-sponsored open-source journals, particularly Electronic Journal of Statistics Electronic Journal of Probability Electronic Communications in Probability All IMS journals (e.g., AOS, AOAS, AOP, AOAP) now publish production-quality preprints on the arXiv statistics section, including all articles since 2004, as detailed on their website. Forthcoming articles are also available for free; see the Annals of Applied Statistics "Next Issues" page for an example. Some other journals have gone to an online-access model recently, including, e.g., Sankhya.
Recommendation for peer-reviewed open-source journal? A rather lengthy list can be found at the Directory of Open Access Journals. Using the search term statistics yielded a list of 124 open-source journals (updated following the DOAJ's move to a new pla
8,945
Recommendation for peer-reviewed open-source journal?
In case your method is somewhat implemented, Journal of Statistical Software is a pretty nice option -- they put emphasis on reproducibility and availability of methods and algorithms.
Recommendation for peer-reviewed open-source journal?
In case your method is somewhat implemented, Journal of Statistical Software is a pretty nice option -- they put emphasis on reproducibility and availability of methods and algorithms.
Recommendation for peer-reviewed open-source journal? In case your method is somewhat implemented, Journal of Statistical Software is a pretty nice option -- they put emphasis on reproducibility and availability of methods and algorithms.
Recommendation for peer-reviewed open-source journal? In case your method is somewhat implemented, Journal of Statistical Software is a pretty nice option -- they put emphasis on reproducibility and availability of methods and algorithms.
8,946
Recommendation for peer-reviewed open-source journal?
To add to what cardinal has said the journal Statistics in Biopharmaceutical Research is a purely online journal but you do have to subscribe. Like what cardinal says about Annals of Applied Statistics this journal does give selected issues or some individual articles out for free. It is published by Taylor and Francis. I am curious about your article. In your question you state that you want to publish an article about using a bootstrap method to test a hypothesis about a population mean. This is a well studied topic. What is it about your paper that makes it original?
Recommendation for peer-reviewed open-source journal?
To add to what cardinal has said the journal Statistics in Biopharmaceutical Research is a purely online journal but you do have to subscribe. Like what cardinal says about Annals of Applied Statistic
Recommendation for peer-reviewed open-source journal? To add to what cardinal has said the journal Statistics in Biopharmaceutical Research is a purely online journal but you do have to subscribe. Like what cardinal says about Annals of Applied Statistics this journal does give selected issues or some individual articles out for free. It is published by Taylor and Francis. I am curious about your article. In your question you state that you want to publish an article about using a bootstrap method to test a hypothesis about a population mean. This is a well studied topic. What is it about your paper that makes it original?
Recommendation for peer-reviewed open-source journal? To add to what cardinal has said the journal Statistics in Biopharmaceutical Research is a purely online journal but you do have to subscribe. Like what cardinal says about Annals of Applied Statistic
8,947
Proof of LOOCV formula
I'll show the result for any multiple linear regression, whether the regressors are polynomials of $X_t$ or not. In fact, it shows a little more than what you asked, because it shows that each LOOCV residual is identical to the corresponding leverage-weighted residual from the full regression, not just that you can obtain the LOOCV error as in (5.2) (there could be other ways in which the averages agree, even if not each term in the average is the same). Let me take the liberty to use slightly adapted notation. We first show that \begin{align*} \hat\beta-\hat\beta_{(t)}&=\left(\frac{\hat u_t}{1-h_t}\right)(X'X)^{-1}X_t', \quad\quad \textrm{(A)} \end{align*} where $\hat\beta$ is the estimate using all data and $\hat\beta_{(t)}$ the estimate when leaving out $X_{(t)}$, observation $t$. Let $X_t$ be defined as a row vector such that $\hat y_t=X_t\hat\beta$. $\hat u_t$ are the residuals. The proof uses the following matrix algebraic result. Let $A$ be a nonsingular matrix, $b$ a vector and $\lambda$ a scalar. If \begin{align*} \lambda&\neq -\frac{1}{b'A^{-1}b} \end{align*}Then \begin{align*} (A+\lambda bb')^{-1}&=A^{-1}-\left(\frac{\lambda}{1+\lambda b'A^{-1}b}\right)A^{-1}bb'A^{-1}\quad\quad \textrm{(B) }\end{align*} The proof of (B) follows immediately from verifying \begin{align*} \left\{A^{-1}-\left(\frac{\lambda}{1+\lambda b'A^{-1}b}\right)A^{-1}bb'A^{-1}\right\}(A+\lambda bb')=I. \end{align*} The following result is helpful to prove (A) \begin{align} (X_{(t)}'X_{(t)})^{-1}X_t'=\left(\frac{1}{1-h_t}\right)(X'X)^{-1}X_t'.\quad\quad \textrm{ (C)} \end{align} Proof of (C): By (B) we have, using $\sum_{t=1}^TX_t'X_t=X'X$, \begin{align*} (X_{(t)}'X_{(t)})^{-1}&=(X'X-X_t'X_t)^{-1}\\ &=(X'X)^{-1}+\frac{(X'X)^{-1}X_t'X_t(X'X)^{-1}}{1-X_t(X'X)^{-1}X_t'}. \end{align*} So we find \begin{align*} (X_{(t)}'X_{(t)})^{-1}X_t'&=(X'X)^{-1}X_t'+(X'X)^{-1}X_t'\left(\frac{X_t(X'X)^{-1}X_t'}{1-X_t(X'X)^{-1}X_t'}\right)\\ &=\left(\frac{1}{1-h_t}\right)(X'X)^{-1}X_t'. \end{align*} The proof of (A) now follows from (C): As \begin{align*} X'X\hat\beta&=X'y, \end{align*} we have \begin{align*} (X_{(t)}'X_{(t)}+X_t'X_t)\hat\beta &=X_{(t)}'y_{(t)}+X_t' y_t, \end{align*} or \begin{align*} \left\{I_k+(X_{(t)}'X_{(t)})^{-1}X_t'X_t\right\}\hat\beta&=\hat\beta_{(t)}+(X_{(t)}'X_{(t)})^{-1}X_t'(X_t\hat\beta+\hat u_t). \end{align*} So, \begin{align*} \hat\beta&=\hat\beta_{(t)}+(X_{(t)}'X_{(t)})^{-1}X_t'\hat u_t\\ &=\hat\beta_{(t)}+(X'X)^{-1}X_t'\frac{\hat u_t}{1-h_t}, \end{align*} where the last equality follows from (C). Now, note $h_t=X_t(X'X)^{-1}X_t'$. Multiply through in (A) by $X_t$, add $y_t$ on both sides and rearrange to get, with $\hat u_{(t)}$ the residuals resulting from using $\hat\beta_{(t)}$ ($y_t-X_t\hat\beta_{(t)}$), $$ \hat u_{(t)}=\hat u_t+\left(\frac{\hat u_t}{1-h_t}\right)h_t $$ or $$ \hat u_{(t)}=\frac{\hat u_t(1-h_t)+\hat u_th_t}{1-h_t}=\frac{\hat u_t}{1-h_t} $$
Proof of LOOCV formula
I'll show the result for any multiple linear regression, whether the regressors are polynomials of $X_t$ or not. In fact, it shows a little more than what you asked, because it shows that each LOOCV r
Proof of LOOCV formula I'll show the result for any multiple linear regression, whether the regressors are polynomials of $X_t$ or not. In fact, it shows a little more than what you asked, because it shows that each LOOCV residual is identical to the corresponding leverage-weighted residual from the full regression, not just that you can obtain the LOOCV error as in (5.2) (there could be other ways in which the averages agree, even if not each term in the average is the same). Let me take the liberty to use slightly adapted notation. We first show that \begin{align*} \hat\beta-\hat\beta_{(t)}&=\left(\frac{\hat u_t}{1-h_t}\right)(X'X)^{-1}X_t', \quad\quad \textrm{(A)} \end{align*} where $\hat\beta$ is the estimate using all data and $\hat\beta_{(t)}$ the estimate when leaving out $X_{(t)}$, observation $t$. Let $X_t$ be defined as a row vector such that $\hat y_t=X_t\hat\beta$. $\hat u_t$ are the residuals. The proof uses the following matrix algebraic result. Let $A$ be a nonsingular matrix, $b$ a vector and $\lambda$ a scalar. If \begin{align*} \lambda&\neq -\frac{1}{b'A^{-1}b} \end{align*}Then \begin{align*} (A+\lambda bb')^{-1}&=A^{-1}-\left(\frac{\lambda}{1+\lambda b'A^{-1}b}\right)A^{-1}bb'A^{-1}\quad\quad \textrm{(B) }\end{align*} The proof of (B) follows immediately from verifying \begin{align*} \left\{A^{-1}-\left(\frac{\lambda}{1+\lambda b'A^{-1}b}\right)A^{-1}bb'A^{-1}\right\}(A+\lambda bb')=I. \end{align*} The following result is helpful to prove (A) \begin{align} (X_{(t)}'X_{(t)})^{-1}X_t'=\left(\frac{1}{1-h_t}\right)(X'X)^{-1}X_t'.\quad\quad \textrm{ (C)} \end{align} Proof of (C): By (B) we have, using $\sum_{t=1}^TX_t'X_t=X'X$, \begin{align*} (X_{(t)}'X_{(t)})^{-1}&=(X'X-X_t'X_t)^{-1}\\ &=(X'X)^{-1}+\frac{(X'X)^{-1}X_t'X_t(X'X)^{-1}}{1-X_t(X'X)^{-1}X_t'}. \end{align*} So we find \begin{align*} (X_{(t)}'X_{(t)})^{-1}X_t'&=(X'X)^{-1}X_t'+(X'X)^{-1}X_t'\left(\frac{X_t(X'X)^{-1}X_t'}{1-X_t(X'X)^{-1}X_t'}\right)\\ &=\left(\frac{1}{1-h_t}\right)(X'X)^{-1}X_t'. \end{align*} The proof of (A) now follows from (C): As \begin{align*} X'X\hat\beta&=X'y, \end{align*} we have \begin{align*} (X_{(t)}'X_{(t)}+X_t'X_t)\hat\beta &=X_{(t)}'y_{(t)}+X_t' y_t, \end{align*} or \begin{align*} \left\{I_k+(X_{(t)}'X_{(t)})^{-1}X_t'X_t\right\}\hat\beta&=\hat\beta_{(t)}+(X_{(t)}'X_{(t)})^{-1}X_t'(X_t\hat\beta+\hat u_t). \end{align*} So, \begin{align*} \hat\beta&=\hat\beta_{(t)}+(X_{(t)}'X_{(t)})^{-1}X_t'\hat u_t\\ &=\hat\beta_{(t)}+(X'X)^{-1}X_t'\frac{\hat u_t}{1-h_t}, \end{align*} where the last equality follows from (C). Now, note $h_t=X_t(X'X)^{-1}X_t'$. Multiply through in (A) by $X_t$, add $y_t$ on both sides and rearrange to get, with $\hat u_{(t)}$ the residuals resulting from using $\hat\beta_{(t)}$ ($y_t-X_t\hat\beta_{(t)}$), $$ \hat u_{(t)}=\hat u_t+\left(\frac{\hat u_t}{1-h_t}\right)h_t $$ or $$ \hat u_{(t)}=\frac{\hat u_t(1-h_t)+\hat u_th_t}{1-h_t}=\frac{\hat u_t}{1-h_t} $$
Proof of LOOCV formula I'll show the result for any multiple linear regression, whether the regressors are polynomials of $X_t$ or not. In fact, it shows a little more than what you asked, because it shows that each LOOCV r
8,948
Getting p-values for "multinom" in R (nnet package)
You can use that custom function that I`ve created, for example you can just get true or false for Hipotesis test. The TRUE ones should represent P-Value > 0,5. zWald_test <- function(x){ zWald_modelo<- (summary(x)$coefficients / summary(x)$standard.errors) a <- t(apply(zWald_modelo, 1, function(x) {x < qnorm(0.025, lower.tail = FALSE)} )) b <- t(apply(zWald_modelo, 1, function(x) {x > -qnorm(0.025, lower.tail = FALSE)} )) ifelse(a==TRUE & b==TRUE, TRUE, FALSE) } or if you want to confirm the p-values you can use the following function: pValue_extract <- function(x){ z <- summary(x)$coefficients/summary(x)$standard.errors # 2-tailed Wald z tests to test significance of coefficients p <- (1 - pnorm(abs(z), 0, 1)) * 2 p }
Getting p-values for "multinom" in R (nnet package)
You can use that custom function that I`ve created, for example you can just get true or false for Hipotesis test. The TRUE ones should represent P-Value > 0,5. zWald_test <- function(x){ zWald_mode
Getting p-values for "multinom" in R (nnet package) You can use that custom function that I`ve created, for example you can just get true or false for Hipotesis test. The TRUE ones should represent P-Value > 0,5. zWald_test <- function(x){ zWald_modelo<- (summary(x)$coefficients / summary(x)$standard.errors) a <- t(apply(zWald_modelo, 1, function(x) {x < qnorm(0.025, lower.tail = FALSE)} )) b <- t(apply(zWald_modelo, 1, function(x) {x > -qnorm(0.025, lower.tail = FALSE)} )) ifelse(a==TRUE & b==TRUE, TRUE, FALSE) } or if you want to confirm the p-values you can use the following function: pValue_extract <- function(x){ z <- summary(x)$coefficients/summary(x)$standard.errors # 2-tailed Wald z tests to test significance of coefficients p <- (1 - pnorm(abs(z), 0, 1)) * 2 p }
Getting p-values for "multinom" in R (nnet package) You can use that custom function that I`ve created, for example you can just get true or false for Hipotesis test. The TRUE ones should represent P-Value > 0,5. zWald_test <- function(x){ zWald_mode
8,949
Getting p-values for "multinom" in R (nnet package)
What about using z <- summary(test)$coefficients/summary(test)$standard.errors # 2-tailed Wald z tests to test significance of coefficients p <- (1 - pnorm(abs(z), 0, 1)) * 2 p Basically, this would be based on the estimated coefficients relative to their standard error, and would use a z test to test against a significant difference with zero based on a two-tailed test. The factor of two corrects the problem Peter Dalgaard referred to above (you need it because you want a two tailed test, not a one tailed one), and it uses a z-test, rather than a t-test, to solve the other problem that you mention. You can also get the same result (Wald z-tests) using library(AER) coeftest(test) Likelihood ratio tests are generally regarded as more accurate though than Wald z tests (the latter use a normal approximation, LR tests do not), and these can be gotten using library(afex) set_sum_contrasts() # use sum coding, necessary to make type III LR tests valid library(car) Anova(test,type="III") If you would like to carry out pairwise Tukey posthoc tests, then these can be obtained using the lsmeans package as explained in my other post!
Getting p-values for "multinom" in R (nnet package)
What about using z <- summary(test)$coefficients/summary(test)$standard.errors # 2-tailed Wald z tests to test significance of coefficients p <- (1 - pnorm(abs(z), 0, 1)) * 2 p Basically, this would
Getting p-values for "multinom" in R (nnet package) What about using z <- summary(test)$coefficients/summary(test)$standard.errors # 2-tailed Wald z tests to test significance of coefficients p <- (1 - pnorm(abs(z), 0, 1)) * 2 p Basically, this would be based on the estimated coefficients relative to their standard error, and would use a z test to test against a significant difference with zero based on a two-tailed test. The factor of two corrects the problem Peter Dalgaard referred to above (you need it because you want a two tailed test, not a one tailed one), and it uses a z-test, rather than a t-test, to solve the other problem that you mention. You can also get the same result (Wald z-tests) using library(AER) coeftest(test) Likelihood ratio tests are generally regarded as more accurate though than Wald z tests (the latter use a normal approximation, LR tests do not), and these can be gotten using library(afex) set_sum_contrasts() # use sum coding, necessary to make type III LR tests valid library(car) Anova(test,type="III") If you would like to carry out pairwise Tukey posthoc tests, then these can be obtained using the lsmeans package as explained in my other post!
Getting p-values for "multinom" in R (nnet package) What about using z <- summary(test)$coefficients/summary(test)$standard.errors # 2-tailed Wald z tests to test significance of coefficients p <- (1 - pnorm(abs(z), 0, 1)) * 2 p Basically, this would
8,950
Getting p-values for "multinom" in R (nnet package)
As already said by OP (by his quote of B Ripley), wald tests is not really good for multinomial models, we really should use likelihoodratio tests. Below I show an easy way of getting that via functions from the MASS package, using an example from the help page of nnet::multinom. The workhorse function used is MASS::dropterm: > library(nnet) > example(birthwt) (bwt.mn <- multinom(low ~ . , bwt) ) brthwt> bwt <- with(birthwt, { brthwt+ race <- factor(race, labels = c("white", "black", "other")) brthwt+ ptd <- factor(ptl > 0) . . . Call: multinom(formula = low ~ ., data = bwt) Coefficients: (Intercept) age lwt raceblack raceother smokeTRUE 0.82320102 -0.03723828 -0.01565359 1.19240391 0.74065606 0.75550487 ptdTRUE htTRUE uiTRUE ftv1 ftv2+ 1.34375901 1.91320116 0.68020207 -0.43638470 0.17900392 Residual Deviance: 195.4755 AIC: 217.4755 > confint(bwt.mn) 2.5 % 97.5 % (Intercept) -1.61649875 3.262900795 age -0.11309745 0.038620883 lwt -0.02953168 -0.001775495 raceblack 0.14190092 2.242906899 raceother -0.16438896 1.645701076 smokeTRUE -0.07755089 1.588560638 ptdTRUE 0.40173272 2.285785295 htTRUE 0.50053490 3.325867418 uiTRUE -0.22990670 1.590310835 ftv1 -1.37601313 0.503243725 ftv2+ -0.71550657 1.073514417 > MASS::dropterm(bwt.mn, trace=FALSE, test="Chisq") # weights: 11 (10 variable) initial value 131.004817 iter 10 value 98.297550 . . . Single term deletions Model: low ~ age + lwt + race + smoke + ptd + ht + ui + ftv Df AIC LRT Pr(Chi) <none> 217.48 age 1 216.42 0.9419 0.331796 lwt 1 220.95 5.4739 0.019302 * race 2 219.23 5.7513 0.056380 . smoke 1 218.67 3.1982 0.073717 . ptd 1 223.58 8.1085 0.004406 ** ht 1 222.93 7.4584 0.006314 ** ui 1 217.59 2.1100 0.146342 ftv 2 214.83 1.3582 0.507077 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 There are many other ways ... but using functions from MASS together with functions from nnet seems prudent.
Getting p-values for "multinom" in R (nnet package)
As already said by OP (by his quote of B Ripley), wald tests is not really good for multinomial models, we really should use likelihoodratio tests. Below I show an easy way of getting that via functio
Getting p-values for "multinom" in R (nnet package) As already said by OP (by his quote of B Ripley), wald tests is not really good for multinomial models, we really should use likelihoodratio tests. Below I show an easy way of getting that via functions from the MASS package, using an example from the help page of nnet::multinom. The workhorse function used is MASS::dropterm: > library(nnet) > example(birthwt) (bwt.mn <- multinom(low ~ . , bwt) ) brthwt> bwt <- with(birthwt, { brthwt+ race <- factor(race, labels = c("white", "black", "other")) brthwt+ ptd <- factor(ptl > 0) . . . Call: multinom(formula = low ~ ., data = bwt) Coefficients: (Intercept) age lwt raceblack raceother smokeTRUE 0.82320102 -0.03723828 -0.01565359 1.19240391 0.74065606 0.75550487 ptdTRUE htTRUE uiTRUE ftv1 ftv2+ 1.34375901 1.91320116 0.68020207 -0.43638470 0.17900392 Residual Deviance: 195.4755 AIC: 217.4755 > confint(bwt.mn) 2.5 % 97.5 % (Intercept) -1.61649875 3.262900795 age -0.11309745 0.038620883 lwt -0.02953168 -0.001775495 raceblack 0.14190092 2.242906899 raceother -0.16438896 1.645701076 smokeTRUE -0.07755089 1.588560638 ptdTRUE 0.40173272 2.285785295 htTRUE 0.50053490 3.325867418 uiTRUE -0.22990670 1.590310835 ftv1 -1.37601313 0.503243725 ftv2+ -0.71550657 1.073514417 > MASS::dropterm(bwt.mn, trace=FALSE, test="Chisq") # weights: 11 (10 variable) initial value 131.004817 iter 10 value 98.297550 . . . Single term deletions Model: low ~ age + lwt + race + smoke + ptd + ht + ui + ftv Df AIC LRT Pr(Chi) <none> 217.48 age 1 216.42 0.9419 0.331796 lwt 1 220.95 5.4739 0.019302 * race 2 219.23 5.7513 0.056380 . smoke 1 218.67 3.1982 0.073717 . ptd 1 223.58 8.1085 0.004406 ** ht 1 222.93 7.4584 0.006314 ** ui 1 217.59 2.1100 0.146342 ftv 2 214.83 1.3582 0.507077 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 There are many other ways ... but using functions from MASS together with functions from nnet seems prudent.
Getting p-values for "multinom" in R (nnet package) As already said by OP (by his quote of B Ripley), wald tests is not really good for multinomial models, we really should use likelihoodratio tests. Below I show an easy way of getting that via functio
8,951
Getting p-values for "multinom" in R (nnet package)
Also you could be interested in Likehood Ratio test p-values, as seen here: http://thestatsgeek.com/2014/02/08/wald-vs-likelihood-ratio-test/ Wich you could extract like this (sorry, its a custom function :D) likehoodmultinom_p <- function(model_lmm) { i <- 1 variables <-c("No funciona") valores <- c("No funciona") for (var in model_lmm$coefnames[-1]) { # Qutiamos el -1 de coefnames para no obener un NA variables[i] =paste(var) valores[i]= lrtest(model_lmm, var)[[5]][2] i=i+1 ## Contributed to stack at: https://stackoverflow.com/questions/23018238/assesing-the-goodness-of-fit-for-the-multinomial-logit-in-r-with-the-nnet-packag/60835647#60835647 } return (data.frame(variables,valores)) } L_iris= likehoodmultinom_p(iris_fit) In my function you obtain a df with factors, so you maybe gotta change them a bit to extrac them. I have yet to correct my original function: L_iris= likehoodmultinom_p(iris_fit) L_iris$valores = as.character(L_iris$valores) # Pass them as chr L_iris$valores = as.numeric(L_iris$valores) # And as numeric. Then you can acces them easily. I also usually sort them in base of p-values.
Getting p-values for "multinom" in R (nnet package)
Also you could be interested in Likehood Ratio test p-values, as seen here: http://thestatsgeek.com/2014/02/08/wald-vs-likelihood-ratio-test/ Wich you could extract like this (sorry, its a custom func
Getting p-values for "multinom" in R (nnet package) Also you could be interested in Likehood Ratio test p-values, as seen here: http://thestatsgeek.com/2014/02/08/wald-vs-likelihood-ratio-test/ Wich you could extract like this (sorry, its a custom function :D) likehoodmultinom_p <- function(model_lmm) { i <- 1 variables <-c("No funciona") valores <- c("No funciona") for (var in model_lmm$coefnames[-1]) { # Qutiamos el -1 de coefnames para no obener un NA variables[i] =paste(var) valores[i]= lrtest(model_lmm, var)[[5]][2] i=i+1 ## Contributed to stack at: https://stackoverflow.com/questions/23018238/assesing-the-goodness-of-fit-for-the-multinomial-logit-in-r-with-the-nnet-packag/60835647#60835647 } return (data.frame(variables,valores)) } L_iris= likehoodmultinom_p(iris_fit) In my function you obtain a df with factors, so you maybe gotta change them a bit to extrac them. I have yet to correct my original function: L_iris= likehoodmultinom_p(iris_fit) L_iris$valores = as.character(L_iris$valores) # Pass them as chr L_iris$valores = as.numeric(L_iris$valores) # And as numeric. Then you can acces them easily. I also usually sort them in base of p-values.
Getting p-values for "multinom" in R (nnet package) Also you could be interested in Likehood Ratio test p-values, as seen here: http://thestatsgeek.com/2014/02/08/wald-vs-likelihood-ratio-test/ Wich you could extract like this (sorry, its a custom func
8,952
Getting p-values for "multinom" in R (nnet package)
One way to think about the p-value is a likelihood test that your fit is better than some simpler fit with fewer terms (or possibly no terms, the constant fit). Below is some code. # Multinomial fit fit <- nnet::multinom(cyl ~ mpg + hp, data=datasets::mtcars) # Multinomial fit with one or more terms dropped base_fit <- nnet::multinom(cyl ~ 1, data=datasets::mtcars) base_fit2 <- nnet::multinom(cyl ~ mpg, data=datasets::mtcars) # p-value that the fit is better than the base_fit result <- lmtest::lrtest(fit, base_fit) p_val1 <- result$`Pr(>Chisq)`[[2]] # p-value that the fit is better than the base_fit2 result <- lmtest::lrtest(fit, base_fit2) p_val2 <- result$`Pr(>Chisq)`[[2]] Results: > p_val1 [1] 6.250054e-14 > p_val2 [1] 0.0003148036 Apparently dropping hp makes the fit worse (p=0.0003), and dropping both mpg and hp makes it much worse (p near zero).
Getting p-values for "multinom" in R (nnet package)
One way to think about the p-value is a likelihood test that your fit is better than some simpler fit with fewer terms (or possibly no terms, the constant fit). Below is some code. # Multinomial fit
Getting p-values for "multinom" in R (nnet package) One way to think about the p-value is a likelihood test that your fit is better than some simpler fit with fewer terms (or possibly no terms, the constant fit). Below is some code. # Multinomial fit fit <- nnet::multinom(cyl ~ mpg + hp, data=datasets::mtcars) # Multinomial fit with one or more terms dropped base_fit <- nnet::multinom(cyl ~ 1, data=datasets::mtcars) base_fit2 <- nnet::multinom(cyl ~ mpg, data=datasets::mtcars) # p-value that the fit is better than the base_fit result <- lmtest::lrtest(fit, base_fit) p_val1 <- result$`Pr(>Chisq)`[[2]] # p-value that the fit is better than the base_fit2 result <- lmtest::lrtest(fit, base_fit2) p_val2 <- result$`Pr(>Chisq)`[[2]] Results: > p_val1 [1] 6.250054e-14 > p_val2 [1] 0.0003148036 Apparently dropping hp makes the fit worse (p=0.0003), and dropping both mpg and hp makes it much worse (p near zero).
Getting p-values for "multinom" in R (nnet package) One way to think about the p-value is a likelihood test that your fit is better than some simpler fit with fewer terms (or possibly no terms, the constant fit). Below is some code. # Multinomial fit
8,953
How to use early stopping properly for training deep neural network?
What would be a good validation frequency? Should I check my model on the validation data at the end of each epoch? (My batch size is 1) There is no gold rule, computing the validation error after each epoch is quite common. Since your validation set much smaller than your training set, it will not slow down the training much. Is it the case that the first few epochs might yield worse result before it starts converging to better value? yes In that case, should we train our network for several epochs before checking for early stopping? You could, but then the issue is how many epochs should you skip. So in practice, most of the time people do not skip any epoch. How to handle the case when the validation loss might go up and down? In that case, early stopping might prevent my model from learning further, right? People typically define a patience, i.e. the number of epochs to wait before early stop if no progress on the validation set. The patience is often set somewhere between 10 and 100 (10 or 20 is more common), but it really depends on your dataset and network. Example with patience = 10:
How to use early stopping properly for training deep neural network?
What would be a good validation frequency? Should I check my model on the validation data at the end of each epoch? (My batch size is 1) There is no gold rule, computing the validation error after ea
How to use early stopping properly for training deep neural network? What would be a good validation frequency? Should I check my model on the validation data at the end of each epoch? (My batch size is 1) There is no gold rule, computing the validation error after each epoch is quite common. Since your validation set much smaller than your training set, it will not slow down the training much. Is it the case that the first few epochs might yield worse result before it starts converging to better value? yes In that case, should we train our network for several epochs before checking for early stopping? You could, but then the issue is how many epochs should you skip. So in practice, most of the time people do not skip any epoch. How to handle the case when the validation loss might go up and down? In that case, early stopping might prevent my model from learning further, right? People typically define a patience, i.e. the number of epochs to wait before early stop if no progress on the validation set. The patience is often set somewhere between 10 and 100 (10 or 20 is more common), but it really depends on your dataset and network. Example with patience = 10:
How to use early stopping properly for training deep neural network? What would be a good validation frequency? Should I check my model on the validation data at the end of each epoch? (My batch size is 1) There is no gold rule, computing the validation error after ea
8,954
How to use early stopping properly for training deep neural network?
To add to other excellent answers, you can also - not stop. I usually: run NN for far more time I would have thought is sensible, save the model weights every N epochs, and when I see the training loss has stabilized, I just pick the model with lowest validation loss. Of course that only makes sense when you don't pay by minute (or the cost is small enough) and when you can stop the training manually. The upside is that it is far easier to determine lowest validation error in hindsight.
How to use early stopping properly for training deep neural network?
To add to other excellent answers, you can also - not stop. I usually: run NN for far more time I would have thought is sensible, save the model weights every N epochs, and when I see the training lo
How to use early stopping properly for training deep neural network? To add to other excellent answers, you can also - not stop. I usually: run NN for far more time I would have thought is sensible, save the model weights every N epochs, and when I see the training loss has stabilized, I just pick the model with lowest validation loss. Of course that only makes sense when you don't pay by minute (or the cost is small enough) and when you can stop the training manually. The upside is that it is far easier to determine lowest validation error in hindsight.
How to use early stopping properly for training deep neural network? To add to other excellent answers, you can also - not stop. I usually: run NN for far more time I would have thought is sensible, save the model weights every N epochs, and when I see the training lo
8,955
Sandwich estimator intuition
For OLS, you can imagine that you're using the estimated variance of the residuals (under the assumption of independence and homoscedasticity) as an estimate for the conditional variance of the $Y_i$s. In the sandwich based estimator, you're using the observed squared residuals as a plug-in estimate of the same variance which can vary between observations. \begin{equation} \mbox{var}\left(\hat{\beta}\right) = \left(X^TX\right)^{-1}\left(X^T\mbox{diag}\left(\mbox{var}\left(Y|X\right)\right)X\right)\left(X^TX\right)^{-1} \end{equation} In the ordinary least squares standard error estimate for the regression coefficient estimate, the conditional variance of the outcome is treated as constant and independent, so that it can be estimated consistently. \begin{equation} \widehat{\mbox{var}}_{OLS}\left(\hat{\beta}\right) = \left(X^TX\right)^{-1}\left(r^2X^TX\right)\left(X^TX\right)^{-1} \end{equation} For the sandwich, we eschew consistent estimation of the conditional variance and instead use a plug-in estimate of the variance of each component using the squared residual \begin{equation} \widehat{\mbox{var}}_{RSE}\left(\hat{\beta}\right) = \left(X^TX\right)^{-1}\left(X^T\mbox{diag}\left(r_i^2\right)X\right)\left(X^TX\right)^{-1} \end{equation} By using the plug-in variance estimate, we get consistent estimates of the variance of $\hat{\beta}$ by the Lyapunov Central Limit Theorem. Intuitively, these observed squared residuals will mop up any unexplained error due to heteroscedasticity that would have otherwise been unexpected under the assumption of constant variance.
Sandwich estimator intuition
For OLS, you can imagine that you're using the estimated variance of the residuals (under the assumption of independence and homoscedasticity) as an estimate for the conditional variance of the $Y_i$s
Sandwich estimator intuition For OLS, you can imagine that you're using the estimated variance of the residuals (under the assumption of independence and homoscedasticity) as an estimate for the conditional variance of the $Y_i$s. In the sandwich based estimator, you're using the observed squared residuals as a plug-in estimate of the same variance which can vary between observations. \begin{equation} \mbox{var}\left(\hat{\beta}\right) = \left(X^TX\right)^{-1}\left(X^T\mbox{diag}\left(\mbox{var}\left(Y|X\right)\right)X\right)\left(X^TX\right)^{-1} \end{equation} In the ordinary least squares standard error estimate for the regression coefficient estimate, the conditional variance of the outcome is treated as constant and independent, so that it can be estimated consistently. \begin{equation} \widehat{\mbox{var}}_{OLS}\left(\hat{\beta}\right) = \left(X^TX\right)^{-1}\left(r^2X^TX\right)\left(X^TX\right)^{-1} \end{equation} For the sandwich, we eschew consistent estimation of the conditional variance and instead use a plug-in estimate of the variance of each component using the squared residual \begin{equation} \widehat{\mbox{var}}_{RSE}\left(\hat{\beta}\right) = \left(X^TX\right)^{-1}\left(X^T\mbox{diag}\left(r_i^2\right)X\right)\left(X^TX\right)^{-1} \end{equation} By using the plug-in variance estimate, we get consistent estimates of the variance of $\hat{\beta}$ by the Lyapunov Central Limit Theorem. Intuitively, these observed squared residuals will mop up any unexplained error due to heteroscedasticity that would have otherwise been unexpected under the assumption of constant variance.
Sandwich estimator intuition For OLS, you can imagine that you're using the estimated variance of the residuals (under the assumption of independence and homoscedasticity) as an estimate for the conditional variance of the $Y_i$s
8,956
Clustering variables based on correlations between them
Here's a simple example in R using the bfi dataset: bfi is a dataset of 25 personality test items organised around 5 factors. library(psych) data(bfi) x <- bfi A hiearchical cluster analysis using the euclidan distance between variables based on the absolute correlation between variables can be obtained like so: plot(hclust(dist(abs(cor(na.omit(x)))))) The dendrogram shows how items generally cluster with other items according to theorised groupings (e.g., N (Neuroticism) items group together). It also shows how some items within clusters are more similar (e.g., C5 and C1 might be more similar than C5 with C3). It also suggests that the N cluster is less similar to other clusters. Alternatively you could do a standard factor analysis like so: factanal(na.omit(x), 5, rotation = "Promax") Uniquenesses: A1 A2 A3 A4 A5 C1 C2 C3 C4 C5 E1 E2 E3 E4 E5 N1 0.848 0.630 0.642 0.829 0.442 0.566 0.635 0.572 0.504 0.603 0.541 0.457 0.541 0.420 0.549 0.272 N2 N3 N4 N5 O1 O2 O3 O4 O5 0.321 0.526 0.514 0.675 0.625 0.804 0.544 0.630 0.814 Loadings: Factor1 Factor2 Factor3 Factor4 Factor5 A1 0.242 -0.154 -0.253 -0.164 A2 0.570 A3 -0.100 0.522 0.114 A4 0.137 0.351 -0.158 A5 -0.145 0.691 C1 0.630 0.184 C2 0.131 0.120 0.603 C3 0.154 0.638 C4 0.167 -0.656 C5 0.149 -0.571 0.125 E1 0.618 0.125 -0.210 -0.120 E2 0.665 -0.204 E3 -0.404 0.332 0.289 E4 -0.506 0.555 -0.155 E5 0.175 -0.525 0.234 0.228 N1 0.879 -0.150 N2 0.875 -0.152 N3 0.658 N4 0.406 0.342 -0.148 0.196 N5 0.471 0.253 0.140 -0.101 O1 -0.108 0.595 O2 -0.145 0.421 0.125 0.199 O3 -0.204 0.605 O4 0.244 0.548 O5 0.139 0.177 -0.441 Factor1 Factor2 Factor3 Factor4 Factor5 SS loadings 2.610 2.138 2.075 1.899 1.570 Proportion Var 0.104 0.086 0.083 0.076 0.063 Cumulative Var 0.104 0.190 0.273 0.349 0.412 Test of the hypothesis that 5 factors are sufficient. The chi square statistic is 767.57 on 185 degrees of freedom. The p-value is 5.93e-72
Clustering variables based on correlations between them
Here's a simple example in R using the bfi dataset: bfi is a dataset of 25 personality test items organised around 5 factors. library(psych) data(bfi) x <- bfi A hiearchical cluster analysis using t
Clustering variables based on correlations between them Here's a simple example in R using the bfi dataset: bfi is a dataset of 25 personality test items organised around 5 factors. library(psych) data(bfi) x <- bfi A hiearchical cluster analysis using the euclidan distance between variables based on the absolute correlation between variables can be obtained like so: plot(hclust(dist(abs(cor(na.omit(x)))))) The dendrogram shows how items generally cluster with other items according to theorised groupings (e.g., N (Neuroticism) items group together). It also shows how some items within clusters are more similar (e.g., C5 and C1 might be more similar than C5 with C3). It also suggests that the N cluster is less similar to other clusters. Alternatively you could do a standard factor analysis like so: factanal(na.omit(x), 5, rotation = "Promax") Uniquenesses: A1 A2 A3 A4 A5 C1 C2 C3 C4 C5 E1 E2 E3 E4 E5 N1 0.848 0.630 0.642 0.829 0.442 0.566 0.635 0.572 0.504 0.603 0.541 0.457 0.541 0.420 0.549 0.272 N2 N3 N4 N5 O1 O2 O3 O4 O5 0.321 0.526 0.514 0.675 0.625 0.804 0.544 0.630 0.814 Loadings: Factor1 Factor2 Factor3 Factor4 Factor5 A1 0.242 -0.154 -0.253 -0.164 A2 0.570 A3 -0.100 0.522 0.114 A4 0.137 0.351 -0.158 A5 -0.145 0.691 C1 0.630 0.184 C2 0.131 0.120 0.603 C3 0.154 0.638 C4 0.167 -0.656 C5 0.149 -0.571 0.125 E1 0.618 0.125 -0.210 -0.120 E2 0.665 -0.204 E3 -0.404 0.332 0.289 E4 -0.506 0.555 -0.155 E5 0.175 -0.525 0.234 0.228 N1 0.879 -0.150 N2 0.875 -0.152 N3 0.658 N4 0.406 0.342 -0.148 0.196 N5 0.471 0.253 0.140 -0.101 O1 -0.108 0.595 O2 -0.145 0.421 0.125 0.199 O3 -0.204 0.605 O4 0.244 0.548 O5 0.139 0.177 -0.441 Factor1 Factor2 Factor3 Factor4 Factor5 SS loadings 2.610 2.138 2.075 1.899 1.570 Proportion Var 0.104 0.086 0.083 0.076 0.063 Cumulative Var 0.104 0.190 0.273 0.349 0.412 Test of the hypothesis that 5 factors are sufficient. The chi square statistic is 767.57 on 185 degrees of freedom. The p-value is 5.93e-72
Clustering variables based on correlations between them Here's a simple example in R using the bfi dataset: bfi is a dataset of 25 personality test items organised around 5 factors. library(psych) data(bfi) x <- bfi A hiearchical cluster analysis using t
8,957
Clustering variables based on correlations between them
When Clustering Correlations it is important not to calculate the distance twice. When you take the correlation matrix you are in essence making a distance calculation. You will want to convert it to a true distance by taking 1 - the absolute value. 1-abs(cor(x)) When you go to convert this matrix to a distance object, if you utilize the dist function you will be taking the distances between your correlations. Instead you want to use the as.dist() function which will simply transform your pre-calculated distances into a into a "dist" object. Applying this method to the Alglim example library(psych) data(bfi) x <- bfi plot(hclust(as.dist(1-abs(cor(na.omit(x)))))) results in a different dendroggram
Clustering variables based on correlations between them
When Clustering Correlations it is important not to calculate the distance twice. When you take the correlation matrix you are in essence making a distance calculation. You will want to convert it t
Clustering variables based on correlations between them When Clustering Correlations it is important not to calculate the distance twice. When you take the correlation matrix you are in essence making a distance calculation. You will want to convert it to a true distance by taking 1 - the absolute value. 1-abs(cor(x)) When you go to convert this matrix to a distance object, if you utilize the dist function you will be taking the distances between your correlations. Instead you want to use the as.dist() function which will simply transform your pre-calculated distances into a into a "dist" object. Applying this method to the Alglim example library(psych) data(bfi) x <- bfi plot(hclust(as.dist(1-abs(cor(na.omit(x)))))) results in a different dendroggram
Clustering variables based on correlations between them When Clustering Correlations it is important not to calculate the distance twice. When you take the correlation matrix you are in essence making a distance calculation. You will want to convert it t
8,958
What is the oracle property of an estimator?
An oracle knows the truth: it knows the true subset and is willing to act on it. The oracle property is that the asymptotic distribution of the estimator is the same as the asymptotic distribution of the MLE on only the true support. That is, the estimator adapts to knowing the true support without paying a price (in terms of the asymptotic distribution.) By the asymptotic optimality properties of the MLE discussed in, for instance, Keener's theoretical statistics in theorem 9.14, we know, under some technical conditions which hold when, for instance, the error is Gaussian, that $$\sqrt{n} \left( \hat\beta_S - \beta^*_S \right) \to \mathcal{N} (0, I^{-1}(\beta^*_S)),$$ where we assume that $\beta^*_S$ is the true coefficient on the true support $S$. Notice that the variance of the asymptotic distribution is the inverse of the Fisher information, showing that $\hat\beta_S$ is asymptotically efficient. Since the MLE knowing the true support achieves this, it is also required as part of the oracle property. However, we do pay a steep nonasymptotic price: see, for instance, Hannes Leeb, Benedikt M. Pötscher, Sparse estimators and the oracle property, or the return of Hodges’ estimator, Journal of Econometrics, Volume 142, Issue 1, 2008, Pages 201-211, which shows that the risk of any "oracle estimator" (in the sense of Fan and Li, 2001) has a supremum which diverges to infinity.
What is the oracle property of an estimator?
An oracle knows the truth: it knows the true subset and is willing to act on it. The oracle property is that the asymptotic distribution of the estimator is the same as the asymptotic distribution of
What is the oracle property of an estimator? An oracle knows the truth: it knows the true subset and is willing to act on it. The oracle property is that the asymptotic distribution of the estimator is the same as the asymptotic distribution of the MLE on only the true support. That is, the estimator adapts to knowing the true support without paying a price (in terms of the asymptotic distribution.) By the asymptotic optimality properties of the MLE discussed in, for instance, Keener's theoretical statistics in theorem 9.14, we know, under some technical conditions which hold when, for instance, the error is Gaussian, that $$\sqrt{n} \left( \hat\beta_S - \beta^*_S \right) \to \mathcal{N} (0, I^{-1}(\beta^*_S)),$$ where we assume that $\beta^*_S$ is the true coefficient on the true support $S$. Notice that the variance of the asymptotic distribution is the inverse of the Fisher information, showing that $\hat\beta_S$ is asymptotically efficient. Since the MLE knowing the true support achieves this, it is also required as part of the oracle property. However, we do pay a steep nonasymptotic price: see, for instance, Hannes Leeb, Benedikt M. Pötscher, Sparse estimators and the oracle property, or the return of Hodges’ estimator, Journal of Econometrics, Volume 142, Issue 1, 2008, Pages 201-211, which shows that the risk of any "oracle estimator" (in the sense of Fan and Li, 2001) has a supremum which diverges to infinity.
What is the oracle property of an estimator? An oracle knows the truth: it knows the true subset and is willing to act on it. The oracle property is that the asymptotic distribution of the estimator is the same as the asymptotic distribution of
8,959
What is the oracle property of an estimator?
The definition of Oracle property is related highly to the context. The very short but precise answer in linear regression (precisely high dimensional one) is this: an oracle estimator must be consistent in parameter estimation and variable selection. Notice that an estimator that is consistent in variable selection is not necessarily consistent in parameter estimation. See adaptive lasso paper for mathematical definitions or simply see this slides.
What is the oracle property of an estimator?
The definition of Oracle property is related highly to the context. The very short but precise answer in linear regression (precisely high dimensional one) is this: an oracle estimator must be consis
What is the oracle property of an estimator? The definition of Oracle property is related highly to the context. The very short but precise answer in linear regression (precisely high dimensional one) is this: an oracle estimator must be consistent in parameter estimation and variable selection. Notice that an estimator that is consistent in variable selection is not necessarily consistent in parameter estimation. See adaptive lasso paper for mathematical definitions or simply see this slides.
What is the oracle property of an estimator? The definition of Oracle property is related highly to the context. The very short but precise answer in linear regression (precisely high dimensional one) is this: an oracle estimator must be consis
8,960
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox?
In short: 1:0 for Yudkowsky. Cosma Shalizi considers a probability distribution subjected to some measurements. He updates the probabilities accordingly (here it is not important if it is the Bayensian inference or anything else). No surprising at all, the entropy of the probability distribution decreases. However, he makes a wrong conclusion that it says something about the arrow of time: These assumptions reverse the arrow of time, i.e., they make entropy non-increasing. As it was pointed out in comments, what matters to thermodynamics, is the entropy of a closed system. That is, according to the second law of thermodynamics, entropy of a closed system cannot decrease. It says nothing about the entropy of a subsystem (or an open system); otherwise you couldn't use your fridge. And once we measure sth (i.e. interact and gather information) it is not a closed system anymore. Either we cannot use the second law, or - we need to consider a closed system made of the measured system and the observer (i.e. ourselves). In particular, when we measure the exact state of a particle (while before we knew its distribution), indeed we lower its entropy. However, to store the information we need to increase our entropy by at least the same amount (typically there is huge overhead). So Eliezer Yudkowsky makes a good point: 1) Measurements use work (or at least erasure in preparation for the next measurement uses work). Actually, the remark about work is not the most important here. While the thermodynamics is about relating (or trading) entropy to energy, you can get around (i.e. we don't need to resort to Landauer's principle, of which Shalizi is skeptical). To gather some new information you need to erase the previous information. To be consistent with classical mechanics (and quantum as well), you cannot make a function arbitrarily mapping anything to all zeros (with no side effects). You can make a function mapping your memory to all zero, but at the same time dumping the information somewhere, which effectively increases the entropy of the environment. (The above originates from Hamiltonian dynamics - i.e. preservation of the phase space in the classical case, and unitarity of evolution in the quantum case.) PS: A trick for today - "reducing entropy": Flip an unbiased coin, but don't look at the result ($H = 1$ bit). Open your eyes. Now you know its state, so its entropy is $H = 0$ bits.
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox?
In short: 1:0 for Yudkowsky. Cosma Shalizi considers a probability distribution subjected to some measurements. He updates the probabilities accordingly (here it is not important if it is the Bayensia
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox? In short: 1:0 for Yudkowsky. Cosma Shalizi considers a probability distribution subjected to some measurements. He updates the probabilities accordingly (here it is not important if it is the Bayensian inference or anything else). No surprising at all, the entropy of the probability distribution decreases. However, he makes a wrong conclusion that it says something about the arrow of time: These assumptions reverse the arrow of time, i.e., they make entropy non-increasing. As it was pointed out in comments, what matters to thermodynamics, is the entropy of a closed system. That is, according to the second law of thermodynamics, entropy of a closed system cannot decrease. It says nothing about the entropy of a subsystem (or an open system); otherwise you couldn't use your fridge. And once we measure sth (i.e. interact and gather information) it is not a closed system anymore. Either we cannot use the second law, or - we need to consider a closed system made of the measured system and the observer (i.e. ourselves). In particular, when we measure the exact state of a particle (while before we knew its distribution), indeed we lower its entropy. However, to store the information we need to increase our entropy by at least the same amount (typically there is huge overhead). So Eliezer Yudkowsky makes a good point: 1) Measurements use work (or at least erasure in preparation for the next measurement uses work). Actually, the remark about work is not the most important here. While the thermodynamics is about relating (or trading) entropy to energy, you can get around (i.e. we don't need to resort to Landauer's principle, of which Shalizi is skeptical). To gather some new information you need to erase the previous information. To be consistent with classical mechanics (and quantum as well), you cannot make a function arbitrarily mapping anything to all zeros (with no side effects). You can make a function mapping your memory to all zero, but at the same time dumping the information somewhere, which effectively increases the entropy of the environment. (The above originates from Hamiltonian dynamics - i.e. preservation of the phase space in the classical case, and unitarity of evolution in the quantum case.) PS: A trick for today - "reducing entropy": Flip an unbiased coin, but don't look at the result ($H = 1$ bit). Open your eyes. Now you know its state, so its entropy is $H = 0$ bits.
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox? In short: 1:0 for Yudkowsky. Cosma Shalizi considers a probability distribution subjected to some measurements. He updates the probabilities accordingly (here it is not important if it is the Bayensia
8,961
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox?
Shalizi's flaw is very basic and derives from assumption I, that the time evolution is invertible (reversible). The time evolution of INDIVIDUAL states is reversible. The time evolution of a distribution over ALL OF PHASE SPACE is most certainly not reversible, unless the system is in equilibrium. The paper treats time-evolution of distributions over all of phase space, not that of individual states, and so the assumption of invertibility is totally unphysical. In the equilibrium case, the results are trivial. The arrow of time comes from this fact, actually, that time evolution of distributions are not reversible (the reason gradients run down and gases spread out). The irreversibility is known to emerge out of 'collision terms' If you take this into account, his argument falls apart. Information entropy = thermodynamic entropy, still, for now. :D
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox?
Shalizi's flaw is very basic and derives from assumption I, that the time evolution is invertible (reversible). The time evolution of INDIVIDUAL states is reversible. The time evolution of a distribu
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox? Shalizi's flaw is very basic and derives from assumption I, that the time evolution is invertible (reversible). The time evolution of INDIVIDUAL states is reversible. The time evolution of a distribution over ALL OF PHASE SPACE is most certainly not reversible, unless the system is in equilibrium. The paper treats time-evolution of distributions over all of phase space, not that of individual states, and so the assumption of invertibility is totally unphysical. In the equilibrium case, the results are trivial. The arrow of time comes from this fact, actually, that time evolution of distributions are not reversible (the reason gradients run down and gases spread out). The irreversibility is known to emerge out of 'collision terms' If you take this into account, his argument falls apart. Information entropy = thermodynamic entropy, still, for now. :D
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox? Shalizi's flaw is very basic and derives from assumption I, that the time evolution is invertible (reversible). The time evolution of INDIVIDUAL states is reversible. The time evolution of a distribu
8,962
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox?
The linked paper explicitly assumes that The evolution operator T is invertible. But if you use QM in the conventional way, then this assumption doesn't hold. Suppose you have a state X1 which can evolve into either X2 or X3 with equal probability. You would say that state X1 evolves into the weighted set [1/2 X2 + 1/2 X3]. Shalizi proves that this set has no more entropy than X1 did. But we, as observers or as part of that system, only get to look at one of the branches, either X2 or X3. Picking which of those two branches we get to look at adds one bit of new entropy, and this selection is not invertible. This is where the increase in entropy with time comes from. What Shalizi has done, is to use math in which all entropy originates in quantum branching, then forget that quantum branching happens.
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox?
The linked paper explicitly assumes that The evolution operator T is invertible. But if you use QM in the conventional way, then this assumption doesn't hold. Suppose you have a state X1 which can e
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox? The linked paper explicitly assumes that The evolution operator T is invertible. But if you use QM in the conventional way, then this assumption doesn't hold. Suppose you have a state X1 which can evolve into either X2 or X3 with equal probability. You would say that state X1 evolves into the weighted set [1/2 X2 + 1/2 X3]. Shalizi proves that this set has no more entropy than X1 did. But we, as observers or as part of that system, only get to look at one of the branches, either X2 or X3. Picking which of those two branches we get to look at adds one bit of new entropy, and this selection is not invertible. This is where the increase in entropy with time comes from. What Shalizi has done, is to use math in which all entropy originates in quantum branching, then forget that quantum branching happens.
Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox? The linked paper explicitly assumes that The evolution operator T is invertible. But if you use QM in the conventional way, then this assumption doesn't hold. Suppose you have a state X1 which can e
8,963
Choosing among proper scoring rules
Why would someone use one of these rather than logarithmic scoring? So ideally, we always distinguish fitting a model from making a decision. In Bayesian methodology, model scoring & selection should always be done using the marginal likelihood. You then use the model to make probabilistic predictions, and your loss function tells you how to act on those predictions. Unfortunately in the real world, computational performance often dictates that we conflate the model-selection and the decision-making and so use a loss function to fit our models. This is where subjectivity in model selection creeps in, because you've got to guess just how much different kinds of mistake will cost you. The classic example is a diagnostic for cancer: overestimating someone's probability of cancer is not good, but underestimating it is much worse. As an aside, if you're looking for guidance on how to pick a scoring rule, you might also want to look for guidance on picking a loss function or designing a utility function, as I think the literature on those two topics is a lot more voluminous.
Choosing among proper scoring rules
Why would someone use one of these rather than logarithmic scoring? So ideally, we always distinguish fitting a model from making a decision. In Bayesian methodology, model scoring & selection should
Choosing among proper scoring rules Why would someone use one of these rather than logarithmic scoring? So ideally, we always distinguish fitting a model from making a decision. In Bayesian methodology, model scoring & selection should always be done using the marginal likelihood. You then use the model to make probabilistic predictions, and your loss function tells you how to act on those predictions. Unfortunately in the real world, computational performance often dictates that we conflate the model-selection and the decision-making and so use a loss function to fit our models. This is where subjectivity in model selection creeps in, because you've got to guess just how much different kinds of mistake will cost you. The classic example is a diagnostic for cancer: overestimating someone's probability of cancer is not good, but underestimating it is much worse. As an aside, if you're looking for guidance on how to pick a scoring rule, you might also want to look for guidance on picking a loss function or designing a utility function, as I think the literature on those two topics is a lot more voluminous.
Choosing among proper scoring rules Why would someone use one of these rather than logarithmic scoring? So ideally, we always distinguish fitting a model from making a decision. In Bayesian methodology, model scoring & selection should
8,964
Choosing among proper scoring rules
(as to my intuition) the less the difference between predicted & actual - the more precise the forecast is. Just for the purpose of maximization of differencies - different scores are used - either log (log-loss) or difference between squares (Brier score). Everything is obvious in the mathematical formulation of the score & your needs: e.g. if you consider the bigger difference between forcasted & actual value to be the bigger errorness you'd like to take into account - of course, you'll choose log-loss, if any error (independently of size) is error for your purposes - of course, you can see Brier score (in any case, Brier score is for binary categorical outcomes -- and even in multiclass classification you will use one-vs-rest binary comparison logics). Here can see figures for log-loss & Brier. And here three properties a scoring rule should have. Sometimes for your purposes you can even choose improper scoring rules - it's up to the purpose of your classification You can always pick any loss_function (or cost function) or even design your own appropriate for the purposes of your estimator in training step && evaluating scores in testing step is just a mathematical formulation of how good the points are forecasted. This goodness you evaluate according this mathematical formulation - chosen according the nature of outcomes (numerical or categorical, but discrete anyway for classification) P.S. In statistics: statistical estimation should be unbiased, effective, careful. And Variance Components used in estimation include: Continuous dependent - Dependent, Categorical dependent - Random effects, Categorical predictors - Fixed effects, Continuous predictors - Covariates, .. and their interactions. So, In probability theory applied to statistically meaningful data I prefer to follow the same rules for scoring: unbiased, effective, careful -- though it is really not so easy to develop such model [for any distribution of features given, much depends on the size of sample and its inner variation for comprehensive modelling] -- applied mathematics, I think, should help in designing appropriate loss-functions & scores based on them (just for your task's objectivity & convenience). ALSO the choice of score can depend on the nature of process you explore: either stochastic or deterministic or dynamic, I think. You should be aware of either you need probabilistic or deterministic model based on your task. With first you can input in loss (or/and score) the size of errorness, with second you need just any score for binary outcomes, with third even improper naive linear score would be enough for me sometimes Anyway, with statistically meaningful data (feature engineered & selected correctly) modelling becomes easier & scores simplier are affordable
Choosing among proper scoring rules
(as to my intuition) the less the difference between predicted & actual - the more precise the forecast is. Just for the purpose of maximization of differencies - different scores are used - either lo
Choosing among proper scoring rules (as to my intuition) the less the difference between predicted & actual - the more precise the forecast is. Just for the purpose of maximization of differencies - different scores are used - either log (log-loss) or difference between squares (Brier score). Everything is obvious in the mathematical formulation of the score & your needs: e.g. if you consider the bigger difference between forcasted & actual value to be the bigger errorness you'd like to take into account - of course, you'll choose log-loss, if any error (independently of size) is error for your purposes - of course, you can see Brier score (in any case, Brier score is for binary categorical outcomes -- and even in multiclass classification you will use one-vs-rest binary comparison logics). Here can see figures for log-loss & Brier. And here three properties a scoring rule should have. Sometimes for your purposes you can even choose improper scoring rules - it's up to the purpose of your classification You can always pick any loss_function (or cost function) or even design your own appropriate for the purposes of your estimator in training step && evaluating scores in testing step is just a mathematical formulation of how good the points are forecasted. This goodness you evaluate according this mathematical formulation - chosen according the nature of outcomes (numerical or categorical, but discrete anyway for classification) P.S. In statistics: statistical estimation should be unbiased, effective, careful. And Variance Components used in estimation include: Continuous dependent - Dependent, Categorical dependent - Random effects, Categorical predictors - Fixed effects, Continuous predictors - Covariates, .. and their interactions. So, In probability theory applied to statistically meaningful data I prefer to follow the same rules for scoring: unbiased, effective, careful -- though it is really not so easy to develop such model [for any distribution of features given, much depends on the size of sample and its inner variation for comprehensive modelling] -- applied mathematics, I think, should help in designing appropriate loss-functions & scores based on them (just for your task's objectivity & convenience). ALSO the choice of score can depend on the nature of process you explore: either stochastic or deterministic or dynamic, I think. You should be aware of either you need probabilistic or deterministic model based on your task. With first you can input in loss (or/and score) the size of errorness, with second you need just any score for binary outcomes, with third even improper naive linear score would be enough for me sometimes Anyway, with statistically meaningful data (feature engineered & selected correctly) modelling becomes easier & scores simplier are affordable
Choosing among proper scoring rules (as to my intuition) the less the difference between predicted & actual - the more precise the forecast is. Just for the purpose of maximization of differencies - different scores are used - either lo
8,965
Extending the birthday paradox to more than 2 people
This is a counting problem: there are $b^n$ possible assignments of $b$ birthdays to $n$ people. Of those, let $q(k; n, b)$ be the number of assignments for which no birthday is shared by more than $k$ people but at least one birthday actually is shared by $k$ people. The probability we seek can be found by summing the $q(k;n,b)$ for appropriate values of $k$ and multiplying the result by $b^{-n}$. These counts can be found exactly for values of $n$ less than several hundred. However, they will not follow any straightforward formula: we have to consider the patterns of ways in which birthdays can be assigned. I will illustrate this in lieu of providing a general demonstration. Let $n = 4$ (this is the smallest interesting situation). The possibilities are: Each person has a unique birthday; the code is {4}. Exactly two people share a birthday; the code is {2,1}. Two people have one birthday and the other two have another; the code is {0,2}. Three people share a birthday; the code is {1,0,1}. Four people share a birthday; the code is {0,0,0,1}. Generally, the code $\{a[1], a[2], \ldots\}$ is a tuple of counts whose $k^\text{th}$ element stipulates how many distinct birthdates are shared by exactly $k$ people. Thus, in particular, $$1 a[1] + 2a[2] + ... + k a[k] + \ldots = n.$$ Note, even in this simple case, that there are two ways in which the maximum of two people per birthday is attained: one with the code $\{0,2\}$ and another with the code $\{2,1\}$. We can directly count the number of possible birthday assignments corresponding to any given code. This number is the product of three terms. One is a multinomial coefficient; it counts the number of ways of partitioning $n$ people into $a[1]$ groups of $1$, $a[2]$ groups of $2$, and so on. Because the sequence of groups does not matter, we have to divide this multinomial coefficient by $a[1]!a[2]!\cdots$; its reciprocal is the second term. Finally, line up the groups and assign them each a birthday: there are $b$ candidates for the first group, $b-1$ for the second, and so on. These values have to be multiplied together, forming the third term. It is equal to the "factorial product" $b^{(a[1]+a[2]+\cdots)}$ where $b^{(m)}$ means $b(b-1)\cdots(b-m+1)$. There is an obvious and fairly simple recursion relating the count for a pattern $\{a[1], \ldots, a[k]\}$ to the count for the pattern $\{a[1], \ldots, a[k-1]\}$. This enables rapid calculation of the counts for modest values of $n$. Specifically, $a[k]$ represents $a[k]$ birthdates shared by exactly $k$ people each. After these $a[k]$ groups of $k$ people have been drawn from the $n$ people, which can be done in $x$ distinct ways (say), it remains to count the number of ways of achieving the pattern $\{a[1], \ldots, a[k-1]\}$ among the remaining people. Multiplying this by $x$ gives the recursion. I doubt there is a closed form formula for $q(k; n, b)$, which is obtained by summing the counts for all partitions of $n$ whose maximum term equals $k$. Let me offer some examples: With $b=5$ (five possible birthdays) and $n=4$ (four people), we obtain $$\eqalign{ q(1) &= q(1;4,5) &= 120 \\ q(2) &= 360 + 60 &= 420 \\ q(3) &&= 80 \\ q(4) &&= 5.\\ }$$ Whence, for example, the chance that three or more people out of four share the same "birthday" (out of $5$ possible dates) equals $(80 + 5)/625 = 0.136$. As another example, take $b = 365$ and $n = 23$. Here are the values of $q( k;23,365)$ for the smallest $k$ (to six sig figs only): $$\eqalign{ k=1: &0.49270 \\ k=2: &0.494592 \\ k=3: &0.0125308 \\ k=4: &0.000172844 \\ k=5: &1.80449E-6 \\ k=6: &1.48722E-8 \\ k=7: &9.92255E-11 \\ k=8: &5.45195E-13. }$$ Using this technique, we can readily compute that there is about a 50% chance of (at least) a three-way birthday collision among 87 people, a 50% chance of a four-way collision among 187, and a 50% chance of a five-way collision among 310 people. That last calculation starts taking a few seconds (in Mathematica, anyway) because the number of partitions to consider starts getting large. For substantially larger $n$ we need an approximation. One approximation is obtained by means of the Poisson distribution with expectation $n/b$, because we can view a birthday assignment as arising from $b$ almost (but not quite) independent Poisson variables each with expectation $n/b$: the variable for any given possible birthday describes how many of the $n$ people have that birthday. The distribution of the maximum is therefore approximately $F(k)^b$ where $F$ is the Poisson CDF. This is not a rigorous argument, so let's do a little testing. The approximation for $n = 23$, $b = 365$ gives $$\eqalign{ k=1: &0.498783 \\ k=2: &0.496803\\ k=3: &0.014187\\ k=4: &0.000225115. }$$ By comparing with the preceding you can see that the relative probabilities can be poor when they are small, but the absolute probabilities are reasonably well approximated to about 0.5%. Testing with a wide range of $n$ and $b$ suggests the approximation is usually about this good. To wrap up, let's consider the original question: take $n = 10,000$ (the number of observations) and $b = 1\,000\,000$ (the number of possible "structures," approximately). The approximate distribution for the maximum number of "shared birthdays" is $$\eqalign{ k=1: &0 \\ k=2: &0.8475+\\ k=3: &0.1520+\\ k=4: &0.0004+\\ k\gt 4: &\lt 1E-6. }$$ (This is a fast calculation.) Clearly, observing one structure 10 times out of 10,000 would be highly significant. Because $n$ and $b$ are both large, I expect the approximation to work quite well here. Incidentally, as Shane intimated, simulations can provide useful checks. A Mathematica simulation is created with a function like simulate[n_, b_] := Max[Last[Transpose[Tally[RandomInteger[{0, b - 1}, n]]]]]; which is then iterated and summarized, as in this example which runs 10,000 iterations of the $n = 10000$, $b = 1\,000\,000$ case: Tally[Table[simulate[10000, 1000000], {n, 1, 10000}]] // TableForm Its output is 2 8503 3 1493 4 4 These frequencies closely agree with those predicted by the Poisson approximation.
Extending the birthday paradox to more than 2 people
This is a counting problem: there are $b^n$ possible assignments of $b$ birthdays to $n$ people. Of those, let $q(k; n, b)$ be the number of assignments for which no birthday is shared by more than $
Extending the birthday paradox to more than 2 people This is a counting problem: there are $b^n$ possible assignments of $b$ birthdays to $n$ people. Of those, let $q(k; n, b)$ be the number of assignments for which no birthday is shared by more than $k$ people but at least one birthday actually is shared by $k$ people. The probability we seek can be found by summing the $q(k;n,b)$ for appropriate values of $k$ and multiplying the result by $b^{-n}$. These counts can be found exactly for values of $n$ less than several hundred. However, they will not follow any straightforward formula: we have to consider the patterns of ways in which birthdays can be assigned. I will illustrate this in lieu of providing a general demonstration. Let $n = 4$ (this is the smallest interesting situation). The possibilities are: Each person has a unique birthday; the code is {4}. Exactly two people share a birthday; the code is {2,1}. Two people have one birthday and the other two have another; the code is {0,2}. Three people share a birthday; the code is {1,0,1}. Four people share a birthday; the code is {0,0,0,1}. Generally, the code $\{a[1], a[2], \ldots\}$ is a tuple of counts whose $k^\text{th}$ element stipulates how many distinct birthdates are shared by exactly $k$ people. Thus, in particular, $$1 a[1] + 2a[2] + ... + k a[k] + \ldots = n.$$ Note, even in this simple case, that there are two ways in which the maximum of two people per birthday is attained: one with the code $\{0,2\}$ and another with the code $\{2,1\}$. We can directly count the number of possible birthday assignments corresponding to any given code. This number is the product of three terms. One is a multinomial coefficient; it counts the number of ways of partitioning $n$ people into $a[1]$ groups of $1$, $a[2]$ groups of $2$, and so on. Because the sequence of groups does not matter, we have to divide this multinomial coefficient by $a[1]!a[2]!\cdots$; its reciprocal is the second term. Finally, line up the groups and assign them each a birthday: there are $b$ candidates for the first group, $b-1$ for the second, and so on. These values have to be multiplied together, forming the third term. It is equal to the "factorial product" $b^{(a[1]+a[2]+\cdots)}$ where $b^{(m)}$ means $b(b-1)\cdots(b-m+1)$. There is an obvious and fairly simple recursion relating the count for a pattern $\{a[1], \ldots, a[k]\}$ to the count for the pattern $\{a[1], \ldots, a[k-1]\}$. This enables rapid calculation of the counts for modest values of $n$. Specifically, $a[k]$ represents $a[k]$ birthdates shared by exactly $k$ people each. After these $a[k]$ groups of $k$ people have been drawn from the $n$ people, which can be done in $x$ distinct ways (say), it remains to count the number of ways of achieving the pattern $\{a[1], \ldots, a[k-1]\}$ among the remaining people. Multiplying this by $x$ gives the recursion. I doubt there is a closed form formula for $q(k; n, b)$, which is obtained by summing the counts for all partitions of $n$ whose maximum term equals $k$. Let me offer some examples: With $b=5$ (five possible birthdays) and $n=4$ (four people), we obtain $$\eqalign{ q(1) &= q(1;4,5) &= 120 \\ q(2) &= 360 + 60 &= 420 \\ q(3) &&= 80 \\ q(4) &&= 5.\\ }$$ Whence, for example, the chance that three or more people out of four share the same "birthday" (out of $5$ possible dates) equals $(80 + 5)/625 = 0.136$. As another example, take $b = 365$ and $n = 23$. Here are the values of $q( k;23,365)$ for the smallest $k$ (to six sig figs only): $$\eqalign{ k=1: &0.49270 \\ k=2: &0.494592 \\ k=3: &0.0125308 \\ k=4: &0.000172844 \\ k=5: &1.80449E-6 \\ k=6: &1.48722E-8 \\ k=7: &9.92255E-11 \\ k=8: &5.45195E-13. }$$ Using this technique, we can readily compute that there is about a 50% chance of (at least) a three-way birthday collision among 87 people, a 50% chance of a four-way collision among 187, and a 50% chance of a five-way collision among 310 people. That last calculation starts taking a few seconds (in Mathematica, anyway) because the number of partitions to consider starts getting large. For substantially larger $n$ we need an approximation. One approximation is obtained by means of the Poisson distribution with expectation $n/b$, because we can view a birthday assignment as arising from $b$ almost (but not quite) independent Poisson variables each with expectation $n/b$: the variable for any given possible birthday describes how many of the $n$ people have that birthday. The distribution of the maximum is therefore approximately $F(k)^b$ where $F$ is the Poisson CDF. This is not a rigorous argument, so let's do a little testing. The approximation for $n = 23$, $b = 365$ gives $$\eqalign{ k=1: &0.498783 \\ k=2: &0.496803\\ k=3: &0.014187\\ k=4: &0.000225115. }$$ By comparing with the preceding you can see that the relative probabilities can be poor when they are small, but the absolute probabilities are reasonably well approximated to about 0.5%. Testing with a wide range of $n$ and $b$ suggests the approximation is usually about this good. To wrap up, let's consider the original question: take $n = 10,000$ (the number of observations) and $b = 1\,000\,000$ (the number of possible "structures," approximately). The approximate distribution for the maximum number of "shared birthdays" is $$\eqalign{ k=1: &0 \\ k=2: &0.8475+\\ k=3: &0.1520+\\ k=4: &0.0004+\\ k\gt 4: &\lt 1E-6. }$$ (This is a fast calculation.) Clearly, observing one structure 10 times out of 10,000 would be highly significant. Because $n$ and $b$ are both large, I expect the approximation to work quite well here. Incidentally, as Shane intimated, simulations can provide useful checks. A Mathematica simulation is created with a function like simulate[n_, b_] := Max[Last[Transpose[Tally[RandomInteger[{0, b - 1}, n]]]]]; which is then iterated and summarized, as in this example which runs 10,000 iterations of the $n = 10000$, $b = 1\,000\,000$ case: Tally[Table[simulate[10000, 1000000], {n, 1, 10000}]] // TableForm Its output is 2 8503 3 1493 4 4 These frequencies closely agree with those predicted by the Poisson approximation.
Extending the birthday paradox to more than 2 people This is a counting problem: there are $b^n$ possible assignments of $b$ birthdays to $n$ people. Of those, let $q(k; n, b)$ be the number of assignments for which no birthday is shared by more than $
8,966
Extending the birthday paradox to more than 2 people
It is always possible to solve this problem with a monte-carlo solution, although that's far from the most efficient. Here's a simple example of the 2 person problem in R (from a presentation I gave last year; I used this as an example of inefficient code), which could be easily adjusted to account for more than 2: birthday.paradox <- function(n.people, n.trials) { matches <- 0 for (trial in 1:n.trials) { birthdays <- cbind(as.matrix(1:365), rep(0, 365)) for (person in 1:n.people) { day <- sample(1:365, 1, replace = TRUE) if (birthdays[birthdays[, 1] == day, 2] == 1) { matches <- matches + 1 break } birthdays[birthdays[, 1] == day, 2] <- 1 } birthdays <- NULL } print(paste("Probability of birthday matches = ", matches/n.trials)) }
Extending the birthday paradox to more than 2 people
It is always possible to solve this problem with a monte-carlo solution, although that's far from the most efficient. Here's a simple example of the 2 person problem in R (from a presentation I gave
Extending the birthday paradox to more than 2 people It is always possible to solve this problem with a monte-carlo solution, although that's far from the most efficient. Here's a simple example of the 2 person problem in R (from a presentation I gave last year; I used this as an example of inefficient code), which could be easily adjusted to account for more than 2: birthday.paradox <- function(n.people, n.trials) { matches <- 0 for (trial in 1:n.trials) { birthdays <- cbind(as.matrix(1:365), rep(0, 365)) for (person in 1:n.people) { day <- sample(1:365, 1, replace = TRUE) if (birthdays[birthdays[, 1] == day, 2] == 1) { matches <- matches + 1 break } birthdays[birthdays[, 1] == day, 2] <- 1 } birthdays <- NULL } print(paste("Probability of birthday matches = ", matches/n.trials)) }
Extending the birthday paradox to more than 2 people It is always possible to solve this problem with a monte-carlo solution, although that's far from the most efficient. Here's a simple example of the 2 person problem in R (from a presentation I gave
8,967
Extending the birthday paradox to more than 2 people
This is an attempt at a general solution. There may be some mistakes so use with caution! First some notation: $P(x,n)$ be the probability that $x$ or more people share a birthday among $n$ people, $P(y|n)$ be the probability that exactly $y$ people share a birthday among $n$ people. Notes: Abuse of notation as $P(.)$ is being used in two different ways. By definition $y$ cannot take the value of 1 as it does not make any sense and $y$ = 0 can be interpreted to mean that no one shares a common birthday. Then the required probability is given by: $P(x,n) = 1 - P(0|n) - P(2|n) - P(3|n) .... - P(x-1|n)$ Now, $P(y|n) = {n \choose y} (\frac{365}{365})^y \ \prod_{k=1}^{k=n-y}(1 -\frac{k}{365})$ Here is the logic: You need the probability that exactly $y$ people share a birthday. Step 1: You can pick $y$ people in ${n \choose y}$ ways. Step 2: Since they share a birthday it can be any of the 365 days in a year. So, we basically have 365 choices which gives us $(\frac{365}{365})^y$. Step 3: The remaining $n-y$ people should not share a birthday with the first $y$ people or with each other. This reasoning gives us $\prod_{k=1}^{k=n-y}(1 -\frac{k}{365})$. You can check that for $x$ = 2 the above collapses to the standard birthday paradox solution.
Extending the birthday paradox to more than 2 people
This is an attempt at a general solution. There may be some mistakes so use with caution! First some notation: $P(x,n)$ be the probability that $x$ or more people share a birthday among $n$ people, $P
Extending the birthday paradox to more than 2 people This is an attempt at a general solution. There may be some mistakes so use with caution! First some notation: $P(x,n)$ be the probability that $x$ or more people share a birthday among $n$ people, $P(y|n)$ be the probability that exactly $y$ people share a birthday among $n$ people. Notes: Abuse of notation as $P(.)$ is being used in two different ways. By definition $y$ cannot take the value of 1 as it does not make any sense and $y$ = 0 can be interpreted to mean that no one shares a common birthday. Then the required probability is given by: $P(x,n) = 1 - P(0|n) - P(2|n) - P(3|n) .... - P(x-1|n)$ Now, $P(y|n) = {n \choose y} (\frac{365}{365})^y \ \prod_{k=1}^{k=n-y}(1 -\frac{k}{365})$ Here is the logic: You need the probability that exactly $y$ people share a birthday. Step 1: You can pick $y$ people in ${n \choose y}$ ways. Step 2: Since they share a birthday it can be any of the 365 days in a year. So, we basically have 365 choices which gives us $(\frac{365}{365})^y$. Step 3: The remaining $n-y$ people should not share a birthday with the first $y$ people or with each other. This reasoning gives us $\prod_{k=1}^{k=n-y}(1 -\frac{k}{365})$. You can check that for $x$ = 2 the above collapses to the standard birthday paradox solution.
Extending the birthday paradox to more than 2 people This is an attempt at a general solution. There may be some mistakes so use with caution! First some notation: $P(x,n)$ be the probability that $x$ or more people share a birthday among $n$ people, $P
8,968
Predicting with both continuous and categorical features
As far as I know, and I've researched this issue deeply in the past, there are no predictive modeling techniques (beside trees, XgBoost, etc.) that are designed to handle both types of input at the same time without simply transforming the type of the features. Note that algorithms like Random Forest and XGBoost accept an input of mixed features, but they apply some logic to handle them during split of a node. Make sure you understand the logic "under the hood" and that you're OK with whatever is happening in the black-box. Yet, distance/kernel based models (e.g., K-NN, NN regression, support vector machines) can be used to handle mixed type feature space by defining a “special” distance function. Such that, for every feature, applies an appropriate distance metric (e.g., for a numeric feature we’ll calculate the Euclidean distance of 2 numbers while for a categorical feature we’ll simple calculate the overlap distance of 2 string values). So, the distance/similarity between user $u_1$ and $u_2$ in feature $f_i$, as follows: $d(u_1,u_2 )_{f_i}=(dis-categorical(u_1,u_2 )_{f_i} $ if feature $f_i$ is categorical, $d(u_1,u_2 )_{f_i}=dis-numeric(u_1,u_2 )_{f_i} $ if feature $f_i$ is numerical. and 1 if feature $f_i$ is not defined in $u_1$ or $u_2$. Some known distance function for categorical features: Levenshtien distance (or any form of "edit distance") Longest common subsequence metric Gower distance And more metrics here Boriah, S., Chandola and V., Kumar, V. (2008). Similarity measures for categorical data: A comparative evaluation. In: Proceedings of the 8th SIAM International Conference on Data Mining, SIAM, p. 243-254.
Predicting with both continuous and categorical features
As far as I know, and I've researched this issue deeply in the past, there are no predictive modeling techniques (beside trees, XgBoost, etc.) that are designed to handle both types of input at the sa
Predicting with both continuous and categorical features As far as I know, and I've researched this issue deeply in the past, there are no predictive modeling techniques (beside trees, XgBoost, etc.) that are designed to handle both types of input at the same time without simply transforming the type of the features. Note that algorithms like Random Forest and XGBoost accept an input of mixed features, but they apply some logic to handle them during split of a node. Make sure you understand the logic "under the hood" and that you're OK with whatever is happening in the black-box. Yet, distance/kernel based models (e.g., K-NN, NN regression, support vector machines) can be used to handle mixed type feature space by defining a “special” distance function. Such that, for every feature, applies an appropriate distance metric (e.g., for a numeric feature we’ll calculate the Euclidean distance of 2 numbers while for a categorical feature we’ll simple calculate the overlap distance of 2 string values). So, the distance/similarity between user $u_1$ and $u_2$ in feature $f_i$, as follows: $d(u_1,u_2 )_{f_i}=(dis-categorical(u_1,u_2 )_{f_i} $ if feature $f_i$ is categorical, $d(u_1,u_2 )_{f_i}=dis-numeric(u_1,u_2 )_{f_i} $ if feature $f_i$ is numerical. and 1 if feature $f_i$ is not defined in $u_1$ or $u_2$. Some known distance function for categorical features: Levenshtien distance (or any form of "edit distance") Longest common subsequence metric Gower distance And more metrics here Boriah, S., Chandola and V., Kumar, V. (2008). Similarity measures for categorical data: A comparative evaluation. In: Proceedings of the 8th SIAM International Conference on Data Mining, SIAM, p. 243-254.
Predicting with both continuous and categorical features As far as I know, and I've researched this issue deeply in the past, there are no predictive modeling techniques (beside trees, XgBoost, etc.) that are designed to handle both types of input at the sa
8,969
Predicting with both continuous and categorical features
I know it's been a while since this question was posted, but if you're still looking at this problem (or similar ones) you may want to consider using generalized additive models (GAM's). I'm no expert, but these models allow you to combine different models to create a single prediction. The process used to find coefficients for the models you put in solves for all of them at once, so you can send a generalized additive model your favorite model for categorical predictors and your favorite model for continuous predictors and get a single model that minimizes RSS or whatever other error criterion you want to use. Off the top of my head, the only software package which I know has an implementation of GAM's is the language R, but I'm sure there are others.
Predicting with both continuous and categorical features
I know it's been a while since this question was posted, but if you're still looking at this problem (or similar ones) you may want to consider using generalized additive models (GAM's). I'm no expert
Predicting with both continuous and categorical features I know it's been a while since this question was posted, but if you're still looking at this problem (or similar ones) you may want to consider using generalized additive models (GAM's). I'm no expert, but these models allow you to combine different models to create a single prediction. The process used to find coefficients for the models you put in solves for all of them at once, so you can send a generalized additive model your favorite model for categorical predictors and your favorite model for continuous predictors and get a single model that minimizes RSS or whatever other error criterion you want to use. Off the top of my head, the only software package which I know has an implementation of GAM's is the language R, but I'm sure there are others.
Predicting with both continuous and categorical features I know it's been a while since this question was posted, but if you're still looking at this problem (or similar ones) you may want to consider using generalized additive models (GAM's). I'm no expert
8,970
Predicting with both continuous and categorical features
While discretization transforms continous data to discrete data it can hardly be said that dummy variables transform categorical data to continous data. Indeed, since algorithms can be run on computers there can hardly be a classificator algorithm which does NOT transform categorical data into dummy variables. In the same sense a classificator ultimately transforms it predictors into a discrete variable indicating class belonging (even if it outputs a class probability, you ultimately choose a cutoff). De facto many classificators like logistic regression, random forest, decision trees and SVM all work fine with both types of data. I suspect it would be hard to find an algorithm which works with continous data but cannot handle categorical data at all. Usually I tend to find it makes more difference on what type of data you have on the left side of your model.
Predicting with both continuous and categorical features
While discretization transforms continous data to discrete data it can hardly be said that dummy variables transform categorical data to continous data. Indeed, since algorithms can be run on computer
Predicting with both continuous and categorical features While discretization transforms continous data to discrete data it can hardly be said that dummy variables transform categorical data to continous data. Indeed, since algorithms can be run on computers there can hardly be a classificator algorithm which does NOT transform categorical data into dummy variables. In the same sense a classificator ultimately transforms it predictors into a discrete variable indicating class belonging (even if it outputs a class probability, you ultimately choose a cutoff). De facto many classificators like logistic regression, random forest, decision trees and SVM all work fine with both types of data. I suspect it would be hard to find an algorithm which works with continous data but cannot handle categorical data at all. Usually I tend to find it makes more difference on what type of data you have on the left side of your model.
Predicting with both continuous and categorical features While discretization transforms continous data to discrete data it can hardly be said that dummy variables transform categorical data to continous data. Indeed, since algorithms can be run on computer
8,971
Predicting with both continuous and categorical features
This is a deep philosophical question which is commonly addressed from the statistical as well as machine learning end. Some say, categorizing is better for discrete to categorical indicator, so that the packages can easily digest the model inputs. Others say, that binning can cause information loss, but however categorical variables can/must be converted to {1,0} indicator variables leaving out the last class for the model residuals. The book - Applied linear regression (Kutner et al. ) mentions about the logic of introducing indicator variables in the model in the first few chapters. There may be other similar text too. My take on this maybe a bit too far-fetched: If we imagine the categorical variables like blocks in an experimental design, the indicator variable is a natural extension to non-experiment based data analysis. With respect to data mining algorithms (decision tree families), categorization is inevitable (either manually or automated-binning) which has to be fed to the model. Hence, there may not be a model that is specialized for numerical as well as categorical variables in the same way (without binning-numerical or using indicators-categorical).
Predicting with both continuous and categorical features
This is a deep philosophical question which is commonly addressed from the statistical as well as machine learning end. Some say, categorizing is better for discrete to categorical indicator, so that
Predicting with both continuous and categorical features This is a deep philosophical question which is commonly addressed from the statistical as well as machine learning end. Some say, categorizing is better for discrete to categorical indicator, so that the packages can easily digest the model inputs. Others say, that binning can cause information loss, but however categorical variables can/must be converted to {1,0} indicator variables leaving out the last class for the model residuals. The book - Applied linear regression (Kutner et al. ) mentions about the logic of introducing indicator variables in the model in the first few chapters. There may be other similar text too. My take on this maybe a bit too far-fetched: If we imagine the categorical variables like blocks in an experimental design, the indicator variable is a natural extension to non-experiment based data analysis. With respect to data mining algorithms (decision tree families), categorization is inevitable (either manually or automated-binning) which has to be fed to the model. Hence, there may not be a model that is specialized for numerical as well as categorical variables in the same way (without binning-numerical or using indicators-categorical).
Predicting with both continuous and categorical features This is a deep philosophical question which is commonly addressed from the statistical as well as machine learning end. Some say, categorizing is better for discrete to categorical indicator, so that
8,972
Is cross validation a proper substitute for validation set?
You have indeed correctly described the way to work with crossvalidation. In fact, you are 'lucky' to have a reasonable validation set at the end, because often, crossvalidation is used to optimize a model, but no "real" validation is done. As @Simon Stelling said in his comment, crossvalidation will lead to lower estimated errors (which makes sense because you are constantly reusing the data), but fortunately this is the case for all models, so, barring catastrophy (i.e.: errors are only reduced slightly for a "bad" model, and more for "the good" model), selecting the model that performs best on a crossvalidated criterion, will typically also be the best "for real". A method that is sometimes used to correct somewhat for the lower errors, especially if you are looking for parsimoneous models, is to select the smallest model/simplest method for which the crossvalidated error is within one SD from the (crossvalidated) optimum. As crossvalidation itself, this is a heuristic, so it should be used with some care (if this is an option: make a plot of your errors against your tuning parameters: this will give you some idea whether you have acceptable results) Given the downward bias of the errors, it is important to not publish the errors or other performance measure from the crossvalidation without mentioning that these come from crossvalidation (although, truth be told: I have seen too many publications that don't mention that the performance measure was obtained from checking the performance on the original dataset either --- so mentioning crossvalidation actually makes your results worth more). For you, this will not be an issue, since you have a validation set. A final warning: if your model fitting results in some close competitors, it is a good idea to look at their performances on your validation set afterwards, but do not base your final model selection on that: you can at best use this to soothe your conscience, but your "final" model must have been picked before you ever look at the validation set. Wrt your second question: I believe Simon has given your all the answers you need in his comment, but to complete the picture: as often, it is the bias-variance trade-off that comes into play. If you know that, on average, you will reach the correct result (unbiasedness), the price is typically that each of your individual calculations may lie pretty far from it (high variance). In the old days, unbiasedness was the nec plus ultra, in current days, one has accepted at times a (small) bias (so you don't even know that the average of your calculations will result in the correct result), if it results in lower variance. Experience has shown that the balance is acceptable with 10-fold crossvalidation. For you, the bias would only be an issue for your model optimization, since you can estimate the criterion afterwards (unbiasedly) on the validation set. As such, there is little reason not to use crossvalidation.
Is cross validation a proper substitute for validation set?
You have indeed correctly described the way to work with crossvalidation. In fact, you are 'lucky' to have a reasonable validation set at the end, because often, crossvalidation is used to optimize a
Is cross validation a proper substitute for validation set? You have indeed correctly described the way to work with crossvalidation. In fact, you are 'lucky' to have a reasonable validation set at the end, because often, crossvalidation is used to optimize a model, but no "real" validation is done. As @Simon Stelling said in his comment, crossvalidation will lead to lower estimated errors (which makes sense because you are constantly reusing the data), but fortunately this is the case for all models, so, barring catastrophy (i.e.: errors are only reduced slightly for a "bad" model, and more for "the good" model), selecting the model that performs best on a crossvalidated criterion, will typically also be the best "for real". A method that is sometimes used to correct somewhat for the lower errors, especially if you are looking for parsimoneous models, is to select the smallest model/simplest method for which the crossvalidated error is within one SD from the (crossvalidated) optimum. As crossvalidation itself, this is a heuristic, so it should be used with some care (if this is an option: make a plot of your errors against your tuning parameters: this will give you some idea whether you have acceptable results) Given the downward bias of the errors, it is important to not publish the errors or other performance measure from the crossvalidation without mentioning that these come from crossvalidation (although, truth be told: I have seen too many publications that don't mention that the performance measure was obtained from checking the performance on the original dataset either --- so mentioning crossvalidation actually makes your results worth more). For you, this will not be an issue, since you have a validation set. A final warning: if your model fitting results in some close competitors, it is a good idea to look at their performances on your validation set afterwards, but do not base your final model selection on that: you can at best use this to soothe your conscience, but your "final" model must have been picked before you ever look at the validation set. Wrt your second question: I believe Simon has given your all the answers you need in his comment, but to complete the picture: as often, it is the bias-variance trade-off that comes into play. If you know that, on average, you will reach the correct result (unbiasedness), the price is typically that each of your individual calculations may lie pretty far from it (high variance). In the old days, unbiasedness was the nec plus ultra, in current days, one has accepted at times a (small) bias (so you don't even know that the average of your calculations will result in the correct result), if it results in lower variance. Experience has shown that the balance is acceptable with 10-fold crossvalidation. For you, the bias would only be an issue for your model optimization, since you can estimate the criterion afterwards (unbiasedly) on the validation set. As such, there is little reason not to use crossvalidation.
Is cross validation a proper substitute for validation set? You have indeed correctly described the way to work with crossvalidation. In fact, you are 'lucky' to have a reasonable validation set at the end, because often, crossvalidation is used to optimize a
8,973
Can a Multinomial(1/n, ..., 1/n) be characterized as a discretized Dirichlet(1, .., 1)?
Those the two distributions are different for every $n \geq 4$. Notation I'm going to rescale your simplex by a factor $n$, so that the lattice points have integer coordinates. This doesn't change anything, I just think it makes the notation a little less cumbersome. Let $S$ be the $(n-1)$-simplex, given as the convex hull of the points $(n,0,\ldots,0)$, ..., $(0,\ldots,0,n)$ in $\mathbb R^{n}$. In other words, these are the points where all coordinates are non-negative, and where the coordinates sum to $n$. Let $\Lambda$ denote the set of lattice points, i.e. those points in $S$ where all coordinates are integral. If $P$ is a lattice point, we let $V_P$ denote its Voronoi cell, defined as those points in $S$ which are (strictly) closer to $P$ than to any other point in $\Lambda$. We put two probability distributions we can put on $\Lambda$. One is the multinomial distribution, where the point $(a_1, ..., a_n)$ has the probability $2^{-n} n!/(a_1! \cdots a_n!)$. The other we will call the Dirichlet model, and it assigns to each $P \in \Lambda$ a probability proportional to the volume of $V_P$. Very informal justification I'm claiming that the multinomial model and the Dirichlet model give different distributions on $\Lambda$, whenever $n \geq 4$. To see this, consider the case $n=4$, and the points $A = (2,2,0,0)$ and $B=(3,1,0,0)$. I claim that $V_A$ and $V_B$ are congruent via a translation by the vector $(1,-1,0,0)$. This means that $V_A$ and $V_B$ have the same volume, and thus that $A$ and $B$ have the same probability in the Dirichlet model. On the other hand, in the multinomial model, they have different probabilities ($2^{-4} \cdot 4!/(2!2!)$ and $2^{-4} \cdot 4!/3!$), and it follows that the distributions cannot be equal. The fact that $V_A$ and $V_B$ are congruent follows from the following plausible but non-obvious (and somewhat vague) claim: Plausible Claim: The shape and size of $V_P$ is only affected by the "immediate neighbors" of $P$, (i.e. those points in $\Lambda$ which differ from $P$ by a vector that looks like $(1,-1,0,\ldots,0)$, where the $1$ and $-1$ may be in other places) It's easy to see that the configurations of "immediate neighbors" of $A$ and $B$ are the same, and it then follows that $V_A$ and $V_B$ are congruent. In case $n \geq 5$, we can play the same game, with $A = (2,2,n-4,0,\ldots,0)$ and $B=(3,1,n-4,0,\ldots,0)$, for example. I don't think this claim is completely obvious, and I'm not going to prove it, instead of a slightly different strategy. However, I think this is a more intuitive answer to why the distributions are different for $n \geq 4$. Rigorous proof Take $A$ and $B$ as in the informal justification above. We only need to prove that $V_A$ and $V_B$ are congruent. Given $P = (p_1, \ldots, p_n) \in \Lambda$, we will define $W_P$ as follows: $W_P$ is the set of points $(x_1, \ldots, x_n) \in S$, for which $\max_{1 \leq i \leq n} (a_i - p_i) - \min_{1 \leq i \leq n} (a_i - p_i) < 1$. (In a more digestible manner: Let $v_i = a_i - p_i$. $W_P$ is the set of points for which the difference between the highest and lowest $v_i$ is less than 1.) We will show that $V_P = W_P$. Step 1 Claim: $V_P \subseteq W_P$. This is fairly easy: Suppose that $X = (x_1, \ldots, x_n)$ is not in $W_P$. Let $v_i = x_i - p_i$, and assume (without loss of generality) that $v_1 = \max_{1\leq i\leq n} v_i$, $v_2 = \min_{1\leq i\leq n} v_i$. $v_1 - v_2 \geq 1$ Since $\sum_{i=1}^n v_i = 0$, we also know that $v_1 > 0 > v_2$. Let now $Q = (p_1 + 1, p_2 - 1, p_3, \ldots, p_n)$. Since $P$ and $X$ both have non-negative coordinates, so does $Q$, and it follows that $Q \in S$, and so $Q \in \Lambda$. On the other hand, $\mathrm{dist}^2(X, P) - \mathrm{dist}^2(X, Q) = v_1^2 + v_2^2 - (1-v_1)^2 - (1+v_2)^2 = -2 + 2(v_1 - v2) \geq 0$. Thus, $X$ is at least as close to $Q$ as to $P$, so $X \not\in V_P$. This shows (by taking complements) that $V_p \subseteq W_P$. Step 2 Claim: The $W_P$ are pairwise disjoint. Suppose otherwise. Let $P=(p_1,\ldots, p_n)$ and $Q = (q_1,\ldots,q_n)$ be distinct points in $\Lambda$, and let $X \in W_P \cap W_Q$. Since $P$ and $Q$ are distinct and both in $\Lambda$, there must be one index $i$ where $p_i \geq q_i + 1$, and one where $p_i \leq q_i - 1$. Without loss of generality, we assume that $p_1 \geq q_1 + 1$, and $p_2 \leq q_2 - 1$. Rearranging and adding together, we get $q_1 - p_1 + p_2 - q_2 \geq 2$. Consider now the numbers $x_1$ and $x_2$. From the fact that $X \in W_P$, we have $x_1 - p_1 - (x_2 - p_2) < 1$. Similarly, $X \in W_Q$ implies that $x_2 - q_2 - (x_1 - q_1) < 1$. Adding these together, we get $q_1 - p_1 + p_2 - q_2 < 2$, and we have a contradiction. Step 3 We have shown that $V_P \subseteq W_P$, and that the $W_P$ are disjoint. The $V_P$ cover $S$ up to a set of measure zero, and it follows that $W_P = V_P$ (up to a set of measure zero). [Since $W_P$ and $V_P$ are both open, we actually have $W_P = V_P$ exactly, but this is not essential.] Now, we are almost done. Consider the points $A = (2,2,n-4,0,\ldots,0)$ and $B = (3,1,n-4,0,\ldots,0)$. It is easy to see that $W_A$ and $W_B$ are congruent and translations of each other: the only way they could differ, is if the boundary of $S$ (other than the faces on which $A$ and $B$ both lie) would ``cut off'' either $W_A$ or $W_B$ but not the other. But to reach such a part of the boundary of $S$, we would need to change one coordinate of $A$ or $B$ by at least 1, which would be enough to guarantee to take us out of $W_A$ and $W_B$ anyway. Thus, even though $S$ does look different from the vantage points $A$ and $B$, the differences are too far away to be picked up by the definitions of $W_A$ and $W_B$, and thus $W_A$ and $W_B$ are congruent. It follows then that $V_A$ and $V_B$ have the same volume, and thus the Dirichlet model assigns them the same probability, even though they have different probabilities in the multinomial model.
Can a Multinomial(1/n, ..., 1/n) be characterized as a discretized Dirichlet(1, .., 1)?
Those the two distributions are different for every $n \geq 4$. Notation I'm going to rescale your simplex by a factor $n$, so that the lattice points have integer coordinates. This doesn't change any
Can a Multinomial(1/n, ..., 1/n) be characterized as a discretized Dirichlet(1, .., 1)? Those the two distributions are different for every $n \geq 4$. Notation I'm going to rescale your simplex by a factor $n$, so that the lattice points have integer coordinates. This doesn't change anything, I just think it makes the notation a little less cumbersome. Let $S$ be the $(n-1)$-simplex, given as the convex hull of the points $(n,0,\ldots,0)$, ..., $(0,\ldots,0,n)$ in $\mathbb R^{n}$. In other words, these are the points where all coordinates are non-negative, and where the coordinates sum to $n$. Let $\Lambda$ denote the set of lattice points, i.e. those points in $S$ where all coordinates are integral. If $P$ is a lattice point, we let $V_P$ denote its Voronoi cell, defined as those points in $S$ which are (strictly) closer to $P$ than to any other point in $\Lambda$. We put two probability distributions we can put on $\Lambda$. One is the multinomial distribution, where the point $(a_1, ..., a_n)$ has the probability $2^{-n} n!/(a_1! \cdots a_n!)$. The other we will call the Dirichlet model, and it assigns to each $P \in \Lambda$ a probability proportional to the volume of $V_P$. Very informal justification I'm claiming that the multinomial model and the Dirichlet model give different distributions on $\Lambda$, whenever $n \geq 4$. To see this, consider the case $n=4$, and the points $A = (2,2,0,0)$ and $B=(3,1,0,0)$. I claim that $V_A$ and $V_B$ are congruent via a translation by the vector $(1,-1,0,0)$. This means that $V_A$ and $V_B$ have the same volume, and thus that $A$ and $B$ have the same probability in the Dirichlet model. On the other hand, in the multinomial model, they have different probabilities ($2^{-4} \cdot 4!/(2!2!)$ and $2^{-4} \cdot 4!/3!$), and it follows that the distributions cannot be equal. The fact that $V_A$ and $V_B$ are congruent follows from the following plausible but non-obvious (and somewhat vague) claim: Plausible Claim: The shape and size of $V_P$ is only affected by the "immediate neighbors" of $P$, (i.e. those points in $\Lambda$ which differ from $P$ by a vector that looks like $(1,-1,0,\ldots,0)$, where the $1$ and $-1$ may be in other places) It's easy to see that the configurations of "immediate neighbors" of $A$ and $B$ are the same, and it then follows that $V_A$ and $V_B$ are congruent. In case $n \geq 5$, we can play the same game, with $A = (2,2,n-4,0,\ldots,0)$ and $B=(3,1,n-4,0,\ldots,0)$, for example. I don't think this claim is completely obvious, and I'm not going to prove it, instead of a slightly different strategy. However, I think this is a more intuitive answer to why the distributions are different for $n \geq 4$. Rigorous proof Take $A$ and $B$ as in the informal justification above. We only need to prove that $V_A$ and $V_B$ are congruent. Given $P = (p_1, \ldots, p_n) \in \Lambda$, we will define $W_P$ as follows: $W_P$ is the set of points $(x_1, \ldots, x_n) \in S$, for which $\max_{1 \leq i \leq n} (a_i - p_i) - \min_{1 \leq i \leq n} (a_i - p_i) < 1$. (In a more digestible manner: Let $v_i = a_i - p_i$. $W_P$ is the set of points for which the difference between the highest and lowest $v_i$ is less than 1.) We will show that $V_P = W_P$. Step 1 Claim: $V_P \subseteq W_P$. This is fairly easy: Suppose that $X = (x_1, \ldots, x_n)$ is not in $W_P$. Let $v_i = x_i - p_i$, and assume (without loss of generality) that $v_1 = \max_{1\leq i\leq n} v_i$, $v_2 = \min_{1\leq i\leq n} v_i$. $v_1 - v_2 \geq 1$ Since $\sum_{i=1}^n v_i = 0$, we also know that $v_1 > 0 > v_2$. Let now $Q = (p_1 + 1, p_2 - 1, p_3, \ldots, p_n)$. Since $P$ and $X$ both have non-negative coordinates, so does $Q$, and it follows that $Q \in S$, and so $Q \in \Lambda$. On the other hand, $\mathrm{dist}^2(X, P) - \mathrm{dist}^2(X, Q) = v_1^2 + v_2^2 - (1-v_1)^2 - (1+v_2)^2 = -2 + 2(v_1 - v2) \geq 0$. Thus, $X$ is at least as close to $Q$ as to $P$, so $X \not\in V_P$. This shows (by taking complements) that $V_p \subseteq W_P$. Step 2 Claim: The $W_P$ are pairwise disjoint. Suppose otherwise. Let $P=(p_1,\ldots, p_n)$ and $Q = (q_1,\ldots,q_n)$ be distinct points in $\Lambda$, and let $X \in W_P \cap W_Q$. Since $P$ and $Q$ are distinct and both in $\Lambda$, there must be one index $i$ where $p_i \geq q_i + 1$, and one where $p_i \leq q_i - 1$. Without loss of generality, we assume that $p_1 \geq q_1 + 1$, and $p_2 \leq q_2 - 1$. Rearranging and adding together, we get $q_1 - p_1 + p_2 - q_2 \geq 2$. Consider now the numbers $x_1$ and $x_2$. From the fact that $X \in W_P$, we have $x_1 - p_1 - (x_2 - p_2) < 1$. Similarly, $X \in W_Q$ implies that $x_2 - q_2 - (x_1 - q_1) < 1$. Adding these together, we get $q_1 - p_1 + p_2 - q_2 < 2$, and we have a contradiction. Step 3 We have shown that $V_P \subseteq W_P$, and that the $W_P$ are disjoint. The $V_P$ cover $S$ up to a set of measure zero, and it follows that $W_P = V_P$ (up to a set of measure zero). [Since $W_P$ and $V_P$ are both open, we actually have $W_P = V_P$ exactly, but this is not essential.] Now, we are almost done. Consider the points $A = (2,2,n-4,0,\ldots,0)$ and $B = (3,1,n-4,0,\ldots,0)$. It is easy to see that $W_A$ and $W_B$ are congruent and translations of each other: the only way they could differ, is if the boundary of $S$ (other than the faces on which $A$ and $B$ both lie) would ``cut off'' either $W_A$ or $W_B$ but not the other. But to reach such a part of the boundary of $S$, we would need to change one coordinate of $A$ or $B$ by at least 1, which would be enough to guarantee to take us out of $W_A$ and $W_B$ anyway. Thus, even though $S$ does look different from the vantage points $A$ and $B$, the differences are too far away to be picked up by the definitions of $W_A$ and $W_B$, and thus $W_A$ and $W_B$ are congruent. It follows then that $V_A$ and $V_B$ have the same volume, and thus the Dirichlet model assigns them the same probability, even though they have different probabilities in the multinomial model.
Can a Multinomial(1/n, ..., 1/n) be characterized as a discretized Dirichlet(1, .., 1)? Those the two distributions are different for every $n \geq 4$. Notation I'm going to rescale your simplex by a factor $n$, so that the lattice points have integer coordinates. This doesn't change any
8,974
Meaning of p-values in regression
The p-value for $a$ is the p-value in a test of the hypothesis "$\alpha = 0$" (usually a 2-sided $t$-test). The p-value for $b$ is the p-value in a test of the hypothesis "$\beta = 0$" (also usually a 2-sided $t$-test) and likewise for any other coefficients in the regression. The probability models for these tests are determined by the one assumed in the linear regression model. For least-squares linear regression, the pair ($a,b$) follows a bivariate normal distribution centered on the true parameter values ($\alpha, \beta$), and the hypothesis test for each coefficient is equivalent to $t$-testing whether $\alpha = 0$ (resp. $\beta=0$) based on samples from a suitable normal distribution [of one variable, i.e., the distribution of $a$ or $b$ alone]. The details of which normal distributions appear are somewhat complicated and involve "degrees of freedom" and "hat matrices" (based on the notation $\hat{A}$ for some of the matrices that constantly appear in the theory of OLS regression). Yes. Usually it is done (and defined) by Maximum Likelihood Estimation. For OLS linear regression and a small number of other models there are exact formulas for estimating the parameters from the data. For more general regressions the solutions are iterative and numerical in nature. Not directly. A p-value is calculated separately for a test of the whole model, that is, a test of the hypothesis that all the coefficients (of the variables presumed to actually vary, so not including the coefficient of the "constant term" if there is one). But this p-value cannot usually be calculated from knowledge of the p-values of the coefficients.
Meaning of p-values in regression
The p-value for $a$ is the p-value in a test of the hypothesis "$\alpha = 0$" (usually a 2-sided $t$-test). The p-value for $b$ is the p-value in a test of the hypothesis "$\beta = 0$" (also usually
Meaning of p-values in regression The p-value for $a$ is the p-value in a test of the hypothesis "$\alpha = 0$" (usually a 2-sided $t$-test). The p-value for $b$ is the p-value in a test of the hypothesis "$\beta = 0$" (also usually a 2-sided $t$-test) and likewise for any other coefficients in the regression. The probability models for these tests are determined by the one assumed in the linear regression model. For least-squares linear regression, the pair ($a,b$) follows a bivariate normal distribution centered on the true parameter values ($\alpha, \beta$), and the hypothesis test for each coefficient is equivalent to $t$-testing whether $\alpha = 0$ (resp. $\beta=0$) based on samples from a suitable normal distribution [of one variable, i.e., the distribution of $a$ or $b$ alone]. The details of which normal distributions appear are somewhat complicated and involve "degrees of freedom" and "hat matrices" (based on the notation $\hat{A}$ for some of the matrices that constantly appear in the theory of OLS regression). Yes. Usually it is done (and defined) by Maximum Likelihood Estimation. For OLS linear regression and a small number of other models there are exact formulas for estimating the parameters from the data. For more general regressions the solutions are iterative and numerical in nature. Not directly. A p-value is calculated separately for a test of the whole model, that is, a test of the hypothesis that all the coefficients (of the variables presumed to actually vary, so not including the coefficient of the "constant term" if there is one). But this p-value cannot usually be calculated from knowledge of the p-values of the coefficients.
Meaning of p-values in regression The p-value for $a$ is the p-value in a test of the hypothesis "$\alpha = 0$" (usually a 2-sided $t$-test). The p-value for $b$ is the p-value in a test of the hypothesis "$\beta = 0$" (also usually
8,975
Meaning of p-values in regression
wrt your first question: this depends on your software of choice. There are really two types of p-values that are used frequently in these scenarios, both typically based upon likelihood ratio tests (there are others but these are typically equivalent or at least differ little in their results). It is important to realize that all of these p-values are conditional on (part of) the rest of the parameters. That means: Assuming (some of) the other parameter estimates are correct, you test whether or not the coefficient for a parameter is zero. Typically, the null hypothesis for these tests is that the coefficient is zero, so if you have a small p-value, it means (conditionally on the value of the other coefficients) that the coefficient itself is unlikely to be zero. Type I tests test for the zeroness of each coefficient conditionally on the value of the coefficients that come before it in the model (left to right). Type III tests (marginal tests), test for the zeroness of each coefficient conditional on the value of all other coefficients. Different tools present different p-values as the default, although typically you have ways of obtaining both. If you don't have a reason outside of statistics to include the parameters in some order, you will generally be interested in the type III test results. Finally (relating more to your last question), with a likelihood ratio test you can always create a test for any set of coefficients conditional on the rest. This is the way to go if you want to test for multiple coefficients being zero at the same time (otherwise you run into some nasty multiple testing issues).
Meaning of p-values in regression
wrt your first question: this depends on your software of choice. There are really two types of p-values that are used frequently in these scenarios, both typically based upon likelihood ratio tests (
Meaning of p-values in regression wrt your first question: this depends on your software of choice. There are really two types of p-values that are used frequently in these scenarios, both typically based upon likelihood ratio tests (there are others but these are typically equivalent or at least differ little in their results). It is important to realize that all of these p-values are conditional on (part of) the rest of the parameters. That means: Assuming (some of) the other parameter estimates are correct, you test whether or not the coefficient for a parameter is zero. Typically, the null hypothesis for these tests is that the coefficient is zero, so if you have a small p-value, it means (conditionally on the value of the other coefficients) that the coefficient itself is unlikely to be zero. Type I tests test for the zeroness of each coefficient conditionally on the value of the coefficients that come before it in the model (left to right). Type III tests (marginal tests), test for the zeroness of each coefficient conditional on the value of all other coefficients. Different tools present different p-values as the default, although typically you have ways of obtaining both. If you don't have a reason outside of statistics to include the parameters in some order, you will generally be interested in the type III test results. Finally (relating more to your last question), with a likelihood ratio test you can always create a test for any set of coefficients conditional on the rest. This is the way to go if you want to test for multiple coefficients being zero at the same time (otherwise you run into some nasty multiple testing issues).
Meaning of p-values in regression wrt your first question: this depends on your software of choice. There are really two types of p-values that are used frequently in these scenarios, both typically based upon likelihood ratio tests (
8,976
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ridge regression)
This is not a solution but some reflections on the possibilities and difficulties that I know of. Whenever it is possible to specify a time-series model as $$Y_{t+1} = \mathbf{x}_t \beta + \epsilon_{t+1}$$ with $\mathbf{x}_t$ computable from covariates and time-lagged observations, it is also possible to compute the least-squares elastic net penalized estimator of $\beta$ using glmnet in R. It requires that you write code to compute $\mathbf{x}_t$ to form the model matrix that is to be specified in glmnet. This works for AR-models but not directly for ARMA-models, say. Moreover, the cross-validation procedures of glmnet are not sensible per se for time-series data. For more general models $$Y_{t+1} = f(\mathbf{x}_t, \beta) + \epsilon_{t+1}$$ an implementation of an algorithm for computing the non-linear least-squares elastic net penalized estimator of $\beta$ is needed. To the best of my knowledge there is no such implementation in R. I am currently writing an implementation to solve the case where $$Y_{t+1} = \mathbf{x}_t g(\beta) + \epsilon_{t+1}$$ the point being that it is paramount for model selection that the lasso penalization is on $\beta$ and not $g(\beta)$. If I recall the ARIMA-parametrization correctly it also takes this form $-$ but I cannot offer any code at the moment. It is (will be) based on A coordinate gradient descent method for nonsmooth separable minimization. Another issue is the selection of the amount of penalization (the tuning parameters). It will generally require a form of cross-validation for time-series, but I hope to be able to work out some less computationally demanding methods for specific models.
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ri
This is not a solution but some reflections on the possibilities and difficulties that I know of. Whenever it is possible to specify a time-series model as $$Y_{t+1} = \mathbf{x}_t \beta + \epsilon
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ridge regression) This is not a solution but some reflections on the possibilities and difficulties that I know of. Whenever it is possible to specify a time-series model as $$Y_{t+1} = \mathbf{x}_t \beta + \epsilon_{t+1}$$ with $\mathbf{x}_t$ computable from covariates and time-lagged observations, it is also possible to compute the least-squares elastic net penalized estimator of $\beta$ using glmnet in R. It requires that you write code to compute $\mathbf{x}_t$ to form the model matrix that is to be specified in glmnet. This works for AR-models but not directly for ARMA-models, say. Moreover, the cross-validation procedures of glmnet are not sensible per se for time-series data. For more general models $$Y_{t+1} = f(\mathbf{x}_t, \beta) + \epsilon_{t+1}$$ an implementation of an algorithm for computing the non-linear least-squares elastic net penalized estimator of $\beta$ is needed. To the best of my knowledge there is no such implementation in R. I am currently writing an implementation to solve the case where $$Y_{t+1} = \mathbf{x}_t g(\beta) + \epsilon_{t+1}$$ the point being that it is paramount for model selection that the lasso penalization is on $\beta$ and not $g(\beta)$. If I recall the ARIMA-parametrization correctly it also takes this form $-$ but I cannot offer any code at the moment. It is (will be) based on A coordinate gradient descent method for nonsmooth separable minimization. Another issue is the selection of the amount of penalization (the tuning parameters). It will generally require a form of cross-validation for time-series, but I hope to be able to work out some less computationally demanding methods for specific models.
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ri This is not a solution but some reflections on the possibilities and difficulties that I know of. Whenever it is possible to specify a time-series model as $$Y_{t+1} = \mathbf{x}_t \beta + \epsilon
8,977
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ridge regression)
I was challenged by a client to solve this problem in an automatic i.e. turnkey way. I implemented an approach that for each pair ( i.e. y and a candidate x ) , prewhiten , compute cross-correlations of the pre-whitened series, identify the PDL ( OR ADL AUTOREGRESSIVE DISTRIBUTED LAG MODEL including any DEAD TIME ) while incorporating Intervention Detection to yield robust estimates, develop a "measure" for this structure. After conducting this for ALL candidate regressors, rank them by the "measure" and then select the top K regressors based upon the "measure". This is sometimes referred to as Linear Filtering. We successfully incorporated this heuristic into our commercially available time series package. You should be able to "ROLL YOUR OWN" if you have sufficient time and statistical programming skills and/or available modules to implement some of these tasks.
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ri
I was challenged by a client to solve this problem in an automatic i.e. turnkey way. I implemented an approach that for each pair ( i.e. y and a candidate x ) , prewhiten , compute cross-correlations
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ridge regression) I was challenged by a client to solve this problem in an automatic i.e. turnkey way. I implemented an approach that for each pair ( i.e. y and a candidate x ) , prewhiten , compute cross-correlations of the pre-whitened series, identify the PDL ( OR ADL AUTOREGRESSIVE DISTRIBUTED LAG MODEL including any DEAD TIME ) while incorporating Intervention Detection to yield robust estimates, develop a "measure" for this structure. After conducting this for ALL candidate regressors, rank them by the "measure" and then select the top K regressors based upon the "measure". This is sometimes referred to as Linear Filtering. We successfully incorporated this heuristic into our commercially available time series package. You should be able to "ROLL YOUR OWN" if you have sufficient time and statistical programming skills and/or available modules to implement some of these tasks.
Fitting an ARIMAX model with regularization or penalization (e.g. with the lasso, elastic net, or ri I was challenged by a client to solve this problem in an automatic i.e. turnkey way. I implemented an approach that for each pair ( i.e. y and a candidate x ) , prewhiten , compute cross-correlations
8,978
Beautifully written papers
I'll give it a shot...: Benjamini, Yoav; Hochberg, Yosef (1995). "Controlling the false discovery rate: a practical and powerful approach to multiple testing". Journal of the Royal Statistical Society, Series B 57 (1): 289–300. MR 1325392. Link to PDF: http://www.math.tau.ac.il/~ybenja/MyPapers/benjamini_hochberg1995.pdf I think the importance of the paper is undisputable. In fields like genomics, experiments with 1000s of tests involved are the norm and the BH method is the most popular way to address the multiple testing issue. Not surprisingly perhaps, this paper appears in the top 100 most cited articles. Is it beautifully written? I think so. In this paper you have 1) The mathematical formalism (although I can't judge whether this could be made better); 2) An understandable, plain English explanation of what the problem is, why other methods are unsatisfactory and how the BH method works; 3) A simple worked example of how it is done. (I'm very intersted in this questions, hope others come up with answers & opinions)
Beautifully written papers
I'll give it a shot...: Benjamini, Yoav; Hochberg, Yosef (1995). "Controlling the false discovery rate: a practical and powerful approach to multiple testing". Journal of the Royal Statistical Society
Beautifully written papers I'll give it a shot...: Benjamini, Yoav; Hochberg, Yosef (1995). "Controlling the false discovery rate: a practical and powerful approach to multiple testing". Journal of the Royal Statistical Society, Series B 57 (1): 289–300. MR 1325392. Link to PDF: http://www.math.tau.ac.il/~ybenja/MyPapers/benjamini_hochberg1995.pdf I think the importance of the paper is undisputable. In fields like genomics, experiments with 1000s of tests involved are the norm and the BH method is the most popular way to address the multiple testing issue. Not surprisingly perhaps, this paper appears in the top 100 most cited articles. Is it beautifully written? I think so. In this paper you have 1) The mathematical formalism (although I can't judge whether this could be made better); 2) An understandable, plain English explanation of what the problem is, why other methods are unsatisfactory and how the BH method works; 3) A simple worked example of how it is done. (I'm very intersted in this questions, hope others come up with answers & opinions)
Beautifully written papers I'll give it a shot...: Benjamini, Yoav; Hochberg, Yosef (1995). "Controlling the false discovery rate: a practical and powerful approach to multiple testing". Journal of the Royal Statistical Society
8,979
Computing repeatability of effects from an lmer model
I think I can answer your questions at least concerning the unadjusted repeatability estimates, i.e., the classical intra-class correlations (ICCs). As for the "adjusted" repeatability estimates, I skimmed over the paper you linked and didn't really see where the formula that you apply can be found in the paper? Based on the mathematical expression, it appears to be the repeatability of mean scores (rather than individual scores). But it's not clear that this is a critical part of your question anyway, so I will ignore it. (1.) Do the above computations for obtaining the point estimate of the repeatability of an effect make sense? Yes, the expression you propose does make sense, but a slight modification to your proposed formula is necessary. Below I show how one could derive your proposed repeatability coefficient. I hope this both clarifies the conceptual meaning of the coefficient and also shows why it would be desirable to modify it slightly. To start off, let's first take the repeatability coefficient in your first case and clarify what it means and where it comes from. Understanding this will help us to understand the more complicated second case. Random intercepts only In this case, the mixed model for the $i$th response in the $j$th group is $$ y_{ij} = \beta_0 + u_{0j} + e_{ij}, $$ where the random intercepts $u_{0j}$ have variance $\sigma^2_{u_0}$ and the residuals $e_{ij}$ have variance $\sigma^2_e$. Now, the correlation between two random variables $x$ and $y$ is defined as $$ corr = \frac{cov(x, y)}{\sqrt{var(x)var(y)}}. $$ The expression for ICC / repeatability coefficient then comes from letting the two random variables $x$ and $y$ be two observations drawn from the same $j$ group, $$ ICC = \frac{cov(\beta_0 + u_{0j} + e_{i_1j}, \beta_0 + u_{0j} + e_{i_2j})}{\sqrt{var(\beta_0 + u_{0j} + e_{i_1j})var(\beta_0 + u_{0j} + e_{i_2j})}}, $$ and if you simplify this using the definitions given above and the properties of variances/covariances (a process which I will not show here, unless you or others would prefer that I did), you end up with $$ ICC = \frac{\sigma^2_{u_0}}{\sigma^2_{u_0} + \sigma^2_e}. $$ What this means is that the ICC or "unadjusted repeatability coefficient" in this case has a simple interpretation as the expected correlation between a pair observations from the same cluster (net of the fixed effects, which in this case is just the grand mean). The fact that the ICC is also interpretable as a proportion of variance in this case is coincidental; that interpretation is not true in general for more complicated ICCs. The interpretation as some sort of correlation is what is primary. Random intercepts and random slopes Now for the second case, we have to first clarify what precisely is meant by "the reliability of effects (i.e. sum contrast effect of a variable with 2 levels)" -- your words. First we lay out the model. The mixed model for the $i$th response in the $j$th group under the $k$th level of a contrast-coded predictor $x$ is $$ y_{ijk} = \beta_0 + \beta_1x_k + u_{0j} + u_{1j}x_k + e_{ijk}, $$ where the random intercepts have variance $\sigma^2_{u_0}$, the random slopes have variance $\sigma^2_{u_1}$, the random intercepts and slopes have covariance $\sigma_{u_{01}}$, and the residuals $e_{ij}$ have variance $\sigma^2_e$. So what is the "repeatability of an effect" under this model? I think a good candidate definition is that it is the expected correlation between two pairs of difference scores computed within the same $j$ cluster, but across different pairs of observations $i$. So the pair of difference scores in question would be (remember that we assumed $x$ is contrast coded so that $|x_1|=|x_2|=x$): $$ y_{i_1jk_2}-y_{i_1jk_1}=(\beta_0-\beta_0)+\beta_1(x_{k_2}-x_{k_1})+(u_{0j}-u_{0j})+u_{1j}(x_{k_2}-x_{k_1})+(e_{i_1jk_2}-e_{i_1jk_1}) \\=2x\beta_1+2xu_{1j}+e_{i_1jk_2}-e_{i_1jk_1} $$ and $$ y_{i_2jk_2}-y_{i_2jk_1}=2x\beta_1+2xu_{1j}+e_{i_2jk_2}-e_{i_2jk_1}. $$ Plugging these into the correlation formula gives us $$ ICC = \frac{cov(2x\beta_1+2xu_{1j}+e_{i_1jk_2}-e_{i_1jk_1}, 2x\beta_1+2xu_{1j}+e_{i_2jk_2}-e_{i_2jk_1})}{\sqrt{var(2x\beta_1+2xu_{1j}+e_{i_1jk_2}-e_{i_1jk_1})var(2x\beta_1+2xu_{1j}+e_{i_2jk_2}-e_{i_2jk_1})}}, $$ which simplifies down to $$ ICC = \frac{2x^2\sigma^2_{u_1}}{2x^2\sigma^2_{u_1} + \sigma^2_e}. $$ Notice that the ICC is technically a function of $x$! However, in this case $x$ can only take 2 possible values, and the ICC is identical at both of these values. As you can see, this is very similar to the repeatability coefficient that you proposed in your question, the only difference is that the random slope variance must be appropriately scaled if the expression is to be interpreted as an ICC or "unadjusted repeatability coefficient." The expression that you wrote works in the special case where the $x$ predictor is coded $\pm\frac{1}{\sqrt{2}}$, but not in general. (2.) When I have multiple variables whose repeatability I want to estimate, adding them all to the same fit (e.g. lmer(dv~(iv1+iv2|unit)+iv1+iv2) seems to yield higher repeatability estimates than creating a separate model for each effect. This makes sense computationally to me, as inclusion of multiple effects will tend to decrease the residual variance, but I'm not positive that the resulting repeatability estimates are valid. Are they? I believe that working through a similar derivation as presented above for a model with multiple predictors with their own random slopes would show that the repeatability coefficient above would still be valid, except for the added complication that the difference scores we are conceptually interested in would now have a slightly different definition: namely, we are interested in the expected correlation of the differences between adjusted means after controlling for the other predictors in the model. If the other predictors are orthogonal to the predictor of interest (as in, e.g., a balanced experiment), I would think the ICC / repeatability coefficient elaborated above should work without any modification. If they are not orthogonal then you would need to modify the formula to take account of this, which could get complicated, but hopefully my answer has given some hints about what that might look like.
Computing repeatability of effects from an lmer model
I think I can answer your questions at least concerning the unadjusted repeatability estimates, i.e., the classical intra-class correlations (ICCs). As for the "adjusted" repeatability estimates, I sk
Computing repeatability of effects from an lmer model I think I can answer your questions at least concerning the unadjusted repeatability estimates, i.e., the classical intra-class correlations (ICCs). As for the "adjusted" repeatability estimates, I skimmed over the paper you linked and didn't really see where the formula that you apply can be found in the paper? Based on the mathematical expression, it appears to be the repeatability of mean scores (rather than individual scores). But it's not clear that this is a critical part of your question anyway, so I will ignore it. (1.) Do the above computations for obtaining the point estimate of the repeatability of an effect make sense? Yes, the expression you propose does make sense, but a slight modification to your proposed formula is necessary. Below I show how one could derive your proposed repeatability coefficient. I hope this both clarifies the conceptual meaning of the coefficient and also shows why it would be desirable to modify it slightly. To start off, let's first take the repeatability coefficient in your first case and clarify what it means and where it comes from. Understanding this will help us to understand the more complicated second case. Random intercepts only In this case, the mixed model for the $i$th response in the $j$th group is $$ y_{ij} = \beta_0 + u_{0j} + e_{ij}, $$ where the random intercepts $u_{0j}$ have variance $\sigma^2_{u_0}$ and the residuals $e_{ij}$ have variance $\sigma^2_e$. Now, the correlation between two random variables $x$ and $y$ is defined as $$ corr = \frac{cov(x, y)}{\sqrt{var(x)var(y)}}. $$ The expression for ICC / repeatability coefficient then comes from letting the two random variables $x$ and $y$ be two observations drawn from the same $j$ group, $$ ICC = \frac{cov(\beta_0 + u_{0j} + e_{i_1j}, \beta_0 + u_{0j} + e_{i_2j})}{\sqrt{var(\beta_0 + u_{0j} + e_{i_1j})var(\beta_0 + u_{0j} + e_{i_2j})}}, $$ and if you simplify this using the definitions given above and the properties of variances/covariances (a process which I will not show here, unless you or others would prefer that I did), you end up with $$ ICC = \frac{\sigma^2_{u_0}}{\sigma^2_{u_0} + \sigma^2_e}. $$ What this means is that the ICC or "unadjusted repeatability coefficient" in this case has a simple interpretation as the expected correlation between a pair observations from the same cluster (net of the fixed effects, which in this case is just the grand mean). The fact that the ICC is also interpretable as a proportion of variance in this case is coincidental; that interpretation is not true in general for more complicated ICCs. The interpretation as some sort of correlation is what is primary. Random intercepts and random slopes Now for the second case, we have to first clarify what precisely is meant by "the reliability of effects (i.e. sum contrast effect of a variable with 2 levels)" -- your words. First we lay out the model. The mixed model for the $i$th response in the $j$th group under the $k$th level of a contrast-coded predictor $x$ is $$ y_{ijk} = \beta_0 + \beta_1x_k + u_{0j} + u_{1j}x_k + e_{ijk}, $$ where the random intercepts have variance $\sigma^2_{u_0}$, the random slopes have variance $\sigma^2_{u_1}$, the random intercepts and slopes have covariance $\sigma_{u_{01}}$, and the residuals $e_{ij}$ have variance $\sigma^2_e$. So what is the "repeatability of an effect" under this model? I think a good candidate definition is that it is the expected correlation between two pairs of difference scores computed within the same $j$ cluster, but across different pairs of observations $i$. So the pair of difference scores in question would be (remember that we assumed $x$ is contrast coded so that $|x_1|=|x_2|=x$): $$ y_{i_1jk_2}-y_{i_1jk_1}=(\beta_0-\beta_0)+\beta_1(x_{k_2}-x_{k_1})+(u_{0j}-u_{0j})+u_{1j}(x_{k_2}-x_{k_1})+(e_{i_1jk_2}-e_{i_1jk_1}) \\=2x\beta_1+2xu_{1j}+e_{i_1jk_2}-e_{i_1jk_1} $$ and $$ y_{i_2jk_2}-y_{i_2jk_1}=2x\beta_1+2xu_{1j}+e_{i_2jk_2}-e_{i_2jk_1}. $$ Plugging these into the correlation formula gives us $$ ICC = \frac{cov(2x\beta_1+2xu_{1j}+e_{i_1jk_2}-e_{i_1jk_1}, 2x\beta_1+2xu_{1j}+e_{i_2jk_2}-e_{i_2jk_1})}{\sqrt{var(2x\beta_1+2xu_{1j}+e_{i_1jk_2}-e_{i_1jk_1})var(2x\beta_1+2xu_{1j}+e_{i_2jk_2}-e_{i_2jk_1})}}, $$ which simplifies down to $$ ICC = \frac{2x^2\sigma^2_{u_1}}{2x^2\sigma^2_{u_1} + \sigma^2_e}. $$ Notice that the ICC is technically a function of $x$! However, in this case $x$ can only take 2 possible values, and the ICC is identical at both of these values. As you can see, this is very similar to the repeatability coefficient that you proposed in your question, the only difference is that the random slope variance must be appropriately scaled if the expression is to be interpreted as an ICC or "unadjusted repeatability coefficient." The expression that you wrote works in the special case where the $x$ predictor is coded $\pm\frac{1}{\sqrt{2}}$, but not in general. (2.) When I have multiple variables whose repeatability I want to estimate, adding them all to the same fit (e.g. lmer(dv~(iv1+iv2|unit)+iv1+iv2) seems to yield higher repeatability estimates than creating a separate model for each effect. This makes sense computationally to me, as inclusion of multiple effects will tend to decrease the residual variance, but I'm not positive that the resulting repeatability estimates are valid. Are they? I believe that working through a similar derivation as presented above for a model with multiple predictors with their own random slopes would show that the repeatability coefficient above would still be valid, except for the added complication that the difference scores we are conceptually interested in would now have a slightly different definition: namely, we are interested in the expected correlation of the differences between adjusted means after controlling for the other predictors in the model. If the other predictors are orthogonal to the predictor of interest (as in, e.g., a balanced experiment), I would think the ICC / repeatability coefficient elaborated above should work without any modification. If they are not orthogonal then you would need to modify the formula to take account of this, which could get complicated, but hopefully my answer has given some hints about what that might look like.
Computing repeatability of effects from an lmer model I think I can answer your questions at least concerning the unadjusted repeatability estimates, i.e., the classical intra-class correlations (ICCs). As for the "adjusted" repeatability estimates, I sk
8,980
How to construct a multivariate Beta distribution?
It is natural to use a Gaussian copula for this construction. This amounts to transforming the marginal distributions of a $d$-dimensional Gaussian random variable into specified Beta marginals. The details are given below. The question actually describes only $2d + d(d-1)/2$ parameters: two parameters $a_i, b_i$ for each marginal Beta distribution and the $d(d-1)/2$ correlation coefficients $\rho_{i,j}=\rho_{j,i},$ $1\le i \lt j \le d.$ The latter determine the covariance matrix $\Sigma$ of the Gaussian random variable $Z$ (which might as well have standardized marginals and therefore has unit variances on the diagonal). It is conventional to write $$\mathbf Z \sim \mathcal{N}(\mathbf 0, \Sigma).$$ Thus, writing $\Phi$ for the standard Normal distribution function (its cdf) and $F_{a,b}^{-1}$ for the Beta$(a,b)$ quantile function, define $$X_i = F_{a_i, b_i}^{-1}\left(\Phi(Z_i)\right).$$ By construction the $X_i$ have the desired Beta marginals and their correlation matrix is determined by the $d(d-1)/2$ independent entries in $\Sigma.$ Here, to illustrate, is an R implementation of a function to generate $n$ iid multivariate Beta values according to this recipe. The caller specifies the Beta parameters $(a)$ and $(b)$ as vectors along with the correlation matrix $\Sigma,$ followed by any optional parameters to be passed to the multivariate Gaussian generator MASS::mvrnorm. The output is an $n\times d$ array whose rows are the realizations. rmbeta <- function(n, a, b, Sigma, ...) { require(MASS) Z <- mvrnorm(n, rep(0, nrow(Sigma)), Sigma, ...) t(qbeta(t(pnorm(Z, 0, sqrt(diag(Sigma)))), a, b)) } In this code, qbeta implements $F^{-1}_{a,b}$ and pnorm implements $\Phi.$ rmbeta should be equally simple to write on almost any statistical computing platform. A test of this algorithm will establish that the columns of the output (1) are correlated and (2) have the intended Beta distributions. In the following example with $d=4,$ in which one million multivariate values were generated (taking about one second), the input correlations were $\rho_{i,j} = (-0.8)^{|i-j|}.$ This specifies strong negative correlations among neighboring columns, fairly strong positive correlations for $(Z_1,Z_3)$ and $(Z_2,Z_4),$ and a weak negative correlation for $(Z_1,Z_4).$ These correlation patterns will persist, at least qualitatively, when the $Z_i$ are transformed to the $X_i.$ Those correlations are all apparent in this scatterplot matrix of the first two thousand of the $X_i$ values (plotting millions of points would be superfluous and take too long): The correlations are evident in the point clouds. The observed correlations among these generated values are obtained from the cor function, yielding the matrix X.1 X.2 X.3 X.4 X.1 1.000 -0.794 0.610 -0.509 X.2 -0.794 1.000 -0.739 0.628 X.3 0.610 -0.739 1.000 -0.778 X.4 -0.509 0.628 -0.778 1.000 They are remarkably close to the correlations of $-0.800,$ $0.640,$ and $-0.512$ specified for the parent Gaussian distribution of the $Z_i.$ Note, though, that (unlike multivariate Gaussians) these clouds tend to follow curvilinear trends: this is forced on them by the differing shapes of the marginal distributions. Here are the marginal distributions. (The histogram titles show the Beta parameters.) The red curves are the intended density functions: the data fit them nicely. I have not analyzed whether all such multivariate Beta distributions are unimodal. We shouldn't expect them to be unless all pairs of $(a_i,b_i)$ parameters include at least one value of $1$ or greater. (Otherwise, the marginals themselves are bimodal.) In such cases I believe unimodality will hold, but do not offer any proof of that. (Reasons to be cautious about drawing conclusions concerning multivariate modes from modes of the marginals are suggested by the examples offered at https://stats.stackexchange.com/a/91944/919.) Finally, little of this construction is specific to Beta distributions: you can create correlated multivariate distributions with any intended marginal distributions by means of this Gaussian copula construction. Just replace the quantile functions $F_{a,b}^{-1}$ by any quantile functions (and any parameters) you wish. Appendix Here is the R code needed to reproduce the data in the figures. It generates the Beta parameters a and b randomly. Functions pairs and hist were later used for the plots. set.seed(17) d <- 4 rho <- -0.8 a <- 1 + rexp(d, 1/5) b <- 1 + rexp(d, 1/5) Sigma <- outer(1:d, 1:d, function(i,j) rho^abs(i-j)) X <- rmbeta(1e6, a, b, Sigma)
How to construct a multivariate Beta distribution?
It is natural to use a Gaussian copula for this construction. This amounts to transforming the marginal distributions of a $d$-dimensional Gaussian random variable into specified Beta marginals. The
How to construct a multivariate Beta distribution? It is natural to use a Gaussian copula for this construction. This amounts to transforming the marginal distributions of a $d$-dimensional Gaussian random variable into specified Beta marginals. The details are given below. The question actually describes only $2d + d(d-1)/2$ parameters: two parameters $a_i, b_i$ for each marginal Beta distribution and the $d(d-1)/2$ correlation coefficients $\rho_{i,j}=\rho_{j,i},$ $1\le i \lt j \le d.$ The latter determine the covariance matrix $\Sigma$ of the Gaussian random variable $Z$ (which might as well have standardized marginals and therefore has unit variances on the diagonal). It is conventional to write $$\mathbf Z \sim \mathcal{N}(\mathbf 0, \Sigma).$$ Thus, writing $\Phi$ for the standard Normal distribution function (its cdf) and $F_{a,b}^{-1}$ for the Beta$(a,b)$ quantile function, define $$X_i = F_{a_i, b_i}^{-1}\left(\Phi(Z_i)\right).$$ By construction the $X_i$ have the desired Beta marginals and their correlation matrix is determined by the $d(d-1)/2$ independent entries in $\Sigma.$ Here, to illustrate, is an R implementation of a function to generate $n$ iid multivariate Beta values according to this recipe. The caller specifies the Beta parameters $(a)$ and $(b)$ as vectors along with the correlation matrix $\Sigma,$ followed by any optional parameters to be passed to the multivariate Gaussian generator MASS::mvrnorm. The output is an $n\times d$ array whose rows are the realizations. rmbeta <- function(n, a, b, Sigma, ...) { require(MASS) Z <- mvrnorm(n, rep(0, nrow(Sigma)), Sigma, ...) t(qbeta(t(pnorm(Z, 0, sqrt(diag(Sigma)))), a, b)) } In this code, qbeta implements $F^{-1}_{a,b}$ and pnorm implements $\Phi.$ rmbeta should be equally simple to write on almost any statistical computing platform. A test of this algorithm will establish that the columns of the output (1) are correlated and (2) have the intended Beta distributions. In the following example with $d=4,$ in which one million multivariate values were generated (taking about one second), the input correlations were $\rho_{i,j} = (-0.8)^{|i-j|}.$ This specifies strong negative correlations among neighboring columns, fairly strong positive correlations for $(Z_1,Z_3)$ and $(Z_2,Z_4),$ and a weak negative correlation for $(Z_1,Z_4).$ These correlation patterns will persist, at least qualitatively, when the $Z_i$ are transformed to the $X_i.$ Those correlations are all apparent in this scatterplot matrix of the first two thousand of the $X_i$ values (plotting millions of points would be superfluous and take too long): The correlations are evident in the point clouds. The observed correlations among these generated values are obtained from the cor function, yielding the matrix X.1 X.2 X.3 X.4 X.1 1.000 -0.794 0.610 -0.509 X.2 -0.794 1.000 -0.739 0.628 X.3 0.610 -0.739 1.000 -0.778 X.4 -0.509 0.628 -0.778 1.000 They are remarkably close to the correlations of $-0.800,$ $0.640,$ and $-0.512$ specified for the parent Gaussian distribution of the $Z_i.$ Note, though, that (unlike multivariate Gaussians) these clouds tend to follow curvilinear trends: this is forced on them by the differing shapes of the marginal distributions. Here are the marginal distributions. (The histogram titles show the Beta parameters.) The red curves are the intended density functions: the data fit them nicely. I have not analyzed whether all such multivariate Beta distributions are unimodal. We shouldn't expect them to be unless all pairs of $(a_i,b_i)$ parameters include at least one value of $1$ or greater. (Otherwise, the marginals themselves are bimodal.) In such cases I believe unimodality will hold, but do not offer any proof of that. (Reasons to be cautious about drawing conclusions concerning multivariate modes from modes of the marginals are suggested by the examples offered at https://stats.stackexchange.com/a/91944/919.) Finally, little of this construction is specific to Beta distributions: you can create correlated multivariate distributions with any intended marginal distributions by means of this Gaussian copula construction. Just replace the quantile functions $F_{a,b}^{-1}$ by any quantile functions (and any parameters) you wish. Appendix Here is the R code needed to reproduce the data in the figures. It generates the Beta parameters a and b randomly. Functions pairs and hist were later used for the plots. set.seed(17) d <- 4 rho <- -0.8 a <- 1 + rexp(d, 1/5) b <- 1 + rexp(d, 1/5) Sigma <- outer(1:d, 1:d, function(i,j) rho^abs(i-j)) X <- rmbeta(1e6, a, b, Sigma)
How to construct a multivariate Beta distribution? It is natural to use a Gaussian copula for this construction. This amounts to transforming the marginal distributions of a $d$-dimensional Gaussian random variable into specified Beta marginals. The
8,981
How to construct a multivariate Beta distribution?
Here is a paper that does it in arbitrary dimensions by extending the bivariate construction mentioned by other commenters: Trippa, Lorenzo, Peter Müller, and Wesley Johnson. "The multivariate beta process and an extension of the Polya tree model." Biometrika 98.1 (2011): 17-34. The paper has a lot of notation but the idea is pretty simple: center a kernel at each of your dependent data points, partition the line/plane/$R^d$/whatever based on all the points of intersection of those kernels (see Figure 1a), sample from a Dirichlet process evaluated on that partition, and then add everything back up and normalize to get the required beta marginals with correlation between them.
How to construct a multivariate Beta distribution?
Here is a paper that does it in arbitrary dimensions by extending the bivariate construction mentioned by other commenters: Trippa, Lorenzo, Peter Müller, and Wesley Johnson. "The multivariate beta pr
How to construct a multivariate Beta distribution? Here is a paper that does it in arbitrary dimensions by extending the bivariate construction mentioned by other commenters: Trippa, Lorenzo, Peter Müller, and Wesley Johnson. "The multivariate beta process and an extension of the Polya tree model." Biometrika 98.1 (2011): 17-34. The paper has a lot of notation but the idea is pretty simple: center a kernel at each of your dependent data points, partition the line/plane/$R^d$/whatever based on all the points of intersection of those kernels (see Figure 1a), sample from a Dirichlet process evaluated on that partition, and then add everything back up and normalize to get the required beta marginals with correlation between them.
How to construct a multivariate Beta distribution? Here is a paper that does it in arbitrary dimensions by extending the bivariate construction mentioned by other commenters: Trippa, Lorenzo, Peter Müller, and Wesley Johnson. "The multivariate beta pr
8,982
What are the branches of statistics?
You could look into the keywords/tags of the Cross Validated website. Branches as a network One way to do this is to plot it as a network based on the relationships between the keywords (how often they coincide in the same post). When you use this sql-script to get the data of the site from (data.stackexchange.com/stats/query/edit/1122036) select Tags from Posts where PostTypeId = 1 and Score >2 Then you obtain a list of keywords for all questions with a score of 2 or higher. You could explore that list by plotting something like the following: Update: the same with color (based on eigenvectors of the relation matrix) and without the self-study tag You could clean this graph up a bit further (e.g. take out the tags which do not relate to statistical concepts like software tags, in the above graph this is already done for the 'r' tag) and improve the visual representation, but I guess that this image above already shows a nice starting point. R-code: #the sql-script saved like an sql file network <- read.csv("~/../Desktop/network.csv", stringsAsFactors = 0) #it looks like this: > network[1][1:5,] [1] "<r><biostatistics><bioinformatics>" [2] "<hypothesis-testing><nonlinear-regression><regression-coefficients>" [3] "<aic>" [4] "<regression><nonparametric><kernel-smoothing>" [5] "<r><regression><experiment-design><simulation><random-generation>" l <- length(network[,1]) nk <- 1 keywords <- c("<r>") M <- matrix(0,1) for (j in 1:l) { # loop all lines in the text file s <- stringr::str_match_all(network[j,],"<.*?>") # extract keywords m <- c(0) for (is in s[[1]]) { if (sum(keywords == is) == 0) { # check if there is a new keyword keywords <- c(keywords,is) # add to the keywords table nk<-nk+1 M <- cbind(M,rep(0,nk-1)) # expand the relation matrix with zero's M <- rbind(M,rep(0,nk)) } m <- c(m, which(keywords == is)) lm <- length(m) if (lm>2) { # for keywords >2 add +1 to the relations for (mi in m[-c(1,lm)]) { M[mi,m[lm]] <- M[mi,m[lm]]+1 M[m[lm],mi] <- M[m[lm],mi]+1 } } } } #getting rid of < > skeywords <- sub(c("<"),"",keywords) skeywords <- sub(c(">"),"",skeywords) # plotting connections library(igraph) library("visNetwork") # reduces nodes and edges Ms<-M[-1,-1] # -1,-1 elliminates the 'r' tag which offsets the graph Ms[which(Ms<50)] <- 0 ww <- colSums(Ms) el <- which(ww==0) # convert to data object for VisNetwork function g <- graph.adjacency(Ms[-el,-el], weighted=TRUE, mode = "undirected") data <- toVisNetworkData(g) # adjust some plotting parameters some data$nodes['label'] <- skeywords[-1][-el] data$nodes['title'] <- skeywords[-1][-el] data$nodes['value'] <- colSums(Ms)[-el] data$edges['width'] <- sqrt(data$edges['weight'])*1 data$nodes['font.size'] <- 20+log(ww[-el])*6 data$edges['color'] <- "#eeeeff" #plot visNetwork(nodes = data$nodes, edges = data$edges) %>% visPhysics(solver = "forceAtlas2Based", stabilization = TRUE, forceAtlas2Based = list(nodeDistance=70, springConstant = 0.04, springLength = 50, avoidOverlap =1) ) Hierarchical branches I believe that these type of network graphs above relate to some of the criticisms regarding a purely branched hierarchical structure. If you like, I guess that you could perform a hierarchical-clustering to force it into a hierarchical structure. Below is an example of such hierarchical model. One would still need to find proper group names for the various clusters (but, I do not think that this hierarchical clustering is the good direction, so I leave it open). The distance measure for the clustering has been found by trial and error (making adjustments until the clusters appear nice. ##### ##### cluster library(cluster) Ms<-M[-1,-1] Ms[which(Ms<50)] <- 0 ww <- colSums(Ms) el <- which(ww==0) Ms<-M[-1,-1] R <- (keycount[-1]^-1) %*% t(keycount[-1]^-1) Ms <- log(Ms*R+0.00000001) Mc <- Ms[-el,-el] colnames(Mc) <- skeywords[-1][-el] cmod <- agnes(-Mc, diss = TRUE) plot(as.hclust(cmod), cex = 0.65, hang=-1, xlab = "", ylab ="")
What are the branches of statistics?
You could look into the keywords/tags of the Cross Validated website. Branches as a network One way to do this is to plot it as a network based on the relationships between the keywords (how often th
What are the branches of statistics? You could look into the keywords/tags of the Cross Validated website. Branches as a network One way to do this is to plot it as a network based on the relationships between the keywords (how often they coincide in the same post). When you use this sql-script to get the data of the site from (data.stackexchange.com/stats/query/edit/1122036) select Tags from Posts where PostTypeId = 1 and Score >2 Then you obtain a list of keywords for all questions with a score of 2 or higher. You could explore that list by plotting something like the following: Update: the same with color (based on eigenvectors of the relation matrix) and without the self-study tag You could clean this graph up a bit further (e.g. take out the tags which do not relate to statistical concepts like software tags, in the above graph this is already done for the 'r' tag) and improve the visual representation, but I guess that this image above already shows a nice starting point. R-code: #the sql-script saved like an sql file network <- read.csv("~/../Desktop/network.csv", stringsAsFactors = 0) #it looks like this: > network[1][1:5,] [1] "<r><biostatistics><bioinformatics>" [2] "<hypothesis-testing><nonlinear-regression><regression-coefficients>" [3] "<aic>" [4] "<regression><nonparametric><kernel-smoothing>" [5] "<r><regression><experiment-design><simulation><random-generation>" l <- length(network[,1]) nk <- 1 keywords <- c("<r>") M <- matrix(0,1) for (j in 1:l) { # loop all lines in the text file s <- stringr::str_match_all(network[j,],"<.*?>") # extract keywords m <- c(0) for (is in s[[1]]) { if (sum(keywords == is) == 0) { # check if there is a new keyword keywords <- c(keywords,is) # add to the keywords table nk<-nk+1 M <- cbind(M,rep(0,nk-1)) # expand the relation matrix with zero's M <- rbind(M,rep(0,nk)) } m <- c(m, which(keywords == is)) lm <- length(m) if (lm>2) { # for keywords >2 add +1 to the relations for (mi in m[-c(1,lm)]) { M[mi,m[lm]] <- M[mi,m[lm]]+1 M[m[lm],mi] <- M[m[lm],mi]+1 } } } } #getting rid of < > skeywords <- sub(c("<"),"",keywords) skeywords <- sub(c(">"),"",skeywords) # plotting connections library(igraph) library("visNetwork") # reduces nodes and edges Ms<-M[-1,-1] # -1,-1 elliminates the 'r' tag which offsets the graph Ms[which(Ms<50)] <- 0 ww <- colSums(Ms) el <- which(ww==0) # convert to data object for VisNetwork function g <- graph.adjacency(Ms[-el,-el], weighted=TRUE, mode = "undirected") data <- toVisNetworkData(g) # adjust some plotting parameters some data$nodes['label'] <- skeywords[-1][-el] data$nodes['title'] <- skeywords[-1][-el] data$nodes['value'] <- colSums(Ms)[-el] data$edges['width'] <- sqrt(data$edges['weight'])*1 data$nodes['font.size'] <- 20+log(ww[-el])*6 data$edges['color'] <- "#eeeeff" #plot visNetwork(nodes = data$nodes, edges = data$edges) %>% visPhysics(solver = "forceAtlas2Based", stabilization = TRUE, forceAtlas2Based = list(nodeDistance=70, springConstant = 0.04, springLength = 50, avoidOverlap =1) ) Hierarchical branches I believe that these type of network graphs above relate to some of the criticisms regarding a purely branched hierarchical structure. If you like, I guess that you could perform a hierarchical-clustering to force it into a hierarchical structure. Below is an example of such hierarchical model. One would still need to find proper group names for the various clusters (but, I do not think that this hierarchical clustering is the good direction, so I leave it open). The distance measure for the clustering has been found by trial and error (making adjustments until the clusters appear nice. ##### ##### cluster library(cluster) Ms<-M[-1,-1] Ms[which(Ms<50)] <- 0 ww <- colSums(Ms) el <- which(ww==0) Ms<-M[-1,-1] R <- (keycount[-1]^-1) %*% t(keycount[-1]^-1) Ms <- log(Ms*R+0.00000001) Mc <- Ms[-el,-el] colnames(Mc) <- skeywords[-1][-el] cmod <- agnes(-Mc, diss = TRUE) plot(as.hclust(cmod), cex = 0.65, hang=-1, xlab = "", ylab ="")
What are the branches of statistics? You could look into the keywords/tags of the Cross Validated website. Branches as a network One way to do this is to plot it as a network based on the relationships between the keywords (how often th
8,983
What are the branches of statistics?
I find these classification systems extremely unhelpful and contradictory. For example: neural networks is a form of supervised learning Calculus is used in differential geometry Probability theory can be formalized as a part of set theory and so on. There are no unambiguous "branches" of mathematics, and nor should there be of statistics.
What are the branches of statistics?
I find these classification systems extremely unhelpful and contradictory. For example: neural networks is a form of supervised learning Calculus is used in differential geometry Probability theory c
What are the branches of statistics? I find these classification systems extremely unhelpful and contradictory. For example: neural networks is a form of supervised learning Calculus is used in differential geometry Probability theory can be formalized as a part of set theory and so on. There are no unambiguous "branches" of mathematics, and nor should there be of statistics.
What are the branches of statistics? I find these classification systems extremely unhelpful and contradictory. For example: neural networks is a form of supervised learning Calculus is used in differential geometry Probability theory c
8,984
What are the branches of statistics?
This is a minor counterpoint to Rob Hyndman's answer. It started off as a comment and then grew too complex for one. If this is too far from addressing the main question, I apologise and will delete it. Biology has been depicting hierarchical relationships since long before Darwin's first doodle (see Nick Cox's comment for a link). Most evolutionary relationships are still shown with this type of nice, clean, branching 'phylogenetic tree': However, we eventually realised that biology is messier than this. Occasionally there is genetic exchange (through interbreeding and other processes) between distinct species and genes present in one part of the tree 'jump' to a different part of the tree. Horizontal gene transfer moves genes around in a way that makes the simple tree depiction above inaccurate. However, we did not abandon trees, but merely created modifications to this type of visualisation: This is harder to follow, but it conveys a more accurate picture of reality. Another example: However, we never introduce these more complex figures to start with, because they are hard to grasp without understanding the basic concepts. Instead, we teach the basic idea with the simple figure, and then present them with the more complex figure and the newer complications to the story. Any 'map' of statistics would similarly be both inaccurate and a valuable teaching tool. Visualisations of the form OP suggests are very useful for students and should not be ignored just because they fail to capture reality in total. We can add more complexity to the picture once they have a basic framework in place.
What are the branches of statistics?
This is a minor counterpoint to Rob Hyndman's answer. It started off as a comment and then grew too complex for one. If this is too far from addressing the main question, I apologise and will delete i
What are the branches of statistics? This is a minor counterpoint to Rob Hyndman's answer. It started off as a comment and then grew too complex for one. If this is too far from addressing the main question, I apologise and will delete it. Biology has been depicting hierarchical relationships since long before Darwin's first doodle (see Nick Cox's comment for a link). Most evolutionary relationships are still shown with this type of nice, clean, branching 'phylogenetic tree': However, we eventually realised that biology is messier than this. Occasionally there is genetic exchange (through interbreeding and other processes) between distinct species and genes present in one part of the tree 'jump' to a different part of the tree. Horizontal gene transfer moves genes around in a way that makes the simple tree depiction above inaccurate. However, we did not abandon trees, but merely created modifications to this type of visualisation: This is harder to follow, but it conveys a more accurate picture of reality. Another example: However, we never introduce these more complex figures to start with, because they are hard to grasp without understanding the basic concepts. Instead, we teach the basic idea with the simple figure, and then present them with the more complex figure and the newer complications to the story. Any 'map' of statistics would similarly be both inaccurate and a valuable teaching tool. Visualisations of the form OP suggests are very useful for students and should not be ignored just because they fail to capture reality in total. We can add more complexity to the picture once they have a basic framework in place.
What are the branches of statistics? This is a minor counterpoint to Rob Hyndman's answer. It started off as a comment and then grew too complex for one. If this is too far from addressing the main question, I apologise and will delete i
8,985
What are the branches of statistics?
An easy way to go about answering your question is to look up the common classification tables. For instance, 2010 Mathematics Subject Classification is used by some publications to classify papers. These are relevant because that's how a lot of authors classify their own papers. There are many examples of similar classifications, e.g. arxiv's classification or Russian education ministry's UDK (universal decimal classifictaion) which is used widely for all publications and research. Another example is JEL Claasification System of American Economic Association. Rob Hyndman's paper "Automatic time series forecasting: the forecast package for R." It's classified as C53,C22,C52 according to JEL. Hyndman has a point though in criticizing the tree classifications. A better approach could be tagging, e.g. the keywords in his paper are: "ARIMA models, automatic forecasting, exponential smoothing, prediction intervals, state space models, time series, R." One could argue that these are better way to classify the papers, as they're not hierarchical and multiple hierarchies could be built. @whuber made a good point that some latest advances such as machine learning will not be under statistics in current classifications. For instance, take a look at the paper "Deep Learning: An Introduction for Applied Mathematicians" by Catherine F. Higham, Desmond J. Higham. They classified their paper under aforementioned MSC as 97R40, 68T01, 65K10, 62M45. these are under computer science, math education and numerical analysis in addition to stats
What are the branches of statistics?
An easy way to go about answering your question is to look up the common classification tables. For instance, 2010 Mathematics Subject Classification is used by some publications to classify papers. T
What are the branches of statistics? An easy way to go about answering your question is to look up the common classification tables. For instance, 2010 Mathematics Subject Classification is used by some publications to classify papers. These are relevant because that's how a lot of authors classify their own papers. There are many examples of similar classifications, e.g. arxiv's classification or Russian education ministry's UDK (universal decimal classifictaion) which is used widely for all publications and research. Another example is JEL Claasification System of American Economic Association. Rob Hyndman's paper "Automatic time series forecasting: the forecast package for R." It's classified as C53,C22,C52 according to JEL. Hyndman has a point though in criticizing the tree classifications. A better approach could be tagging, e.g. the keywords in his paper are: "ARIMA models, automatic forecasting, exponential smoothing, prediction intervals, state space models, time series, R." One could argue that these are better way to classify the papers, as they're not hierarchical and multiple hierarchies could be built. @whuber made a good point that some latest advances such as machine learning will not be under statistics in current classifications. For instance, take a look at the paper "Deep Learning: An Introduction for Applied Mathematicians" by Catherine F. Higham, Desmond J. Higham. They classified their paper under aforementioned MSC as 97R40, 68T01, 65K10, 62M45. these are under computer science, math education and numerical analysis in addition to stats
What are the branches of statistics? An easy way to go about answering your question is to look up the common classification tables. For instance, 2010 Mathematics Subject Classification is used by some publications to classify papers. T
8,986
What are the branches of statistics?
One way to approach the problem is look at citation and co-authorship networks in statistics journals, such as the Annals of Statistics, Biometrika, JASA, and JRSS-B. This was done by: Ji, P., & Jin, J. (2016). Coauthorship and citation networks for statisticians. The Annals of Applied Statistics, 10(4), 1779-1812. They identified communities of statisticians and used their domain understanding to label the communities as: High-Dimensional Data Analysis (HDDA-Coau-A) Theoretical Machine Learning Dimension Reduction Johns Hopkins Duke Stanford Quantile Regression Experimental Design Objective Bayes Biostatistics High-Dimensional Data Analysis (HDDA-Coau-B) Large-Scale Multiple Testing Variable Selection Spatial & Semi-parametric/Non-parametric Statistics The paper includes a detailed discussion of the communities along with decompositions of the bigger ones into further subcommunities. This may not entirely answer the question, since it's concerning the fields of researching statisticians rather than all fields, including ones which are no longer active. Hopefully it nonetheless is helpful. Of course, there's other caveats (such as only considering these four journals) which are discussed further in the paper.
What are the branches of statistics?
One way to approach the problem is look at citation and co-authorship networks in statistics journals, such as the Annals of Statistics, Biometrika, JASA, and JRSS-B. This was done by: Ji, P., & Jin,
What are the branches of statistics? One way to approach the problem is look at citation and co-authorship networks in statistics journals, such as the Annals of Statistics, Biometrika, JASA, and JRSS-B. This was done by: Ji, P., & Jin, J. (2016). Coauthorship and citation networks for statisticians. The Annals of Applied Statistics, 10(4), 1779-1812. They identified communities of statisticians and used their domain understanding to label the communities as: High-Dimensional Data Analysis (HDDA-Coau-A) Theoretical Machine Learning Dimension Reduction Johns Hopkins Duke Stanford Quantile Regression Experimental Design Objective Bayes Biostatistics High-Dimensional Data Analysis (HDDA-Coau-B) Large-Scale Multiple Testing Variable Selection Spatial & Semi-parametric/Non-parametric Statistics The paper includes a detailed discussion of the communities along with decompositions of the bigger ones into further subcommunities. This may not entirely answer the question, since it's concerning the fields of researching statisticians rather than all fields, including ones which are no longer active. Hopefully it nonetheless is helpful. Of course, there's other caveats (such as only considering these four journals) which are discussed further in the paper.
What are the branches of statistics? One way to approach the problem is look at citation and co-authorship networks in statistics journals, such as the Annals of Statistics, Biometrika, JASA, and JRSS-B. This was done by: Ji, P., & Jin,
8,987
What are the branches of statistics?
I see many amazing answers, and I don't know how an humble self made classification may be received, but I don't know any all-comprensive book of all statistics to show the summary of, and I do think that, as @mkt brillantly commented, a classification of a study field can be useful. So, here is my shot: descriptive statistics simple inference simple hypothesis testing plotting/data visualization sampling design experimental design survey design multivariate statistics (unsipervised) clustering component analysis latent variables models linear models (which are actually multivariate as well) ordinary least squares generalized linear models logit model other linear models Cox model quantile regression multivariate inference multiple hypothesis testing adjusted hypothesis testing models for structured data mixed effects models spacial models time series models non linear extensions generalized additive models bayesian statistics (actually bayesian methods exist for many things I already listed) non parametric regression and classification many machine learning methods fit here Of course this is over-simplicistic, it is only meant to get some idea straight to someone who barely knows the field, each of us here surely knows that there are a lot of methods in between the categories up here, many others I didn't list because they are less famous or because I simply forgot. Hope you like it.
What are the branches of statistics?
I see many amazing answers, and I don't know how an humble self made classification may be received, but I don't know any all-comprensive book of all statistics to show the summary of, and I do think
What are the branches of statistics? I see many amazing answers, and I don't know how an humble self made classification may be received, but I don't know any all-comprensive book of all statistics to show the summary of, and I do think that, as @mkt brillantly commented, a classification of a study field can be useful. So, here is my shot: descriptive statistics simple inference simple hypothesis testing plotting/data visualization sampling design experimental design survey design multivariate statistics (unsipervised) clustering component analysis latent variables models linear models (which are actually multivariate as well) ordinary least squares generalized linear models logit model other linear models Cox model quantile regression multivariate inference multiple hypothesis testing adjusted hypothesis testing models for structured data mixed effects models spacial models time series models non linear extensions generalized additive models bayesian statistics (actually bayesian methods exist for many things I already listed) non parametric regression and classification many machine learning methods fit here Of course this is over-simplicistic, it is only meant to get some idea straight to someone who barely knows the field, each of us here surely knows that there are a lot of methods in between the categories up here, many others I didn't list because they are less famous or because I simply forgot. Hope you like it.
What are the branches of statistics? I see many amazing answers, and I don't know how an humble self made classification may be received, but I don't know any all-comprensive book of all statistics to show the summary of, and I do think
8,988
What are the branches of statistics?
One way to organize this information is to find a good book and look at the table of contents. This is a paradox because you specifically asked about statistics, whereas most introductory graduate level texts on the topic are for statistics and probability theory together. A book I am reading on regression now has the following TOC: Frequentist Inference Bayesian Inference Hypothesis Testing and Variable Selection Linear Models General Regression Models Binary Data Models General Regression Models Preliminaries for Nonparametric Regression [a precursor to...] Spline and Kernel Methods Nonparametric Regression with Multiple Predictors (The remaining sections are supporting mathematics and probability theory) Differentiation of Matrix Expressions Matrix Results Some Linear Algebra Probability Distributions and Generating Functions Functions of Normal Random Variables Some Results from Classical Statistics Basic Large Sample Theory
What are the branches of statistics?
One way to organize this information is to find a good book and look at the table of contents. This is a paradox because you specifically asked about statistics, whereas most introductory graduate lev
What are the branches of statistics? One way to organize this information is to find a good book and look at the table of contents. This is a paradox because you specifically asked about statistics, whereas most introductory graduate level texts on the topic are for statistics and probability theory together. A book I am reading on regression now has the following TOC: Frequentist Inference Bayesian Inference Hypothesis Testing and Variable Selection Linear Models General Regression Models Binary Data Models General Regression Models Preliminaries for Nonparametric Regression [a precursor to...] Spline and Kernel Methods Nonparametric Regression with Multiple Predictors (The remaining sections are supporting mathematics and probability theory) Differentiation of Matrix Expressions Matrix Results Some Linear Algebra Probability Distributions and Generating Functions Functions of Normal Random Variables Some Results from Classical Statistics Basic Large Sample Theory
What are the branches of statistics? One way to organize this information is to find a good book and look at the table of contents. This is a paradox because you specifically asked about statistics, whereas most introductory graduate lev
8,989
What are the myths associated with linear regression, data transformations?
There are three myths that bother me. Predictor variables need to be normal. The pooled/marginal distribution of $Y$ has to be normal. Predictor variables should not be correlated, and if they are, some should be removed. I believe that the first two come from misunderstanding the standard assumption about normality in an OLS linear regression, which assumes that the error terms, which are estimated by the residuals, are normal. It seems that people have misinterpreted this to mean that the pooled/marginal distribution of all $Y$ values has to be normal. Indeed, as is mentioned in a comment, we still get a lot of what we like about OLS linear regression without having normal error terms, though we do not need a normal marginal distribution of $Y$ or normal features in order to have the OLS estimator coincide with maximum likelihood estimation. For the myth about correlated predictors, I have two hypotheses. People misinterpret the Gauss-Markov assumption about error term independence to mean that the predictors are independent. People think they can eliminate features to get strong performance with fewer variables, decreasing the overfitting. I understand the idea of dropping predictors in order to have less overfitting risk without sacrificing much of the information in your feature space, but that seems not to work out. My post here gets into why and links to further reading.
What are the myths associated with linear regression, data transformations?
There are three myths that bother me. Predictor variables need to be normal. The pooled/marginal distribution of $Y$ has to be normal. Predictor variables should not be correlated, and if they are,
What are the myths associated with linear regression, data transformations? There are three myths that bother me. Predictor variables need to be normal. The pooled/marginal distribution of $Y$ has to be normal. Predictor variables should not be correlated, and if they are, some should be removed. I believe that the first two come from misunderstanding the standard assumption about normality in an OLS linear regression, which assumes that the error terms, which are estimated by the residuals, are normal. It seems that people have misinterpreted this to mean that the pooled/marginal distribution of all $Y$ values has to be normal. Indeed, as is mentioned in a comment, we still get a lot of what we like about OLS linear regression without having normal error terms, though we do not need a normal marginal distribution of $Y$ or normal features in order to have the OLS estimator coincide with maximum likelihood estimation. For the myth about correlated predictors, I have two hypotheses. People misinterpret the Gauss-Markov assumption about error term independence to mean that the predictors are independent. People think they can eliminate features to get strong performance with fewer variables, decreasing the overfitting. I understand the idea of dropping predictors in order to have less overfitting risk without sacrificing much of the information in your feature space, but that seems not to work out. My post here gets into why and links to further reading.
What are the myths associated with linear regression, data transformations? There are three myths that bother me. Predictor variables need to be normal. The pooled/marginal distribution of $Y$ has to be normal. Predictor variables should not be correlated, and if they are,
8,990
What are the myths associated with linear regression, data transformations?
Myth A linear regression model can only model linear relationships between the outcome $y$ and the explanatory variables. Fact Despite the name, linear regression models can easily accomodate nonlinear relationships using polynomials, fractional polynomials, splines and other methods. The term "linear" in linear regression pertains to the fact that the model is linear in the parameters $\beta_0, \beta_1, \ldots$. For an in-depth explanation about the term "linear" with regards to models, I highly recommend this post.
What are the myths associated with linear regression, data transformations?
Myth A linear regression model can only model linear relationships between the outcome $y$ and the explanatory variables. Fact Despite the name, linear regression models can easily accomodate nonlinea
What are the myths associated with linear regression, data transformations? Myth A linear regression model can only model linear relationships between the outcome $y$ and the explanatory variables. Fact Despite the name, linear regression models can easily accomodate nonlinear relationships using polynomials, fractional polynomials, splines and other methods. The term "linear" in linear regression pertains to the fact that the model is linear in the parameters $\beta_0, \beta_1, \ldots$. For an in-depth explanation about the term "linear" with regards to models, I highly recommend this post.
What are the myths associated with linear regression, data transformations? Myth A linear regression model can only model linear relationships between the outcome $y$ and the explanatory variables. Fact Despite the name, linear regression models can easily accomodate nonlinea
8,991
What are the myths associated with linear regression, data transformations?
@Dave's answers are excellent. Here are some more myths. The original scale/transformation for Y is one you should use in the model. The central limit theorem means you don't have to worry about any of this if N is moderately large. Trying different transformations for Y does not distort standard errors, p-values, or confidence interval widths.
What are the myths associated with linear regression, data transformations?
@Dave's answers are excellent. Here are some more myths. The original scale/transformation for Y is one you should use in the model. The central limit theorem means you don't have to worry about any
What are the myths associated with linear regression, data transformations? @Dave's answers are excellent. Here are some more myths. The original scale/transformation for Y is one you should use in the model. The central limit theorem means you don't have to worry about any of this if N is moderately large. Trying different transformations for Y does not distort standard errors, p-values, or confidence interval widths.
What are the myths associated with linear regression, data transformations? @Dave's answers are excellent. Here are some more myths. The original scale/transformation for Y is one you should use in the model. The central limit theorem means you don't have to worry about any
8,992
What are the myths associated with linear regression, data transformations?
Myth: Variables that are not "significant" should be removed from a multiple regression. See When should one include a variable in a regression despite it not being statistically significant? for a discussion. Then search our site for "model identification," "regularization," "Lasso," etc.
What are the myths associated with linear regression, data transformations?
Myth: Variables that are not "significant" should be removed from a multiple regression. See When should one include a variable in a regression despite it not being statistically significant? for a di
What are the myths associated with linear regression, data transformations? Myth: Variables that are not "significant" should be removed from a multiple regression. See When should one include a variable in a regression despite it not being statistically significant? for a discussion. Then search our site for "model identification," "regularization," "Lasso," etc.
What are the myths associated with linear regression, data transformations? Myth: Variables that are not "significant" should be removed from a multiple regression. See When should one include a variable in a regression despite it not being statistically significant? for a di
8,993
What are the myths associated with linear regression, data transformations?
Myth: You should always standardize (or somehow "normalize") variables for the purpose of fitting regression models. Usually not: software will either do this automatically (under the hood, as it were) or uses algorithms that accommodate huge ranges of values among the variables without losing numerical precision. When the order of magnitude of one explanatory variable is more than about eight times greater than of another variable, though, then watch out: even preliminary standardization can run into trouble. ("Eight" orders of magnitude is the square root of double precision, which is about 15.6 orders of magnitude.) The commonest example is when a date is used along with other variables, because some dates are represented as the number of seconds elapsed since approximately 1970, which is on the order of $10^9$ seconds.
What are the myths associated with linear regression, data transformations?
Myth: You should always standardize (or somehow "normalize") variables for the purpose of fitting regression models. Usually not: software will either do this automatically (under the hood, as it were
What are the myths associated with linear regression, data transformations? Myth: You should always standardize (or somehow "normalize") variables for the purpose of fitting regression models. Usually not: software will either do this automatically (under the hood, as it were) or uses algorithms that accommodate huge ranges of values among the variables without losing numerical precision. When the order of magnitude of one explanatory variable is more than about eight times greater than of another variable, though, then watch out: even preliminary standardization can run into trouble. ("Eight" orders of magnitude is the square root of double precision, which is about 15.6 orders of magnitude.) The commonest example is when a date is used along with other variables, because some dates are represented as the number of seconds elapsed since approximately 1970, which is on the order of $10^9$ seconds.
What are the myths associated with linear regression, data transformations? Myth: You should always standardize (or somehow "normalize") variables for the purpose of fitting regression models. Usually not: software will either do this automatically (under the hood, as it were
8,994
What are the myths associated with linear regression, data transformations?
Myths: The normality of residuals (and possibly other assumptions of the model) should be tested with a formal hypothesis test, such as the Shapiro-Wilk test. A small $p$-value of such tests indicates that the model is invalid. Facts: Formal test of normality (and of other assumptions such as homoskedasticity) do not answer the relevant questions and if they are used to guide subsequent actions, can distort the operating characteristic of the models (e.g. inflating type 1 errors, change distribution of $p$-values under the null etc.). A "significant" Shapiro-Wilk test of the residuals just indicates some degree of incompatibiltiy with a normal distribution. It does not say that the (inevitable) deviation from a normal distribution is meaningful or impactful concerning the operating characteristics of the model. Some aspects - e.g. prediction intervals - are more sensitive with regards to the distribution of the errors than others. The $t$-test of the coefficients are reasonably robust (with regards to type 1 errors), for example. Whether or not the deviation of the residuals from a normal distribution is worrysome depends on a number of things: the goal of the analysis, the sample size, the degree of deviation, and more.
What are the myths associated with linear regression, data transformations?
Myths: The normality of residuals (and possibly other assumptions of the model) should be tested with a formal hypothesis test, such as the Shapiro-Wilk test. A small $p$-value of such tests indicate
What are the myths associated with linear regression, data transformations? Myths: The normality of residuals (and possibly other assumptions of the model) should be tested with a formal hypothesis test, such as the Shapiro-Wilk test. A small $p$-value of such tests indicates that the model is invalid. Facts: Formal test of normality (and of other assumptions such as homoskedasticity) do not answer the relevant questions and if they are used to guide subsequent actions, can distort the operating characteristic of the models (e.g. inflating type 1 errors, change distribution of $p$-values under the null etc.). A "significant" Shapiro-Wilk test of the residuals just indicates some degree of incompatibiltiy with a normal distribution. It does not say that the (inevitable) deviation from a normal distribution is meaningful or impactful concerning the operating characteristics of the model. Some aspects - e.g. prediction intervals - are more sensitive with regards to the distribution of the errors than others. The $t$-test of the coefficients are reasonably robust (with regards to type 1 errors), for example. Whether or not the deviation of the residuals from a normal distribution is worrysome depends on a number of things: the goal of the analysis, the sample size, the degree of deviation, and more.
What are the myths associated with linear regression, data transformations? Myths: The normality of residuals (and possibly other assumptions of the model) should be tested with a formal hypothesis test, such as the Shapiro-Wilk test. A small $p$-value of such tests indicate
8,995
What are the myths associated with linear regression, data transformations?
Where do these ideas come from? Poor texts (correction: very poor texts) after treating descriptive statistics often include some more or less mangled version of an idea that (1) you ideally need normally distributed variables to do anything inferential, or else (2) you need non-parametric tests. Then they may or may not mention that transformations could get you nearer (1). The first context for writing like ,this is often Student $t$ tests for comparing means and (Pearson) correlations. There is some historical context for this, for example in treatments that focused on a reference case of a bivariate normal distribution with a correlation as one parameter. So then writers start talking about regression. These texts are usually innocent of any formal specification of a data generation process.
What are the myths associated with linear regression, data transformations?
Where do these ideas come from? Poor texts (correction: very poor texts) after treating descriptive statistics often include some more or less mangled version of an idea that (1) you ideally need norm
What are the myths associated with linear regression, data transformations? Where do these ideas come from? Poor texts (correction: very poor texts) after treating descriptive statistics often include some more or less mangled version of an idea that (1) you ideally need normally distributed variables to do anything inferential, or else (2) you need non-parametric tests. Then they may or may not mention that transformations could get you nearer (1). The first context for writing like ,this is often Student $t$ tests for comparing means and (Pearson) correlations. There is some historical context for this, for example in treatments that focused on a reference case of a bivariate normal distribution with a correlation as one parameter. So then writers start talking about regression. These texts are usually innocent of any formal specification of a data generation process.
What are the myths associated with linear regression, data transformations? Where do these ideas come from? Poor texts (correction: very poor texts) after treating descriptive statistics often include some more or less mangled version of an idea that (1) you ideally need norm
8,996
What are the myths associated with linear regression, data transformations?
"Also, how did such myths come about?" One common assumption in regression is homoscedasticity (and a myth is that this is also necessary). Transformations are used to bring the data closer to this assumption. The violation of the assumption doesn't make the fitting method bad, least squares regression is the best unbiased linear estimator (in terms of lowest variance of the estimates) no matter what the underlying distribution is. But, the violation of the assumptions may cause wrong inferences when we express the observed effects in terms of significance/p-values. There is a difference between the assumptions that are necessary for least squares regression to work, and the assumptions that are necessary for the significance and hypothesis tests based on least squares regression to work.
What are the myths associated with linear regression, data transformations?
"Also, how did such myths come about?" One common assumption in regression is homoscedasticity (and a myth is that this is also necessary). Transformations are used to bring the data closer to this a
What are the myths associated with linear regression, data transformations? "Also, how did such myths come about?" One common assumption in regression is homoscedasticity (and a myth is that this is also necessary). Transformations are used to bring the data closer to this assumption. The violation of the assumption doesn't make the fitting method bad, least squares regression is the best unbiased linear estimator (in terms of lowest variance of the estimates) no matter what the underlying distribution is. But, the violation of the assumptions may cause wrong inferences when we express the observed effects in terms of significance/p-values. There is a difference between the assumptions that are necessary for least squares regression to work, and the assumptions that are necessary for the significance and hypothesis tests based on least squares regression to work.
What are the myths associated with linear regression, data transformations? "Also, how did such myths come about?" One common assumption in regression is homoscedasticity (and a myth is that this is also necessary). Transformations are used to bring the data closer to this a
8,997
What are the myths associated with linear regression, data transformations?
Myth: The error/deviation of the observations needs to be normally distributed. No, it doesn't. It is not just about the distribution of the errors of the observations, Instead what often matters is the distribution of the error of the estimates. These estimates are computed as a weighted sum of the observations $$\hat\beta = M \cdot y$$ with $$M = (X^TX)^{-1}X^T$$ If we want to estimate the error or significance of the estimates $\hat\beta$, then it is sufficient if those estimates follow approximately a normal distribution. This can happen also when the sampled error of observations $y$ do not follow a normal distribution. Due to the same principle of the central limit theorem, a statistic that is a weighted sum of variables or some sort of mean of variables will approach a normal distribution. So even if the distribution of the error/deviation of the observations is not normally distributed, the error/deviation estimates might still be approximately normally distributed.
What are the myths associated with linear regression, data transformations?
Myth: The error/deviation of the observations needs to be normally distributed. No, it doesn't. It is not just about the distribution of the errors of the observations, Instead what often matters is t
What are the myths associated with linear regression, data transformations? Myth: The error/deviation of the observations needs to be normally distributed. No, it doesn't. It is not just about the distribution of the errors of the observations, Instead what often matters is the distribution of the error of the estimates. These estimates are computed as a weighted sum of the observations $$\hat\beta = M \cdot y$$ with $$M = (X^TX)^{-1}X^T$$ If we want to estimate the error or significance of the estimates $\hat\beta$, then it is sufficient if those estimates follow approximately a normal distribution. This can happen also when the sampled error of observations $y$ do not follow a normal distribution. Due to the same principle of the central limit theorem, a statistic that is a weighted sum of variables or some sort of mean of variables will approach a normal distribution. So even if the distribution of the error/deviation of the observations is not normally distributed, the error/deviation estimates might still be approximately normally distributed.
What are the myths associated with linear regression, data transformations? Myth: The error/deviation of the observations needs to be normally distributed. No, it doesn't. It is not just about the distribution of the errors of the observations, Instead what often matters is t
8,998
What are the myths associated with linear regression, data transformations?
Myth: If the histogram of the residuals is nicely bell-shaped, and if the normal q-q plot of the residuals is very close to a straight line (and the sample size is reasonably large so that sampling error is minor), then the normality assumption is reasonable.
What are the myths associated with linear regression, data transformations?
Myth: If the histogram of the residuals is nicely bell-shaped, and if the normal q-q plot of the residuals is very close to a straight line (and the sample size is reasonably large so that sampling er
What are the myths associated with linear regression, data transformations? Myth: If the histogram of the residuals is nicely bell-shaped, and if the normal q-q plot of the residuals is very close to a straight line (and the sample size is reasonably large so that sampling error is minor), then the normality assumption is reasonable.
What are the myths associated with linear regression, data transformations? Myth: If the histogram of the residuals is nicely bell-shaped, and if the normal q-q plot of the residuals is very close to a straight line (and the sample size is reasonably large so that sampling er
8,999
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global extreme value?
They say an image is worth more than a thousand words. In the following example (courtesy of MS Paint, a handy tool for amateur and professional statisticians both) you can see a convex function surface and a point where the direction of the steepest descent clearly differs from the direction towards the optimum. On a serious note: There are far superior answers in this thread that also deserve an upvote.
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global e
They say an image is worth more than a thousand words. In the following example (courtesy of MS Paint, a handy tool for amateur and professional statisticians both) you can see a convex function surfa
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global extreme value? They say an image is worth more than a thousand words. In the following example (courtesy of MS Paint, a handy tool for amateur and professional statisticians both) you can see a convex function surface and a point where the direction of the steepest descent clearly differs from the direction towards the optimum. On a serious note: There are far superior answers in this thread that also deserve an upvote.
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global e They say an image is worth more than a thousand words. In the following example (courtesy of MS Paint, a handy tool for amateur and professional statisticians both) you can see a convex function surfa
9,000
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global extreme value?
Gradient descent methods use the slope of the surface. This will not necessarily (or even most likely not) point directly towards the extreme point. An intuitive view is to imagine a path of descent that is a curved path. See for instance the examples below. As an analogy: Imagine I blindfold you and put you somewhere on a mountain with the task to walk back to the extreme (low) point. On the hill, if you only have local information, then you are not knowing in which direction the bottom of the lake will be. If you can assume convexity Then you know that there is only one extreme point. Then you know that you are certainly gonna reach the extreme point as long as you move downwards. And then you also know that the angle between the steepest descent direction and the optimum direction is always at most $\pi/2$, as Solomonoff's Secret mentioned in the comments. Without convexity The angle may exceed $\pi/2$. In the image below this is emphasized by drawing an arrow of direction of descent for a particular point where the final solution is behind the line perpendicular to the direction of descent. In the convex problem this is not possible. You could relate this to the isolines for the cost function having a curvature all in the same direction when the problem is convex. In Stochastic Gradient Descent You follow the steepest direction for a single point (and you repeatedly take a step for a different point). In the example the problem is convex, but there may be more than one solutions. In the example the extreme values are on a line (instead of a single point), and from this particular viewpoint you could say that The steepest descent direction, may point directly to the "optimum" (although it is only the optimum for the function of that particular training sample point) Below is another view for four data points. Each of the four images shows the surface for a different single point. Each step a different point is chosen along which the gradient is computed. This makes that there are only four directions along which a step is made, but the stepsizes decrease when we get closer to the solution. The above images are for 4 datapoints generated by the function: $$y_i = e^{-0.4x_i}-e^{-0.8 x_i} + \epsilon_i$$ x = 0 2 4 6 y = 0.006 0.249 0.153 0.098 which results in: a non-convex optimization problem when we minimize the (non-linear) cost function $$ S(a,b) = \sum_{i=1} \left( y_i - (e^{-ax_i}-e^{-b x_i}) \right)^2$$ $$\nabla S(a,b) = \begin{bmatrix} \sum_{i=1} 2 x_i e^{-a x_i}\left( y_i - e^{-ax_i}-e^{-b x_i} \right) \\ \sum_{i=1} -2 x_i e^{-b x_i}\left( y_i - e^{-ax_i}-e^{-b x_i} \right) \end{bmatrix}$$ a convex optimization problem (like any linear least squares) when we minimize $$ S(a,b) = \sum_{i=1} \left( y_i - (a e^{-0.4 x_i}- b e^{-0.8 x_i} )\right)^2$$ $$\nabla S(a,b) = \begin{bmatrix} \sum_{i=1} -2 e^{-0.4x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \\ \sum_{i=1} 2 e^{-0.8x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \end{bmatrix}$$ a convex optimization problem (but not with a single minimum) when we minimize for some specific $i$ $$ S(a,b) = \left( y_i - (a e^{-0.4 b x_i}- b e^{-0.8 x_i}) \right)^2$$ which has gradient $$\nabla S(a,b) = \begin{bmatrix} -2 e^{-0.4x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \\ 2 e^{-0.8x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \end{bmatrix}$$ this has multiple minima (there are multiple $a$ and $b$ for which $S = 0$ )
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global e
Gradient descent methods use the slope of the surface. This will not necessarily (or even most likely not) point directly towards the extreme point. An intuitive view is to imagine a path of descent
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global extreme value? Gradient descent methods use the slope of the surface. This will not necessarily (or even most likely not) point directly towards the extreme point. An intuitive view is to imagine a path of descent that is a curved path. See for instance the examples below. As an analogy: Imagine I blindfold you and put you somewhere on a mountain with the task to walk back to the extreme (low) point. On the hill, if you only have local information, then you are not knowing in which direction the bottom of the lake will be. If you can assume convexity Then you know that there is only one extreme point. Then you know that you are certainly gonna reach the extreme point as long as you move downwards. And then you also know that the angle between the steepest descent direction and the optimum direction is always at most $\pi/2$, as Solomonoff's Secret mentioned in the comments. Without convexity The angle may exceed $\pi/2$. In the image below this is emphasized by drawing an arrow of direction of descent for a particular point where the final solution is behind the line perpendicular to the direction of descent. In the convex problem this is not possible. You could relate this to the isolines for the cost function having a curvature all in the same direction when the problem is convex. In Stochastic Gradient Descent You follow the steepest direction for a single point (and you repeatedly take a step for a different point). In the example the problem is convex, but there may be more than one solutions. In the example the extreme values are on a line (instead of a single point), and from this particular viewpoint you could say that The steepest descent direction, may point directly to the "optimum" (although it is only the optimum for the function of that particular training sample point) Below is another view for four data points. Each of the four images shows the surface for a different single point. Each step a different point is chosen along which the gradient is computed. This makes that there are only four directions along which a step is made, but the stepsizes decrease when we get closer to the solution. The above images are for 4 datapoints generated by the function: $$y_i = e^{-0.4x_i}-e^{-0.8 x_i} + \epsilon_i$$ x = 0 2 4 6 y = 0.006 0.249 0.153 0.098 which results in: a non-convex optimization problem when we minimize the (non-linear) cost function $$ S(a,b) = \sum_{i=1} \left( y_i - (e^{-ax_i}-e^{-b x_i}) \right)^2$$ $$\nabla S(a,b) = \begin{bmatrix} \sum_{i=1} 2 x_i e^{-a x_i}\left( y_i - e^{-ax_i}-e^{-b x_i} \right) \\ \sum_{i=1} -2 x_i e^{-b x_i}\left( y_i - e^{-ax_i}-e^{-b x_i} \right) \end{bmatrix}$$ a convex optimization problem (like any linear least squares) when we minimize $$ S(a,b) = \sum_{i=1} \left( y_i - (a e^{-0.4 x_i}- b e^{-0.8 x_i} )\right)^2$$ $$\nabla S(a,b) = \begin{bmatrix} \sum_{i=1} -2 e^{-0.4x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \\ \sum_{i=1} 2 e^{-0.8x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \end{bmatrix}$$ a convex optimization problem (but not with a single minimum) when we minimize for some specific $i$ $$ S(a,b) = \left( y_i - (a e^{-0.4 b x_i}- b e^{-0.8 x_i}) \right)^2$$ which has gradient $$\nabla S(a,b) = \begin{bmatrix} -2 e^{-0.4x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \\ 2 e^{-0.8x_i}\left( y_i - a e^{-0.4x_i}- b e^{-0.8 x_i} \right) \end{bmatrix}$$ this has multiple minima (there are multiple $a$ and $b$ for which $S = 0$ )
For convex problems, does gradient in Stochastic Gradient Descent (SGD) always point at the global e Gradient descent methods use the slope of the surface. This will not necessarily (or even most likely not) point directly towards the extreme point. An intuitive view is to imagine a path of descent