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
|
|---|---|---|---|---|---|---|
6,801
|
The meaning of "positive dependency" as a condition to use the usual method for FDR control
|
Positive dependence in this case means that the set of tests are positively correlated. The idea then is that if the variables in the set of tests that you have P-values for are positively correlated then each of the variables are not independent.
If you think back about a Bonferroni p-value correction, for example, you can guarantee that the type 1 error rate is less than 10% over say 100 statistically independent tests by setting your significance threshold to 0.1/100 = 0.001. But, what if each of those 100 tests a correlated in some way? Then you haven't really performed 100 separate tests.
In FDR, the idea is slightly different than the Bonferroni correction. The idea is to guarantee that only a certain percent (say 10%) of the things you declare significant are falsely declared significant. If you have correlated markers (positive dependence) in your dataset, the FDR value is chosen based on the total number of tests you perform (but the actual number of statistically independent tests is smaller). In this way it is more safe to conclude that the false discovery rate is falsely declaring significant 10% or less of the tests in your set of P-values.
Please see this book chapter for a discussion of positive dependence.
|
The meaning of "positive dependency" as a condition to use the usual method for FDR control
|
Positive dependence in this case means that the set of tests are positively correlated. The idea then is that if the variables in the set of tests that you have P-values for are positively correlated
|
The meaning of "positive dependency" as a condition to use the usual method for FDR control
Positive dependence in this case means that the set of tests are positively correlated. The idea then is that if the variables in the set of tests that you have P-values for are positively correlated then each of the variables are not independent.
If you think back about a Bonferroni p-value correction, for example, you can guarantee that the type 1 error rate is less than 10% over say 100 statistically independent tests by setting your significance threshold to 0.1/100 = 0.001. But, what if each of those 100 tests a correlated in some way? Then you haven't really performed 100 separate tests.
In FDR, the idea is slightly different than the Bonferroni correction. The idea is to guarantee that only a certain percent (say 10%) of the things you declare significant are falsely declared significant. If you have correlated markers (positive dependence) in your dataset, the FDR value is chosen based on the total number of tests you perform (but the actual number of statistically independent tests is smaller). In this way it is more safe to conclude that the false discovery rate is falsely declaring significant 10% or less of the tests in your set of P-values.
Please see this book chapter for a discussion of positive dependence.
|
The meaning of "positive dependency" as a condition to use the usual method for FDR control
Positive dependence in this case means that the set of tests are positively correlated. The idea then is that if the variables in the set of tests that you have P-values for are positively correlated
|
6,802
|
Pooling vs. stride for downsampling
|
The advantage of the convolution layer is that it can learn certain properties that you might not think of while you add pooling layer. Pooling is a fixed operation and convolution can be learned. On the other hand, pooling is a cheaper operation than convolution, both in terms of the amount of computation that you need to do and number of parameters that you need to store (no parameters for pooling layer).
There are examples when one of them is better choice than the other.
Example when the convolution with strides is better than pooling
The first layer in the ResNet uses convolution with strides. This is a great example of when striding gives you an advantage. This layer by itself significantly reduces the amount of computation that has to be done by the network in the subsequent layers. It compresses multiple 3x3 convolution (3 to be exact) in to one 7x7 convolution, to make sure that it has exactly the same receptive field as 3 convolution layers (even though it is less powerful in terms of what it can learn). At the same time this layer applies stride=2 that downsamples the image. Because this first layer in ResNet does convolution and downsampling at the same time, the operation becomes significantly cheaper computationally. If you use stride=1 and pooling for downsampling, then you will end up with convolution that does 4 times more computation + extra computation for the next pooling layer. The same trick was used in SqueezeNet and some other neural network architectures.
Example where pooling is better than convolution
In the NIPS 2018, there was a new architecture presented called FishNet. One thing that they try is to fix the problems with the residual connections used in the ResNet. In the ResNet, in few places, they put 1x1 convolution in the skip connection when downsampling was applied to the image. This convolution layer makes gradient propagation harder. One of the major changes in their paper is that they get rid of the convolutions in the residual connections and replaced them with pooling and simple upscales/identities/concatenations. This solution fixes problem with gradient propagation in very deep networks.
From the FishNet paper (Section 3.2)
The layers in the head are composed of concatenation, convolution with
identity mapping, and max-pooling. Therefore, the gradient propagation
problem from the previous backbone network in the tail are solved with
the FishNet by 1) excluding I-conv at the head; and 2) using
concatenation at the body and the head.
|
Pooling vs. stride for downsampling
|
The advantage of the convolution layer is that it can learn certain properties that you might not think of while you add pooling layer. Pooling is a fixed operation and convolution can be learned. On
|
Pooling vs. stride for downsampling
The advantage of the convolution layer is that it can learn certain properties that you might not think of while you add pooling layer. Pooling is a fixed operation and convolution can be learned. On the other hand, pooling is a cheaper operation than convolution, both in terms of the amount of computation that you need to do and number of parameters that you need to store (no parameters for pooling layer).
There are examples when one of them is better choice than the other.
Example when the convolution with strides is better than pooling
The first layer in the ResNet uses convolution with strides. This is a great example of when striding gives you an advantage. This layer by itself significantly reduces the amount of computation that has to be done by the network in the subsequent layers. It compresses multiple 3x3 convolution (3 to be exact) in to one 7x7 convolution, to make sure that it has exactly the same receptive field as 3 convolution layers (even though it is less powerful in terms of what it can learn). At the same time this layer applies stride=2 that downsamples the image. Because this first layer in ResNet does convolution and downsampling at the same time, the operation becomes significantly cheaper computationally. If you use stride=1 and pooling for downsampling, then you will end up with convolution that does 4 times more computation + extra computation for the next pooling layer. The same trick was used in SqueezeNet and some other neural network architectures.
Example where pooling is better than convolution
In the NIPS 2018, there was a new architecture presented called FishNet. One thing that they try is to fix the problems with the residual connections used in the ResNet. In the ResNet, in few places, they put 1x1 convolution in the skip connection when downsampling was applied to the image. This convolution layer makes gradient propagation harder. One of the major changes in their paper is that they get rid of the convolutions in the residual connections and replaced them with pooling and simple upscales/identities/concatenations. This solution fixes problem with gradient propagation in very deep networks.
From the FishNet paper (Section 3.2)
The layers in the head are composed of concatenation, convolution with
identity mapping, and max-pooling. Therefore, the gradient propagation
problem from the previous backbone network in the tail are solved with
the FishNet by 1) excluding I-conv at the head; and 2) using
concatenation at the body and the head.
|
Pooling vs. stride for downsampling
The advantage of the convolution layer is that it can learn certain properties that you might not think of while you add pooling layer. Pooling is a fixed operation and convolution can be learned. On
|
6,803
|
Pooling vs. stride for downsampling
|
In essence, max-pooling (or any kind of pooling) is a fixed operation and replacing it with a strided convolution can also be seen as learning the pooling operation, which increases the model's expressiveness ability. The down side is that it also increases the number of trainable parameters, but this is not a real problem in our days.
There is a very good article by JT Springenberg, where they replace all the max-pooling operations in a network with strided-convolutions. The paper demonstrates how doing so, improves the overall accuracy of a model with the same depth and width: "when pooling is replaced by an additional convolution layer with stride r = 2 performance stabilizes and even improves on the base model"
Striving for Simplicity: The All Convolutional Net
I encourage you to read the article, it isn't a hard read.
|
Pooling vs. stride for downsampling
|
In essence, max-pooling (or any kind of pooling) is a fixed operation and replacing it with a strided convolution can also be seen as learning the pooling operation, which increases the model's expres
|
Pooling vs. stride for downsampling
In essence, max-pooling (or any kind of pooling) is a fixed operation and replacing it with a strided convolution can also be seen as learning the pooling operation, which increases the model's expressiveness ability. The down side is that it also increases the number of trainable parameters, but this is not a real problem in our days.
There is a very good article by JT Springenberg, where they replace all the max-pooling operations in a network with strided-convolutions. The paper demonstrates how doing so, improves the overall accuracy of a model with the same depth and width: "when pooling is replaced by an additional convolution layer with stride r = 2 performance stabilizes and even improves on the base model"
Striving for Simplicity: The All Convolutional Net
I encourage you to read the article, it isn't a hard read.
|
Pooling vs. stride for downsampling
In essence, max-pooling (or any kind of pooling) is a fixed operation and replacing it with a strided convolution can also be seen as learning the pooling operation, which increases the model's expres
|
6,804
|
Is there Factor analysis or PCA for ordinal or binary data?
|
Traditional (linear) PCA and Factor analysis require scale-level (interval or ratio) data. Often likert-type rating data are assumed to be scale-level, because such data are easier to analyze. And the decision is sometimes warranted statistically, especially when the number of ordered categories is greater than 5 or 6. (Albeit purely logically the question of the data type and the number of scale levels are distinct.)
What if you prefer to treat polytomous likert scale as ordinal, though? Or you have dichotomous data? Is it possible to do exploratory factor analysis or PCA for them?
There are currently three main approaches to perform FA (including PCA as its special case) on categorical ordinal or binary variables (read also this account about binary data case, and this consideration about what might be done with ordinal scale).
Optimal scaling approach (a family of applications). Also called Categorical PCA (CatPCA) or nonlinear FA. In CatPCA, ordinal variables are monotonically transformed ("quantified") into their "underlying" interval versions under the objective to maximize the variance explained by the selected number of principal components extracted from those interval data. Which makes the method openly goal-driven (rather than theory-driven) and important to decide on the number of principal components in advance. If true FA is needed instead of PCA, usual linear FA can then naturally be performed on those transformed variables output from CatPCA. With binary variables, CatPCA (regrettably?) behaves in the manner of usual PCA, that is, as if they are continuous variables. CatPCA accepts also nominal variables and any mixture of variable types (nice).
Inferred underlying variable approach. Also known as PCA/FA performed on tetrachoric (for binary data) or polychoric (for ordinal data) correlations. Normal distribution is assumed for the underlying (then binned) continuous variable for every manifest variable. Then
classic FA is applied to analyze the aforesaid correlations. The approach easily allows for a mixture of interval, ordinal, binary data. One disadvantage of the approach is that - at inferring the correlations - it has no clues to the multivariate distribution of the underlying variables, - can "conceive of" at most bivariate distributions, thus bases itself not on full information.
Item response theory (IRT) approach. Sometimes also called logistic FA or latent trait analysis. A model very close to binary logit (for binary data) or proportional log odds (for ordinal data) model is applied. The algorithm is not tied with decomposing of a correlation matrix, so it is a bit away from traditional FA, still it is a bona fide categorical FA. "Discrimination parameters" closely correspond to loadings of FA, but "difficulties" replace the notion of "uniquenesses" of FA. IRT fitting certainty quickly decreases as the number of factors grows, which is a problematic side of this approach. IRT is extandible in its own way to incorporate mixed interval+binary+ordinal and possibly nominal variables.
Factor scores in approaches (2) and (3) are more difficult to estimate than factor scores in classic FA or in approach (1). However, several methods do exist (expected or maximum aposteriori methods, maximum likelihood method, etc.).
Factor analysis model assumptions is chiefly the same in the three approaches as in traditional FA. Approach (1) is available in R, SPSS, SAS (to my mind). Approaches (2) and (3) are implemented mostly in specialized latent-variable packages - Mplus, LISREL, EQS.
Polynomial approach. That has not been developed in full yet. Principal components can be modeled as polynomial combinations of variables (using polynomials is a popular way to model nonlinear effects of ordinal regressors.). Also, observed categories in turn can be modeled as discrete manifestations of polynomial combinations of latent factors.
There exist a flourishing field of nonlinear techniques of dimensionality reduction; some of them can be applied or adopted to work with categorical data (especially binary or after binarizing into a high-dimensional sparse dataset).
Performing classic (linear) FA/PCA on rank correlations or other associations suited for categorical data (Spearman/Kendall/Somer's etc.). In case of ordinal data, that is purely heuristic approach, lacking theoretical grounds and not recommended at all. With binary data, Spearman rho and Kendall tau-b correlations and Phi association all equal Pearson r correlation, therefore using them is nothing but doing usual linear FA/PCA on binary data (some perils of it here). It is also possible (albeit not unquestionable) doing the analysis on $r$ rescaled wrt its current magnitude bound.
Look also in this, this, this, this, this, this, this, this.
|
Is there Factor analysis or PCA for ordinal or binary data?
|
Traditional (linear) PCA and Factor analysis require scale-level (interval or ratio) data. Often likert-type rating data are assumed to be scale-level, because such data are easier to analyze. And the
|
Is there Factor analysis or PCA for ordinal or binary data?
Traditional (linear) PCA and Factor analysis require scale-level (interval or ratio) data. Often likert-type rating data are assumed to be scale-level, because such data are easier to analyze. And the decision is sometimes warranted statistically, especially when the number of ordered categories is greater than 5 or 6. (Albeit purely logically the question of the data type and the number of scale levels are distinct.)
What if you prefer to treat polytomous likert scale as ordinal, though? Or you have dichotomous data? Is it possible to do exploratory factor analysis or PCA for them?
There are currently three main approaches to perform FA (including PCA as its special case) on categorical ordinal or binary variables (read also this account about binary data case, and this consideration about what might be done with ordinal scale).
Optimal scaling approach (a family of applications). Also called Categorical PCA (CatPCA) or nonlinear FA. In CatPCA, ordinal variables are monotonically transformed ("quantified") into their "underlying" interval versions under the objective to maximize the variance explained by the selected number of principal components extracted from those interval data. Which makes the method openly goal-driven (rather than theory-driven) and important to decide on the number of principal components in advance. If true FA is needed instead of PCA, usual linear FA can then naturally be performed on those transformed variables output from CatPCA. With binary variables, CatPCA (regrettably?) behaves in the manner of usual PCA, that is, as if they are continuous variables. CatPCA accepts also nominal variables and any mixture of variable types (nice).
Inferred underlying variable approach. Also known as PCA/FA performed on tetrachoric (for binary data) or polychoric (for ordinal data) correlations. Normal distribution is assumed for the underlying (then binned) continuous variable for every manifest variable. Then
classic FA is applied to analyze the aforesaid correlations. The approach easily allows for a mixture of interval, ordinal, binary data. One disadvantage of the approach is that - at inferring the correlations - it has no clues to the multivariate distribution of the underlying variables, - can "conceive of" at most bivariate distributions, thus bases itself not on full information.
Item response theory (IRT) approach. Sometimes also called logistic FA or latent trait analysis. A model very close to binary logit (for binary data) or proportional log odds (for ordinal data) model is applied. The algorithm is not tied with decomposing of a correlation matrix, so it is a bit away from traditional FA, still it is a bona fide categorical FA. "Discrimination parameters" closely correspond to loadings of FA, but "difficulties" replace the notion of "uniquenesses" of FA. IRT fitting certainty quickly decreases as the number of factors grows, which is a problematic side of this approach. IRT is extandible in its own way to incorporate mixed interval+binary+ordinal and possibly nominal variables.
Factor scores in approaches (2) and (3) are more difficult to estimate than factor scores in classic FA or in approach (1). However, several methods do exist (expected or maximum aposteriori methods, maximum likelihood method, etc.).
Factor analysis model assumptions is chiefly the same in the three approaches as in traditional FA. Approach (1) is available in R, SPSS, SAS (to my mind). Approaches (2) and (3) are implemented mostly in specialized latent-variable packages - Mplus, LISREL, EQS.
Polynomial approach. That has not been developed in full yet. Principal components can be modeled as polynomial combinations of variables (using polynomials is a popular way to model nonlinear effects of ordinal regressors.). Also, observed categories in turn can be modeled as discrete manifestations of polynomial combinations of latent factors.
There exist a flourishing field of nonlinear techniques of dimensionality reduction; some of them can be applied or adopted to work with categorical data (especially binary or after binarizing into a high-dimensional sparse dataset).
Performing classic (linear) FA/PCA on rank correlations or other associations suited for categorical data (Spearman/Kendall/Somer's etc.). In case of ordinal data, that is purely heuristic approach, lacking theoretical grounds and not recommended at all. With binary data, Spearman rho and Kendall tau-b correlations and Phi association all equal Pearson r correlation, therefore using them is nothing but doing usual linear FA/PCA on binary data (some perils of it here). It is also possible (albeit not unquestionable) doing the analysis on $r$ rescaled wrt its current magnitude bound.
Look also in this, this, this, this, this, this, this, this.
|
Is there Factor analysis or PCA for ordinal or binary data?
Traditional (linear) PCA and Factor analysis require scale-level (interval or ratio) data. Often likert-type rating data are assumed to be scale-level, because such data are easier to analyze. And the
|
6,805
|
Difference between Bayesian networks and Markov process?
|
A probabilistic graphical model (PGM) is a graph formalism for compactly modeling joint probability distributions and (in)dependence relations over a set of random variables. A PGM is called a Bayesian network when the underlying graph is directed, and a Markov network/Markov random field when the underlying graph is undirected. Generally speaking, you use the former to model probabilistic influence between variables that have clear directionality, otherwise you use the latter; in both versions of PGMs, the lack of edges in the associated graphs represent conditional independencies in the encoded distributions, although their exact semantics differ. The "Markov" in "Markov network" refers to a generic notion of conditional independence encoded by PGMs, that of a set of random variables $x_A$ being independent of others $x_C$ given some set of "important" variables $x_B$ (the technical name is a Markov blanket), i.e. $p(x_A|x_B, x_C) = p(x_A|x_B)$.
A Markov process is any stochastic process $\{X_{t}\}$ that satisfies the Markov property. Here the emphasis is on a collection of (scalar) random variables $X_1, X_2, X_3, ...$ typically thought of as being indexed by time, that satisfies a specific kind of conditional independence, i.e., "the future is independent of the past given the present", roughly speaking $p(x_{t+1}|x_t, x_{t-1}, ..., x_1) = p(x_{t+1}|x_t)$.
This is a special case of the 'Markov' notion defined by PGMs: simply take the set $A=\{t+1\}, B=\{t\}$, and take $C$ to be any subset of $\{t-1, t-2, ..., 1\}$ and invoke the previous statement $p(x_A|x_B, x_C) = p(x_A|x_B)$. From this we see that the Markov blanket of any variable $X_{t+1}$ is its predecessor $X_t$.
Therefore you can represent a Markov process with a Bayesian network, as a linear chain indexed by time (for simplicity we only consider the case of discrete time/state here; picture from Bishop's PRML book):
This kind of Bayesian network is known as a dynamic Bayesian network. Since it's a Bayesian network (hence a PGM), one can apply standard PGM algorithms for probabilistic inference (like the sum-product algorithm, of which the Chapman−Kolmogorov Equations represent a special case) and parameter estimation (e.g. maximum likelihood, which boils down to simple counting) over the chain. Example applications of this are the HMM and n-gram language model.
Often you see a diagram depiction of a Markov chain like this one
This is not a PGM, because the nodes are not random variables, but elements of the state space of the chain; the edges correspond to the (non-zero) transitional probabilities between two consecutive states. You can also think of this graph as describing the CPT (conditional probability table) $p(X_t|X_{t-1})$ of the chain PGM. This Markov chain only encodes the state of the world at each time stamp as a single random variable (Mood); what if we want to capture other interacting aspects of the world (like Health, and Income of some person), and treat $X_t$ as a vector of random variables $(X_t^{(1)},...X_t^{(D)})$? This is where PGMs (in particular, dynamic Bayesian networks) can help. We can model complex distributions for $p(X_t^{(1)},...X_t^{(D)}|X_{t-1}^{(1)},...X_{t-1}^{(D)})$
using a conditional Bayesian network typically called a 2TBN (2-time-slice Bayesian network), which can be thought of as a fancier version of the simple chain Bayesian network.
TL;DR: a Bayesian network is a kind of PGM (probabilistic graphical model) that uses a directed (acyclic) graph to represent a factorized probability distribution and associated conditional independence over a set of variables. A Markov process is a stochastic process (typically thought of as a collection of random variables) with the property of "the future being independent of the past given the present"; the emphasis is more on studying the evolution of the the single "template" random variable $X_t$ across time (often as $t \to \infty$). A (scalar) Markov process defines the specific conditional independence property $p(x_{t+1}|x_t, x_{t-1}, ..., x_1) = p(x_{t+1}|x_t)$ and therefore can be trivially represented by a chain Bayesian network, whereas dynamic Bayesian networks can exploit the full representational power of PGMs to model interactions among multiple random variables (i.e., random vectors) across time; a great reference on this is Daphne Koller's PGM book chapter 6.
|
Difference between Bayesian networks and Markov process?
|
A probabilistic graphical model (PGM) is a graph formalism for compactly modeling joint probability distributions and (in)dependence relations over a set of random variables. A PGM is called a Bayesia
|
Difference between Bayesian networks and Markov process?
A probabilistic graphical model (PGM) is a graph formalism for compactly modeling joint probability distributions and (in)dependence relations over a set of random variables. A PGM is called a Bayesian network when the underlying graph is directed, and a Markov network/Markov random field when the underlying graph is undirected. Generally speaking, you use the former to model probabilistic influence between variables that have clear directionality, otherwise you use the latter; in both versions of PGMs, the lack of edges in the associated graphs represent conditional independencies in the encoded distributions, although their exact semantics differ. The "Markov" in "Markov network" refers to a generic notion of conditional independence encoded by PGMs, that of a set of random variables $x_A$ being independent of others $x_C$ given some set of "important" variables $x_B$ (the technical name is a Markov blanket), i.e. $p(x_A|x_B, x_C) = p(x_A|x_B)$.
A Markov process is any stochastic process $\{X_{t}\}$ that satisfies the Markov property. Here the emphasis is on a collection of (scalar) random variables $X_1, X_2, X_3, ...$ typically thought of as being indexed by time, that satisfies a specific kind of conditional independence, i.e., "the future is independent of the past given the present", roughly speaking $p(x_{t+1}|x_t, x_{t-1}, ..., x_1) = p(x_{t+1}|x_t)$.
This is a special case of the 'Markov' notion defined by PGMs: simply take the set $A=\{t+1\}, B=\{t\}$, and take $C$ to be any subset of $\{t-1, t-2, ..., 1\}$ and invoke the previous statement $p(x_A|x_B, x_C) = p(x_A|x_B)$. From this we see that the Markov blanket of any variable $X_{t+1}$ is its predecessor $X_t$.
Therefore you can represent a Markov process with a Bayesian network, as a linear chain indexed by time (for simplicity we only consider the case of discrete time/state here; picture from Bishop's PRML book):
This kind of Bayesian network is known as a dynamic Bayesian network. Since it's a Bayesian network (hence a PGM), one can apply standard PGM algorithms for probabilistic inference (like the sum-product algorithm, of which the Chapman−Kolmogorov Equations represent a special case) and parameter estimation (e.g. maximum likelihood, which boils down to simple counting) over the chain. Example applications of this are the HMM and n-gram language model.
Often you see a diagram depiction of a Markov chain like this one
This is not a PGM, because the nodes are not random variables, but elements of the state space of the chain; the edges correspond to the (non-zero) transitional probabilities between two consecutive states. You can also think of this graph as describing the CPT (conditional probability table) $p(X_t|X_{t-1})$ of the chain PGM. This Markov chain only encodes the state of the world at each time stamp as a single random variable (Mood); what if we want to capture other interacting aspects of the world (like Health, and Income of some person), and treat $X_t$ as a vector of random variables $(X_t^{(1)},...X_t^{(D)})$? This is where PGMs (in particular, dynamic Bayesian networks) can help. We can model complex distributions for $p(X_t^{(1)},...X_t^{(D)}|X_{t-1}^{(1)},...X_{t-1}^{(D)})$
using a conditional Bayesian network typically called a 2TBN (2-time-slice Bayesian network), which can be thought of as a fancier version of the simple chain Bayesian network.
TL;DR: a Bayesian network is a kind of PGM (probabilistic graphical model) that uses a directed (acyclic) graph to represent a factorized probability distribution and associated conditional independence over a set of variables. A Markov process is a stochastic process (typically thought of as a collection of random variables) with the property of "the future being independent of the past given the present"; the emphasis is more on studying the evolution of the the single "template" random variable $X_t$ across time (often as $t \to \infty$). A (scalar) Markov process defines the specific conditional independence property $p(x_{t+1}|x_t, x_{t-1}, ..., x_1) = p(x_{t+1}|x_t)$ and therefore can be trivially represented by a chain Bayesian network, whereas dynamic Bayesian networks can exploit the full representational power of PGMs to model interactions among multiple random variables (i.e., random vectors) across time; a great reference on this is Daphne Koller's PGM book chapter 6.
|
Difference between Bayesian networks and Markov process?
A probabilistic graphical model (PGM) is a graph formalism for compactly modeling joint probability distributions and (in)dependence relations over a set of random variables. A PGM is called a Bayesia
|
6,806
|
Difference between Bayesian networks and Markov process?
|
First a few words about Markov Processes. There are four distinct flavours of that beast, depending on the state space (discrete/continuous) and time variable (discrete/ continuous). The general idea of any Markov Process is that "given the present, future is independent of the past".
The simplest Markov Process, is discrete and finite space, and discrete time Markov Chain. You can visualize it as a set of nodes, with directed edges between them. The graph may have cycles, and even loops. On each edge you can write a number between 0 and 1, in such a manner, that for each node numbers on edges outgoing from that node sum to 1.
Now imagine a following process: you start in a given state A. Every second, you choose at random an outgoing edge from the state you're currently in, with probability of choosing that edge equal to the number on that edge. In such a way, you generate at random a sequence of states.
A very cool visualization of such a process can be found here: http://setosa.io/blog/2014/07/26/markov-chains/
The takeaway message is, that a graphical representation of a discrete space discrete time Markov Process is a general graph, that represents a distribution on sequences of nodes of the graph (given a starting node, or a starting distribution on nodes).
On the other hand, a Bayesian Network is a DAG (Directed Acyclic Graph) which represents a factorization of some joint probability distribution. Usually this representation tries to take into account conditional independence between some variables, to simplify the graph and decrease the number of parameters needed to estimate the joint probability distribution.
|
Difference between Bayesian networks and Markov process?
|
First a few words about Markov Processes. There are four distinct flavours of that beast, depending on the state space (discrete/continuous) and time variable (discrete/ continuous). The general idea
|
Difference between Bayesian networks and Markov process?
First a few words about Markov Processes. There are four distinct flavours of that beast, depending on the state space (discrete/continuous) and time variable (discrete/ continuous). The general idea of any Markov Process is that "given the present, future is independent of the past".
The simplest Markov Process, is discrete and finite space, and discrete time Markov Chain. You can visualize it as a set of nodes, with directed edges between them. The graph may have cycles, and even loops. On each edge you can write a number between 0 and 1, in such a manner, that for each node numbers on edges outgoing from that node sum to 1.
Now imagine a following process: you start in a given state A. Every second, you choose at random an outgoing edge from the state you're currently in, with probability of choosing that edge equal to the number on that edge. In such a way, you generate at random a sequence of states.
A very cool visualization of such a process can be found here: http://setosa.io/blog/2014/07/26/markov-chains/
The takeaway message is, that a graphical representation of a discrete space discrete time Markov Process is a general graph, that represents a distribution on sequences of nodes of the graph (given a starting node, or a starting distribution on nodes).
On the other hand, a Bayesian Network is a DAG (Directed Acyclic Graph) which represents a factorization of some joint probability distribution. Usually this representation tries to take into account conditional independence between some variables, to simplify the graph and decrease the number of parameters needed to estimate the joint probability distribution.
|
Difference between Bayesian networks and Markov process?
First a few words about Markov Processes. There are four distinct flavours of that beast, depending on the state space (discrete/continuous) and time variable (discrete/ continuous). The general idea
|
6,807
|
Difference between Bayesian networks and Markov process?
|
While I was searching for an answer to the same question I came across these answers. But none of them clarify the topic. When I found some good explanations I wanted to share with people who thought like me.
In book "Probabilistic reasoning in intelligent systems:Networks of Plausible Inference" written by Judea Pearl, chapter 3: Markov and Bayesian Networks:Two Graphical Representations of Probabilistic Knowledge, p.116:
The main weakness of Markov networks is their inability to represent induced and non-transitive dependencies; two independent variables will be directly connected by an edge, merely because some other variable depends on both. As a result, many useful independencies go unrepresented in the network. To overcome this deficiency, Bayesian networks use the richer language of directed graphs, where the directions of the arrows permit us to distinguish genuine dependencies from spurious dependencies induced by hypothetical observations.
|
Difference between Bayesian networks and Markov process?
|
While I was searching for an answer to the same question I came across these answers. But none of them clarify the topic. When I found some good explanations I wanted to share with people who thought
|
Difference between Bayesian networks and Markov process?
While I was searching for an answer to the same question I came across these answers. But none of them clarify the topic. When I found some good explanations I wanted to share with people who thought like me.
In book "Probabilistic reasoning in intelligent systems:Networks of Plausible Inference" written by Judea Pearl, chapter 3: Markov and Bayesian Networks:Two Graphical Representations of Probabilistic Knowledge, p.116:
The main weakness of Markov networks is their inability to represent induced and non-transitive dependencies; two independent variables will be directly connected by an edge, merely because some other variable depends on both. As a result, many useful independencies go unrepresented in the network. To overcome this deficiency, Bayesian networks use the richer language of directed graphs, where the directions of the arrows permit us to distinguish genuine dependencies from spurious dependencies induced by hypothetical observations.
|
Difference between Bayesian networks and Markov process?
While I was searching for an answer to the same question I came across these answers. But none of them clarify the topic. When I found some good explanations I wanted to share with people who thought
|
6,808
|
Difference between Bayesian networks and Markov process?
|
A Markov process is a stochastic process with the Markovian property (when the index is the time, the Markovian property is a special conditional independence, which says given present, past and future are independent.)
A Bayesian network is a directed graphical model.
(A Markov random field is a undirected graphical model.)
A graphical model captures the conditional independence, which can be different from the Markovian property.
I am not familiar with graphical models, but I think a graphical model can be seen as a stochastic process.
|
Difference between Bayesian networks and Markov process?
|
A Markov process is a stochastic process with the Markovian property (when the index is the time, the Markovian property is a special conditional independence, which says given present, past and futur
|
Difference between Bayesian networks and Markov process?
A Markov process is a stochastic process with the Markovian property (when the index is the time, the Markovian property is a special conditional independence, which says given present, past and future are independent.)
A Bayesian network is a directed graphical model.
(A Markov random field is a undirected graphical model.)
A graphical model captures the conditional independence, which can be different from the Markovian property.
I am not familiar with graphical models, but I think a graphical model can be seen as a stochastic process.
|
Difference between Bayesian networks and Markov process?
A Markov process is a stochastic process with the Markovian property (when the index is the time, the Markovian property is a special conditional independence, which says given present, past and futur
|
6,809
|
Difference between Bayesian networks and Markov process?
|
-The general idea of any Markov Process is that "given the present, future is independent of the past".
-The general idea of any Bayesian method is that "given the prior, future is independent of the past", its parameters, if indexed by observations, will follow a Markov process
PLUS
"all the following will be the same in how I update my beliefs
you give me new information A, then you give me new information B,
you give me new information B, then new information A
you give me A and B together"
So its parameters will really be a Markov process indexed by time, and not by observations
|
Difference between Bayesian networks and Markov process?
|
-The general idea of any Markov Process is that "given the present, future is independent of the past".
-The general idea of any Bayesian method is that "given the prior, future is independent of the
|
Difference between Bayesian networks and Markov process?
-The general idea of any Markov Process is that "given the present, future is independent of the past".
-The general idea of any Bayesian method is that "given the prior, future is independent of the past", its parameters, if indexed by observations, will follow a Markov process
PLUS
"all the following will be the same in how I update my beliefs
you give me new information A, then you give me new information B,
you give me new information B, then new information A
you give me A and B together"
So its parameters will really be a Markov process indexed by time, and not by observations
|
Difference between Bayesian networks and Markov process?
-The general idea of any Markov Process is that "given the present, future is independent of the past".
-The general idea of any Bayesian method is that "given the prior, future is independent of the
|
6,810
|
Why do we need to normalize the images before we put them into CNN?
|
First note: you really should be also dividing by the standard deviation of each feature (pixel) value as well. Subtracting the mean centers the input to 0, and dividing by the standard deviation makes any scaled feature value the number of standard deviations away from the mean.
To answer your question: Consider how a neural network learns its weights. C(NN)s learn by continually adding gradient error vectors (multiplied by a learning rate) computed from backpropagation to various weight matrices throughout the network as training examples are passed through.
The thing to notice here is the "multiplied by a learning rate".
If we didn't scale our input training vectors, the ranges of our distributions of feature values would likely be different for each feature, and thus the learning rate would cause corrections in each dimension that would differ (proportionally speaking) from one another. We might be over compensating a correction in one weight dimension while undercompensating in another.
This is non-ideal as we might find ourselves in a oscillating (unable to center onto a better maxima in cost(weights) space) state or in a slow moving (traveling too slow to get to a better maxima) state.
It is of course possible to have a per-weight learning rate, but it's yet more hyperparameters to introduce into an already complicated network that we'd also have to optimize to find. Generally learning rates are scalars.
Thus we try to normalize images before using them as input into NN (or any gradient based) algorithm.
|
Why do we need to normalize the images before we put them into CNN?
|
First note: you really should be also dividing by the standard deviation of each feature (pixel) value as well. Subtracting the mean centers the input to 0, and dividing by the standard deviation make
|
Why do we need to normalize the images before we put them into CNN?
First note: you really should be also dividing by the standard deviation of each feature (pixel) value as well. Subtracting the mean centers the input to 0, and dividing by the standard deviation makes any scaled feature value the number of standard deviations away from the mean.
To answer your question: Consider how a neural network learns its weights. C(NN)s learn by continually adding gradient error vectors (multiplied by a learning rate) computed from backpropagation to various weight matrices throughout the network as training examples are passed through.
The thing to notice here is the "multiplied by a learning rate".
If we didn't scale our input training vectors, the ranges of our distributions of feature values would likely be different for each feature, and thus the learning rate would cause corrections in each dimension that would differ (proportionally speaking) from one another. We might be over compensating a correction in one weight dimension while undercompensating in another.
This is non-ideal as we might find ourselves in a oscillating (unable to center onto a better maxima in cost(weights) space) state or in a slow moving (traveling too slow to get to a better maxima) state.
It is of course possible to have a per-weight learning rate, but it's yet more hyperparameters to introduce into an already complicated network that we'd also have to optimize to find. Generally learning rates are scalars.
Thus we try to normalize images before using them as input into NN (or any gradient based) algorithm.
|
Why do we need to normalize the images before we put them into CNN?
First note: you really should be also dividing by the standard deviation of each feature (pixel) value as well. Subtracting the mean centers the input to 0, and dividing by the standard deviation make
|
6,811
|
Is it possible to find the combined standard deviation?
|
So, if you just want to have two of these samples brought together into one you have:
$s_1 = \sqrt{\frac{1}{n_1}\Sigma_{i = 1}^{n_1} (x_i - \bar{y}_1)^2}$
$s_2 = \sqrt{\frac{1}{n_2}\Sigma_{i = 1}^{n_2} (y_i - \bar{y}_2)^2}$
where $\bar{y}_1$ and $\bar{y}_2$ are sample means and $s_1$ and $s_2$ are sample standard deviations.
To add them up you have:
$s = \sqrt{\frac{1}{n_1 + n_2}\Sigma_{i = 1}^{n_1 + n_2} (z_i - \bar{y})^2}$
which is not that straightforward since the new mean $\bar{y}$ is different from $\bar{y}_1$ and $\bar{y}_2$:
$\bar{y} = \frac{1}{n_1 + n_2}\Sigma_{i = 1}^{n_1 + n_2} z_i = \frac{n_1 \bar{y}_1 + n_2 \bar{y}_2}{n_1 + n_2}$
The final formula is:
$s = \sqrt{\frac{n_1 s_1^2 + n_2 s_2^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }}$
For the commonly-used Bessel-corrected ("$n-1$-denominator") version of standard deviation, the results for the means are as before, but
$s = \sqrt{\frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2 + n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1+n_2 - 1} }$
You can read more info here: http://en.wikipedia.org/wiki/Standard_deviation
|
Is it possible to find the combined standard deviation?
|
So, if you just want to have two of these samples brought together into one you have:
$s_1 = \sqrt{\frac{1}{n_1}\Sigma_{i = 1}^{n_1} (x_i - \bar{y}_1)^2}$
$s_2 = \sqrt{\frac{1}{n_2}\Sigma_{i = 1}^{n_2
|
Is it possible to find the combined standard deviation?
So, if you just want to have two of these samples brought together into one you have:
$s_1 = \sqrt{\frac{1}{n_1}\Sigma_{i = 1}^{n_1} (x_i - \bar{y}_1)^2}$
$s_2 = \sqrt{\frac{1}{n_2}\Sigma_{i = 1}^{n_2} (y_i - \bar{y}_2)^2}$
where $\bar{y}_1$ and $\bar{y}_2$ are sample means and $s_1$ and $s_2$ are sample standard deviations.
To add them up you have:
$s = \sqrt{\frac{1}{n_1 + n_2}\Sigma_{i = 1}^{n_1 + n_2} (z_i - \bar{y})^2}$
which is not that straightforward since the new mean $\bar{y}$ is different from $\bar{y}_1$ and $\bar{y}_2$:
$\bar{y} = \frac{1}{n_1 + n_2}\Sigma_{i = 1}^{n_1 + n_2} z_i = \frac{n_1 \bar{y}_1 + n_2 \bar{y}_2}{n_1 + n_2}$
The final formula is:
$s = \sqrt{\frac{n_1 s_1^2 + n_2 s_2^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }}$
For the commonly-used Bessel-corrected ("$n-1$-denominator") version of standard deviation, the results for the means are as before, but
$s = \sqrt{\frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2 + n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1+n_2 - 1} }$
You can read more info here: http://en.wikipedia.org/wiki/Standard_deviation
|
Is it possible to find the combined standard deviation?
So, if you just want to have two of these samples brought together into one you have:
$s_1 = \sqrt{\frac{1}{n_1}\Sigma_{i = 1}^{n_1} (x_i - \bar{y}_1)^2}$
$s_2 = \sqrt{\frac{1}{n_2}\Sigma_{i = 1}^{n_2
|
6,812
|
Is it possible to find the combined standard deviation?
|
This obviously extends to $K$ groups:
$$ s = \sqrt{ \frac{\sum_{k=1}^K (n_k-1)s_k^2 + n_k(\bar{y}_k-\bar{y})^2} {(\sum_{k=1}^K n_k) -1} }$$
|
Is it possible to find the combined standard deviation?
|
This obviously extends to $K$ groups:
$$ s = \sqrt{ \frac{\sum_{k=1}^K (n_k-1)s_k^2 + n_k(\bar{y}_k-\bar{y})^2} {(\sum_{k=1}^K n_k) -1} }$$
|
Is it possible to find the combined standard deviation?
This obviously extends to $K$ groups:
$$ s = \sqrt{ \frac{\sum_{k=1}^K (n_k-1)s_k^2 + n_k(\bar{y}_k-\bar{y})^2} {(\sum_{k=1}^K n_k) -1} }$$
|
Is it possible to find the combined standard deviation?
This obviously extends to $K$ groups:
$$ s = \sqrt{ \frac{\sum_{k=1}^K (n_k-1)s_k^2 + n_k(\bar{y}_k-\bar{y})^2} {(\sum_{k=1}^K n_k) -1} }$$
|
6,813
|
Is it possible to find the combined standard deviation?
|
I had the same problem: having the standard deviation, means and sizes of several subsets with empty intersection, compute the standard deviation of the union of those subsets.
I like the answer of sashkello and Glen_b ♦, but I wanted to find a proof of it. I did it in this way, and I leave it here in case it is of help for anybody.
So the aim is to see that indeed:
$$s = \left(\frac{n_1 s_1^2 + n_2 s_2^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }\right)^{1/2}$$
Step by step:
$$\left(\frac{n_1 s_1^2 + n_2 s_2^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}(x_i - \bar{y_1})^2 + \sum_{i=1}^{n_2}(y_i - \bar{y_2})^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left((x_i - \bar{y_1})^2 + (\bar{y}_1-\bar{y})^2\right) + \sum_{i=1}^{n_2}\left((y_i - \bar{y_2})^2 + (\bar{y}_2-\bar{y})^2\right)}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 + 2\bar{y_1}^2 -2x_i\bar{y_1} -2\bar{y_1}\bar{y} \right)}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 + 2\bar{y_2}^2 -2y_i\bar{y_2} -2\bar{y_2}\bar{y} \right)}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}\right) + 2n_1\bar{y_1}^2 -2\bar{y_1}\sum_{i=1}^{n_1}x_i}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_2}\frac{y_j}{n_2}\right) + 2n_2\bar{y_2}^2 -2\bar{y_2}\sum_{i=1}^{n_2}y_i}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}\right) + 2n_1\bar{y_1}^2 -2\bar{y_1}n_1\bar{y_1}}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_2}\frac{y_j}{n_2}\right) + 2n_2\bar{y_2}^2 -2\bar{y_2}n_2\bar{y_2}}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}\right)}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_2}\frac{y_j}{n_2}\right)}{n_1 + n_2}\right)^{1/2}
$$
Now the trick is to realize that we can reorder the sums: since each $$-2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}$$
term appears $n_1$ times, we can re-write the numerator as
$$\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}x_i\right),$$
and hence, continuing with the equality chain:
$$
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i - \bar{y}\right)^2}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i - \bar{y}\right)^2}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1 + n_2}\left(z_i - \bar{y}\right)^2}{n_1 + n_2}\right)^{1/2} = s \qquad \square$$
This been said, there is probably a simpler way to do this.
The formula can be extended to $k$ subsets as stated before. The proof would be induction on the number of sets. The base case is already proven, and for the induction step you should apply a similar equality chain to the latter.
|
Is it possible to find the combined standard deviation?
|
I had the same problem: having the standard deviation, means and sizes of several subsets with empty intersection, compute the standard deviation of the union of those subsets.
I like the answer of sa
|
Is it possible to find the combined standard deviation?
I had the same problem: having the standard deviation, means and sizes of several subsets with empty intersection, compute the standard deviation of the union of those subsets.
I like the answer of sashkello and Glen_b ♦, but I wanted to find a proof of it. I did it in this way, and I leave it here in case it is of help for anybody.
So the aim is to see that indeed:
$$s = \left(\frac{n_1 s_1^2 + n_2 s_2^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }\right)^{1/2}$$
Step by step:
$$\left(\frac{n_1 s_1^2 + n_2 s_2^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}(x_i - \bar{y_1})^2 + \sum_{i=1}^{n_2}(y_i - \bar{y_2})^2+ n_1(\bar{y}_1-\bar{y})^2 +n_2(\bar{y}_2-\bar{y})^2}{n_1 + n_2 }\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left((x_i - \bar{y_1})^2 + (\bar{y}_1-\bar{y})^2\right) + \sum_{i=1}^{n_2}\left((y_i - \bar{y_2})^2 + (\bar{y}_2-\bar{y})^2\right)}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 + 2\bar{y_1}^2 -2x_i\bar{y_1} -2\bar{y_1}\bar{y} \right)}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 + 2\bar{y_2}^2 -2y_i\bar{y_2} -2\bar{y_2}\bar{y} \right)}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}\right) + 2n_1\bar{y_1}^2 -2\bar{y_1}\sum_{i=1}^{n_1}x_i}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_2}\frac{y_j}{n_2}\right) + 2n_2\bar{y_2}^2 -2\bar{y_2}\sum_{i=1}^{n_2}y_i}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}\right) + 2n_1\bar{y_1}^2 -2\bar{y_1}n_1\bar{y_1}}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_2}\frac{y_j}{n_2}\right) + 2n_2\bar{y_2}^2 -2\bar{y_2}n_2\bar{y_2}}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}\right)}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i^2 + \bar{y}^2 -2\bar{y}\sum_{j=1}^{n_2}\frac{y_j}{n_2}\right)}{n_1 + n_2}\right)^{1/2}
$$
Now the trick is to realize that we can reorder the sums: since each $$-2\bar{y}\sum_{j=1}^{n_1}\frac{x_j}{n_1}$$
term appears $n_1$ times, we can re-write the numerator as
$$\sum_{i=1}^{n_1}\left(x_i^2 + \bar{y}^2 -2\bar{y}x_i\right),$$
and hence, continuing with the equality chain:
$$
=
\left(\frac{\sum_{i=1}^{n_1}\left(x_i - \bar{y}\right)^2}{n_1 + n_2} +
\frac{\sum_{i=1}^{n_2}\left(y_i - \bar{y}\right)^2}{n_1 + n_2}\right)^{1/2}
=
\left(\frac{\sum_{i=1}^{n_1 + n_2}\left(z_i - \bar{y}\right)^2}{n_1 + n_2}\right)^{1/2} = s \qquad \square$$
This been said, there is probably a simpler way to do this.
The formula can be extended to $k$ subsets as stated before. The proof would be induction on the number of sets. The base case is already proven, and for the induction step you should apply a similar equality chain to the latter.
|
Is it possible to find the combined standard deviation?
I had the same problem: having the standard deviation, means and sizes of several subsets with empty intersection, compute the standard deviation of the union of those subsets.
I like the answer of sa
|
6,814
|
How to calculate goodness of fit in glm (R)
|
Use the Null Deviance and the Residual Deviance, specifically:
1 - (Residual Deviance/Null Deviance)
If you think about it, you're trying to measure the ratio of the deviance in your model to the null; how much better your model is (residual deviance) than just the intercept (null deviance). If that ratio is tiny, you're 'explaining' most of the deviance in the null; 1 minus that gets you your R-squared.
In your instance you'd get .998.
If you just call the linear model (lm) instead of glm it will explicitly give you an R-squared in the summary and you can see it's the same number.
With the standard glm object in R, you can calculate this as:
reg = glm(...)
with(summary(reg), 1 - deviance/null.deviance)
|
How to calculate goodness of fit in glm (R)
|
Use the Null Deviance and the Residual Deviance, specifically:
1 - (Residual Deviance/Null Deviance)
If you think about it, you're trying to measure the ratio of the deviance in your model to the nul
|
How to calculate goodness of fit in glm (R)
Use the Null Deviance and the Residual Deviance, specifically:
1 - (Residual Deviance/Null Deviance)
If you think about it, you're trying to measure the ratio of the deviance in your model to the null; how much better your model is (residual deviance) than just the intercept (null deviance). If that ratio is tiny, you're 'explaining' most of the deviance in the null; 1 minus that gets you your R-squared.
In your instance you'd get .998.
If you just call the linear model (lm) instead of glm it will explicitly give you an R-squared in the summary and you can see it's the same number.
With the standard glm object in R, you can calculate this as:
reg = glm(...)
with(summary(reg), 1 - deviance/null.deviance)
|
How to calculate goodness of fit in glm (R)
Use the Null Deviance and the Residual Deviance, specifically:
1 - (Residual Deviance/Null Deviance)
If you think about it, you're trying to measure the ratio of the deviance in your model to the nul
|
6,815
|
How to calculate goodness of fit in glm (R)
|
The default error family for a glm model in (the language) R is Gaussian, so with the code submitted you are getting ordinary linear regression where $R^2$ is a widely accepted measure of "goodness of fit". The R glm function doesn't report the Nagelkerke-pseudo-"$R^2$" but rather the AIC (Akaike Information Criterion). In the case of an OLS model, the Nagelkerke GOF measure will be roughly the same as the $R^2$.
$$R^2_{\mathrm{GLM}}=1-\frac{(\sum_id_{i,\mathrm{model}}^2)^{2/N} }{(\sum_id_{i,\mathrm{null}}^2)^{2/N}} ~~~~~~~~.=.~~~~~~~~ 1-\frac{\mathit{SSE}/n[\mathrm{model}]}{\mathit{SST}/n[\mathrm{total}]} = R^2_{\mathrm{OLS}}$$
There is some debate about how such a measure on the LHS gets interpreted, but only when the models depart from the simpler Gaussian/OLS situation. But in GLMs where the link function may not be "identity", as was here, and the "squared error" may not have the same clear interpretation, so the Akaike Information Criterion is also reported because it appears to be more general. There are several other contenders in the GLM GOF sweepstakes with no clear winner.
You might want to consider not reporting a GOF measure if you are going to be using GLMs with other error structures: Which pseudo-$R^2$ measure is the one to report for logistic regression (Cox & Snell or Nagelkerke)?
|
How to calculate goodness of fit in glm (R)
|
The default error family for a glm model in (the language) R is Gaussian, so with the code submitted you are getting ordinary linear regression where $R^2$ is a widely accepted measure of "goodness of
|
How to calculate goodness of fit in glm (R)
The default error family for a glm model in (the language) R is Gaussian, so with the code submitted you are getting ordinary linear regression where $R^2$ is a widely accepted measure of "goodness of fit". The R glm function doesn't report the Nagelkerke-pseudo-"$R^2$" but rather the AIC (Akaike Information Criterion). In the case of an OLS model, the Nagelkerke GOF measure will be roughly the same as the $R^2$.
$$R^2_{\mathrm{GLM}}=1-\frac{(\sum_id_{i,\mathrm{model}}^2)^{2/N} }{(\sum_id_{i,\mathrm{null}}^2)^{2/N}} ~~~~~~~~.=.~~~~~~~~ 1-\frac{\mathit{SSE}/n[\mathrm{model}]}{\mathit{SST}/n[\mathrm{total}]} = R^2_{\mathrm{OLS}}$$
There is some debate about how such a measure on the LHS gets interpreted, but only when the models depart from the simpler Gaussian/OLS situation. But in GLMs where the link function may not be "identity", as was here, and the "squared error" may not have the same clear interpretation, so the Akaike Information Criterion is also reported because it appears to be more general. There are several other contenders in the GLM GOF sweepstakes with no clear winner.
You might want to consider not reporting a GOF measure if you are going to be using GLMs with other error structures: Which pseudo-$R^2$ measure is the one to report for logistic regression (Cox & Snell or Nagelkerke)?
|
How to calculate goodness of fit in glm (R)
The default error family for a glm model in (the language) R is Gaussian, so with the code submitted you are getting ordinary linear regression where $R^2$ is a widely accepted measure of "goodness of
|
6,816
|
How to calculate goodness of fit in glm (R)
|
If you are running a binary logistic model, you can also run the Hosmer Lemeshow Goodness of Fit test on your glm() model. Using the ResourceSelection library.
library(ResourceSelection)
model <- glm(tmpData$Y ~ tmpData$X1 + tmpData$X2 + tmpData$X3 +
as.numeric(tmpData$X4) + tmpData$X5 + tmpData$X6 + tmpData$X7, family = binomial)
summary(model)
hoslem.test(model$y, model$fitted)
|
How to calculate goodness of fit in glm (R)
|
If you are running a binary logistic model, you can also run the Hosmer Lemeshow Goodness of Fit test on your glm() model. Using the ResourceSelection library.
library(ResourceSelection)
model <- glm
|
How to calculate goodness of fit in glm (R)
If you are running a binary logistic model, you can also run the Hosmer Lemeshow Goodness of Fit test on your glm() model. Using the ResourceSelection library.
library(ResourceSelection)
model <- glm(tmpData$Y ~ tmpData$X1 + tmpData$X2 + tmpData$X3 +
as.numeric(tmpData$X4) + tmpData$X5 + tmpData$X6 + tmpData$X7, family = binomial)
summary(model)
hoslem.test(model$y, model$fitted)
|
How to calculate goodness of fit in glm (R)
If you are running a binary logistic model, you can also run the Hosmer Lemeshow Goodness of Fit test on your glm() model. Using the ResourceSelection library.
library(ResourceSelection)
model <- glm
|
6,817
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an elastic net regression?
|
Friedman, Hastie, and Tibshirani (2010), citing The Elements of Statistical Learning, write,
We often use the “one-standard-error” rule when selecting the best model; this acknowledges the fact that the risk curves are estimated with error, so errs on the side of parsimony.
The reason for using one standard error, as opposed to any other amount, seems to be because it's, well... standard. Krstajic, et al (2014) write (bold emphasis mine):
Breiman et al. [25] have found in the case of selecting optimal
tree size for classification tree models that the tree size with minimal cross-validation error generates a model which generally overfits. Therefore, in Section 3.4.3 of their book Breiman et al. [25] define the one standard error rule (1 SE rule) for choosing an optimal tree size, and they implement it throughout the book. In order to calculate the standard error for single V-fold cross- validation, accuracy needs to be calculated for each fold, and the standard error is calculated from V accuracies from each fold. Hastie et al. [4] define the 1 SE rule as selecting the most parsimonious model whose error is no more than one standard error above the error of the best model, and they suggest in several places using the 1 SE rule for general cross-validation use. The main point of the 1 SE rule, with which we agree, is to choose the simplest model whose accuracy is comparable with the best model.
The suggestion is that the choice of one standard error is entirely heuristic, based on the sense that one standard error typically is not large relative to the range of $\lambda$ values.
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an e
|
Friedman, Hastie, and Tibshirani (2010), citing The Elements of Statistical Learning, write,
We often use the “one-standard-error” rule when selecting the best model; this acknowledges the fact that
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an elastic net regression?
Friedman, Hastie, and Tibshirani (2010), citing The Elements of Statistical Learning, write,
We often use the “one-standard-error” rule when selecting the best model; this acknowledges the fact that the risk curves are estimated with error, so errs on the side of parsimony.
The reason for using one standard error, as opposed to any other amount, seems to be because it's, well... standard. Krstajic, et al (2014) write (bold emphasis mine):
Breiman et al. [25] have found in the case of selecting optimal
tree size for classification tree models that the tree size with minimal cross-validation error generates a model which generally overfits. Therefore, in Section 3.4.3 of their book Breiman et al. [25] define the one standard error rule (1 SE rule) for choosing an optimal tree size, and they implement it throughout the book. In order to calculate the standard error for single V-fold cross- validation, accuracy needs to be calculated for each fold, and the standard error is calculated from V accuracies from each fold. Hastie et al. [4] define the 1 SE rule as selecting the most parsimonious model whose error is no more than one standard error above the error of the best model, and they suggest in several places using the 1 SE rule for general cross-validation use. The main point of the 1 SE rule, with which we agree, is to choose the simplest model whose accuracy is comparable with the best model.
The suggestion is that the choice of one standard error is entirely heuristic, based on the sense that one standard error typically is not large relative to the range of $\lambda$ values.
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an e
Friedman, Hastie, and Tibshirani (2010), citing The Elements of Statistical Learning, write,
We often use the “one-standard-error” rule when selecting the best model; this acknowledges the fact that
|
6,818
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an elastic net regression?
|
Breiman et al.'s book (cited in the other answer's quote from Krstajic) is the oldest reference I've found for the 1SE rule.
This is Breiman, Friedman, Stone, and Olshen's Classification and Regression Trees (1984). They "derive" this rule in section 3.4.3.
So if you need a formal citation, that seems to be the original source.
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an e
|
Breiman et al.'s book (cited in the other answer's quote from Krstajic) is the oldest reference I've found for the 1SE rule.
This is Breiman, Friedman, Stone, and Olshen's Classification and Regressio
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an elastic net regression?
Breiman et al.'s book (cited in the other answer's quote from Krstajic) is the oldest reference I've found for the 1SE rule.
This is Breiman, Friedman, Stone, and Olshen's Classification and Regression Trees (1984). They "derive" this rule in section 3.4.3.
So if you need a formal citation, that seems to be the original source.
|
Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an e
Breiman et al.'s book (cited in the other answer's quote from Krstajic) is the oldest reference I've found for the 1SE rule.
This is Breiman, Friedman, Stone, and Olshen's Classification and Regressio
|
6,819
|
Graphical data overview (summary) function in R
|
Frank Harrell's Hmisc package has some basic graphics with options for annotation: check out the summary.formula() and related plot wrap functions. I also like the describe() function.
For additional information, have a look at the The Hmisc Library or An Introduction to S-Plus and the Hmisc and Design Libraries.
Here are some pictures taken from the on-line help (bpplt, describe, and plot(summary(...))):
Many other examples can be browsed on-line on the R Graphical Manual, see Hmisc (and don't miss rms).
|
Graphical data overview (summary) function in R
|
Frank Harrell's Hmisc package has some basic graphics with options for annotation: check out the summary.formula() and related plot wrap functions. I also like the describe() function.
For additional
|
Graphical data overview (summary) function in R
Frank Harrell's Hmisc package has some basic graphics with options for annotation: check out the summary.formula() and related plot wrap functions. I also like the describe() function.
For additional information, have a look at the The Hmisc Library or An Introduction to S-Plus and the Hmisc and Design Libraries.
Here are some pictures taken from the on-line help (bpplt, describe, and plot(summary(...))):
Many other examples can be browsed on-line on the R Graphical Manual, see Hmisc (and don't miss rms).
|
Graphical data overview (summary) function in R
Frank Harrell's Hmisc package has some basic graphics with options for annotation: check out the summary.formula() and related plot wrap functions. I also like the describe() function.
For additional
|
6,820
|
Graphical data overview (summary) function in R
|
I highly recommend the function chart.Correlations in the package PerformanceAnalytics. It packs an amazing amount of information into a single chart: kernel-density plots and histograms for each variable, and scatterplots, lowess smoothers, and correlations for each variable pair. It's one of my favorite graphical data summary functions:
library(PerformanceAnalytics)
chart.Correlation(iris[,1:4],col=iris$Species)
|
Graphical data overview (summary) function in R
|
I highly recommend the function chart.Correlations in the package PerformanceAnalytics. It packs an amazing amount of information into a single chart: kernel-density plots and histograms for each var
|
Graphical data overview (summary) function in R
I highly recommend the function chart.Correlations in the package PerformanceAnalytics. It packs an amazing amount of information into a single chart: kernel-density plots and histograms for each variable, and scatterplots, lowess smoothers, and correlations for each variable pair. It's one of my favorite graphical data summary functions:
library(PerformanceAnalytics)
chart.Correlation(iris[,1:4],col=iris$Species)
|
Graphical data overview (summary) function in R
I highly recommend the function chart.Correlations in the package PerformanceAnalytics. It packs an amazing amount of information into a single chart: kernel-density plots and histograms for each var
|
6,821
|
Graphical data overview (summary) function in R
|
I have found this function helpful... the original author's handle is respiratoryclub.
f_summary <- function(data_to_plot)
{
## univariate data summary
require(nortest)
#data <- as.numeric(scan ("data.txt")) #commenting out by mike
data <- na.omit(as.numeric(as.character(data_to_plot))) #added by mike
dataFull <- as.numeric(as.character(data_to_plot))
# first job is to save the graphics parameters currently used
def.par <- par(no.readonly = TRUE)
par("plt" = c(.2,.95,.2,.8))
layout( matrix(c(1,1,2,2,1,1,2,2,4,5,8,8,6,7,9,10,3,3,9,10), 5, 4, byrow = TRUE))
#histogram on the top left
h <- hist(data, breaks = "Sturges", plot = FALSE)
xfit<-seq(min(data),max(data),length=100)
yfit<-yfit<-dnorm(xfit,mean=mean(data),sd=sd(data))
yfit <- yfit*diff(h$mids[1:2])*length(data)
plot (h, axes = TRUE, main = paste(deparse(substitute(data_to_plot))), cex.main=2, xlab=NA)
lines(xfit, yfit, col="blue", lwd=2)
leg1 <- paste("mean = ", round(mean(data), digits = 4))
leg2 <- paste("sd = ", round(sd(data),digits = 4))
count <- paste("count = ", sum(!is.na(dataFull)))
missing <- paste("missing = ", sum(is.na(dataFull)))
legend(x = "topright", c(leg1,leg2,count,missing), bty = "n")
## normal qq plot
qqnorm(data, bty = "n", pch = 20)
qqline(data)
p <- ad.test(data)
leg <- paste("Anderson-Darling p = ", round(as.numeric(p[2]), digits = 4))
legend(x = "topleft", leg, bty = "n")
## boxplot (bottom left)
boxplot(data, horizontal = TRUE)
leg1 <- paste("median = ", round(median(data), digits = 4))
lq <- quantile(data, 0.25)
leg2 <- paste("25th percentile = ", round(lq,digits = 4))
uq <- quantile(data, 0.75)
leg3 <- paste("75th percentile = ", round(uq,digits = 4))
legend(x = "top", leg1, bty = "n")
legend(x = "bottom", paste(leg2, leg3, sep = "; "), bty = "n")
## the various histograms with different bins
h2 <- hist(data, breaks = (0:20 * (max(data) - min (data))/20)+min(data), plot = FALSE)
plot (h2, axes = TRUE, main = "20 bins")
h3 <- hist(data, breaks = (0:10 * (max(data) - min (data))/10)+min(data), plot = FALSE)
plot (h3, axes = TRUE, main = "10 bins")
h4 <- hist(data, breaks = (0:8 * (max(data) - min (data))/8)+min(data), plot = FALSE)
plot (h4, axes = TRUE, main = "8 bins")
h5 <- hist(data, breaks = (0:6 * (max(data) - min (data))/6)+min(data), plot = FALSE)
plot (h5, axes = TRUE,main = "6 bins")
## the time series, ACF and PACF
plot (data, main = "Time series", pch = 20, ylab = paste(deparse(substitute(data_to_plot))))
acf(data, lag.max = 20)
pacf(data, lag.max = 20)
## reset the graphics display to default
par(def.par)
#original code for f_summary by respiratoryclub
}
|
Graphical data overview (summary) function in R
|
I have found this function helpful... the original author's handle is respiratoryclub.
f_summary <- function(data_to_plot)
{
## univariate data summary
require(nortest)
#data <- as.numeric(scan ("dat
|
Graphical data overview (summary) function in R
I have found this function helpful... the original author's handle is respiratoryclub.
f_summary <- function(data_to_plot)
{
## univariate data summary
require(nortest)
#data <- as.numeric(scan ("data.txt")) #commenting out by mike
data <- na.omit(as.numeric(as.character(data_to_plot))) #added by mike
dataFull <- as.numeric(as.character(data_to_plot))
# first job is to save the graphics parameters currently used
def.par <- par(no.readonly = TRUE)
par("plt" = c(.2,.95,.2,.8))
layout( matrix(c(1,1,2,2,1,1,2,2,4,5,8,8,6,7,9,10,3,3,9,10), 5, 4, byrow = TRUE))
#histogram on the top left
h <- hist(data, breaks = "Sturges", plot = FALSE)
xfit<-seq(min(data),max(data),length=100)
yfit<-yfit<-dnorm(xfit,mean=mean(data),sd=sd(data))
yfit <- yfit*diff(h$mids[1:2])*length(data)
plot (h, axes = TRUE, main = paste(deparse(substitute(data_to_plot))), cex.main=2, xlab=NA)
lines(xfit, yfit, col="blue", lwd=2)
leg1 <- paste("mean = ", round(mean(data), digits = 4))
leg2 <- paste("sd = ", round(sd(data),digits = 4))
count <- paste("count = ", sum(!is.na(dataFull)))
missing <- paste("missing = ", sum(is.na(dataFull)))
legend(x = "topright", c(leg1,leg2,count,missing), bty = "n")
## normal qq plot
qqnorm(data, bty = "n", pch = 20)
qqline(data)
p <- ad.test(data)
leg <- paste("Anderson-Darling p = ", round(as.numeric(p[2]), digits = 4))
legend(x = "topleft", leg, bty = "n")
## boxplot (bottom left)
boxplot(data, horizontal = TRUE)
leg1 <- paste("median = ", round(median(data), digits = 4))
lq <- quantile(data, 0.25)
leg2 <- paste("25th percentile = ", round(lq,digits = 4))
uq <- quantile(data, 0.75)
leg3 <- paste("75th percentile = ", round(uq,digits = 4))
legend(x = "top", leg1, bty = "n")
legend(x = "bottom", paste(leg2, leg3, sep = "; "), bty = "n")
## the various histograms with different bins
h2 <- hist(data, breaks = (0:20 * (max(data) - min (data))/20)+min(data), plot = FALSE)
plot (h2, axes = TRUE, main = "20 bins")
h3 <- hist(data, breaks = (0:10 * (max(data) - min (data))/10)+min(data), plot = FALSE)
plot (h3, axes = TRUE, main = "10 bins")
h4 <- hist(data, breaks = (0:8 * (max(data) - min (data))/8)+min(data), plot = FALSE)
plot (h4, axes = TRUE, main = "8 bins")
h5 <- hist(data, breaks = (0:6 * (max(data) - min (data))/6)+min(data), plot = FALSE)
plot (h5, axes = TRUE,main = "6 bins")
## the time series, ACF and PACF
plot (data, main = "Time series", pch = 20, ylab = paste(deparse(substitute(data_to_plot))))
acf(data, lag.max = 20)
pacf(data, lag.max = 20)
## reset the graphics display to default
par(def.par)
#original code for f_summary by respiratoryclub
}
|
Graphical data overview (summary) function in R
I have found this function helpful... the original author's handle is respiratoryclub.
f_summary <- function(data_to_plot)
{
## univariate data summary
require(nortest)
#data <- as.numeric(scan ("dat
|
6,822
|
Graphical data overview (summary) function in R
|
I'm not sure if this is what you were thinking of, but you might want to check out the fitdistrplus package. This has a lot of nice functions that automatically generate useful summary information about your distribution, and make plots of some of that information. Here are some examples from the vignette:
library(fitdistrplus)
data(groundbeef)
windows() # or quartz() for mac
plotdist(groundbeef$serving)
windows()
> descdist(groundbeef$serving, boot=1000)
summary statistics
------
min: 10 max: 200
median: 79
mean: 73.64567
estimated sd: 35.88487
estimated skewness: 0.7352745
estimated kurtosis: 3.551384
fw = fitdist(groundbeef$serving, "weibull")
>summary(fw)
Fitting of the distribution ' weibull ' by maximum likelihood
Parameters :
estimate Std. Error
shape 2.185885 0.1045755
scale 83.347679 2.5268626
Loglikelihood: -1255.225 AIC: 2514.449 BIC: 2521.524
Correlation matrix:
shape scale
shape 1.000000 0.321821
scale 0.321821 1.000000
fg = fitdist(groundbeef$serving, "gamma")
fln = fitdist(groundbeef$serving, "lnorm")
windows()
plot(fw)
windows()
cdfcomp(list(fw,fln,fg), legendtext=c("Weibull","logNormal","gamma"), lwd=2,
xlab="serving sizes (g)")
>gofstat(fw)
Kolmogorov-Smirnov statistic: 0.1396646
Cramer-von Mises statistic: 0.6840994
Anderson-Darling statistic: 3.573646
|
Graphical data overview (summary) function in R
|
I'm not sure if this is what you were thinking of, but you might want to check out the fitdistrplus package. This has a lot of nice functions that automatically generate useful summary information ab
|
Graphical data overview (summary) function in R
I'm not sure if this is what you were thinking of, but you might want to check out the fitdistrplus package. This has a lot of nice functions that automatically generate useful summary information about your distribution, and make plots of some of that information. Here are some examples from the vignette:
library(fitdistrplus)
data(groundbeef)
windows() # or quartz() for mac
plotdist(groundbeef$serving)
windows()
> descdist(groundbeef$serving, boot=1000)
summary statistics
------
min: 10 max: 200
median: 79
mean: 73.64567
estimated sd: 35.88487
estimated skewness: 0.7352745
estimated kurtosis: 3.551384
fw = fitdist(groundbeef$serving, "weibull")
>summary(fw)
Fitting of the distribution ' weibull ' by maximum likelihood
Parameters :
estimate Std. Error
shape 2.185885 0.1045755
scale 83.347679 2.5268626
Loglikelihood: -1255.225 AIC: 2514.449 BIC: 2521.524
Correlation matrix:
shape scale
shape 1.000000 0.321821
scale 0.321821 1.000000
fg = fitdist(groundbeef$serving, "gamma")
fln = fitdist(groundbeef$serving, "lnorm")
windows()
plot(fw)
windows()
cdfcomp(list(fw,fln,fg), legendtext=c("Weibull","logNormal","gamma"), lwd=2,
xlab="serving sizes (g)")
>gofstat(fw)
Kolmogorov-Smirnov statistic: 0.1396646
Cramer-von Mises statistic: 0.6840994
Anderson-Darling statistic: 3.573646
|
Graphical data overview (summary) function in R
I'm not sure if this is what you were thinking of, but you might want to check out the fitdistrplus package. This has a lot of nice functions that automatically generate useful summary information ab
|
6,823
|
Graphical data overview (summary) function in R
|
To explore dataset I really like rattle. Install the package and just call rattle(). The interface is quite self explainatory.
|
Graphical data overview (summary) function in R
|
To explore dataset I really like rattle. Install the package and just call rattle(). The interface is quite self explainatory.
|
Graphical data overview (summary) function in R
To explore dataset I really like rattle. Install the package and just call rattle(). The interface is quite self explainatory.
|
Graphical data overview (summary) function in R
To explore dataset I really like rattle. Install the package and just call rattle(). The interface is quite self explainatory.
|
6,824
|
Graphical data overview (summary) function in R
|
Maybe you are looking for the library ggplot2 that lets you plot things in a pretty way.
Or you can check this website that seems to have lots of R graphic utilities
http://addictedtor.free.fr/graphiques/
|
Graphical data overview (summary) function in R
|
Maybe you are looking for the library ggplot2 that lets you plot things in a pretty way.
Or you can check this website that seems to have lots of R graphic utilities
http://addictedtor.free.fr/graphiq
|
Graphical data overview (summary) function in R
Maybe you are looking for the library ggplot2 that lets you plot things in a pretty way.
Or you can check this website that seems to have lots of R graphic utilities
http://addictedtor.free.fr/graphiques/
|
Graphical data overview (summary) function in R
Maybe you are looking for the library ggplot2 that lets you plot things in a pretty way.
Or you can check this website that seems to have lots of R graphic utilities
http://addictedtor.free.fr/graphiq
|
6,825
|
Graphical data overview (summary) function in R
|
Its probably not exactly what you are looking for, but the pairs.panels() function in the psych package for R may prove useful. It gives you correlation values in the upper diagonal, loess lines and points in the lower diagonal, and shows a histogram of each variable's scores in the diagonal line of the matrix. I personally think its one of the best graphical summaries of data around.
|
Graphical data overview (summary) function in R
|
Its probably not exactly what you are looking for, but the pairs.panels() function in the psych package for R may prove useful. It gives you correlation values in the upper diagonal, loess lines and
|
Graphical data overview (summary) function in R
Its probably not exactly what you are looking for, but the pairs.panels() function in the psych package for R may prove useful. It gives you correlation values in the upper diagonal, loess lines and points in the lower diagonal, and shows a histogram of each variable's scores in the diagonal line of the matrix. I personally think its one of the best graphical summaries of data around.
|
Graphical data overview (summary) function in R
Its probably not exactly what you are looking for, but the pairs.panels() function in the psych package for R may prove useful. It gives you correlation values in the upper diagonal, loess lines and
|
6,826
|
Graphical data overview (summary) function in R
|
My favourite is DescTools
library(DescTools)
data("iris")
Desc(iris, plotit = T)
Which produces a series of plots like these:
and displays a series of descriptive values (including mean, meanSE, median, percentiles, range, sd, IQR, values of skewness, and kurtosis):
Alternatively, tabplot is also very good for a graphical overview.
It produces fancy plots with tableplot(iris, sortCol=Species)
There is even a D3 version of tabplot, i.e. tabplotd3.
|
Graphical data overview (summary) function in R
|
My favourite is DescTools
library(DescTools)
data("iris")
Desc(iris, plotit = T)
Which produces a series of plots like these:
and displays a series of descriptive values (including mean, meanSE, me
|
Graphical data overview (summary) function in R
My favourite is DescTools
library(DescTools)
data("iris")
Desc(iris, plotit = T)
Which produces a series of plots like these:
and displays a series of descriptive values (including mean, meanSE, median, percentiles, range, sd, IQR, values of skewness, and kurtosis):
Alternatively, tabplot is also very good for a graphical overview.
It produces fancy plots with tableplot(iris, sortCol=Species)
There is even a D3 version of tabplot, i.e. tabplotd3.
|
Graphical data overview (summary) function in R
My favourite is DescTools
library(DescTools)
data("iris")
Desc(iris, plotit = T)
Which produces a series of plots like these:
and displays a series of descriptive values (including mean, meanSE, me
|
6,827
|
What is the meaning of the "." (dot) in R?
|
The dot can be used as in normal name. It has however additional special interpretation. Suppose we have an object with specific class:
a <- list(b=1)
class(a) <- "myclass"
Now declare myfunction as standard generic in the following way:
myfunction <- function(x,...) UseMethod("myfunction")
Now declare the function
myfunction.myclass <- function(x,...) x$b+1
Then the dot has special meaning. For all objects with class myclass calling
myfunction(a)
will actualy call function myfunction.myclass:
> myfunction(a)
[1] 2
This is used widely in R, the most apropriate example is function summary. Each class has its own summary function, so when you fit some model for example (which usually returns object with specific class), you need to invoke summary and it will call appropriate summary function for that specific model.
|
What is the meaning of the "." (dot) in R?
|
The dot can be used as in normal name. It has however additional special interpretation. Suppose we have an object with specific class:
a <- list(b=1)
class(a) <- "myclass"
Now declare myfunction a
|
What is the meaning of the "." (dot) in R?
The dot can be used as in normal name. It has however additional special interpretation. Suppose we have an object with specific class:
a <- list(b=1)
class(a) <- "myclass"
Now declare myfunction as standard generic in the following way:
myfunction <- function(x,...) UseMethod("myfunction")
Now declare the function
myfunction.myclass <- function(x,...) x$b+1
Then the dot has special meaning. For all objects with class myclass calling
myfunction(a)
will actualy call function myfunction.myclass:
> myfunction(a)
[1] 2
This is used widely in R, the most apropriate example is function summary. Each class has its own summary function, so when you fit some model for example (which usually returns object with specific class), you need to invoke summary and it will call appropriate summary function for that specific model.
|
What is the meaning of the "." (dot) in R?
The dot can be used as in normal name. It has however additional special interpretation. Suppose we have an object with specific class:
a <- list(b=1)
class(a) <- "myclass"
Now declare myfunction a
|
6,828
|
What is the meaning of the "." (dot) in R?
|
Look at the help page for ?formula with regard to . Here's the relevant bits:
There are two special interpretations of . in a formula. The usual one
is in the context of a data argument of model fitting functions and
means ‘all columns not otherwise in the formula’: see terms.formula.
In the context of update.formula, only, it means ‘what was previously
in this part of the formula’.
Alternatively, the reshape and reshape2 packages use . and ... a bit differently (from ?cast):
There are a couple of special variables: "..." represents all other
variables not used in the formula and "." represents no variable
|
What is the meaning of the "." (dot) in R?
|
Look at the help page for ?formula with regard to . Here's the relevant bits:
There are two special interpretations of . in a formula. The usual one
is in the context of a data argument of model fi
|
What is the meaning of the "." (dot) in R?
Look at the help page for ?formula with regard to . Here's the relevant bits:
There are two special interpretations of . in a formula. The usual one
is in the context of a data argument of model fitting functions and
means ‘all columns not otherwise in the formula’: see terms.formula.
In the context of update.formula, only, it means ‘what was previously
in this part of the formula’.
Alternatively, the reshape and reshape2 packages use . and ... a bit differently (from ?cast):
There are a couple of special variables: "..." represents all other
variables not used in the formula and "." represents no variable
|
What is the meaning of the "." (dot) in R?
Look at the help page for ?formula with regard to . Here's the relevant bits:
There are two special interpretations of . in a formula. The usual one
is in the context of a data argument of model fi
|
6,829
|
What is the meaning of the "." (dot) in R?
|
There are some exceptions (S3 method dispatch), but generally it is simply used as legibility aid, and as such has no special meaning.
|
What is the meaning of the "." (dot) in R?
|
There are some exceptions (S3 method dispatch), but generally it is simply used as legibility aid, and as such has no special meaning.
|
What is the meaning of the "." (dot) in R?
There are some exceptions (S3 method dispatch), but generally it is simply used as legibility aid, and as such has no special meaning.
|
What is the meaning of the "." (dot) in R?
There are some exceptions (S3 method dispatch), but generally it is simply used as legibility aid, and as such has no special meaning.
|
6,830
|
What is the meaning of the "." (dot) in R?
|
The dot in sample.formula doesn't separate sample from formula, other than visually. It is just a variable name. R variables names can consist of alphanumerics and dot (.) and underscore (_) with one exception. Here is the actual rule:
"A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number. Names such as ".2way" are not valid, and neither are the reserved words."
The second case (i.e., the case of is_spam~.) is different and is explained above.
|
What is the meaning of the "." (dot) in R?
|
The dot in sample.formula doesn't separate sample from formula, other than visually. It is just a variable name. R variables names can consist of alphanumerics and dot (.) and underscore (_) with one
|
What is the meaning of the "." (dot) in R?
The dot in sample.formula doesn't separate sample from formula, other than visually. It is just a variable name. R variables names can consist of alphanumerics and dot (.) and underscore (_) with one exception. Here is the actual rule:
"A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number. Names such as ".2way" are not valid, and neither are the reserved words."
The second case (i.e., the case of is_spam~.) is different and is explained above.
|
What is the meaning of the "." (dot) in R?
The dot in sample.formula doesn't separate sample from formula, other than visually. It is just a variable name. R variables names can consist of alphanumerics and dot (.) and underscore (_) with one
|
6,831
|
Difference between longitudinal design and time series
|
I will add that in time series context it is usually assumed that data observed is a realisation of stochastic process. Hence in time series a lot of attention is given to properties of stochastic processes, such as stationarity, ergodicity, etc. In longitudinal context in my understanding data comes from usual samples (by sample I mean sequence of iid variables) observed at different points in time, so classical statistic methods are applied, since they always assume that sample is observed.
For short answer, one might say that time series are studied in econometrics, longitudinal design -- in statistics. But that does not answer the question, just shifts it to another question. On the other hand a lot of short answers do exactly that.
|
Difference between longitudinal design and time series
|
I will add that in time series context it is usually assumed that data observed is a realisation of stochastic process. Hence in time series a lot of attention is given to properties of stochastic pro
|
Difference between longitudinal design and time series
I will add that in time series context it is usually assumed that data observed is a realisation of stochastic process. Hence in time series a lot of attention is given to properties of stochastic processes, such as stationarity, ergodicity, etc. In longitudinal context in my understanding data comes from usual samples (by sample I mean sequence of iid variables) observed at different points in time, so classical statistic methods are applied, since they always assume that sample is observed.
For short answer, one might say that time series are studied in econometrics, longitudinal design -- in statistics. But that does not answer the question, just shifts it to another question. On the other hand a lot of short answers do exactly that.
|
Difference between longitudinal design and time series
I will add that in time series context it is usually assumed that data observed is a realisation of stochastic process. Hence in time series a lot of attention is given to properties of stochastic pro
|
6,832
|
Difference between longitudinal design and time series
|
If we think of designs made up of $n$ cases measured on $k$ occasions, then the following loose definition seems to me to be descriptive of the distinction:
longitudinal designs: high $n$, low $k$
time series: low $n$, high $k$
Of course, this raises the question of what is high and what is low.
Summarising my own rough sense of these fuzzy definitions, prototypical examples of:
time series might have $n$ = 1, 2, or 5 and $k$ = 20, 50, 100, or 1000, and
longitudinal designs might have $n$ = 10, 50, 100, 1000 and $k$ = 2, 3, 5, 10, 20
Update:
Following up on Dr Who's question about what is the purpose of the distinction, I don't have an authoritative answer, but here are a few thoughts:
terminology evolves in disciplines concerned with particular substantive problems
time series
often concerned with forecasting future time points
often concerned with modelling various cyclical and trend processes
often concerned with describing temporal dynamics in great detail
often studies phenomena where the particular thing measured is of specific interest (e.g., unemployment rate, stock market indices, etc.)
temporal indices are often pre-existing
longitudinal designs:
often use samples of cases as exemplars of a population in order to make inferences about the population (e.g., sample of children to study how children change in general)
often concerned with fairly general temporal processes like growth, variability and relatively simple functional change models
study is often specifically designed to have a given number of time points.
often interested in variation in change processes
Given the differences in the actual temporal dynamics, and the particular combination of $k$ and $n$ this creates different statistical modelling challenges.
For example, with high $n$ and low $k$ multilevel models are often used that borrow strength from the typical change process to describe the individual change process.
These different disciplines, modelling challenges, and literatures encourage the creation of distinct terminology.
Anyway, that's my impression. Perhaps others have greater insight.
|
Difference between longitudinal design and time series
|
If we think of designs made up of $n$ cases measured on $k$ occasions, then the following loose definition seems to me to be descriptive of the distinction:
longitudinal designs: high $n$, low $k$
ti
|
Difference between longitudinal design and time series
If we think of designs made up of $n$ cases measured on $k$ occasions, then the following loose definition seems to me to be descriptive of the distinction:
longitudinal designs: high $n$, low $k$
time series: low $n$, high $k$
Of course, this raises the question of what is high and what is low.
Summarising my own rough sense of these fuzzy definitions, prototypical examples of:
time series might have $n$ = 1, 2, or 5 and $k$ = 20, 50, 100, or 1000, and
longitudinal designs might have $n$ = 10, 50, 100, 1000 and $k$ = 2, 3, 5, 10, 20
Update:
Following up on Dr Who's question about what is the purpose of the distinction, I don't have an authoritative answer, but here are a few thoughts:
terminology evolves in disciplines concerned with particular substantive problems
time series
often concerned with forecasting future time points
often concerned with modelling various cyclical and trend processes
often concerned with describing temporal dynamics in great detail
often studies phenomena where the particular thing measured is of specific interest (e.g., unemployment rate, stock market indices, etc.)
temporal indices are often pre-existing
longitudinal designs:
often use samples of cases as exemplars of a population in order to make inferences about the population (e.g., sample of children to study how children change in general)
often concerned with fairly general temporal processes like growth, variability and relatively simple functional change models
study is often specifically designed to have a given number of time points.
often interested in variation in change processes
Given the differences in the actual temporal dynamics, and the particular combination of $k$ and $n$ this creates different statistical modelling challenges.
For example, with high $n$ and low $k$ multilevel models are often used that borrow strength from the typical change process to describe the individual change process.
These different disciplines, modelling challenges, and literatures encourage the creation of distinct terminology.
Anyway, that's my impression. Perhaps others have greater insight.
|
Difference between longitudinal design and time series
If we think of designs made up of $n$ cases measured on $k$ occasions, then the following loose definition seems to me to be descriptive of the distinction:
longitudinal designs: high $n$, low $k$
ti
|
6,833
|
Difference between longitudinal design and time series
|
A time series is simple a sequence of data points spaced out over time, usually with regular time intervals. A longitudinal design is rather more specific, keeping the same sample for each observation over time.
An example of a time series might be unemployment measured every month using a labour force survey with a new sample each time; this would be a sequence of cross-sectional designs. But it could be anything such as your personal savings each year, which would also be longitudinal. Or it might simply follow a particular cohort of people growing older, such as the television documentary Seven Up! and the sequels every seven years after that - the latest was 49 Up in 2005, so there should be another edition next year. Longitudinal designs tend to tell you more about ways in which typical individuals change over time, but might (depending on the details of the design and whether the sample is refreshed) say less about how the population as a whole changes.
|
Difference between longitudinal design and time series
|
A time series is simple a sequence of data points spaced out over time, usually with regular time intervals. A longitudinal design is rather more specific, keeping the same sample for each observatio
|
Difference between longitudinal design and time series
A time series is simple a sequence of data points spaced out over time, usually with regular time intervals. A longitudinal design is rather more specific, keeping the same sample for each observation over time.
An example of a time series might be unemployment measured every month using a labour force survey with a new sample each time; this would be a sequence of cross-sectional designs. But it could be anything such as your personal savings each year, which would also be longitudinal. Or it might simply follow a particular cohort of people growing older, such as the television documentary Seven Up! and the sequels every seven years after that - the latest was 49 Up in 2005, so there should be another edition next year. Longitudinal designs tend to tell you more about ways in which typical individuals change over time, but might (depending on the details of the design and whether the sample is refreshed) say less about how the population as a whole changes.
|
Difference between longitudinal design and time series
A time series is simple a sequence of data points spaced out over time, usually with regular time intervals. A longitudinal design is rather more specific, keeping the same sample for each observatio
|
6,834
|
Difference between longitudinal design and time series
|
Time-series data are assessed at regular intervals for a long period of time. Whereas longitudinal data are not: the repeated measures are for a short period of time. That is data collection can stop / be terminated at a certain point in time to do the analysis or when the measures satisfies the researcher in terms of behavioural change.
|
Difference between longitudinal design and time series
|
Time-series data are assessed at regular intervals for a long period of time. Whereas longitudinal data are not: the repeated measures are for a short period of time. That is data collection can stop
|
Difference between longitudinal design and time series
Time-series data are assessed at regular intervals for a long period of time. Whereas longitudinal data are not: the repeated measures are for a short period of time. That is data collection can stop / be terminated at a certain point in time to do the analysis or when the measures satisfies the researcher in terms of behavioural change.
|
Difference between longitudinal design and time series
Time-series data are assessed at regular intervals for a long period of time. Whereas longitudinal data are not: the repeated measures are for a short period of time. That is data collection can stop
|
6,835
|
How to interpret variance and correlation of random effects in a mixed-effects model?
|
Your fitted model with lme() can be expressed as
$y_{ij} = \alpha_0 + \alpha_1 x_j + \delta_{0i} + \delta_{1i} x_j + \epsilon_{ij}$
where $y_{ij}$ is the score of $i$th employee at $x_j$ weeks, $\alpha_0$ and $\alpha_1$ are the fixed intercept and slope respectively, $\delta_{0i}$ and $\delta_{1i}$ are the random intercept and slope, and $\epsilon_{ij}$ is the residual. The assumptions for the random effects $\delta_{0i}$, $\delta_{1i}$ and residual $\epsilon_{ij}$ are
$(\delta_{0i}, \delta_{1i})^T \stackrel{d}{\sim} N((0, 0)^T, G)$ and $\epsilon_{ij} \stackrel{d}{\sim} N(0, \sigma^2)$,
where the variance-covariance structure $G$ is a 2 x 2 symmetric matrix of form
$$\begin{pmatrix}
g_1^2&g_{12}^2\\
g_{12}^2&g_2^2
\end{pmatrix}$$
You can get the variance matrix between random effects terms from VarCorr(LMER.EduA)$ID.
Your result basically says that
$\alpha_0$ = 261.171, $\alpha_1$ = 11.151,
$g_1^2$ = 680.236, $g_2^2$ = 13.562, and $\sigma^2$ = 774.256.
$g_{12}^2$ can be found in VarCorr(LMER.EduA) or calculated as $0.23\times \sqrt{g_1^2 g_2^2}$.
Specifically $g_1^2$ = 680.236 shows the variability of the intercept across employees, $g_2^2$ = 13.562 is the amount of variability in the slope across employees, and 0.231 indicates the positive correlation between intercept and slope (when an employee's intercept increases by one unit of standard deviation, that employee's slope would increase by 0.231 standard deviations).
|
How to interpret variance and correlation of random effects in a mixed-effects model?
|
Your fitted model with lme() can be expressed as
$y_{ij} = \alpha_0 + \alpha_1 x_j + \delta_{0i} + \delta_{1i} x_j + \epsilon_{ij}$
where $y_{ij}$ is the score of $i$th employee at $x_j$ weeks, $\alph
|
How to interpret variance and correlation of random effects in a mixed-effects model?
Your fitted model with lme() can be expressed as
$y_{ij} = \alpha_0 + \alpha_1 x_j + \delta_{0i} + \delta_{1i} x_j + \epsilon_{ij}$
where $y_{ij}$ is the score of $i$th employee at $x_j$ weeks, $\alpha_0$ and $\alpha_1$ are the fixed intercept and slope respectively, $\delta_{0i}$ and $\delta_{1i}$ are the random intercept and slope, and $\epsilon_{ij}$ is the residual. The assumptions for the random effects $\delta_{0i}$, $\delta_{1i}$ and residual $\epsilon_{ij}$ are
$(\delta_{0i}, \delta_{1i})^T \stackrel{d}{\sim} N((0, 0)^T, G)$ and $\epsilon_{ij} \stackrel{d}{\sim} N(0, \sigma^2)$,
where the variance-covariance structure $G$ is a 2 x 2 symmetric matrix of form
$$\begin{pmatrix}
g_1^2&g_{12}^2\\
g_{12}^2&g_2^2
\end{pmatrix}$$
You can get the variance matrix between random effects terms from VarCorr(LMER.EduA)$ID.
Your result basically says that
$\alpha_0$ = 261.171, $\alpha_1$ = 11.151,
$g_1^2$ = 680.236, $g_2^2$ = 13.562, and $\sigma^2$ = 774.256.
$g_{12}^2$ can be found in VarCorr(LMER.EduA) or calculated as $0.23\times \sqrt{g_1^2 g_2^2}$.
Specifically $g_1^2$ = 680.236 shows the variability of the intercept across employees, $g_2^2$ = 13.562 is the amount of variability in the slope across employees, and 0.231 indicates the positive correlation between intercept and slope (when an employee's intercept increases by one unit of standard deviation, that employee's slope would increase by 0.231 standard deviations).
|
How to interpret variance and correlation of random effects in a mixed-effects model?
Your fitted model with lme() can be expressed as
$y_{ij} = \alpha_0 + \alpha_1 x_j + \delta_{0i} + \delta_{1i} x_j + \epsilon_{ij}$
where $y_{ij}$ is the score of $i$th employee at $x_j$ weeks, $\alph
|
6,836
|
Derivation of change of variables of a probability density function?
|
Suppose $X$ is a continuous random variable with pdf $f$.
Let $Y=g(X)$, where $g$ is a monotonic function.
The function $g$ could be either monotonically increasing or monotonically decreasing. If $g$ were monotonically increasing, then the pdf of $Y$ is obtained as follows:
\begin{eqnarray*}
P(Y\le y) &=& P(g(X)\le y)\\
&=& P(X\le g^{-1}(y))\\
or\;\;F_{Y}(y)&=& F_{X}(g^{-1}(y)),\quad \mbox{by the definition of CDF}\\
\end{eqnarray*}
If $g$ instead were monotonically decreasing, then we would have to swap the inequality signs, since $g^{-1}$ is also monotically decreasing (see here):
\begin{eqnarray*}
P(Y\le y) &=& P(g(X)\le y)\\
&=& P(X\ge g^{-1}(y))\\
or\;\;F_{Y}(y)&=& 1-F_{X}(g^{-1}(y)),\quad \mbox{by the definition of CDF}\\
\end{eqnarray*}
By differentiating the CDFs on both sides w.r.t. $y$ and using the chain rule, we get the pdf of $Y$.
If the function $g$ is monotonically increasing, then the pdf of $Y$ is given by
\begin{equation*}
f_{Y}(y)= f_{X}(g^{-1}(y))\cdot \frac{d}{dy}g^{-1}(y)
\end{equation*}
and other hand, if it is monotonically decreasing, then the pdf of $Y$ is given by
\begin{equation*}
f_{Y}(y)= - f_{X}(g^{-1}(y))\cdot \frac{d}{dy}g^{-1}(y)
\end{equation*}
Since $\left|\frac{d}{dy}g^{-1}(y)\right| = -\frac{d}{dy}g^{-1}(y)$ if $\frac{d}{dy}g^{-1}(y) \le 0$ (which will be the case if $g$ is monotonically decreasing) and $\left|\frac{d}{dy}g^{-1}(y)\right| = \frac{d}{dy}g^{-1}(y)$ if $\frac{d}{dy}g^{-1}(y)\ge 0$ (which will be the case if $g$ is monotonically increasing), then the above two equations can be combined into a single equation:
\begin{equation*}
\therefore f_{Y}(y) = f_{X}(g^{-1}(y))\cdot \left|\frac{d}{dy}g^{-1}(y)\right|
\end{equation*}
|
Derivation of change of variables of a probability density function?
|
Suppose $X$ is a continuous random variable with pdf $f$.
Let $Y=g(X)$, where $g$ is a monotonic function.
The function $g$ could be either monotonically increasing or monotonically decreasing. If $g$
|
Derivation of change of variables of a probability density function?
Suppose $X$ is a continuous random variable with pdf $f$.
Let $Y=g(X)$, where $g$ is a monotonic function.
The function $g$ could be either monotonically increasing or monotonically decreasing. If $g$ were monotonically increasing, then the pdf of $Y$ is obtained as follows:
\begin{eqnarray*}
P(Y\le y) &=& P(g(X)\le y)\\
&=& P(X\le g^{-1}(y))\\
or\;\;F_{Y}(y)&=& F_{X}(g^{-1}(y)),\quad \mbox{by the definition of CDF}\\
\end{eqnarray*}
If $g$ instead were monotonically decreasing, then we would have to swap the inequality signs, since $g^{-1}$ is also monotically decreasing (see here):
\begin{eqnarray*}
P(Y\le y) &=& P(g(X)\le y)\\
&=& P(X\ge g^{-1}(y))\\
or\;\;F_{Y}(y)&=& 1-F_{X}(g^{-1}(y)),\quad \mbox{by the definition of CDF}\\
\end{eqnarray*}
By differentiating the CDFs on both sides w.r.t. $y$ and using the chain rule, we get the pdf of $Y$.
If the function $g$ is monotonically increasing, then the pdf of $Y$ is given by
\begin{equation*}
f_{Y}(y)= f_{X}(g^{-1}(y))\cdot \frac{d}{dy}g^{-1}(y)
\end{equation*}
and other hand, if it is monotonically decreasing, then the pdf of $Y$ is given by
\begin{equation*}
f_{Y}(y)= - f_{X}(g^{-1}(y))\cdot \frac{d}{dy}g^{-1}(y)
\end{equation*}
Since $\left|\frac{d}{dy}g^{-1}(y)\right| = -\frac{d}{dy}g^{-1}(y)$ if $\frac{d}{dy}g^{-1}(y) \le 0$ (which will be the case if $g$ is monotonically decreasing) and $\left|\frac{d}{dy}g^{-1}(y)\right| = \frac{d}{dy}g^{-1}(y)$ if $\frac{d}{dy}g^{-1}(y)\ge 0$ (which will be the case if $g$ is monotonically increasing), then the above two equations can be combined into a single equation:
\begin{equation*}
\therefore f_{Y}(y) = f_{X}(g^{-1}(y))\cdot \left|\frac{d}{dy}g^{-1}(y)\right|
\end{equation*}
|
Derivation of change of variables of a probability density function?
Suppose $X$ is a continuous random variable with pdf $f$.
Let $Y=g(X)$, where $g$ is a monotonic function.
The function $g$ could be either monotonically increasing or monotonically decreasing. If $g$
|
6,837
|
What does entropy tell us?
|
The entropy tells you how much uncertainty is in the system. Let's say you're looking for a cat, and you know that it's somewhere between your house and the neighbors, which is 1 mile away. Your kids tell you that the probability of a cat being on the distance $x$ from your house is described best by beta distribution $f(x;2,2)$. So a cat could be anywhere between 0 and 1, but more likely to be in the middle, i.e. $x_{max}=1/2$.
Let's plug the beta distribution into your equation, then you get $H=-0.125$.
Next, you ask your wife and she tells you that the best distribution to describe her knowledge of your cat is the uniform distribution. If you plug it to your entropy equation, you get $H=0$.
Both uniform and beta distributions let the cat be anywhere between 0 and 1 miles from your house, but there's more uncertainty in the uniform, because your wife has really no clue where the cat is hiding, while kids have some idea, they think it's more likely to be somewhere in the middle. That's why Beta's entropy is lower than Uniform's.
You might try other distributions, maybe your neighbor tells you the cat likes to be near either of the houses, so his beta distribution is with $\alpha=\beta=1/2$. Its $H$ must be lower than that of uniform again, because you get some idea about where to look for a cat. Guess whether your neighbor's information entropy is higher or lower than your kids'? I'd bet on kids any day on these matters.
UPDATE:
How does this work? One way to think of this is to start with a uniform distribution. If you agree that it's the one with the most uncertainty, then think of disturbing it. Let's look at the discrete case for simplicity. Take $\Delta p$ from one point and add it to another like follows:
$$p_i'=p-\Delta p$$
$$p_j'=p+\Delta p$$
Now, let's see how the entropy changes:
$$H-H'=p_i\ln p_i-p_i\ln (p_i-\Delta p)+p_j\ln p_j-p_j\ln (p_j+\Delta p)$$
$$=p\ln p-p\ln [p(1-\Delta p/p)]+p\ln p-p\ln [p(1+\Delta p/p)]$$
$$=-\ln (1-\Delta p/p)-\ln (1+\Delta p/p)>0$$
This means that any disturbance from the uniform distribution reduces the entropy (uncertainty). To show the same in continuous case, I'd have to use calculus of variations or something along this line, but you'll get the same kind of result, in principle.
UPDATE 2:
The mean of $n$ uniform random variables is a random variable itself, and it's from Bates distribution. From CLT we know that this new random variable's variance shrinks as $n\to\infty$. So, uncertainty of its location must reduce with increase in $n$: we're more and more certain that a cat's in the middle. My next plot and MATLAB code shows how the entropy decreases from 0 for $n=1$ (uniform distribution) to $n=13$. I'm using distributions31 library here.
x = 0:0.01:1;
for k=1:5
i = 1 + (k-1)*3;
idx(k) = i;
f = @(x)bates_pdf(x,i);
funb=@(x)f(x).*log(f(x));
fun = @(x)arrayfun(funb,x);
h(k) = -integral(fun,0,1);
subplot(1,5+1,k)
plot(x,arrayfun(f,x))
title(['Bates(x,' num2str(i) ')'])
ylim([0 6])
end
subplot(1,5+1,5+1)
plot(idx,h)
title 'Entropy'
|
What does entropy tell us?
|
The entropy tells you how much uncertainty is in the system. Let's say you're looking for a cat, and you know that it's somewhere between your house and the neighbors, which is 1 mile away. Your kids
|
What does entropy tell us?
The entropy tells you how much uncertainty is in the system. Let's say you're looking for a cat, and you know that it's somewhere between your house and the neighbors, which is 1 mile away. Your kids tell you that the probability of a cat being on the distance $x$ from your house is described best by beta distribution $f(x;2,2)$. So a cat could be anywhere between 0 and 1, but more likely to be in the middle, i.e. $x_{max}=1/2$.
Let's plug the beta distribution into your equation, then you get $H=-0.125$.
Next, you ask your wife and she tells you that the best distribution to describe her knowledge of your cat is the uniform distribution. If you plug it to your entropy equation, you get $H=0$.
Both uniform and beta distributions let the cat be anywhere between 0 and 1 miles from your house, but there's more uncertainty in the uniform, because your wife has really no clue where the cat is hiding, while kids have some idea, they think it's more likely to be somewhere in the middle. That's why Beta's entropy is lower than Uniform's.
You might try other distributions, maybe your neighbor tells you the cat likes to be near either of the houses, so his beta distribution is with $\alpha=\beta=1/2$. Its $H$ must be lower than that of uniform again, because you get some idea about where to look for a cat. Guess whether your neighbor's information entropy is higher or lower than your kids'? I'd bet on kids any day on these matters.
UPDATE:
How does this work? One way to think of this is to start with a uniform distribution. If you agree that it's the one with the most uncertainty, then think of disturbing it. Let's look at the discrete case for simplicity. Take $\Delta p$ from one point and add it to another like follows:
$$p_i'=p-\Delta p$$
$$p_j'=p+\Delta p$$
Now, let's see how the entropy changes:
$$H-H'=p_i\ln p_i-p_i\ln (p_i-\Delta p)+p_j\ln p_j-p_j\ln (p_j+\Delta p)$$
$$=p\ln p-p\ln [p(1-\Delta p/p)]+p\ln p-p\ln [p(1+\Delta p/p)]$$
$$=-\ln (1-\Delta p/p)-\ln (1+\Delta p/p)>0$$
This means that any disturbance from the uniform distribution reduces the entropy (uncertainty). To show the same in continuous case, I'd have to use calculus of variations or something along this line, but you'll get the same kind of result, in principle.
UPDATE 2:
The mean of $n$ uniform random variables is a random variable itself, and it's from Bates distribution. From CLT we know that this new random variable's variance shrinks as $n\to\infty$. So, uncertainty of its location must reduce with increase in $n$: we're more and more certain that a cat's in the middle. My next plot and MATLAB code shows how the entropy decreases from 0 for $n=1$ (uniform distribution) to $n=13$. I'm using distributions31 library here.
x = 0:0.01:1;
for k=1:5
i = 1 + (k-1)*3;
idx(k) = i;
f = @(x)bates_pdf(x,i);
funb=@(x)f(x).*log(f(x));
fun = @(x)arrayfun(funb,x);
h(k) = -integral(fun,0,1);
subplot(1,5+1,k)
plot(x,arrayfun(f,x))
title(['Bates(x,' num2str(i) ')'])
ylim([0 6])
end
subplot(1,5+1,5+1)
plot(idx,h)
title 'Entropy'
|
What does entropy tell us?
The entropy tells you how much uncertainty is in the system. Let's say you're looking for a cat, and you know that it's somewhere between your house and the neighbors, which is 1 mile away. Your kids
|
6,838
|
What does entropy tell us?
|
what does that quantity actually tell me?
I'd like to plug in a straightforward answer as follows:
It's intuitive to illustrate that in a discrete scenario. Suppose that you toss a heavily biased coin, saying the probability of seeing head on each flip is 0.99. Every actual flip tells you very little information because you almost already know that it will be head. But when it comes to a fairer coin, it's harder for you to have any idea what to expect, then every flip tells you more information than any more biased coin. The quantity of information obtained by observing a single toss is equated with $\log \frac{1}{p(x)}$.
What the quantity of the entropy tells us is the information every actual flipping on average(weighted by its probability of occuring) can convey: $E \log \frac{1}{p(x)} = \sum p(x) \log \frac{1}{p(x)} $. The fairer the coin the larger the entropy, and a completely fair coin will be maximally informative.
|
What does entropy tell us?
|
what does that quantity actually tell me?
I'd like to plug in a straightforward answer as follows:
It's intuitive to illustrate that in a discrete scenario. Suppose that you toss a heavily biased co
|
What does entropy tell us?
what does that quantity actually tell me?
I'd like to plug in a straightforward answer as follows:
It's intuitive to illustrate that in a discrete scenario. Suppose that you toss a heavily biased coin, saying the probability of seeing head on each flip is 0.99. Every actual flip tells you very little information because you almost already know that it will be head. But when it comes to a fairer coin, it's harder for you to have any idea what to expect, then every flip tells you more information than any more biased coin. The quantity of information obtained by observing a single toss is equated with $\log \frac{1}{p(x)}$.
What the quantity of the entropy tells us is the information every actual flipping on average(weighted by its probability of occuring) can convey: $E \log \frac{1}{p(x)} = \sum p(x) \log \frac{1}{p(x)} $. The fairer the coin the larger the entropy, and a completely fair coin will be maximally informative.
|
What does entropy tell us?
what does that quantity actually tell me?
I'd like to plug in a straightforward answer as follows:
It's intuitive to illustrate that in a discrete scenario. Suppose that you toss a heavily biased co
|
6,839
|
What does entropy tell us?
|
I don't feel that the most of the answers provided above are answering the question posed, except the comment by whuber. If I understand correctly, the original question pertains to DISCRETE cases as opposed the continuous cases. My impression is that RustyStatistician knows well what entropy means in discrete cases but is not sure of its meaning in continuous cases. Here is my answer: it does not mean much!
The following are my reasons:
I have had the same question for years, have had searched for a satisfactory answer for years, but without success.
To me one of the most important properties of entropy is its label invariance in discrete cases - it does not change its value under permutations on the index set $\{k;k\geq 1\}$, as in $\{p_{k}; k\geq 1\}$. As it is label-invariant, it measures internal volatility of a random element (as opposed to a random variable). In continuous cases (continuous random variables $X$), entropy changes its value if the values on the real line are arbitrarily exchanged. This fact puts entropy in continuous cases in a very different category. It does not mean that it is useless, but is of different meaning and different utility.
I have consulted a world class expert on entropy, his best answer was: if you ask 10 experts the same question, they will give you at least 9 different answers.
Legend has it that Kolmogorov once said to his students that entropy in continuous cases does not mean much. Many years later, I asked one of his students for a reference. He said with heavy Russian accent, "perhaps he just said it."
One day Confucius was asked a question by one of his pupils, "what happens after one dies?" Confucius replied, "it is best to not answer this question until we figured out what happens before one dies."
|
What does entropy tell us?
|
I don't feel that the most of the answers provided above are answering the question posed, except the comment by whuber. If I understand correctly, the original question pertains to DISCRETE cases as
|
What does entropy tell us?
I don't feel that the most of the answers provided above are answering the question posed, except the comment by whuber. If I understand correctly, the original question pertains to DISCRETE cases as opposed the continuous cases. My impression is that RustyStatistician knows well what entropy means in discrete cases but is not sure of its meaning in continuous cases. Here is my answer: it does not mean much!
The following are my reasons:
I have had the same question for years, have had searched for a satisfactory answer for years, but without success.
To me one of the most important properties of entropy is its label invariance in discrete cases - it does not change its value under permutations on the index set $\{k;k\geq 1\}$, as in $\{p_{k}; k\geq 1\}$. As it is label-invariant, it measures internal volatility of a random element (as opposed to a random variable). In continuous cases (continuous random variables $X$), entropy changes its value if the values on the real line are arbitrarily exchanged. This fact puts entropy in continuous cases in a very different category. It does not mean that it is useless, but is of different meaning and different utility.
I have consulted a world class expert on entropy, his best answer was: if you ask 10 experts the same question, they will give you at least 9 different answers.
Legend has it that Kolmogorov once said to his students that entropy in continuous cases does not mean much. Many years later, I asked one of his students for a reference. He said with heavy Russian accent, "perhaps he just said it."
One day Confucius was asked a question by one of his pupils, "what happens after one dies?" Confucius replied, "it is best to not answer this question until we figured out what happens before one dies."
|
What does entropy tell us?
I don't feel that the most of the answers provided above are answering the question posed, except the comment by whuber. If I understand correctly, the original question pertains to DISCRETE cases as
|
6,840
|
Is there any algorithm combining classification and regression?
|
The problem that you are describing can be solved by latent class regression, or cluster-wise regression, or it's extension mixture of generalized linear models that are all members of a wider family of finite mixture models, or latent class models.
It's not a combination of classification (supervised learning) and regression per se, but rather of clustering (unsupervised learning) and regression. The basic approach can be extended so that you predict the class membership using concomitant variables, what makes it even closer to what you are looking for. In fact, using latent class models for classification was described by Vermunt and Magidson (2003) who recommend it for such pourpose.
Latent class regression
This approach is basically a finite mixture model (or latent class analysis) in form
$$ f(y \mid x, \psi) = \sum^K_{k=1} \pi_k \, f_k(y \mid x, \vartheta_k) $$
where $\psi = (\boldsymbol{\pi}, \boldsymbol{\vartheta})$ is a vector of all parameters and $f_k$ are mixture components parametrized by $\vartheta_k$, and each component appears with latent proportions $\pi_k$. So the idea is that the distribution of your data is a mixture of $K$ components, each that can be described by a regression model $f_k$ appearing with probability $\pi_k$. Finite mixture models are very flexible in the choice of $f_k$ components and can be extended to other forms and mixtures of different classes of models (e.g. mixtures of factor analyzers).
Predicting probability of class memberships based on concomitant variables
The simple latent class regression model can be extended to include concomitant variables that predict the class memberships (Dayton and Macready, 1998; see also: Linzer and Lewis, 2011; Grun and Leisch, 2008; McCutcheon, 1987; Hagenaars and McCutcheon, 2009), in such case the model becomes
$$ f(y \mid x, w, \psi) = \sum^K_{k=1} \pi_k(w, \alpha) \, f_k(y \mid x, \vartheta_k) $$
where again $\psi$ is a vector of all parameters, but we include also concomitant variables $w$ and a function $\pi_k(w, \alpha)$ (e.g. logistic) that is used to predict the latent proportions based on the concomitant variables. So you can first predict the probability of class memberships and estimate the cluster-wise regression within a single model.
Pros and cons
What is nice about it, is that it is a model-based clustering technique, what means that you fit models to your data, and such models can be compared using different methods for model comparison (likelihood-ratio tests, BIC, AIC etc.), so the choice of final model is not that subjective as with cluster analysis in general. Braking the problem into two independent problems of clustering and then applying regression can lead to biased results and estimating everything within a single model enables you to use your data more efficiently.
The downside is that you need to make a number of assumptions about your model and have some thought about it, so it's not a black-box method that will simply take the data and return some result without bothering you about it. With noisy data and complicated models you can also have model identifability issues. Also since such models are not that popular, there are not widely implemented (you can check great R packages flexmix and poLCA, as far as I know it is also implemented in SAS and Mplus to some extent), what makes you software-dependent.
Example
Below you can see example of such model from flexmix library (Leisch, 2004; Grun and Leisch, 2008) vignette fitting mixture of two regression models to made-up data.
library("flexmix")
data("NPreg")
m1 <- flexmix(yn ~ x + I(x^2), data = NPreg, k = 2)
summary(m1)
##
## Call:
## flexmix(formula = yn ~ x + I(x^2), data = NPreg, k = 2)
##
## prior size post>0 ratio
## Comp.1 0.506 100 141 0.709
## Comp.2 0.494 100 145 0.690
##
## 'log Lik.' -642.5452 (df=9)
## AIC: 1303.09 BIC: 1332.775
parameters(m1, component = 1)
## Comp.1
## coef.(Intercept) 14.7171662
## coef.x 9.8458171
## coef.I(x^2) -0.9682602
## sigma 3.4808332
parameters(m1, component = 2)
## Comp.2
## coef.(Intercept) -0.20910955
## coef.x 4.81646040
## coef.I(x^2) 0.03629501
## sigma 3.47505076
It is visualized on the following plots (points shapes are the true classes, colors are the classifications).
References and additional resources
For further details you can check the following books and papers:
Wedel, M. and DeSarbo, W.S. (1995). A Mixture Likelihood Approach for
Generalized Linear Models. Journal of Classification , 12,
21–55.
Wedel, M. and Kamakura, W.A. (2001). Market Segmentation – Conceptual
and Methodological Foundations. Kluwer Academic Publishers.
Leisch, F. (2004). Flexmix: A general framework for finite mixture
models and latent glass regression in R. Journal of Statistical
Software, 11(8), 1-18.
Grun, B. and Leisch, F. (2008). FlexMix version 2: finite mixtures
with concomitant variables and varying and constant parameters.
Journal of Statistical Software, 28(1), 1-35.
McLachlan, G. and Peel, D. (2000). Finite Mixture Models. John Wiley & Sons.
Dayton, C.M. and Macready, G.B. (1988). Concomitant-Variable
Latent-Class Models. Journal of the American Statistical Association,
83(401), 173-178.
Linzer, D.A. and Lewis, J.B. (2011). poLCA: An R package for
polytomous variable latent class analysis. Journal of Statistical
Software, 42(10), 1-29.
McCutcheon, A.L. (1987). Latent Class Analysis. Sage.
Hagenaars J.A. and McCutcheon, A.L. (2009). Applied Latent Class
Analysis. Cambridge University Press.
Vermunt, J.K., and Magidson, J. (2003). Latent class models for
classification. Computational Statistics & Data Analysis, 41(3),
531-537.
Grün, B. and Leisch, F. (2007). Applications of finite mixtures of
regression models. flexmix package vignette.
Grün, B., & Leisch, F. (2007). Fitting finite mixtures of generalized
linear regressions in R. Computational Statistics & Data
Analysis, 51(11), 5247-5252.
|
Is there any algorithm combining classification and regression?
|
The problem that you are describing can be solved by latent class regression, or cluster-wise regression, or it's extension mixture of generalized linear models that are all members of a wider family
|
Is there any algorithm combining classification and regression?
The problem that you are describing can be solved by latent class regression, or cluster-wise regression, or it's extension mixture of generalized linear models that are all members of a wider family of finite mixture models, or latent class models.
It's not a combination of classification (supervised learning) and regression per se, but rather of clustering (unsupervised learning) and regression. The basic approach can be extended so that you predict the class membership using concomitant variables, what makes it even closer to what you are looking for. In fact, using latent class models for classification was described by Vermunt and Magidson (2003) who recommend it for such pourpose.
Latent class regression
This approach is basically a finite mixture model (or latent class analysis) in form
$$ f(y \mid x, \psi) = \sum^K_{k=1} \pi_k \, f_k(y \mid x, \vartheta_k) $$
where $\psi = (\boldsymbol{\pi}, \boldsymbol{\vartheta})$ is a vector of all parameters and $f_k$ are mixture components parametrized by $\vartheta_k$, and each component appears with latent proportions $\pi_k$. So the idea is that the distribution of your data is a mixture of $K$ components, each that can be described by a regression model $f_k$ appearing with probability $\pi_k$. Finite mixture models are very flexible in the choice of $f_k$ components and can be extended to other forms and mixtures of different classes of models (e.g. mixtures of factor analyzers).
Predicting probability of class memberships based on concomitant variables
The simple latent class regression model can be extended to include concomitant variables that predict the class memberships (Dayton and Macready, 1998; see also: Linzer and Lewis, 2011; Grun and Leisch, 2008; McCutcheon, 1987; Hagenaars and McCutcheon, 2009), in such case the model becomes
$$ f(y \mid x, w, \psi) = \sum^K_{k=1} \pi_k(w, \alpha) \, f_k(y \mid x, \vartheta_k) $$
where again $\psi$ is a vector of all parameters, but we include also concomitant variables $w$ and a function $\pi_k(w, \alpha)$ (e.g. logistic) that is used to predict the latent proportions based on the concomitant variables. So you can first predict the probability of class memberships and estimate the cluster-wise regression within a single model.
Pros and cons
What is nice about it, is that it is a model-based clustering technique, what means that you fit models to your data, and such models can be compared using different methods for model comparison (likelihood-ratio tests, BIC, AIC etc.), so the choice of final model is not that subjective as with cluster analysis in general. Braking the problem into two independent problems of clustering and then applying regression can lead to biased results and estimating everything within a single model enables you to use your data more efficiently.
The downside is that you need to make a number of assumptions about your model and have some thought about it, so it's not a black-box method that will simply take the data and return some result without bothering you about it. With noisy data and complicated models you can also have model identifability issues. Also since such models are not that popular, there are not widely implemented (you can check great R packages flexmix and poLCA, as far as I know it is also implemented in SAS and Mplus to some extent), what makes you software-dependent.
Example
Below you can see example of such model from flexmix library (Leisch, 2004; Grun and Leisch, 2008) vignette fitting mixture of two regression models to made-up data.
library("flexmix")
data("NPreg")
m1 <- flexmix(yn ~ x + I(x^2), data = NPreg, k = 2)
summary(m1)
##
## Call:
## flexmix(formula = yn ~ x + I(x^2), data = NPreg, k = 2)
##
## prior size post>0 ratio
## Comp.1 0.506 100 141 0.709
## Comp.2 0.494 100 145 0.690
##
## 'log Lik.' -642.5452 (df=9)
## AIC: 1303.09 BIC: 1332.775
parameters(m1, component = 1)
## Comp.1
## coef.(Intercept) 14.7171662
## coef.x 9.8458171
## coef.I(x^2) -0.9682602
## sigma 3.4808332
parameters(m1, component = 2)
## Comp.2
## coef.(Intercept) -0.20910955
## coef.x 4.81646040
## coef.I(x^2) 0.03629501
## sigma 3.47505076
It is visualized on the following plots (points shapes are the true classes, colors are the classifications).
References and additional resources
For further details you can check the following books and papers:
Wedel, M. and DeSarbo, W.S. (1995). A Mixture Likelihood Approach for
Generalized Linear Models. Journal of Classification , 12,
21–55.
Wedel, M. and Kamakura, W.A. (2001). Market Segmentation – Conceptual
and Methodological Foundations. Kluwer Academic Publishers.
Leisch, F. (2004). Flexmix: A general framework for finite mixture
models and latent glass regression in R. Journal of Statistical
Software, 11(8), 1-18.
Grun, B. and Leisch, F. (2008). FlexMix version 2: finite mixtures
with concomitant variables and varying and constant parameters.
Journal of Statistical Software, 28(1), 1-35.
McLachlan, G. and Peel, D. (2000). Finite Mixture Models. John Wiley & Sons.
Dayton, C.M. and Macready, G.B. (1988). Concomitant-Variable
Latent-Class Models. Journal of the American Statistical Association,
83(401), 173-178.
Linzer, D.A. and Lewis, J.B. (2011). poLCA: An R package for
polytomous variable latent class analysis. Journal of Statistical
Software, 42(10), 1-29.
McCutcheon, A.L. (1987). Latent Class Analysis. Sage.
Hagenaars J.A. and McCutcheon, A.L. (2009). Applied Latent Class
Analysis. Cambridge University Press.
Vermunt, J.K., and Magidson, J. (2003). Latent class models for
classification. Computational Statistics & Data Analysis, 41(3),
531-537.
Grün, B. and Leisch, F. (2007). Applications of finite mixtures of
regression models. flexmix package vignette.
Grün, B., & Leisch, F. (2007). Fitting finite mixtures of generalized
linear regressions in R. Computational Statistics & Data
Analysis, 51(11), 5247-5252.
|
Is there any algorithm combining classification and regression?
The problem that you are describing can be solved by latent class regression, or cluster-wise regression, or it's extension mixture of generalized linear models that are all members of a wider family
|
6,841
|
Is there any algorithm combining classification and regression?
|
Multi-Task Learning MLT allows different types of loss-functions ( for example, least-square for regression and logistic or Hinge loss for classification) to be optimized simultaneously.
the components of this heterogeneous loss function can be weighted to control/ distinguish the main task from the secondary one. if the two tasks do not have the same learning difficulties and convergence rates; a stop criterion has to be introduced for the simpler task to avoid overfitting. a 3rd component can also be introduced to the loss-function to ensure smoothness of the whole learning process.
the heterogeneous loss function may look like that (a case for regression and classification):
notice the applied weight to the logistic loss function, and the last regularization term for eights penalization
Now if we want to implement this with Pytorch, we have to split the output and run it through different criteria (again MSE for regression and logistic loss for classification)
let yhat the inintial output of the model that is splited into yhat_1 and yhat_2 such :
yhat = concat(yhat_1, yhat_2)
the same for y the ground truth.
in the learning step the model should be optimized as follow:
criterion1 = nn.MSELoss()
criterion2 = nn.BCELoss()
loss1 = criterion1(yhat_1, y1)
loss2 = criterion1(yhat_2, y2)
loss = loss1 + lambda*loss2
loss.backward()
|
Is there any algorithm combining classification and regression?
|
Multi-Task Learning MLT allows different types of loss-functions ( for example, least-square for regression and logistic or Hinge loss for classification) to be optimized simultaneously.
the component
|
Is there any algorithm combining classification and regression?
Multi-Task Learning MLT allows different types of loss-functions ( for example, least-square for regression and logistic or Hinge loss for classification) to be optimized simultaneously.
the components of this heterogeneous loss function can be weighted to control/ distinguish the main task from the secondary one. if the two tasks do not have the same learning difficulties and convergence rates; a stop criterion has to be introduced for the simpler task to avoid overfitting. a 3rd component can also be introduced to the loss-function to ensure smoothness of the whole learning process.
the heterogeneous loss function may look like that (a case for regression and classification):
notice the applied weight to the logistic loss function, and the last regularization term for eights penalization
Now if we want to implement this with Pytorch, we have to split the output and run it through different criteria (again MSE for regression and logistic loss for classification)
let yhat the inintial output of the model that is splited into yhat_1 and yhat_2 such :
yhat = concat(yhat_1, yhat_2)
the same for y the ground truth.
in the learning step the model should be optimized as follow:
criterion1 = nn.MSELoss()
criterion2 = nn.BCELoss()
loss1 = criterion1(yhat_1, y1)
loss2 = criterion1(yhat_2, y2)
loss = loss1 + lambda*loss2
loss.backward()
|
Is there any algorithm combining classification and regression?
Multi-Task Learning MLT allows different types of loss-functions ( for example, least-square for regression and logistic or Hinge loss for classification) to be optimized simultaneously.
the component
|
6,842
|
How do I know which method of cross validation is best?
|
Since the OP has placed a bounty on this question, it should attract some attention, and thus it is the right place to discuss some general ideas, even if it does not answer the OP directly.
First, names:
a) cross-validation is the general name for all estimation/measure techniques that use a test set different than the train set. Synonym: out-of-sample or extra-sample estimations. Antonym: in-sample estimation.
In-sample estimation are techniques that use some information on the training set to estimate the model quality (not necessarily error). This is very common if the model has a high bias – that is – it makes strong assumptions about the data. In linear models (a high bias model), as the in the example of the question, one uses R-squared, AIC, BIC, deviance, as a measure of model quality – all these are in-sample estimators. In SVM, for example, the ratio data in the support vector to the number of data is an in-sample estimation of error of the model.
There are many cross validation techniques:
b) hold-out is the the method #1 above. Split the set into a training and one test. There is a long history of discussion and practices on the relative sizes of the training and test set.
c) k-fold – method #2 above. Pretty standard.
d) Leave-one-out – method #3 above.
e) bootstrap: if your set has N data, randomly select N samples WITH REPLACEMENT from the set and use it as training. The data from the original set that has not been samples any time is used as the test set. There are different ways to compute the final estimation of the error of the model which uses both the error for the test set (out-of-sample) and the error for the train set (in-sample). See for example, the .632 bootstrap. I think there is also a .632+ formula – they are formulas that estimate the true error of the model using both out-of-sample and in-sample errors.
f) Orthogonal to the selection of the method above is the issue of repetition. Except for leave-one-out, all methods above can be repeated any number of times. In fact one can talk about REPEATED hold-out, or REPEATED k-fold. To be fair, almost always the bootstrap method is used in a repeated fashion.
The next question is, which method is "better". The problem is what "better" means.
1) The first answer is whether each of these methods is biased for the estimation of the model error (for an infinite amount of future data).
2) The second alternative is how fast or how well each of these methods converge to the true model error (if they are not biased). I believe this is still a topic of research. Let me point to these two papers (behind pay-wall) but the abstract gives us some understanding of what they are trying to accomplish. Also notice that it is very common to call k-fold as "cross-validation" by itself.
Measuring the prediction error. A comparison of cross-validation, bootstrap and covariance penalty methods
Estimating classification error rate: Repeated cross-validation, repeated hold-out and bootstrap
There are probably many other papers on these topics. Those are just some examples.
3) Another aspect of "better" is: given a particular measure of the model error using one of the techniques above, how certain can you be that the correct model error is close.
In general, in this case you want to take many measures of the error and calculate a confidence interval (or a credible interval if you follow a Bayesian approach). In this case, the issue is how much can you trust the variance of the set of error measures. Notice that except for the leave-one-out, all techniques above will give you many different measures (k measures for a k-fold, n measures for a n-repeated hold out) and thus you can measure the variance (or standard deviation) of this set and calculate a confidence interval for the measure of error.
Here things get somewhat complicated. From what I understand from the paper No unbiased estimator of the variance of k-fold cross-validation (not behind paywall), one cannot trust the variance you get from a k-fold – so one cannot construct a good confidence interval from k-folds. Also from what I understand from the paper Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms (not behind paywall), techniques that use repeated measures (repeated k-fold, repeated hold-out – not sure about bootstrap) will sub-estimate the true variance of the error measure (it is somewhat easy to see that – since you are sampling from a finite set if you repeat the measure a very large number of times, the same values will keep repeating, which keep the mean the same, but reduce the variance). Thus repeated measures techniques will be too optimistic on the confidence interval.
This last paper suggest doing a 5 repeated 2-fold – which he calls 5×2 CV – as a good balance of many measures (10) but not too much repetitions.
EDIT:
Of course there are great answers in Cross Validated to some of these questions (although sometimes they do not agree among themselves). Here are some:
Cross-validation or bootstrapping to evaluate classification performance?
Differences between cross validation and bootstrapping to estimate the prediction error
Cross-validation or bootstrapping to evaluate classification performance?
Understanding bootstrapping for validation and model selection
In general, the tag cross-validation is your friend here.
So what is the best solution? I don't know. I have been using 5×2 CV when I need to be very rigorous, when I need to be sure that one technique is better than another, especially in publications. And I use a hold out if I am not planning to make any measure of variance or standard deviation, or if I have time constraints – there is only one model learning in a hold-out.
|
How do I know which method of cross validation is best?
|
Since the OP has placed a bounty on this question, it should attract some attention, and thus it is the right place to discuss some general ideas, even if it does not answer the OP directly.
First, na
|
How do I know which method of cross validation is best?
Since the OP has placed a bounty on this question, it should attract some attention, and thus it is the right place to discuss some general ideas, even if it does not answer the OP directly.
First, names:
a) cross-validation is the general name for all estimation/measure techniques that use a test set different than the train set. Synonym: out-of-sample or extra-sample estimations. Antonym: in-sample estimation.
In-sample estimation are techniques that use some information on the training set to estimate the model quality (not necessarily error). This is very common if the model has a high bias – that is – it makes strong assumptions about the data. In linear models (a high bias model), as the in the example of the question, one uses R-squared, AIC, BIC, deviance, as a measure of model quality – all these are in-sample estimators. In SVM, for example, the ratio data in the support vector to the number of data is an in-sample estimation of error of the model.
There are many cross validation techniques:
b) hold-out is the the method #1 above. Split the set into a training and one test. There is a long history of discussion and practices on the relative sizes of the training and test set.
c) k-fold – method #2 above. Pretty standard.
d) Leave-one-out – method #3 above.
e) bootstrap: if your set has N data, randomly select N samples WITH REPLACEMENT from the set and use it as training. The data from the original set that has not been samples any time is used as the test set. There are different ways to compute the final estimation of the error of the model which uses both the error for the test set (out-of-sample) and the error for the train set (in-sample). See for example, the .632 bootstrap. I think there is also a .632+ formula – they are formulas that estimate the true error of the model using both out-of-sample and in-sample errors.
f) Orthogonal to the selection of the method above is the issue of repetition. Except for leave-one-out, all methods above can be repeated any number of times. In fact one can talk about REPEATED hold-out, or REPEATED k-fold. To be fair, almost always the bootstrap method is used in a repeated fashion.
The next question is, which method is "better". The problem is what "better" means.
1) The first answer is whether each of these methods is biased for the estimation of the model error (for an infinite amount of future data).
2) The second alternative is how fast or how well each of these methods converge to the true model error (if they are not biased). I believe this is still a topic of research. Let me point to these two papers (behind pay-wall) but the abstract gives us some understanding of what they are trying to accomplish. Also notice that it is very common to call k-fold as "cross-validation" by itself.
Measuring the prediction error. A comparison of cross-validation, bootstrap and covariance penalty methods
Estimating classification error rate: Repeated cross-validation, repeated hold-out and bootstrap
There are probably many other papers on these topics. Those are just some examples.
3) Another aspect of "better" is: given a particular measure of the model error using one of the techniques above, how certain can you be that the correct model error is close.
In general, in this case you want to take many measures of the error and calculate a confidence interval (or a credible interval if you follow a Bayesian approach). In this case, the issue is how much can you trust the variance of the set of error measures. Notice that except for the leave-one-out, all techniques above will give you many different measures (k measures for a k-fold, n measures for a n-repeated hold out) and thus you can measure the variance (or standard deviation) of this set and calculate a confidence interval for the measure of error.
Here things get somewhat complicated. From what I understand from the paper No unbiased estimator of the variance of k-fold cross-validation (not behind paywall), one cannot trust the variance you get from a k-fold – so one cannot construct a good confidence interval from k-folds. Also from what I understand from the paper Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms (not behind paywall), techniques that use repeated measures (repeated k-fold, repeated hold-out – not sure about bootstrap) will sub-estimate the true variance of the error measure (it is somewhat easy to see that – since you are sampling from a finite set if you repeat the measure a very large number of times, the same values will keep repeating, which keep the mean the same, but reduce the variance). Thus repeated measures techniques will be too optimistic on the confidence interval.
This last paper suggest doing a 5 repeated 2-fold – which he calls 5×2 CV – as a good balance of many measures (10) but not too much repetitions.
EDIT:
Of course there are great answers in Cross Validated to some of these questions (although sometimes they do not agree among themselves). Here are some:
Cross-validation or bootstrapping to evaluate classification performance?
Differences between cross validation and bootstrapping to estimate the prediction error
Cross-validation or bootstrapping to evaluate classification performance?
Understanding bootstrapping for validation and model selection
In general, the tag cross-validation is your friend here.
So what is the best solution? I don't know. I have been using 5×2 CV when I need to be very rigorous, when I need to be sure that one technique is better than another, especially in publications. And I use a hold out if I am not planning to make any measure of variance or standard deviation, or if I have time constraints – there is only one model learning in a hold-out.
|
How do I know which method of cross validation is best?
Since the OP has placed a bounty on this question, it should attract some attention, and thus it is the right place to discuss some general ideas, even if it does not answer the OP directly.
First, na
|
6,843
|
How do I know which method of cross validation is best?
|
Please refer to the wikipedia page for the method definitions (they do a far better job than I could do here).
After you have had a look at that page, the following may be of help to you. Let me focus on the part of the question where one wants to pick one of these methods for their modeling process. Since this is pretty frequent choice that one makes, and they could benefit from additional knowledge, here is my answer for two situations:
Any situation: Use k-fold cross validation with some suitable number of repeats (say 5 or 10).
Splitting the data into 1 half, training on the first half and validating on the other is one step in 2-fold cross validation anyway (the other step being repeating the same exercise with the two halfs interchanged). Hence, rule out 'splitting the data into half' strategy.
Many machine learning and data mining papers use k-fold cross validation (don't have citation), so use it unless you have to be very careful in this step.
Now, leave one out method and other methods like 'leave p out' and 'random split and repeat' (essentially bootstrap like process described above) are defintely good contenders.
If your data size is N, then N-fold cross validation is essentially the same as leave one out.
'leave p out' and 'bootstrap' are a bit more different than k fold cross validation, but the difference is essentially in how folds are defined and the number of repetitions 'k' that happen.
As the wiki page says, both k-fold and 'leave p out' are decent estimators of the 'expected performance/fit' (although the bets are off with regards to the variance of these estimators).
Your situation: You only have a sample size of 200 compared to number of features (100). I think there is a very high chance that there are multiple linear models giving the same performance. I would suggest using k-fold cross validation with > 10 repeats. Pick a k value of 3 or 5.
Reason for k value: generic choice.
Reason for repeat value: A decently high value for repetition is probably critical here because the output of a single k-fold cross validation computation may be suceptible to fold splitting variability/randomness that we introduce.
Additional thoughts:
Maybe I would also employ 'leave p out' and 'bootstrap like random split repeat' methods (in addition to k-fold cross validation) for the same performance/fit measure to check if my k-fold cross validation method's outputs look alright.
Although you want to use all the 100 features, as someone suggested, pay attention to multicollinearity/correlation and maybe reduce the number of features.
|
How do I know which method of cross validation is best?
|
Please refer to the wikipedia page for the method definitions (they do a far better job than I could do here).
After you have had a look at that page, the following may be of help to you. Let me focu
|
How do I know which method of cross validation is best?
Please refer to the wikipedia page for the method definitions (they do a far better job than I could do here).
After you have had a look at that page, the following may be of help to you. Let me focus on the part of the question where one wants to pick one of these methods for their modeling process. Since this is pretty frequent choice that one makes, and they could benefit from additional knowledge, here is my answer for two situations:
Any situation: Use k-fold cross validation with some suitable number of repeats (say 5 or 10).
Splitting the data into 1 half, training on the first half and validating on the other is one step in 2-fold cross validation anyway (the other step being repeating the same exercise with the two halfs interchanged). Hence, rule out 'splitting the data into half' strategy.
Many machine learning and data mining papers use k-fold cross validation (don't have citation), so use it unless you have to be very careful in this step.
Now, leave one out method and other methods like 'leave p out' and 'random split and repeat' (essentially bootstrap like process described above) are defintely good contenders.
If your data size is N, then N-fold cross validation is essentially the same as leave one out.
'leave p out' and 'bootstrap' are a bit more different than k fold cross validation, but the difference is essentially in how folds are defined and the number of repetitions 'k' that happen.
As the wiki page says, both k-fold and 'leave p out' are decent estimators of the 'expected performance/fit' (although the bets are off with regards to the variance of these estimators).
Your situation: You only have a sample size of 200 compared to number of features (100). I think there is a very high chance that there are multiple linear models giving the same performance. I would suggest using k-fold cross validation with > 10 repeats. Pick a k value of 3 or 5.
Reason for k value: generic choice.
Reason for repeat value: A decently high value for repetition is probably critical here because the output of a single k-fold cross validation computation may be suceptible to fold splitting variability/randomness that we introduce.
Additional thoughts:
Maybe I would also employ 'leave p out' and 'bootstrap like random split repeat' methods (in addition to k-fold cross validation) for the same performance/fit measure to check if my k-fold cross validation method's outputs look alright.
Although you want to use all the 100 features, as someone suggested, pay attention to multicollinearity/correlation and maybe reduce the number of features.
|
How do I know which method of cross validation is best?
Please refer to the wikipedia page for the method definitions (they do a far better job than I could do here).
After you have had a look at that page, the following may be of help to you. Let me focu
|
6,844
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
|
The relation between efficiency and illness risk ratio
I want to know why vaccine efficacy is defined as illustrated at the bottom of this page:
$$ \text{VE} = 1 - \text{IRR}$$
where
$$ \text{IRR} = \frac{\text{illness rate in vaccine group}}{\text{illness rate in placebo group}}$$
This is just a definition. Possibly the following expression may help you to get a different intuition about it
$$\begin{array}{}
VE &=& \text{relative illness rate reduction}\\
&=& \frac{\text{change (reduction) in illness rate}}{\text{illness rate}}\\
&=& \frac{\text{illness rate in placebo group} -\text{illness rate in vaccine group}}{\text{illness rate in placebo group}}\\
&=& 1-IRR
\end{array}$$
Modelling with logistic regression
These data alone are enough to determine $\text{VE}$, but surely they're not enough to fit a LR model, and thus to determine $\beta_1$.
Note that
$$\text{logit}(p(Y|X)) = \log \left( \frac{p(Y|X)}{1-p(Y|X)} \right) = \beta_0 + \beta_1 X$$
and given the two observations $\text{logit}(p(Y|X=0))$ and $\text{logit}(p(Y|X=1))$ the two parameters $\beta_0$ and $\beta_1$ can be computed
R-code example:
Note the below code uses cbind in the glm function. For more about entering this see this answer here.
vaccindata <- data.frame(sick = c(5,90),
healthy = c(15000-5,15000-90),
X = c(1,0)
)
mod <- glm(cbind(sick,healthy) ~ X, family = binomial, data = vaccindata)
summary(mod)
This gives the result:
Call:
glm(formula = cbind(sick, healthy) ~ X, family = binomial, data = vaccindata)
Deviance Residuals:
[1] 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.1100 0.1057 -48.332 < 2e-16 ***
X -2.8961 0.4596 -6.301 2.96e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 9.2763e+01 on 1 degrees of freedom
Residual deviance: 2.3825e-12 on 0 degrees of freedom
AIC: 13.814
Number of Fisher Scoring iterations: 3
So the parameter $\beta_1$ is estimated as $-2.8961$ with standard deviation $0.4596$
From this, you can compute (estimate) the odds, the efficiency, and their confidence intervals. See also: How exactly is the "effectiveness" in the Moderna and Pfizer vaccine trials estimated?
The Bayesian model (Table 6)
Also, by looking at page 111-113 of the Pfizer document, it looks like a different (Bayesian?) analysis is performed. Again, the point estimate seems to be $ \text{VE} = 1 - \text{IRR}$, but the power of a test is mentioned, and two tables 7 and 8 are presented which show probability of success and failure. Can you show me how to obtain the results in such tables?
These analyses are performed in an early stage to verify whether, given the outcomes, the vaccine is effective. The tables give hypothetical observations for which they would reach the tipping point to declare either failure (posterior probability of success <5%) or great success (the probability that VE>30% is larger than 0.995).
These percentages for the tipping points are actually based on controlling Type I error (more about that below). They control the overall type I error, but it is not clear how this is distributed among the multiple go/no-go points.
The outcome considered is the ratio/count of vaccinated people among all infected people. Conditional on the total infected people this ratio follows a binomial distribution*. For more details about the computation of the posterior in this case see: How does the beta prior affect the posterior under a binomial likelihood
*There is probably a question here about that; I still have to find a link for this; but you can derive this based on the idea that both groups are approximately Poisson distributed (more precisely they are binomial distributed) and the probability to observe a specific combination of cases $k$ and $n-k$ conditional on reaching $n$ total cases is $$\frac{\lambda_1^k e^{-\lambda_1}/k! \cdot \lambda_2^{n-k}e^{-\lambda_2}/(n-k)! }{\lambda_2^ne^{-(\lambda_1\lambda_2)}/n! } = {n \choose k} \left(\frac{\lambda_1}{\lambda_1+\lambda_2}\right)^k \left(1- \frac{\lambda_1}{\lambda_1+\lambda_2}\right)^{n-l}$$
The graphic below shows a plot for the output for these type of computations
Success boundary
This is computed by the posterior distribution for the value $$\begin{array}{}\theta &=& (1-VE)/(2-VE)\\ &=& RR/(1-RR) \\&=& \text{vaccinated among infected}\end{array}$$
For instance the in case of 6 vaccinated and 26 placebo among the first 32 infected people the posterior is Beta distributed with parameters 0.7+6 and 1+26 and the cumulative distribution for $\theta < (1-0.3)/(2-0.3)$ will be $\approx 0.996476$ for 7 vaccinated and 25 placebo it will be 0.989 which is below the level. In R you would compute these figures as pbeta(7/17,0.700102+6,1+26)
Futility boundary
For this they compute the probability of success which is the power of the test. Say for a given hypothesis the test criterium can be to observe 53 or less cases in the vaccine group among the first 164 cases. Then as function of the true VE you can estimate how probable it is to pass the test.
In the table 6 they compute this not as a function of a single VE, but as an integral over the posterior distribution of the VE or $\theta$ (and this $\theta$ is beta distributed and the test result will be beta-binomial distributed). It seems like they used something like the following:
### predict the probability of success (observing 53 or less in 164 cases at the end)
### k is the number of infections from vaccine
### n is the total number of infections
### based on k and n the posterior distribution can be computed
### based on the posterior distribution (which is a beta distribution)
### we can compute the success probability
predictedPOS <- function(k,n) {
#### posterior alpha and beta
alpha = 0.7+k
beta = 1+n-k
### dispersion and mean
s = alpha + beta
m = alpha/(alpha+beta)
### probability to observe 53 or less out of 164 in final test
### given we allread have observed k out of n (so 53-k to go for the next 164-n infections)
POS <- rmutil::pbetabinom(53-k,164-n,m,s)
return(POS)
}
# 0.03114652
predictedPOS(15,32)
# 0.02486854
predictedPOS(26,62)
# 0.04704588
predictedPOS(35,92)
# 0.07194807
predictedPOS(14,32)
# 0.07194807
predictedPOS(25,62)
# 0.05228662
predictedPOS(34,92)
The values 14, 25, 34 are the highest values for which the posterior POS is still above 0.05. For the values 15, 26, 35 it is below.
Controlling type I error (Table 7 and 8)
Table 7 and 8 give an analysis for the probability to succeed given a certain VE (they display for 30, 50, 60, 70, 80%). It gives the probability that the analysis passes the criterium for success during one of the interim analyses or with the final analysis.
The first column is easy to compute. It is binomially distributed. E.g. The probabilities 0.006, 0.054, 0.150, 0.368, 0.722 in the first columns are the the probability to have 6 cases or less when $p=(100-VE)/(200-VE)$ and $n = 32$.
The other columns are not similar binomial distributions. They represent the probability of reaching the success criterium if there wasn't success during the earlier analysis. I am not sure how they computed this (they refer to a statistical analysis plan, SAP, but it is unclear where this can be found and if it is open access). However, we can simulate it with some R-code
### function to simulate succes for vaccine efficiency analysis
sim <- function(true_p = 0.3) {
p <- (1-true_p)/(2-true_p)
numbers <- c(32,62,92,120,164)
success <- c(6,15,25,35,53)
failure <- c(15,26,35)
n <- c()
### simulate whether the infection cases are from vaccine or placebo group
n[1] <- rbinom(1,numbers[1],p)
n[2] <- rbinom(1,numbers[2]-numbers[1],p)
n[3] <- rbinom(1,numbers[3]-numbers[2],p)
n[4] <- rbinom(1,numbers[4]-numbers[3],p)
n[5] <- rbinom(1,numbers[5]-numbers[4],p)
### days with succes or failure
s <- cumsum(n) <= success
f <- cumsum(n)[1:3] >= failure
### earliest day with success or failure
min_s <- min(which(s==TRUE),7)
min_f <- min(which(f==TRUE),6)
### check whether success occured before failure
### if no success occured then it has value 7 and will be highest
### if no failure occured then it will be 6 and be highest unless no success occured either
result <- (min_s<min_f)
return(result)
}
### compute power (probability of success)
### for different efficienc<y of vaccine
set.seed(1)
nt <- 10^5
x <- c(sum(replicate(nt,sim(0.3)))/nt,
sum(replicate(nt,sim(0.5)))/nt,
sum(replicate(nt,sim(0.6)))/nt,
sum(replicate(nt,sim(0.7)))/nt,
sum(replicate(nt,sim(0.8)))/nt)
x
This gives 0.02073 0.43670 0.86610 0.99465 0.99992 which is close to the overall probability of success in the final column.
Although they use a Bayesian analysis to compute values in table 6. They have chosen the boundaries, based on which they performed the Bayesian analysis, according to controlling the type I error (I think that they use the probability to have success given VE = 0.3, p=0.021, as the basis for the type I error. This means that if the true VE = 0.3 then they might, erroneously, still declare success with probability 0.021, and if the true VE<0.3 this type I error will be even less)
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
|
The relation between efficiency and illness risk ratio
I want to know why vaccine efficacy is defined as illustrated at the bottom of this page:
$$ \text{VE} = 1 - \text{IRR}$$
where
$$ \text{IRR} =
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
The relation between efficiency and illness risk ratio
I want to know why vaccine efficacy is defined as illustrated at the bottom of this page:
$$ \text{VE} = 1 - \text{IRR}$$
where
$$ \text{IRR} = \frac{\text{illness rate in vaccine group}}{\text{illness rate in placebo group}}$$
This is just a definition. Possibly the following expression may help you to get a different intuition about it
$$\begin{array}{}
VE &=& \text{relative illness rate reduction}\\
&=& \frac{\text{change (reduction) in illness rate}}{\text{illness rate}}\\
&=& \frac{\text{illness rate in placebo group} -\text{illness rate in vaccine group}}{\text{illness rate in placebo group}}\\
&=& 1-IRR
\end{array}$$
Modelling with logistic regression
These data alone are enough to determine $\text{VE}$, but surely they're not enough to fit a LR model, and thus to determine $\beta_1$.
Note that
$$\text{logit}(p(Y|X)) = \log \left( \frac{p(Y|X)}{1-p(Y|X)} \right) = \beta_0 + \beta_1 X$$
and given the two observations $\text{logit}(p(Y|X=0))$ and $\text{logit}(p(Y|X=1))$ the two parameters $\beta_0$ and $\beta_1$ can be computed
R-code example:
Note the below code uses cbind in the glm function. For more about entering this see this answer here.
vaccindata <- data.frame(sick = c(5,90),
healthy = c(15000-5,15000-90),
X = c(1,0)
)
mod <- glm(cbind(sick,healthy) ~ X, family = binomial, data = vaccindata)
summary(mod)
This gives the result:
Call:
glm(formula = cbind(sick, healthy) ~ X, family = binomial, data = vaccindata)
Deviance Residuals:
[1] 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.1100 0.1057 -48.332 < 2e-16 ***
X -2.8961 0.4596 -6.301 2.96e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 9.2763e+01 on 1 degrees of freedom
Residual deviance: 2.3825e-12 on 0 degrees of freedom
AIC: 13.814
Number of Fisher Scoring iterations: 3
So the parameter $\beta_1$ is estimated as $-2.8961$ with standard deviation $0.4596$
From this, you can compute (estimate) the odds, the efficiency, and their confidence intervals. See also: How exactly is the "effectiveness" in the Moderna and Pfizer vaccine trials estimated?
The Bayesian model (Table 6)
Also, by looking at page 111-113 of the Pfizer document, it looks like a different (Bayesian?) analysis is performed. Again, the point estimate seems to be $ \text{VE} = 1 - \text{IRR}$, but the power of a test is mentioned, and two tables 7 and 8 are presented which show probability of success and failure. Can you show me how to obtain the results in such tables?
These analyses are performed in an early stage to verify whether, given the outcomes, the vaccine is effective. The tables give hypothetical observations for which they would reach the tipping point to declare either failure (posterior probability of success <5%) or great success (the probability that VE>30% is larger than 0.995).
These percentages for the tipping points are actually based on controlling Type I error (more about that below). They control the overall type I error, but it is not clear how this is distributed among the multiple go/no-go points.
The outcome considered is the ratio/count of vaccinated people among all infected people. Conditional on the total infected people this ratio follows a binomial distribution*. For more details about the computation of the posterior in this case see: How does the beta prior affect the posterior under a binomial likelihood
*There is probably a question here about that; I still have to find a link for this; but you can derive this based on the idea that both groups are approximately Poisson distributed (more precisely they are binomial distributed) and the probability to observe a specific combination of cases $k$ and $n-k$ conditional on reaching $n$ total cases is $$\frac{\lambda_1^k e^{-\lambda_1}/k! \cdot \lambda_2^{n-k}e^{-\lambda_2}/(n-k)! }{\lambda_2^ne^{-(\lambda_1\lambda_2)}/n! } = {n \choose k} \left(\frac{\lambda_1}{\lambda_1+\lambda_2}\right)^k \left(1- \frac{\lambda_1}{\lambda_1+\lambda_2}\right)^{n-l}$$
The graphic below shows a plot for the output for these type of computations
Success boundary
This is computed by the posterior distribution for the value $$\begin{array}{}\theta &=& (1-VE)/(2-VE)\\ &=& RR/(1-RR) \\&=& \text{vaccinated among infected}\end{array}$$
For instance the in case of 6 vaccinated and 26 placebo among the first 32 infected people the posterior is Beta distributed with parameters 0.7+6 and 1+26 and the cumulative distribution for $\theta < (1-0.3)/(2-0.3)$ will be $\approx 0.996476$ for 7 vaccinated and 25 placebo it will be 0.989 which is below the level. In R you would compute these figures as pbeta(7/17,0.700102+6,1+26)
Futility boundary
For this they compute the probability of success which is the power of the test. Say for a given hypothesis the test criterium can be to observe 53 or less cases in the vaccine group among the first 164 cases. Then as function of the true VE you can estimate how probable it is to pass the test.
In the table 6 they compute this not as a function of a single VE, but as an integral over the posterior distribution of the VE or $\theta$ (and this $\theta$ is beta distributed and the test result will be beta-binomial distributed). It seems like they used something like the following:
### predict the probability of success (observing 53 or less in 164 cases at the end)
### k is the number of infections from vaccine
### n is the total number of infections
### based on k and n the posterior distribution can be computed
### based on the posterior distribution (which is a beta distribution)
### we can compute the success probability
predictedPOS <- function(k,n) {
#### posterior alpha and beta
alpha = 0.7+k
beta = 1+n-k
### dispersion and mean
s = alpha + beta
m = alpha/(alpha+beta)
### probability to observe 53 or less out of 164 in final test
### given we allread have observed k out of n (so 53-k to go for the next 164-n infections)
POS <- rmutil::pbetabinom(53-k,164-n,m,s)
return(POS)
}
# 0.03114652
predictedPOS(15,32)
# 0.02486854
predictedPOS(26,62)
# 0.04704588
predictedPOS(35,92)
# 0.07194807
predictedPOS(14,32)
# 0.07194807
predictedPOS(25,62)
# 0.05228662
predictedPOS(34,92)
The values 14, 25, 34 are the highest values for which the posterior POS is still above 0.05. For the values 15, 26, 35 it is below.
Controlling type I error (Table 7 and 8)
Table 7 and 8 give an analysis for the probability to succeed given a certain VE (they display for 30, 50, 60, 70, 80%). It gives the probability that the analysis passes the criterium for success during one of the interim analyses or with the final analysis.
The first column is easy to compute. It is binomially distributed. E.g. The probabilities 0.006, 0.054, 0.150, 0.368, 0.722 in the first columns are the the probability to have 6 cases or less when $p=(100-VE)/(200-VE)$ and $n = 32$.
The other columns are not similar binomial distributions. They represent the probability of reaching the success criterium if there wasn't success during the earlier analysis. I am not sure how they computed this (they refer to a statistical analysis plan, SAP, but it is unclear where this can be found and if it is open access). However, we can simulate it with some R-code
### function to simulate succes for vaccine efficiency analysis
sim <- function(true_p = 0.3) {
p <- (1-true_p)/(2-true_p)
numbers <- c(32,62,92,120,164)
success <- c(6,15,25,35,53)
failure <- c(15,26,35)
n <- c()
### simulate whether the infection cases are from vaccine or placebo group
n[1] <- rbinom(1,numbers[1],p)
n[2] <- rbinom(1,numbers[2]-numbers[1],p)
n[3] <- rbinom(1,numbers[3]-numbers[2],p)
n[4] <- rbinom(1,numbers[4]-numbers[3],p)
n[5] <- rbinom(1,numbers[5]-numbers[4],p)
### days with succes or failure
s <- cumsum(n) <= success
f <- cumsum(n)[1:3] >= failure
### earliest day with success or failure
min_s <- min(which(s==TRUE),7)
min_f <- min(which(f==TRUE),6)
### check whether success occured before failure
### if no success occured then it has value 7 and will be highest
### if no failure occured then it will be 6 and be highest unless no success occured either
result <- (min_s<min_f)
return(result)
}
### compute power (probability of success)
### for different efficienc<y of vaccine
set.seed(1)
nt <- 10^5
x <- c(sum(replicate(nt,sim(0.3)))/nt,
sum(replicate(nt,sim(0.5)))/nt,
sum(replicate(nt,sim(0.6)))/nt,
sum(replicate(nt,sim(0.7)))/nt,
sum(replicate(nt,sim(0.8)))/nt)
x
This gives 0.02073 0.43670 0.86610 0.99465 0.99992 which is close to the overall probability of success in the final column.
Although they use a Bayesian analysis to compute values in table 6. They have chosen the boundaries, based on which they performed the Bayesian analysis, according to controlling the type I error (I think that they use the probability to have success given VE = 0.3, p=0.021, as the basis for the type I error. This means that if the true VE = 0.3 then they might, erroneously, still declare success with probability 0.021, and if the true VE<0.3 this type I error will be even less)
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
The relation between efficiency and illness risk ratio
I want to know why vaccine efficacy is defined as illustrated at the bottom of this page:
$$ \text{VE} = 1 - \text{IRR}$$
where
$$ \text{IRR} =
|
6,845
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
|
All these results are consistent with using the conditional Maximum Likelihood Estimate as implemented in the base R implementation of the fisher's exact test:
splits <- matrix(c(6,26,15,47,25,67,35,85,53,111), ncol = 2, byrow = T)
total <- 43000
for(interim in 1:nrow(splits)) {
positive_vax <- splits[interim, 1]
positive_pla <- splits[interim, 2]
negative_vax <- (total / 2 ) - positive_vax
negative_pla <- (total / 2 ) - positive_pla
cont_tab <- matrix(c(positive_vax, positive_pla, negative_vax, negative_pla), nrow = 2)
test <- fisher.test(cont_tab)
VE <- 1 - test$estimate
print(paste(VE, "% (", positive_vax, ":", positive_pla, ")"))
}
Result:
[1] "0.769425572629548 % ( 6 : 26 )"
[1] "0.681342630733629 % ( 15 : 47 )"
[1] "0.627606975573189 % ( 25 : 67 )"
[1] "0.589208653283242 % ( 35 : 85 )"
[1] "0.523803347975998 % ( 53 : 111 )"
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
|
All these results are consistent with using the conditional Maximum Likelihood Estimate as implemented in the base R implementation of the fisher's exact test:
splits <- matrix(c(6,26,15,47,25,67,35,8
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
All these results are consistent with using the conditional Maximum Likelihood Estimate as implemented in the base R implementation of the fisher's exact test:
splits <- matrix(c(6,26,15,47,25,67,35,85,53,111), ncol = 2, byrow = T)
total <- 43000
for(interim in 1:nrow(splits)) {
positive_vax <- splits[interim, 1]
positive_pla <- splits[interim, 2]
negative_vax <- (total / 2 ) - positive_vax
negative_pla <- (total / 2 ) - positive_pla
cont_tab <- matrix(c(positive_vax, positive_pla, negative_vax, negative_pla), nrow = 2)
test <- fisher.test(cont_tab)
VE <- 1 - test$estimate
print(paste(VE, "% (", positive_vax, ":", positive_pla, ")"))
}
Result:
[1] "0.769425572629548 % ( 6 : 26 )"
[1] "0.681342630733629 % ( 15 : 47 )"
[1] "0.627606975573189 % ( 25 : 67 )"
[1] "0.589208653283242 % ( 35 : 85 )"
[1] "0.523803347975998 % ( 53 : 111 )"
|
Which statistical model is being used in the Pfizer study design for vaccine efficacy?
All these results are consistent with using the conditional Maximum Likelihood Estimate as implemented in the base R implementation of the fisher's exact test:
splits <- matrix(c(6,26,15,47,25,67,35,8
|
6,846
|
Why use stratified cross validation? Why does this not damage variance related benefit?
|
Bootstrapping seeks to simulate the effect of drawing a new sample from the population, and doesn't seek to ensure distinct test sets (residues after N from N sampling with replacement).
RxK-fold Cross-validation ensures K distinct test folds but is then repeated R times for different random partitionings to allow independence assumptions to hold for K-CV, but this is lost with repetition.
Stratified Cross-validation violates the principal that the test labels should never have been looked at before the statistics are calculated, but this is generally thought to be innocuous as the only effect is to balance the folds, but it does lead to loss of diversity (an unwanted loss of variance). It moves even further from the Boostrap idea of constructing a sample similar to what you'd draw naturally from the whole population. Arguably the main reason stratification is important is to address defects in the classification algorithms, as they are too easily biased by over- or under-representation of classes. An algorithm that uses balancing techniques (either by selection or weighting) or optimizes a chance-correct measure (Kappa or preferably Informedness) is less impacted by this, although even such algorithms can't learn or test a class that isn't there.
Forcing each fold to have at least m instances of each class, for some small m, is an alternative to stratification that works for both Bootstrapping and CV. It does have a smoothing bias, making folds tend to be more balanced than they would otherwise be expected to be.
Re ensembles and diversity: If classifiers learned on the training folds are used for fusion not just estimation of generalization error, the increasing rigidity of CV, stratified Bootstrap and stratified CV leads to loss of diversity, and potentially resilience, compared to Bootstrap, forced Bootstrap and forced CV.
|
Why use stratified cross validation? Why does this not damage variance related benefit?
|
Bootstrapping seeks to simulate the effect of drawing a new sample from the population, and doesn't seek to ensure distinct test sets (residues after N from N sampling with replacement).
RxK-fold Cros
|
Why use stratified cross validation? Why does this not damage variance related benefit?
Bootstrapping seeks to simulate the effect of drawing a new sample from the population, and doesn't seek to ensure distinct test sets (residues after N from N sampling with replacement).
RxK-fold Cross-validation ensures K distinct test folds but is then repeated R times for different random partitionings to allow independence assumptions to hold for K-CV, but this is lost with repetition.
Stratified Cross-validation violates the principal that the test labels should never have been looked at before the statistics are calculated, but this is generally thought to be innocuous as the only effect is to balance the folds, but it does lead to loss of diversity (an unwanted loss of variance). It moves even further from the Boostrap idea of constructing a sample similar to what you'd draw naturally from the whole population. Arguably the main reason stratification is important is to address defects in the classification algorithms, as they are too easily biased by over- or under-representation of classes. An algorithm that uses balancing techniques (either by selection or weighting) or optimizes a chance-correct measure (Kappa or preferably Informedness) is less impacted by this, although even such algorithms can't learn or test a class that isn't there.
Forcing each fold to have at least m instances of each class, for some small m, is an alternative to stratification that works for both Bootstrapping and CV. It does have a smoothing bias, making folds tend to be more balanced than they would otherwise be expected to be.
Re ensembles and diversity: If classifiers learned on the training folds are used for fusion not just estimation of generalization error, the increasing rigidity of CV, stratified Bootstrap and stratified CV leads to loss of diversity, and potentially resilience, compared to Bootstrap, forced Bootstrap and forced CV.
|
Why use stratified cross validation? Why does this not damage variance related benefit?
Bootstrapping seeks to simulate the effect of drawing a new sample from the population, and doesn't seek to ensure distinct test sets (residues after N from N sampling with replacement).
RxK-fold Cros
|
6,847
|
Why use stratified cross validation? Why does this not damage variance related benefit?
|
Perhaps you can think of it this way. Let's say you have a dataset where there are 100 samples, 90 in class 'A' and 10 in class 'B'. In this very unbalanced design if you do normal randomized groups, you could end up building models on exceedingly few (or EVEN NONE!) from the 'B' class. If you are building a model that is trained on data where there are so few, or even none, of the other class how could you expect it to predict the rarer group effectively? The stratified cross-validation allows for randomization but also makes sure these unbalanced datasets have some of both classes.
To pacify concerns about using stratified CV with more 'balanced' datasets, let's look at an example using R code.
require(mlbench)
require(caret)
require(cvTools)
# using the Sonar dataset (208 samples)
data(Sonar)
# see the distribution of classes are very well balanced
prop.table(table(Sonar$Class))
> prop.table(table(Sonar$Class))
M R
0.5336538 0.4663462
# stratified
# set seed for consistency
# caret::createFolds does stratified folds by default
set.seed(123)
strat <- createFolds(Sonar$Class, k=10)
# non-stratified using cvTools
set.seed(123)
folds <- cvFolds(nrow(Sonar), K=10, type="random")
df <- data.frame(fold = folds$which, index = folds$subsets)
non_strat <- lapply(split(df, df$fold), FUN=function(x) x$index)
# calculate the average class distribution of the folds
strat_dist <- colMeans(do.call("rbind", lapply(strat, FUN = function(x) prop.table(table(Sonar$Class[x])))))
non_strat_dist <- colMeans(do.call("rbind", lapply(non_strat, FUN = function(x) prop.table(table(Sonar$Class[x])))))
strat_dist
> strat_dist
M R
0.5338312 0.4661688
non_strat_dist
> non_strat_dist
M R
0.5328571 0.4671429
As you can see, in a dataset that is well balanced the folds will have a similar distribution by random chance. Therefore stratified CV is simply an assurance measure in these circumstances. However, to address variance you would need to look at the distributions of each fold. In some circumstances (even starting from 50-50) you could have folds that have splits of 30-70 by random chance (you can run the code above and see this actually happending!). This could lead to a worse performing model because it didn't have enough of one class to accurately predict it thereby increasing overall CV variance. This is obviously more important when you have 'limited' samples where you are more likely to have very extreme differences in distribution.
Now with very large datasets, stratification may not be necessary because the folds will be large enough to still likely contain at least a good proportion of the 'rarer' class. However, there is really no computational loss and no real reason to forgo stratification if your samples are unbalanced no matter how much data you have in my personal opinion.
|
Why use stratified cross validation? Why does this not damage variance related benefit?
|
Perhaps you can think of it this way. Let's say you have a dataset where there are 100 samples, 90 in class 'A' and 10 in class 'B'. In this very unbalanced design if you do normal randomized groups
|
Why use stratified cross validation? Why does this not damage variance related benefit?
Perhaps you can think of it this way. Let's say you have a dataset where there are 100 samples, 90 in class 'A' and 10 in class 'B'. In this very unbalanced design if you do normal randomized groups, you could end up building models on exceedingly few (or EVEN NONE!) from the 'B' class. If you are building a model that is trained on data where there are so few, or even none, of the other class how could you expect it to predict the rarer group effectively? The stratified cross-validation allows for randomization but also makes sure these unbalanced datasets have some of both classes.
To pacify concerns about using stratified CV with more 'balanced' datasets, let's look at an example using R code.
require(mlbench)
require(caret)
require(cvTools)
# using the Sonar dataset (208 samples)
data(Sonar)
# see the distribution of classes are very well balanced
prop.table(table(Sonar$Class))
> prop.table(table(Sonar$Class))
M R
0.5336538 0.4663462
# stratified
# set seed for consistency
# caret::createFolds does stratified folds by default
set.seed(123)
strat <- createFolds(Sonar$Class, k=10)
# non-stratified using cvTools
set.seed(123)
folds <- cvFolds(nrow(Sonar), K=10, type="random")
df <- data.frame(fold = folds$which, index = folds$subsets)
non_strat <- lapply(split(df, df$fold), FUN=function(x) x$index)
# calculate the average class distribution of the folds
strat_dist <- colMeans(do.call("rbind", lapply(strat, FUN = function(x) prop.table(table(Sonar$Class[x])))))
non_strat_dist <- colMeans(do.call("rbind", lapply(non_strat, FUN = function(x) prop.table(table(Sonar$Class[x])))))
strat_dist
> strat_dist
M R
0.5338312 0.4661688
non_strat_dist
> non_strat_dist
M R
0.5328571 0.4671429
As you can see, in a dataset that is well balanced the folds will have a similar distribution by random chance. Therefore stratified CV is simply an assurance measure in these circumstances. However, to address variance you would need to look at the distributions of each fold. In some circumstances (even starting from 50-50) you could have folds that have splits of 30-70 by random chance (you can run the code above and see this actually happending!). This could lead to a worse performing model because it didn't have enough of one class to accurately predict it thereby increasing overall CV variance. This is obviously more important when you have 'limited' samples where you are more likely to have very extreme differences in distribution.
Now with very large datasets, stratification may not be necessary because the folds will be large enough to still likely contain at least a good proportion of the 'rarer' class. However, there is really no computational loss and no real reason to forgo stratification if your samples are unbalanced no matter how much data you have in my personal opinion.
|
Why use stratified cross validation? Why does this not damage variance related benefit?
Perhaps you can think of it this way. Let's say you have a dataset where there are 100 samples, 90 in class 'A' and 10 in class 'B'. In this very unbalanced design if you do normal randomized groups
|
6,848
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
|
The "correlation of fixed effects" output doesn't have the intuitive meaning that most would ascribe to it. Specifically, is not about the correlation of the variables (as OP notes). It is in fact about the expected correlation of the regression coefficients. Although this may speak to multicollinearity it does not necessarily. In this case it is telling you that if you did the experiment again and it so happened that the coefficient for cropforage got smaller, it is likely that so too will would the coeffienct of sbare.
In part his book "Analyzing Linguistic Data: A Practical Introduction to Statistics using R " dealing with lme4 Baayen suppresses that part of the output and declares it useful only in special cases. Here is a listserv message where Bates himself describes how to interpret that part of the output:
It is an approximate correlation of the estimator of the fixed
effects. (I include the word "approximate" because I should but in
this case the approximation is very good.) I'm not sure how to
explain it better than that. Suppose that you took an MCMC sample
from the parameters in the model, then you would expect the sample of
the fixed-effects parameters to display a correlation structure like
this matrix.
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
|
The "correlation of fixed effects" output doesn't have the intuitive meaning that most would ascribe to it. Specifically, is not about the correlation of the variables (as OP notes). It is in fact ab
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
The "correlation of fixed effects" output doesn't have the intuitive meaning that most would ascribe to it. Specifically, is not about the correlation of the variables (as OP notes). It is in fact about the expected correlation of the regression coefficients. Although this may speak to multicollinearity it does not necessarily. In this case it is telling you that if you did the experiment again and it so happened that the coefficient for cropforage got smaller, it is likely that so too will would the coeffienct of sbare.
In part his book "Analyzing Linguistic Data: A Practical Introduction to Statistics using R " dealing with lme4 Baayen suppresses that part of the output and declares it useful only in special cases. Here is a listserv message where Bates himself describes how to interpret that part of the output:
It is an approximate correlation of the estimator of the fixed
effects. (I include the word "approximate" because I should but in
this case the approximation is very good.) I'm not sure how to
explain it better than that. Suppose that you took an MCMC sample
from the parameters in the model, then you would expect the sample of
the fixed-effects parameters to display a correlation structure like
this matrix.
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
The "correlation of fixed effects" output doesn't have the intuitive meaning that most would ascribe to it. Specifically, is not about the correlation of the variables (as OP notes). It is in fact ab
|
6,849
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
|
It can be helpful to show that those correlations between fixed effects are obtained by converting the model's "vcov" to a correlation matrix. If fit is your fitted lme4 model, then
vc <- vcov(fit)
# diagonal matrix of standard deviations associated with vcov
S <- sqrt(diag(diag(vc), nrow(vc), nrow(vc)))
# convert vc to a correlation matrix
solve(S) %*% vc %*% solve(S)
and the correlations between fixed effects are the off-diagonal entries.
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
|
It can be helpful to show that those correlations between fixed effects are obtained by converting the model's "vcov" to a correlation matrix. If fit is your fitted lme4 model, then
vc <- vcov(fit)
#
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
It can be helpful to show that those correlations between fixed effects are obtained by converting the model's "vcov" to a correlation matrix. If fit is your fitted lme4 model, then
vc <- vcov(fit)
# diagonal matrix of standard deviations associated with vcov
S <- sqrt(diag(diag(vc), nrow(vc), nrow(vc)))
# convert vc to a correlation matrix
solve(S) %*% vc %*% solve(S)
and the correlations between fixed effects are the off-diagonal entries.
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
It can be helpful to show that those correlations between fixed effects are obtained by converting the model's "vcov" to a correlation matrix. If fit is your fitted lme4 model, then
vc <- vcov(fit)
#
|
6,850
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
|
If your negative and positive correlations are the same in their value and only their sign differ, you are entering the variable mistakenly. But I don't think this is the case for you as you already seem quite advanced in stats.
The inconsistency you are experiencing can be and is likely caused by multicollinearity. It means when some independent variables share some overlapped effects, or in other words are correlated themselves. for example modeling to variables "growth rate" and "tumor size" can cause multicollinearity, as it is possible and likely that larger tumors have higher growth rates (before they are detected) per se. This can confuse the model. And if your model has few independent variables which are correlated with each other, interpreting the results can sometimes become quite difficult. It sometimes leads to totally strange coefficients, even to such extents that the sign of some of the correlations reverses.
You should first detect the sources of multicollinearity and deal with them and then rerun your analysis.
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
|
If your negative and positive correlations are the same in their value and only their sign differ, you are entering the variable mistakenly. But I don't think this is the case for you as you already s
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
If your negative and positive correlations are the same in their value and only their sign differ, you are entering the variable mistakenly. But I don't think this is the case for you as you already seem quite advanced in stats.
The inconsistency you are experiencing can be and is likely caused by multicollinearity. It means when some independent variables share some overlapped effects, or in other words are correlated themselves. for example modeling to variables "growth rate" and "tumor size" can cause multicollinearity, as it is possible and likely that larger tumors have higher growth rates (before they are detected) per se. This can confuse the model. And if your model has few independent variables which are correlated with each other, interpreting the results can sometimes become quite difficult. It sometimes leads to totally strange coefficients, even to such extents that the sign of some of the correlations reverses.
You should first detect the sources of multicollinearity and deal with them and then rerun your analysis.
|
How do I interpret the 'correlations of fixed effects' in my glmer output?
If your negative and positive correlations are the same in their value and only their sign differ, you are entering the variable mistakenly. But I don't think this is the case for you as you already s
|
6,851
|
Application of machine learning methods in StackExchange websites
|
Yes, I think tag prediction is an interesting one and one for which you have a good shot at "success".
Below are some thoughts intended to potentially aid in brainstorming and further exploration of this topic. I think there are many potentially interesting directions that such a project could take. I would guess that a serious attempt at just one or two of the below would make for a more than adequate project and you're likely to come up with more interesting questions than those I've posed.
I'm going to take a very wide view as to what is considered machine learning. Undoubtedly some of my suggestions would be better classified as exploratory data analysis and more traditional statistical analysis. But, perhaps, it will help in some small way as you formulate your own interesting questions. You'll note, I try to address questions that I think would be interesting in terms of enhancing the functionality of the site. Of course, there are many other interesting questions as well that may not be that related to site friendliness.
Basic descriptive analysis of user behavior: I'm guessing there is a very clear cyclic weekly pattern to user participation on this site. When does the site get the most traffic? What does the graph of user participation on the site look like, say, stratified by hour over the week? You'd want to adjust for potential changes in overall popularity of the site over time. This leads to the question, how has the site's popularity changed since inception? How does the participation of a "typical" user vary with time since joining? I'm guessing it ramps up pretty quickly at the start, then plateaus, and probably heads south after a few weeks or so of joining.
Optimal submission of questions and answers: Getting insight on the first question seems to naturally lead to some more interesting (in an ML sense) questions. Say I have a question I need an answer to. If I want to maximize my probability of getting a response, when should I submit it? If I am responding to a question and I want to maximize my vote count, when should I submit my answer? Maybe the answers to these two are very different. How does this vary by the topic of the question (say, e.g., as defined by the associated tags)?
Biclustering of users and topics: Which users are most alike in terms of their interests, again, perhaps as measured by tags? What topics are most similar according to which users participate? Can you come up with a nice visualization of these relationships? Offshoots of this would be to try to predict which user(s) is most likely to submit an answer to a particular question. (Imagine providing such technology to SE so that users could be notified of potentially interesting questions, not simply based on tags.)
Clustering of answerers by behavior: It seems that there are a few different basic behavioral patterns regarding how answerers use this site. Can you come up with features and a clustering algorithm to cluster answerers according to their behavior. Are the clusters interpretable?
Suggesting new tags: Can you come up with suggestions for new tags based on inferring topics from the questions and answers currently in the database. For example, I believe the tag [mixture-model] was recently added because someone noticed we were getting a bunch of related questions. But, it seems an information-retrieval approach should be able to extract such topics directly and potentially suggest them to moderators.
Semisupervised learning of geographic locations: (This one may be a bit touchy from a privacy perspective.) Some users list where they are located. Others do not. Using usage patterns and potentially vocabulary, etc, can you put a geographic confidence region on the location of each user? Intuitively, it would seem that this would be (much) more accurate in terms of longitude than latitude.
Automated flagging of possible duplicates and highly related questions: The site already has a similar sort of feature with the Related bar in the right margin. Finding nearly exact duplicates and suggesting them could be useful to the moderators. Doing this across sites in the SE community would seem to be new.
Churn prediction and user retention: Using features from each user's history, can you predict the next time you expect to see them? Can you predict the probability they will return to the site conditional on how long they've been absent and features of their past behavior? This could be used, e.g., to try to notice when users are at risk of "churn" and engage them (say, via email) in an effort to retain them. A typical approach would shoot out an email after some fixed period of inactivity. But, each user is very different and there is lots of information about lots of users, so a more tailored approach could be developed.
|
Application of machine learning methods in StackExchange websites
|
Yes, I think tag prediction is an interesting one and one for which you have a good shot at "success".
Below are some thoughts intended to potentially aid in brainstorming and further exploration of
|
Application of machine learning methods in StackExchange websites
Yes, I think tag prediction is an interesting one and one for which you have a good shot at "success".
Below are some thoughts intended to potentially aid in brainstorming and further exploration of this topic. I think there are many potentially interesting directions that such a project could take. I would guess that a serious attempt at just one or two of the below would make for a more than adequate project and you're likely to come up with more interesting questions than those I've posed.
I'm going to take a very wide view as to what is considered machine learning. Undoubtedly some of my suggestions would be better classified as exploratory data analysis and more traditional statistical analysis. But, perhaps, it will help in some small way as you formulate your own interesting questions. You'll note, I try to address questions that I think would be interesting in terms of enhancing the functionality of the site. Of course, there are many other interesting questions as well that may not be that related to site friendliness.
Basic descriptive analysis of user behavior: I'm guessing there is a very clear cyclic weekly pattern to user participation on this site. When does the site get the most traffic? What does the graph of user participation on the site look like, say, stratified by hour over the week? You'd want to adjust for potential changes in overall popularity of the site over time. This leads to the question, how has the site's popularity changed since inception? How does the participation of a "typical" user vary with time since joining? I'm guessing it ramps up pretty quickly at the start, then plateaus, and probably heads south after a few weeks or so of joining.
Optimal submission of questions and answers: Getting insight on the first question seems to naturally lead to some more interesting (in an ML sense) questions. Say I have a question I need an answer to. If I want to maximize my probability of getting a response, when should I submit it? If I am responding to a question and I want to maximize my vote count, when should I submit my answer? Maybe the answers to these two are very different. How does this vary by the topic of the question (say, e.g., as defined by the associated tags)?
Biclustering of users and topics: Which users are most alike in terms of their interests, again, perhaps as measured by tags? What topics are most similar according to which users participate? Can you come up with a nice visualization of these relationships? Offshoots of this would be to try to predict which user(s) is most likely to submit an answer to a particular question. (Imagine providing such technology to SE so that users could be notified of potentially interesting questions, not simply based on tags.)
Clustering of answerers by behavior: It seems that there are a few different basic behavioral patterns regarding how answerers use this site. Can you come up with features and a clustering algorithm to cluster answerers according to their behavior. Are the clusters interpretable?
Suggesting new tags: Can you come up with suggestions for new tags based on inferring topics from the questions and answers currently in the database. For example, I believe the tag [mixture-model] was recently added because someone noticed we were getting a bunch of related questions. But, it seems an information-retrieval approach should be able to extract such topics directly and potentially suggest them to moderators.
Semisupervised learning of geographic locations: (This one may be a bit touchy from a privacy perspective.) Some users list where they are located. Others do not. Using usage patterns and potentially vocabulary, etc, can you put a geographic confidence region on the location of each user? Intuitively, it would seem that this would be (much) more accurate in terms of longitude than latitude.
Automated flagging of possible duplicates and highly related questions: The site already has a similar sort of feature with the Related bar in the right margin. Finding nearly exact duplicates and suggesting them could be useful to the moderators. Doing this across sites in the SE community would seem to be new.
Churn prediction and user retention: Using features from each user's history, can you predict the next time you expect to see them? Can you predict the probability they will return to the site conditional on how long they've been absent and features of their past behavior? This could be used, e.g., to try to notice when users are at risk of "churn" and engage them (say, via email) in an effort to retain them. A typical approach would shoot out an email after some fixed period of inactivity. But, each user is very different and there is lots of information about lots of users, so a more tailored approach could be developed.
|
Application of machine learning methods in StackExchange websites
Yes, I think tag prediction is an interesting one and one for which you have a good shot at "success".
Below are some thoughts intended to potentially aid in brainstorming and further exploration of
|
6,852
|
Application of machine learning methods in StackExchange websites
|
I was thinking about tag prediction, too, I like the idea. I have the feeling that it is possible, but you may need to overcome many issues before you arrive to your final dataset. So I speculate the tag prediction may need a lot of time. In addition to incorrect tags the limit of max 5 tags may play a role. Also that some tags are subcategories of others (e.g. “multiple comparisons” can be viewed as a subcategory of “significance testing”).
I did not check if up-vote times are included in the downloadable database, but a more simple and still interesting project could be to predict the “final” number of votes (maybe after 5 months) on a question depending on the initial votes, and the timing of accepting an answer.
|
Application of machine learning methods in StackExchange websites
|
I was thinking about tag prediction, too, I like the idea. I have the feeling that it is possible, but you may need to overcome many issues before you arrive to your final dataset. So I speculate the
|
Application of machine learning methods in StackExchange websites
I was thinking about tag prediction, too, I like the idea. I have the feeling that it is possible, but you may need to overcome many issues before you arrive to your final dataset. So I speculate the tag prediction may need a lot of time. In addition to incorrect tags the limit of max 5 tags may play a role. Also that some tags are subcategories of others (e.g. “multiple comparisons” can be viewed as a subcategory of “significance testing”).
I did not check if up-vote times are included in the downloadable database, but a more simple and still interesting project could be to predict the “final” number of votes (maybe after 5 months) on a question depending on the initial votes, and the timing of accepting an answer.
|
Application of machine learning methods in StackExchange websites
I was thinking about tag prediction, too, I like the idea. I have the feeling that it is possible, but you may need to overcome many issues before you arrive to your final dataset. So I speculate the
|
6,853
|
Application of machine learning methods in StackExchange websites
|
This is a good question. I too have thought that the publicly available StackExchange datasets would make good subjects for analysis. These are sufficiently unusual that they might also be good testbeds for new statistical methods. Having such a large amount of well structured data is unusual, at any rate.
cardinal suggested a bunch of things which would actually be useful for StackExchange. I won't restrict myself to this.
Here is one obvious candidate for analysis, though it has no obvious use that comes to mind. It is a noticeable effect that high rep users are more likely to get upvotes, other things being equal. However, this effect is probably non-trivial to model. Since we can't compare usefulness across users very easily, an obvious approach would be to assume a users answers were always equally useful (not true in general but one has to start somewhere) and then add an inflationary term to account for his increasing reputation. One could then (I suppose) add in some terms that would account for his answers getting better with increasing experience. Maybe this could be handled by some kind of time series. I'm not sure how the data being interval would affect this. It might be an interesting exercise.
I'll add more examples if/when I think of them.
Is anyone aware of statistical research papers based on SE data? Also, Isaac mentioned that the data has errors. Does anyone know anything more about this?
|
Application of machine learning methods in StackExchange websites
|
This is a good question. I too have thought that the publicly available StackExchange datasets would make good subjects for analysis. These are sufficiently unusual that they might also be good testbe
|
Application of machine learning methods in StackExchange websites
This is a good question. I too have thought that the publicly available StackExchange datasets would make good subjects for analysis. These are sufficiently unusual that they might also be good testbeds for new statistical methods. Having such a large amount of well structured data is unusual, at any rate.
cardinal suggested a bunch of things which would actually be useful for StackExchange. I won't restrict myself to this.
Here is one obvious candidate for analysis, though it has no obvious use that comes to mind. It is a noticeable effect that high rep users are more likely to get upvotes, other things being equal. However, this effect is probably non-trivial to model. Since we can't compare usefulness across users very easily, an obvious approach would be to assume a users answers were always equally useful (not true in general but one has to start somewhere) and then add an inflationary term to account for his increasing reputation. One could then (I suppose) add in some terms that would account for his answers getting better with increasing experience. Maybe this could be handled by some kind of time series. I'm not sure how the data being interval would affect this. It might be an interesting exercise.
I'll add more examples if/when I think of them.
Is anyone aware of statistical research papers based on SE data? Also, Isaac mentioned that the data has errors. Does anyone know anything more about this?
|
Application of machine learning methods in StackExchange websites
This is a good question. I too have thought that the publicly available StackExchange datasets would make good subjects for analysis. These are sufficiently unusual that they might also be good testbe
|
6,854
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
It's a good question. Generally, I would argue that you should try to optimise a loss function which corresponds to the evaluation metric you care most about.
You might however want to know about other evaluation metrics.
For example, when doing classification, I'm of the opinion that you would need to give me a pretty good reason to not be optimising the cross-entropy. That said, the cross-entropy is not a very intuitive metric, so you might, once you've finished training, also want to know how good your classification accuracy is, to get a feel for whether your model is actually going to be of any real world use (it might be the best possible model and have a better cross-entropy than everybody else's, but still have insufficient accuracy to be of use in the real world).
Another argument I'm less familiar with, is, mainly in tree-based (or other greedy) algorithms, whether using certain losses mean you make better splits early on and allow you to better optimise the metric you care about globally. For example, people tend to use Gini or Information Entropy (note, not cross-entropy) when deciding on what the best split in a decision tree is. The only arguments I've ever heard for this, are not very convincing, and are basically arguments for not using accuracy but using cross-entropy instead (things around class imbalance maybe). I can think of two reasons you might use Gini when trying to get the best cross-entropy:
Something to do with local learning and greedy decision-making, as alluded to above (not convinced by this I must add).
Something to do with the actual computational implementation. In theory, a decision tree evaluates every possible split at every node and finds the best according to your criterion, but in reality, as I understand it, it does not do this and uses approximate algorithms, which I suspect leverage properties of your loss criterion.
In summary, the main reason you would have multiple evaluation metrics, is to understand what your model is doing. There might be reasons related to finding the best solution by approximate methods which mean you want to maximise metric A in order to get a solution which comes close to maximising metric B.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
It's a good question. Generally, I would argue that you should try to optimise a loss function which corresponds to the evaluation metric you care most about.
You might however want to know about othe
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
It's a good question. Generally, I would argue that you should try to optimise a loss function which corresponds to the evaluation metric you care most about.
You might however want to know about other evaluation metrics.
For example, when doing classification, I'm of the opinion that you would need to give me a pretty good reason to not be optimising the cross-entropy. That said, the cross-entropy is not a very intuitive metric, so you might, once you've finished training, also want to know how good your classification accuracy is, to get a feel for whether your model is actually going to be of any real world use (it might be the best possible model and have a better cross-entropy than everybody else's, but still have insufficient accuracy to be of use in the real world).
Another argument I'm less familiar with, is, mainly in tree-based (or other greedy) algorithms, whether using certain losses mean you make better splits early on and allow you to better optimise the metric you care about globally. For example, people tend to use Gini or Information Entropy (note, not cross-entropy) when deciding on what the best split in a decision tree is. The only arguments I've ever heard for this, are not very convincing, and are basically arguments for not using accuracy but using cross-entropy instead (things around class imbalance maybe). I can think of two reasons you might use Gini when trying to get the best cross-entropy:
Something to do with local learning and greedy decision-making, as alluded to above (not convinced by this I must add).
Something to do with the actual computational implementation. In theory, a decision tree evaluates every possible split at every node and finds the best according to your criterion, but in reality, as I understand it, it does not do this and uses approximate algorithms, which I suspect leverage properties of your loss criterion.
In summary, the main reason you would have multiple evaluation metrics, is to understand what your model is doing. There might be reasons related to finding the best solution by approximate methods which mean you want to maximise metric A in order to get a solution which comes close to maximising metric B.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
It's a good question. Generally, I would argue that you should try to optimise a loss function which corresponds to the evaluation metric you care most about.
You might however want to know about othe
|
6,855
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
Often, MSE/cross-entropy are easier to optimize than for accuracy, because they are differentiable wrt to the model parameters, and in some cases, even convex, which makes it a lot easier.
Even in cases where the metric is differentiable, you might want a loss which has "better behaved" numerical properties -- see this post on the gradients of the dice-coefficient metric.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
Often, MSE/cross-entropy are easier to optimize than for accuracy, because they are differentiable wrt to the model parameters, and in some cases, even convex, which makes it a lot easier.
Even in ca
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
Often, MSE/cross-entropy are easier to optimize than for accuracy, because they are differentiable wrt to the model parameters, and in some cases, even convex, which makes it a lot easier.
Even in cases where the metric is differentiable, you might want a loss which has "better behaved" numerical properties -- see this post on the gradients of the dice-coefficient metric.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
Often, MSE/cross-entropy are easier to optimize than for accuracy, because they are differentiable wrt to the model parameters, and in some cases, even convex, which makes it a lot easier.
Even in ca
|
6,856
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
It is a good question. I would like to answer it from a different perspective. Assume your model's intent is to find out the price of a house given a host of features (location, num of bedrooms, area etc). So you train a model. Your peer and competitor in same company also develops another model. Now both of you go to the boss and ask her to use the models developed.
For the next 100 customers, she keeps close track of the predictions of both models. The one that predicts prices closest to the actual price is the model that is better and its creator needs to be promoted. But how would she evaluate the models? In all likelihood, she would choose a metric like either the MSE or the MAE. If you knew the metric before-hand, it makes sense to train your model using that same metric as a loss function, provided it is something that has a few mathematical properties needed for gradient descent. So in a sense, the loss function can be selected based on how the model is going to be evaluated.
But there could be situations where the evaluation is based on a metric that may make it difficult for the gradient descent to happen. Maybe it gives out many local minima's or maybe the gradient computation is just too expensive etc. For e.g. in case of MAE above, you may have to write additional code to take care of the learning rate as your model is approaching the minima else it will definitely overshoot...this is a minor code fix. But there could be other cases where your model may not yield the best results if the evaluation metric is directly selected as the loss function. Your best chance is to take the appropriate gradient-friendly loss metric that is most closely applicable to the problem you are trying to solve and take your chance with it. In all likelihood, your results will be much better than if you were to take some gradient un-friendly (evaluation) metric and get stuck at some local minima.
Nonetheless the question itself is highly relevant. Rather than blindly going for MSE for regression and CE for classification, one should definitely look at how the model is going to be evaluated ('used' may be a better term) and plan a loss function accordingly. In most cases a readymade pre-written loss function is available, but certain occasions could demand writing a customized loss function to suit the evaluation metric
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
It is a good question. I would like to answer it from a different perspective. Assume your model's intent is to find out the price of a house given a host of features (location, num of bedrooms, area
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
It is a good question. I would like to answer it from a different perspective. Assume your model's intent is to find out the price of a house given a host of features (location, num of bedrooms, area etc). So you train a model. Your peer and competitor in same company also develops another model. Now both of you go to the boss and ask her to use the models developed.
For the next 100 customers, she keeps close track of the predictions of both models. The one that predicts prices closest to the actual price is the model that is better and its creator needs to be promoted. But how would she evaluate the models? In all likelihood, she would choose a metric like either the MSE or the MAE. If you knew the metric before-hand, it makes sense to train your model using that same metric as a loss function, provided it is something that has a few mathematical properties needed for gradient descent. So in a sense, the loss function can be selected based on how the model is going to be evaluated.
But there could be situations where the evaluation is based on a metric that may make it difficult for the gradient descent to happen. Maybe it gives out many local minima's or maybe the gradient computation is just too expensive etc. For e.g. in case of MAE above, you may have to write additional code to take care of the learning rate as your model is approaching the minima else it will definitely overshoot...this is a minor code fix. But there could be other cases where your model may not yield the best results if the evaluation metric is directly selected as the loss function. Your best chance is to take the appropriate gradient-friendly loss metric that is most closely applicable to the problem you are trying to solve and take your chance with it. In all likelihood, your results will be much better than if you were to take some gradient un-friendly (evaluation) metric and get stuck at some local minima.
Nonetheless the question itself is highly relevant. Rather than blindly going for MSE for regression and CE for classification, one should definitely look at how the model is going to be evaluated ('used' may be a better term) and plan a loss function accordingly. In most cases a readymade pre-written loss function is available, but certain occasions could demand writing a customized loss function to suit the evaluation metric
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
It is a good question. I would like to answer it from a different perspective. Assume your model's intent is to find out the price of a house given a host of features (location, num of bedrooms, area
|
6,857
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
The differences are:
A loss function is used to train your model. A metric is used to evaluate your model.
A loss function is used during the learning process. A metric is used after the learning process
Example: Assuming you train three different models each using different algorithms and loss function to solve the same image classification task. Choosing the best model based on loss error would not always work since they are not directly comparable. Therefore, metrics are used to evaluate your trained models.
In general, when loss error decreases your metric scores improve. Therefore, the two are linked and sharing the same objective.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
The differences are:
A loss function is used to train your model. A metric is used to evaluate your model.
A loss function is used during the learning process. A metric is used after the learning pro
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
The differences are:
A loss function is used to train your model. A metric is used to evaluate your model.
A loss function is used during the learning process. A metric is used after the learning process
Example: Assuming you train three different models each using different algorithms and loss function to solve the same image classification task. Choosing the best model based on loss error would not always work since they are not directly comparable. Therefore, metrics are used to evaluate your trained models.
In general, when loss error decreases your metric scores improve. Therefore, the two are linked and sharing the same objective.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
The differences are:
A loss function is used to train your model. A metric is used to evaluate your model.
A loss function is used during the learning process. A metric is used after the learning pro
|
6,858
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
As explained here in relation to the no free lunch theorem (https://peekaboo-vision.blogspot.com/2019/07/dont-cite-no-free-lunch-theorem.html, see the final part), “learning is impossible without proper assumptions”. If you have a model which simply minimizes the evaluation metric, you are not making any assumption about the data and what's meaningful about it. In other words, how to learn. In this situation, the model cannot learn anything, all it can do is to "memorize" the details (including the noise) of the training set, and will lack generalization power to perform well on unseen data. Basically, you need to build the model on some assumptions. This is of great generality, but in the case of ML and algorithms, those assumptions are expressed in an analytical way, encoded in the loss function. These assumptions define what's relevant about the data, allowing the model to learn something beyond the noise and to have generalizing power.
Let's see with an example of why using the metric as a loss function would not work. Let's consider a typical classification problem, where you have two classes and a 2D feature space. You want that algorithm to find a 1D boundary that crosses the 2D space that will allow you to classify new data points. Now, imagine you create that boundary by simply minimizing the misclassification rate in the training set because you reason that that's the way you will evaluate the model later. In that case, the training step trivial, since you can easily draw the boundary such that you classify correctly 100% of the training set points. Thus, you achieve your goal, a perfect result for the metric in the training step. However, that's obviously overfitting, since you have to draw the boundary without actually learning anything about the data. When you assess the model on the test set the performance will be poor.
Moreover, I think that in some algorithms, the approach doesn't make any sense at all. Think of a tree algorithm. It's based on splitting the data several times, in different steps. What's the best way to split the data at a certain step? The model is based on some analytical assumptions to split it in the most informative way. However, in which way could you split it to maximize the metric (e.g. classification accuracy), if you still need to perform possibly thousand of splitting steps before the model can make such classification?
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
As explained here in relation to the no free lunch theorem (https://peekaboo-vision.blogspot.com/2019/07/dont-cite-no-free-lunch-theorem.html, see the final part), “learning is impossible without prop
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
As explained here in relation to the no free lunch theorem (https://peekaboo-vision.blogspot.com/2019/07/dont-cite-no-free-lunch-theorem.html, see the final part), “learning is impossible without proper assumptions”. If you have a model which simply minimizes the evaluation metric, you are not making any assumption about the data and what's meaningful about it. In other words, how to learn. In this situation, the model cannot learn anything, all it can do is to "memorize" the details (including the noise) of the training set, and will lack generalization power to perform well on unseen data. Basically, you need to build the model on some assumptions. This is of great generality, but in the case of ML and algorithms, those assumptions are expressed in an analytical way, encoded in the loss function. These assumptions define what's relevant about the data, allowing the model to learn something beyond the noise and to have generalizing power.
Let's see with an example of why using the metric as a loss function would not work. Let's consider a typical classification problem, where you have two classes and a 2D feature space. You want that algorithm to find a 1D boundary that crosses the 2D space that will allow you to classify new data points. Now, imagine you create that boundary by simply minimizing the misclassification rate in the training set because you reason that that's the way you will evaluate the model later. In that case, the training step trivial, since you can easily draw the boundary such that you classify correctly 100% of the training set points. Thus, you achieve your goal, a perfect result for the metric in the training step. However, that's obviously overfitting, since you have to draw the boundary without actually learning anything about the data. When you assess the model on the test set the performance will be poor.
Moreover, I think that in some algorithms, the approach doesn't make any sense at all. Think of a tree algorithm. It's based on splitting the data several times, in different steps. What's the best way to split the data at a certain step? The model is based on some analytical assumptions to split it in the most informative way. However, in which way could you split it to maximize the metric (e.g. classification accuracy), if you still need to perform possibly thousand of splitting steps before the model can make such classification?
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
As explained here in relation to the no free lunch theorem (https://peekaboo-vision.blogspot.com/2019/07/dont-cite-no-free-lunch-theorem.html, see the final part), “learning is impossible without prop
|
6,859
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
There is no learning theoretical requirement for loss function and test-evaluation metric mismatch. An argument for such a practice however :
The learned function is so well generalised, even there is a mismatch between loss function and the testing evaluation metric, one could still get a good performance.
Hyper-parameter optimisation is performed with the testing evaluation metric, so it is part of the learning algorithm.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
|
There is no learning theoretical requirement for loss function and test-evaluation metric mismatch. An argument for such a practice however :
The learned function is so well generalised, even there i
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
There is no learning theoretical requirement for loss function and test-evaluation metric mismatch. An argument for such a practice however :
The learned function is so well generalised, even there is a mismatch between loss function and the testing evaluation metric, one could still get a good performance.
Hyper-parameter optimisation is performed with the testing evaluation metric, so it is part of the learning algorithm.
|
Why do we use loss functions to estimate a model instead of evaluation metrics like accuracy?
There is no learning theoretical requirement for loss function and test-evaluation metric mismatch. An argument for such a practice however :
The learned function is so well generalised, even there i
|
6,860
|
Information gain, mutual information and related measures
|
I think that calling the Kullback-Leibler divergence "information gain" is non-standard.
The first definition is standard.
EDIT: However, $H(Y)−H(Y|X)$ can also be called mutual information.
Note that I don't think you will find any scientific discipline that really has a standardized, precise, and consistent naming scheme. So you will always have to look at the formulae, because they will generally give you a better idea.
Textbooks:
see "Good introduction into different kinds of entropy".
Also:
Cosma Shalizi: Methods and Techniques of Complex Systems Science: An Overview, chapter 1 (pp. 33--114) in Thomas S. Deisboeck and J. Yasha Kresh (eds.), Complex Systems Science in Biomedicine
http://arxiv.org/abs/nlin.AO/0307015
Robert M. Gray: Entropy and Information Theory
http://ee.stanford.edu/~gray/it.html
David MacKay: Information Theory, Inference, and Learning Algorithms
http://www.inference.phy.cam.ac.uk/mackay/itila/book.html
also, "What is “entropy and information gain”?"
|
Information gain, mutual information and related measures
|
I think that calling the Kullback-Leibler divergence "information gain" is non-standard.
The first definition is standard.
EDIT: However, $H(Y)−H(Y|X)$ can also be called mutual information.
Note tha
|
Information gain, mutual information and related measures
I think that calling the Kullback-Leibler divergence "information gain" is non-standard.
The first definition is standard.
EDIT: However, $H(Y)−H(Y|X)$ can also be called mutual information.
Note that I don't think you will find any scientific discipline that really has a standardized, precise, and consistent naming scheme. So you will always have to look at the formulae, because they will generally give you a better idea.
Textbooks:
see "Good introduction into different kinds of entropy".
Also:
Cosma Shalizi: Methods and Techniques of Complex Systems Science: An Overview, chapter 1 (pp. 33--114) in Thomas S. Deisboeck and J. Yasha Kresh (eds.), Complex Systems Science in Biomedicine
http://arxiv.org/abs/nlin.AO/0307015
Robert M. Gray: Entropy and Information Theory
http://ee.stanford.edu/~gray/it.html
David MacKay: Information Theory, Inference, and Learning Algorithms
http://www.inference.phy.cam.ac.uk/mackay/itila/book.html
also, "What is “entropy and information gain”?"
|
Information gain, mutual information and related measures
I think that calling the Kullback-Leibler divergence "information gain" is non-standard.
The first definition is standard.
EDIT: However, $H(Y)−H(Y|X)$ can also be called mutual information.
Note tha
|
6,861
|
Information gain, mutual information and related measures
|
The Kullback-Leiber Divergence between $p(X,Y)$ and $P(X)P(Y)$ is the same as mutual information, which can be easily derived:
$$
\begin{align}
I(X; Y) &= H(Y) - H(Y \mid X)\\
&= - \sum_y p(y) \log p(y) + \sum_{x,y} p(x) p(y\mid x) \log p(y\mid x)\\
&= \sum_{x,y} p(x, y) \log{p(y\mid x)} - \sum_{y} \left(\sum_{x}p(x,y)\right) \log p(y)\\
&= \sum_{x,y} p(x, y) \log{p(y\mid x)} - \sum_{x,y}p(x, y) \log p(y)\\
&= \sum_{x,y} p(x, y) \log \frac{p(y\mid x)}{p(y)}\\
&= \sum_{x,y} p(x, y) \log \frac{p(y\mid x)p(x)}{p(y)p(x)}\\
&= \sum_{x,y} p(x, y) \log \frac{p(x, y)}{p(y)p(x)}\\
&= \mathcal D_{KL} (P(X,Y)\mid\mid P(X)P(Y))
\end{align}
$$
Note: $p(y) = \sum_x p(x,y)$
|
Information gain, mutual information and related measures
|
The Kullback-Leiber Divergence between $p(X,Y)$ and $P(X)P(Y)$ is the same as mutual information, which can be easily derived:
$$
\begin{align}
I(X; Y) &= H(Y) - H(Y \mid X)\\
&= - \sum_y p(y) \log p
|
Information gain, mutual information and related measures
The Kullback-Leiber Divergence between $p(X,Y)$ and $P(X)P(Y)$ is the same as mutual information, which can be easily derived:
$$
\begin{align}
I(X; Y) &= H(Y) - H(Y \mid X)\\
&= - \sum_y p(y) \log p(y) + \sum_{x,y} p(x) p(y\mid x) \log p(y\mid x)\\
&= \sum_{x,y} p(x, y) \log{p(y\mid x)} - \sum_{y} \left(\sum_{x}p(x,y)\right) \log p(y)\\
&= \sum_{x,y} p(x, y) \log{p(y\mid x)} - \sum_{x,y}p(x, y) \log p(y)\\
&= \sum_{x,y} p(x, y) \log \frac{p(y\mid x)}{p(y)}\\
&= \sum_{x,y} p(x, y) \log \frac{p(y\mid x)p(x)}{p(y)p(x)}\\
&= \sum_{x,y} p(x, y) \log \frac{p(x, y)}{p(y)p(x)}\\
&= \mathcal D_{KL} (P(X,Y)\mid\mid P(X)P(Y))
\end{align}
$$
Note: $p(y) = \sum_x p(x,y)$
|
Information gain, mutual information and related measures
The Kullback-Leiber Divergence between $p(X,Y)$ and $P(X)P(Y)$ is the same as mutual information, which can be easily derived:
$$
\begin{align}
I(X; Y) &= H(Y) - H(Y \mid X)\\
&= - \sum_y p(y) \log p
|
6,862
|
Information gain, mutual information and related measures
|
Both definitions are correct, and consistent. I'm not sure what you find unclear as you point out multiple points that might need clarification.
Firstly: $MI_{Mutual Information}\equiv$ $IG_{InformationGain}\equiv I_{Information}$ are all different names for the same thing. In different contexts one of these names may be preferable, i will call it hereon Information.
The second point is the relation between the Kullback–Leibler divergence-$D_{KL}$, and Information. The Kullback–Leibler divergence is simply a measure of dissimilarity between two distributions. The Information can be defined in these terms of distributions' dissimilarity (see Yters' response). So information is a special case of $K_{LD}$, where $K_{LD}$ is applied to measure the difference between the actual joint distribution of two variables (which captures their dependence) and the hypothetical joint distribution of the same variables, were they to be independent. We call that quantity Information.
The third point to clarify is the inconsistent, though standard notation being used, namely that $\operatorname{H} (X,Y)$
is both the notation for Joint entropy and for Cross-entropy as well.
So, for example, in the definition of Information:
\begin{aligned}\operatorname {I} (X;Y)&{}\equiv \mathrm {H} (X)-\mathrm {H} (X|Y)\\&{}\equiv \mathrm {H} (Y)-\mathrm {H} (Y|X)\\&{}\equiv \mathrm {H} (X)+\mathrm {H} (Y)-\mathrm {H} (X,Y)\\&{}\equiv \mathrm {H} (X,Y)-\mathrm {H} (X|Y)-\mathrm {H} (Y|X)\end{aligned}
in both last lines, $\operatorname{H}(X,Y)$ is the joint entropy. This may seem inconsistent with the definition in the Information gain page however:
$DKL(P||Q)=H(P,Q)−H(P)$ but you did not fail to quote the important clarification - $\operatorname{H}(P,Q)$ is being used there as the cross-entropy (as is the case too in the cross entropy page).
Joint-entropy and Cross-entropy are NOT the same.
Check out this and this where this ambiguous notation is addressed and a unique notation for cross-entropy is offered - $H_q(p)$
I would hope to see this notation accepted and the wiki-pages updated.
|
Information gain, mutual information and related measures
|
Both definitions are correct, and consistent. I'm not sure what you find unclear as you point out multiple points that might need clarification.
Firstly: $MI_{Mutual Information}\equiv$ $IG_{Informati
|
Information gain, mutual information and related measures
Both definitions are correct, and consistent. I'm not sure what you find unclear as you point out multiple points that might need clarification.
Firstly: $MI_{Mutual Information}\equiv$ $IG_{InformationGain}\equiv I_{Information}$ are all different names for the same thing. In different contexts one of these names may be preferable, i will call it hereon Information.
The second point is the relation between the Kullback–Leibler divergence-$D_{KL}$, and Information. The Kullback–Leibler divergence is simply a measure of dissimilarity between two distributions. The Information can be defined in these terms of distributions' dissimilarity (see Yters' response). So information is a special case of $K_{LD}$, where $K_{LD}$ is applied to measure the difference between the actual joint distribution of two variables (which captures their dependence) and the hypothetical joint distribution of the same variables, were they to be independent. We call that quantity Information.
The third point to clarify is the inconsistent, though standard notation being used, namely that $\operatorname{H} (X,Y)$
is both the notation for Joint entropy and for Cross-entropy as well.
So, for example, in the definition of Information:
\begin{aligned}\operatorname {I} (X;Y)&{}\equiv \mathrm {H} (X)-\mathrm {H} (X|Y)\\&{}\equiv \mathrm {H} (Y)-\mathrm {H} (Y|X)\\&{}\equiv \mathrm {H} (X)+\mathrm {H} (Y)-\mathrm {H} (X,Y)\\&{}\equiv \mathrm {H} (X,Y)-\mathrm {H} (X|Y)-\mathrm {H} (Y|X)\end{aligned}
in both last lines, $\operatorname{H}(X,Y)$ is the joint entropy. This may seem inconsistent with the definition in the Information gain page however:
$DKL(P||Q)=H(P,Q)−H(P)$ but you did not fail to quote the important clarification - $\operatorname{H}(P,Q)$ is being used there as the cross-entropy (as is the case too in the cross entropy page).
Joint-entropy and Cross-entropy are NOT the same.
Check out this and this where this ambiguous notation is addressed and a unique notation for cross-entropy is offered - $H_q(p)$
I would hope to see this notation accepted and the wiki-pages updated.
|
Information gain, mutual information and related measures
Both definitions are correct, and consistent. I'm not sure what you find unclear as you point out multiple points that might need clarification.
Firstly: $MI_{Mutual Information}\equiv$ $IG_{Informati
|
6,863
|
Information gain, mutual information and related measures
|
Mutual information can be defined using Kullback-Liebler as
\begin{align*}
I(X;Y) = D_{KL}(p(x,y)||p(x)p(y)).
\end{align*}
|
Information gain, mutual information and related measures
|
Mutual information can be defined using Kullback-Liebler as
\begin{align*}
I(X;Y) = D_{KL}(p(x,y)||p(x)p(y)).
\end{align*}
|
Information gain, mutual information and related measures
Mutual information can be defined using Kullback-Liebler as
\begin{align*}
I(X;Y) = D_{KL}(p(x,y)||p(x)p(y)).
\end{align*}
|
Information gain, mutual information and related measures
Mutual information can be defined using Kullback-Liebler as
\begin{align*}
I(X;Y) = D_{KL}(p(x,y)||p(x)p(y)).
\end{align*}
|
6,864
|
Understanding p-value
|
First answer
You have to think at the concept of extreme in terms of probability of the test statistics, not in terms of its value or the value of the random variable being tested. I report the following example from
Christensen, R. (2005). Testing Fisher, Neyman, Pearson, and Bayes. The American Statistician, 59(2), 121–126
$$
\phantom{(r\;|\;\theta=0}r\; | \quad 1 \quad \quad 2 \quad \quad 3 \quad \quad 4\\
p(r\;|\;\theta=0) \; |\; 0.980\;0.005\; 0.005\; 0.010\\
\quad p\;\mathrm{value} \; \; | \;\; 1.0 \quad 0.01 \quad 0.01 \;\; 0.02
$$
Here $r$ are the observations, the second line is the probability to observe a given observation under the null hypothesis $\theta=0$, that is used here as test statistics, the third line is the $p$ value. We are here in the framework of Fisherian test: there is one hypothesis ($H_0$, in this case $\theta=0$) under which we want to see whether the data are weird or not. The observations with the smallest probability are 2 and 3 with 0.5% each. If you obtain 2, for example, the probability to observe something as likely or less likely ($r=2$ and $r=3$) is 1%. The observation $r=4$ does not contribute to the $p$ value, although it's further away (if an order relation exists), because it has higher probability to be observed.
This definition works in general, as it accommodates both categorical and multidimensional variables, where an order relation is not defined. In the case of a ingle quantitative variable, where you observe some bias from the most likely result, it might make sense to compute the single tailed $p$ value, and consider only the observations that are on one side of the test statistics distribution.
Second answer
I disagree entirely with this definition from Mathworld.
Third answer
I have to say that I'm not completely sure I understood your question, but I'll try to give a few observations that might help you.
In the simplest context of Fisherian testing, where you only have the null hypothesis, this should be the status quo. This is because Fisherian testing works essentially by contradiction. So, in the case of the coin, unless you have reasons to think differently, you would assume it is fair, $H_0: \theta=0.5$. Then you compute the $p$ value for your data under $H_0$ and, if your $p$ value is below a predefined threshold, you reject the hypothesis (proof by contradiction). You never compute the probability of the null hypothesis.
With the Neyman-Pearson tests you specify two alternative hypotheses and, based on their relative likelihood and the dimensionality of the parameter vectors, you favour one or another. This can be seen, for example, in testing the hypothesis of biased vs. unbiased coin. Unbiased means fixing the parameter to $\theta=0.5$ (the dimensionality of this parameter space is zero), while biased can be any value $\theta \neq 0.5$ (dimensionality equal to one). This solves the problem of trying to contradict the hypothesis of bias by contradiction, which would be impossible, as explained by another user. Fisher and NP give similar results when the sample is large, but they are not exactly equivalent. Here below a simple code in R for a biased coin.
n <- 100 # trials
p_bias <- 0.45 # the coin is biased
k <- as.integer(p_bias * n) # successes
# value obtained by plugging in the MLE of p, i.e. k/n = p_bias
lambda <- 2 * n * log(2) + 2 * k * log(p_bias) + 2 * (n-k) * log(1. - p_bias)
p_value_F <- 2 * pbinom(k, size=n, prob=0.5) # p-value under Fisher test
p_value_NP <- 1 - pchisq(q=lambda, df=1) # p-value under Neyman-Pearson
binom.test(c(k, n-k)) # equivalent to Fisher
|
Understanding p-value
|
First answer
You have to think at the concept of extreme in terms of probability of the test statistics, not in terms of its value or the value of the random variable being tested. I report the follow
|
Understanding p-value
First answer
You have to think at the concept of extreme in terms of probability of the test statistics, not in terms of its value or the value of the random variable being tested. I report the following example from
Christensen, R. (2005). Testing Fisher, Neyman, Pearson, and Bayes. The American Statistician, 59(2), 121–126
$$
\phantom{(r\;|\;\theta=0}r\; | \quad 1 \quad \quad 2 \quad \quad 3 \quad \quad 4\\
p(r\;|\;\theta=0) \; |\; 0.980\;0.005\; 0.005\; 0.010\\
\quad p\;\mathrm{value} \; \; | \;\; 1.0 \quad 0.01 \quad 0.01 \;\; 0.02
$$
Here $r$ are the observations, the second line is the probability to observe a given observation under the null hypothesis $\theta=0$, that is used here as test statistics, the third line is the $p$ value. We are here in the framework of Fisherian test: there is one hypothesis ($H_0$, in this case $\theta=0$) under which we want to see whether the data are weird or not. The observations with the smallest probability are 2 and 3 with 0.5% each. If you obtain 2, for example, the probability to observe something as likely or less likely ($r=2$ and $r=3$) is 1%. The observation $r=4$ does not contribute to the $p$ value, although it's further away (if an order relation exists), because it has higher probability to be observed.
This definition works in general, as it accommodates both categorical and multidimensional variables, where an order relation is not defined. In the case of a ingle quantitative variable, where you observe some bias from the most likely result, it might make sense to compute the single tailed $p$ value, and consider only the observations that are on one side of the test statistics distribution.
Second answer
I disagree entirely with this definition from Mathworld.
Third answer
I have to say that I'm not completely sure I understood your question, but I'll try to give a few observations that might help you.
In the simplest context of Fisherian testing, where you only have the null hypothesis, this should be the status quo. This is because Fisherian testing works essentially by contradiction. So, in the case of the coin, unless you have reasons to think differently, you would assume it is fair, $H_0: \theta=0.5$. Then you compute the $p$ value for your data under $H_0$ and, if your $p$ value is below a predefined threshold, you reject the hypothesis (proof by contradiction). You never compute the probability of the null hypothesis.
With the Neyman-Pearson tests you specify two alternative hypotheses and, based on their relative likelihood and the dimensionality of the parameter vectors, you favour one or another. This can be seen, for example, in testing the hypothesis of biased vs. unbiased coin. Unbiased means fixing the parameter to $\theta=0.5$ (the dimensionality of this parameter space is zero), while biased can be any value $\theta \neq 0.5$ (dimensionality equal to one). This solves the problem of trying to contradict the hypothesis of bias by contradiction, which would be impossible, as explained by another user. Fisher and NP give similar results when the sample is large, but they are not exactly equivalent. Here below a simple code in R for a biased coin.
n <- 100 # trials
p_bias <- 0.45 # the coin is biased
k <- as.integer(p_bias * n) # successes
# value obtained by plugging in the MLE of p, i.e. k/n = p_bias
lambda <- 2 * n * log(2) + 2 * k * log(p_bias) + 2 * (n-k) * log(1. - p_bias)
p_value_F <- 2 * pbinom(k, size=n, prob=0.5) # p-value under Fisher test
p_value_NP <- 1 - pchisq(q=lambda, df=1) # p-value under Neyman-Pearson
binom.test(c(k, n-k)) # equivalent to Fisher
|
Understanding p-value
First answer
You have to think at the concept of extreme in terms of probability of the test statistics, not in terms of its value or the value of the random variable being tested. I report the follow
|
6,865
|
Understanding p-value
|
(1) A statistic is a number you can calculate from a sample. It's used to put into order all the samples you might have got (under an assumed model, where coins don't land on their edges & what have you). If $t$ is what you calculate from the sample you actually got, & $T$ is the corresponding random variable, then the p-value is given by
$\newcommand{\pr}{\mathrm{Pr}}
\pr\left(T\geq t\right)$ under the null hypothesis, $H_0$.
'Greater than' vs 'more extreme' is unimportant in principle. For a two-sided test on a Normal mean we could use
$\pr(|Z|\geq |z|)$ but it's convenient to use
$2\min [\pr(Z\geq z),\pr(Z\leq z)]$
because we have the appropriate tables. (Note the doubling.)
There's no requirement for the test statistic to put the samples in order of their probability under the null hypothesis. There are situations (like Zag's example) where any other way would seem perverse (without more information about what $r$ measures, what kinds of discrepancies with $H_0$ are of most interest, &c.), but often other criteria are used. So you could have a bimodal PDF for the test statistic & still test $H_0$ using the formula above.
(2) Yes, they mean under $H_0$.
(3) A null hypothesis like "The frequency of heads is not 0.5" is no use because you would never be able to reject it. It's a composite null including "the frequency of heads is 0.49999999", or as close as you like. Whether you think beforehand the coin's fair or not, you pick a useful null hypothesis that bears on the problem. Perhaps more useful after the experiment is to calculate a confidence interval for the frequency of heads that shows you either it's clearly not a fair coin, or it's close enough to fair, or you need to do more trials to find out.
An illustration for (1):
Suppose you're testing the fairness of a coin with 10 tosses. There are $2^{10}$ possible results. Here are three of them:
$\mathsf{HHHHHHHHHH}\\
\mathsf{HTHTHTHTHT}\\
\mathsf{HHTHHHTTTH}$
You'll probably agree with me that the first two look a bit suspicious. Yet the probabilities under the null are equal:
$\mathrm{Pr}(\mathsf{HHHHHHHHHH}) = \frac{1}{1024}\\
\mathrm{Pr}(\mathsf{HTHTHTHTHT}) = \frac{1}{1024}\\
\mathrm{Pr}(\mathsf{HHTHHHTTTH}) = \frac{1}{1024}$
To get anywhere you need to consider what types of alternative to the null you want to test. If you're prepared to assume independence of each toss under both null & alternative (& in real situations this often means working very hard to ensure experimental trials are independent), you can use the total count of heads as a test statistic without losing information. (Partitioning the sample space in this way is another important job that statistics do.)
So you have a count between 0 and 10
t<-c(0:10)
Its distribution under the null is
p.null<-dbinom(t,10,0.5)
Under the version of the alternative that best fits the data, if you see (say) 3 out of 10 heads the probability of heads is $\frac{3}{10}$, so
p.alt<-dbinom(t,10,t/10)
Take the ratio of the probability under the null to the probability under the alternative (called the likelihood ratio):
lr<-p.alt/p.null
Compare with
plot(log(lr),p.null)
So for this null, the two statistics order samples the same way. If you repeat with a null of 0.85 (i.e. testing that the long-run frequency of heads is 85%), they don't.
p.null<-dbinom(t,10,0.85)
plot(log(lr),p.null)
To see why
plot(t,p.alt)
Some values of $t$ are less probable under the alternative, & the likelihood ratio test statistic takes this into account. NB this test statistic will not be extreme for
$\mathsf{HTHTHTHTHT}$
And that's fine - every sample can be considered extreme from some point of view. You choose the test statistic according to what kind of discrepancy to the null you want to be able to detect.
... Continuing this train of thought, you can define a statistic that partitions the sample space differently to test the same null against the alternative that one coin toss influences the next one. Call the number of runs $r$, so that
$\mathsf{HHTHHHTTTH}$
has $r=6$:
$\mathsf{HH}\ \mathsf{T}\ \mathsf{HHH}\ \mathsf{TTT}\ \mathsf{H}$
The suspicious sequence
$\mathsf{HTHTHTHTHT}$
has $r=10$. So does
$\mathsf{THTHTHTHTH}$
while at the other extreme
$\mathsf{HHHHHHHHHH}\\
\mathsf{TTTTTTTTTT}$
have $r=1$. Using probability under the null as the test statistic (the way you like) you can say that the p-value of the sample
$\mathsf{HTHTHTHTHT}$
is therefore $\frac{4}{1024}=\frac{1}{256}$. What's worthy of note, comparing this test to the previous, is that even if you stick strictly to the ordering given by probability under the null, the way in which you define your test statistic to partition the sample space is dependent on consideration of alternatives.
|
Understanding p-value
|
(1) A statistic is a number you can calculate from a sample. It's used to put into order all the samples you might have got (under an assumed model, where coins don't land on their edges & what have
|
Understanding p-value
(1) A statistic is a number you can calculate from a sample. It's used to put into order all the samples you might have got (under an assumed model, where coins don't land on their edges & what have you). If $t$ is what you calculate from the sample you actually got, & $T$ is the corresponding random variable, then the p-value is given by
$\newcommand{\pr}{\mathrm{Pr}}
\pr\left(T\geq t\right)$ under the null hypothesis, $H_0$.
'Greater than' vs 'more extreme' is unimportant in principle. For a two-sided test on a Normal mean we could use
$\pr(|Z|\geq |z|)$ but it's convenient to use
$2\min [\pr(Z\geq z),\pr(Z\leq z)]$
because we have the appropriate tables. (Note the doubling.)
There's no requirement for the test statistic to put the samples in order of their probability under the null hypothesis. There are situations (like Zag's example) where any other way would seem perverse (without more information about what $r$ measures, what kinds of discrepancies with $H_0$ are of most interest, &c.), but often other criteria are used. So you could have a bimodal PDF for the test statistic & still test $H_0$ using the formula above.
(2) Yes, they mean under $H_0$.
(3) A null hypothesis like "The frequency of heads is not 0.5" is no use because you would never be able to reject it. It's a composite null including "the frequency of heads is 0.49999999", or as close as you like. Whether you think beforehand the coin's fair or not, you pick a useful null hypothesis that bears on the problem. Perhaps more useful after the experiment is to calculate a confidence interval for the frequency of heads that shows you either it's clearly not a fair coin, or it's close enough to fair, or you need to do more trials to find out.
An illustration for (1):
Suppose you're testing the fairness of a coin with 10 tosses. There are $2^{10}$ possible results. Here are three of them:
$\mathsf{HHHHHHHHHH}\\
\mathsf{HTHTHTHTHT}\\
\mathsf{HHTHHHTTTH}$
You'll probably agree with me that the first two look a bit suspicious. Yet the probabilities under the null are equal:
$\mathrm{Pr}(\mathsf{HHHHHHHHHH}) = \frac{1}{1024}\\
\mathrm{Pr}(\mathsf{HTHTHTHTHT}) = \frac{1}{1024}\\
\mathrm{Pr}(\mathsf{HHTHHHTTTH}) = \frac{1}{1024}$
To get anywhere you need to consider what types of alternative to the null you want to test. If you're prepared to assume independence of each toss under both null & alternative (& in real situations this often means working very hard to ensure experimental trials are independent), you can use the total count of heads as a test statistic without losing information. (Partitioning the sample space in this way is another important job that statistics do.)
So you have a count between 0 and 10
t<-c(0:10)
Its distribution under the null is
p.null<-dbinom(t,10,0.5)
Under the version of the alternative that best fits the data, if you see (say) 3 out of 10 heads the probability of heads is $\frac{3}{10}$, so
p.alt<-dbinom(t,10,t/10)
Take the ratio of the probability under the null to the probability under the alternative (called the likelihood ratio):
lr<-p.alt/p.null
Compare with
plot(log(lr),p.null)
So for this null, the two statistics order samples the same way. If you repeat with a null of 0.85 (i.e. testing that the long-run frequency of heads is 85%), they don't.
p.null<-dbinom(t,10,0.85)
plot(log(lr),p.null)
To see why
plot(t,p.alt)
Some values of $t$ are less probable under the alternative, & the likelihood ratio test statistic takes this into account. NB this test statistic will not be extreme for
$\mathsf{HTHTHTHTHT}$
And that's fine - every sample can be considered extreme from some point of view. You choose the test statistic according to what kind of discrepancy to the null you want to be able to detect.
... Continuing this train of thought, you can define a statistic that partitions the sample space differently to test the same null against the alternative that one coin toss influences the next one. Call the number of runs $r$, so that
$\mathsf{HHTHHHTTTH}$
has $r=6$:
$\mathsf{HH}\ \mathsf{T}\ \mathsf{HHH}\ \mathsf{TTT}\ \mathsf{H}$
The suspicious sequence
$\mathsf{HTHTHTHTHT}$
has $r=10$. So does
$\mathsf{THTHTHTHTH}$
while at the other extreme
$\mathsf{HHHHHHHHHH}\\
\mathsf{TTTTTTTTTT}$
have $r=1$. Using probability under the null as the test statistic (the way you like) you can say that the p-value of the sample
$\mathsf{HTHTHTHTHT}$
is therefore $\frac{4}{1024}=\frac{1}{256}$. What's worthy of note, comparing this test to the previous, is that even if you stick strictly to the ordering given by probability under the null, the way in which you define your test statistic to partition the sample space is dependent on consideration of alternatives.
|
Understanding p-value
(1) A statistic is a number you can calculate from a sample. It's used to put into order all the samples you might have got (under an assumed model, where coins don't land on their edges & what have
|
6,866
|
What does the Akaike Information Criterion (AIC) score of a model mean?
|
This question by caveman is popular, but there were no attempted answers for months until my controversial one. It may be that the actual answer below is not, in itself, controversial, merely that the questions are "loaded" questions, because the field seems (to me, at least) to be populated by acolytes of AIC and BIC who would rather use OLS than each others' methods. Please look at all the assumptions listed, and restrictions placed on data types and methods of analysis, and please comment on them; fix this, contribute. Thus far, some very smart people have contributed, so slow progress is being made. I acknowledge contributions by Richard Hardy and GeoMatt22, kind words from Antoni Parellada, and valiant attempts by Cagdas Ozgenc and Ben Ogorek to relate K-L divergence to an actual divergence.
Before we begin let us review what AIC is, and one source for this is Prerequisites for AIC model comparison and another is from Rob J Hyndman. In specific, AIC is calculated to be equal to
$$2k - 2 \log(L(\theta))\,,$$
where $k$ is the number of parameters in the model and $L(\theta)$ the likelihood function. AIC compares the trade-off between variance ($2k$) and bias ($2\log(L(\theta))$) from modelling assumptions. From Facts and fallacies of the AIC, point 3 "The AIC does not assume the residuals are Gaussian. It is just that the Gaussian likelihood is most frequently used. But if you want to use some other distribution, go ahead." The AIC is the penalized likelihood, whichever likelihood you choose to use. For example, to resolve AIC for Student's-t distributed residuals, we could use the maximum-likelihood solution for Student's-t. The log-likelihood usually applied for AIC is derived from Gaussian log-likelihood and given by
$$ \log(L(\theta)) =-\frac{|D|}{2}\log(2\pi) -\frac{1}{2} \log(|K|) -\frac{1}{2}(x-\mu)^T K^{-1} (x-\mu), $$
$K$ being the covariance structure of the model, $|D|$ the sample size; the number of observations in the datasets, $\mu$ the mean response and $x$ the dependent variable. Note that, strictly speaking, it is unnecessary for AIC to correct for the sample size, because AIC is not used to compare datasets, only models using the same dataset. Thus, we do not have to investigate whether the sample size correction is done correctly or not, but we would have to worry about this if we could somehow generalize AIC to be useful between datasets. Similarly, much is made about $K>>|D|>2$ to insure asymptotic efficiency. A minimalist view might consider AIC to be just an "index," making $K>|D|$ relevant and $K>>|D|$ irrelevant. However, some attention has been given to this in the form of proposing an altered AIC for $K$ not much larger than $|D|$ called AIC$_c$ see second paragraph of answer to Q2 below. This proliferation of "measures" only reinforces the notion that AIC is an index. However, caution is advised when using the "i" word as some AIC advocates equate use of the word "index" with the same fondness as might be attached to referring to their ontogeny as extramarital.
Q1: But a question is: why should we care about this specific fitness-simplicity trade-off?
Answer in two parts. First the specific question. You should only care because that was the way it was defined. If you prefer there is no reason not to define a CIC; a caveman information criterion, it will not be AIC, but CIC would produce the same answers as AIC, it does not effect the tradeoff between goodness-of-fit and positing simplicity. Any constant that could have been used as an AIC multiplier, including one times, would have to have been chosen and adhered to, as there is no reference standard to enforce an absolute scale. However, adhering to a standard definition is not arbitrary in the sense that there is room for one and only one definition, or "convention," for a quantity, like AIC, that is defined only on a relative scale. Also see AIC assumption #3, below.
The second answer to this question pertains to the specifics of AIC tradeoff between goodness-of-fit and positing simplicity irrespective of how its constant multiplier would have been chosen. That is, what actually effects the "tradeoff"? One of the things that effects this, is to degree of freedom readjust for the number of parameters in a model, this led to defining an "new" AIC called AIC$_c$ as follows:
$$\begin{align}AIC_c &= AIC + \frac{2k(k + 1)}{n - k - 1}\\
&= \frac{2kn}{n-k-1} - 2 \ln{(L)}\end{align} \,,$$
where $n$ is the sample size. Since the weighting is now slightly different when comparing models having different numbers of parameters, AIC$_c$ selects models differently than AIC itself, and identically as AIC when the two models are different but have the same number of parameters.
Other methods will also select models differently, for example, "The BIC [sic, Bayesian information criterion] generally penalizes free parameters more strongly than the Akaike information criterion, though it depends..." ANOVA would also penalize supernumerary parameters using partial probabilities of the indispensability of parameter values differently, and in some circumstances would be preferable to AIC use. In general, any method of assessment of appropriateness of a model will have its advantages and disadvantages. My advice would be to test the performance of any model selection method for its application to the data regression methodology more vigorously than testing the models themselves. Any reason to doubt? Yup, care should be taken when constructing or selecting any model test to select methods that are methodologically appropriate. AIC is useful for a subset of model evaluations, for that see Q3, next. For example, extracting information with model A may be best performed with regression method 1, and for model B with regression method 2, where model B and method 2 sometimes yields non-physical answers, and where neither regression method is MLR, where the residuals are a multi-period waveform with two distinct frequencies for either model and the reviewer asks "Why don't you calculate AIC?"
Q3 How does this relate to information theory:
MLR assumption #1. AIC is predicated upon the assumptions of maximum likelihood (MLR) applicability to a regression problem. There is only one circumstance in which ordinary least squares regression and maximum likelihood regression have been pointed out to me as being the same. That would be when the residuals from ordinary least squares (OLS) linear regression are normally distributed, and MLR has a Gaussian loss function. In other cases of OLS linear regression, for nonlinear OLS regression, and non-Gaussian loss functions, MLR and OLS may differ. There are many other regression targets than OLS or MLR or even goodness of fit and frequently a good answer has little to do with either, e.g., for most inverse problems. There are highly cited attempts (e.g., 1100 times) to use generalize AIC for quasi-likelihood so that the dependence on maximum likelihood regression is relaxed to admit more general loss functions. Moreover, MLR for Student's-t, although not in closed form, is robustly convergent. Since Student-t residual distributions are both more common and more general than, as well as inclusive of, Gaussian conditions, I see no special reason to use the Gaussian assumption for AIC.
MLR assumption #2. MLR is an attempt to quantify goodness of fit. It is sometimes applied when it is not appropriate. For example, for trimmed range data, when the model used is not trimmed. Goodness-of-fit is all fine and good if we have complete information coverage. In time series, we do not usually have fast enough information to understand fully what physical events transpire initially or our models may not be complete enough to examine very early data. Even more troubling is that one often cannot test goodness-of-fit at very late times, for lack of data. Thus, goodness-of-fit may only be modelling 30% of the area fit under the curve, and in that case, we are judging an extrapolated model on the basis of where the data is, and we are not examining what that means. In order to extrapolate, we need to look not only at the goodness of fit of 'amounts' but also the derivatives of those amounts failing which we have no "goodness" of extrapolation. Thus, fit techniques like B-splines find use because they can more smoothly predict what the data is when the derivatives are fit, or alternatively inverse problem treatments, e.g., ill-posed integral treatment over the whole model range, like error propagation adaptive Tikhonov regularization.
Another complicated concern, the data can tell us what we should be doing with it. What we need for goodness-of-fit (when appropriate), is to have the residuals that are distances in the sense that a standard deviation is a distance. That is, goodness-of-fit would not make much sense if a residual that is twice as long as a single standard deviation were not also of length two standard deviations. Selection of data transforms should be investigated prior to applying any model selection/regression method. If the data has proportional type error, typically taking the logarithm before selecting a regression is not inappropriate, as it then transforms standard deviations into distances. Alternatively, we can alter the norm to be minimized to accommodate fitting proportional data. The same would apply for Poisson error structure, we can either take the square root of the data to normalize the error, or alter our norm for fitting. There are problems that are much more complicated or even intractable if we cannot alter the norm for fitting, e.g., Poisson counting statistics from nuclear decay when the radionuclide decay introduces an exponential time-based association between the counting data and the actual mass that would have been emanating those counts had there been no decay. Why? If we decay back-correct the count rates, we no longer have Poisson statistics, and residuals (or errors) from the square-root of corrected counts are no longer distances. If we then want to perform a goodness-of-fit test of decay corrected data (e.g., AIC), we would have to do it in some way that is unknown to my humble self. Open question to the readership, if we insist on using MLR, can we alter its norm to account for the error type of the data (desirable), or must we always transform the data to allow MLR usage (not as useful)? Note, AIC does not compare regression methods for a single model, it compares different models for the same regression method.
AIC assumption #1. It would seem that MLR is not restricted to normal residuals, for example, see this question about MLR and Student's-t. Next, let us assume that MLR is appropriate to our problem so that we track its use for comparing AIC values in theory. Next we assume that have 1) complete information, 2) the same type of distribution of residuals (e.g., both normal, both Student's-t) for at least 2 models. That is, we have an accident that two models should now have the type of distribution of residuals. Could that happen? Yes, probably, but certainly not always.
AIC assumption #2. AIC relates the negative logarithm of the quantity (number of parameters in the model divided by the Kullback-Leibler divergence). Is this assumption necessary? In the general loss functions paper a different "divergence" is used. This leads us to question if that other measure is more general than K-L divergence, why are we not using it for AIC as well?
The mismatched information for AIC from Kullback-Leibler divergence is "Although ... often intuited as a way of measuring the distance between probability distributions, the Kullback–Leibler divergence is not a true metric." We shall see why shortly.
The K-L argument gets to the point where the difference between two things the model (P) and the data (Q) are
$$D_{\mathrm{KL}}(P\|Q) = \int_X \log\!\left(\frac{{\rm d}P}{{\rm d}Q}\right) \frac{{\rm d}P}{{\rm d}Q} \, {\rm d}Q \,,$$
which we recognize as the entropy of ''P'' relative to ''Q''.
AIC assumption #3. Most formulas involving the Kullback–Leibler divergence hold regardless of the base of the logarithm. The constant multiplier might have more meaning if AIC were relating more than one data set at at time. As it stands when comparing methods, if $AIC_{data,model 1}<AIC_{data,model 2}$ then any positive number times that will still be $<$. Since it is arbitrary, setting the constant to a specific value as a matter of definition is also not inappropriate.
AIC assumption #4. That would be that AIC measures Shannon entropy or self information." What we need to know is "Is entropy what we need for a metric of information?"
To understand what "self-information" is, it behooves us to normalize information in a physical context, any one will do. Yes, I want a measure of information to have properties that are physical. So what would that look like in a more general context?
The Gibbs free-energy equation ($\Delta G = ΔH – TΔS$) relates the change in energy to the change in enthalpy minus the absolute temperature times the change in entropy. Temperature is an example of a successful type of normalized information content, because if one hot and one cold brick are placed in contact with each other in a thermally closed environment, then heat will flow between them. Now, if we jump at this without thinking too hard, we say that heat is the information. But is it the relative information that predicts behaviour of a system. Information flows until equilibrium is reached, but equilibrium of what? Temperature, that's what, not heat as in particle velocity of certain particle masses, I am not talking about molecular temperature, I am talking about gross temperature of two bricks which may have different masses, made of different materials, having different densities etc., and none of that do I have to know, all I need to know is that the gross temperature is what equilibrates. Thus if one brick is hotter, then it has more relative information content, and when colder, less.
Now, if I am told one brick has more entropy than the other, so what? That, by itself, will not predict if it will gain or lose entropy when placed in contact with another brick. So, is entropy alone a useful measure of information? Yes, but only if we are comparing the same brick to itself thus the term "self-information."
From that comes the last restriction: To use K-L divergence all bricks must be identical. Thus, what makes AIC an atypical index is that it is not portable between data sets (e.g., different bricks), which is not an especially desirable property that might be addressed by normalizing information content. Is K-L divergence linear? Maybe yes, maybe no. However, that does not matter, we do not need to assume linearity to use AIC, and, for example, entropy itself I do not think is linearly related to temperature. In other words, we do not need a linear metric to use entropy calculations.
It has been said that, "In itself, the value of the AIC for a given data set has no meaning." On the optimistic side models that have close results can be differentiated by smoothing to establish confidence intervals, and much much more.
|
What does the Akaike Information Criterion (AIC) score of a model mean?
|
This question by caveman is popular, but there were no attempted answers for months until my controversial one. It may be that the actual answer below is not, in itself, controversial, merely that th
|
What does the Akaike Information Criterion (AIC) score of a model mean?
This question by caveman is popular, but there were no attempted answers for months until my controversial one. It may be that the actual answer below is not, in itself, controversial, merely that the questions are "loaded" questions, because the field seems (to me, at least) to be populated by acolytes of AIC and BIC who would rather use OLS than each others' methods. Please look at all the assumptions listed, and restrictions placed on data types and methods of analysis, and please comment on them; fix this, contribute. Thus far, some very smart people have contributed, so slow progress is being made. I acknowledge contributions by Richard Hardy and GeoMatt22, kind words from Antoni Parellada, and valiant attempts by Cagdas Ozgenc and Ben Ogorek to relate K-L divergence to an actual divergence.
Before we begin let us review what AIC is, and one source for this is Prerequisites for AIC model comparison and another is from Rob J Hyndman. In specific, AIC is calculated to be equal to
$$2k - 2 \log(L(\theta))\,,$$
where $k$ is the number of parameters in the model and $L(\theta)$ the likelihood function. AIC compares the trade-off between variance ($2k$) and bias ($2\log(L(\theta))$) from modelling assumptions. From Facts and fallacies of the AIC, point 3 "The AIC does not assume the residuals are Gaussian. It is just that the Gaussian likelihood is most frequently used. But if you want to use some other distribution, go ahead." The AIC is the penalized likelihood, whichever likelihood you choose to use. For example, to resolve AIC for Student's-t distributed residuals, we could use the maximum-likelihood solution for Student's-t. The log-likelihood usually applied for AIC is derived from Gaussian log-likelihood and given by
$$ \log(L(\theta)) =-\frac{|D|}{2}\log(2\pi) -\frac{1}{2} \log(|K|) -\frac{1}{2}(x-\mu)^T K^{-1} (x-\mu), $$
$K$ being the covariance structure of the model, $|D|$ the sample size; the number of observations in the datasets, $\mu$ the mean response and $x$ the dependent variable. Note that, strictly speaking, it is unnecessary for AIC to correct for the sample size, because AIC is not used to compare datasets, only models using the same dataset. Thus, we do not have to investigate whether the sample size correction is done correctly or not, but we would have to worry about this if we could somehow generalize AIC to be useful between datasets. Similarly, much is made about $K>>|D|>2$ to insure asymptotic efficiency. A minimalist view might consider AIC to be just an "index," making $K>|D|$ relevant and $K>>|D|$ irrelevant. However, some attention has been given to this in the form of proposing an altered AIC for $K$ not much larger than $|D|$ called AIC$_c$ see second paragraph of answer to Q2 below. This proliferation of "measures" only reinforces the notion that AIC is an index. However, caution is advised when using the "i" word as some AIC advocates equate use of the word "index" with the same fondness as might be attached to referring to their ontogeny as extramarital.
Q1: But a question is: why should we care about this specific fitness-simplicity trade-off?
Answer in two parts. First the specific question. You should only care because that was the way it was defined. If you prefer there is no reason not to define a CIC; a caveman information criterion, it will not be AIC, but CIC would produce the same answers as AIC, it does not effect the tradeoff between goodness-of-fit and positing simplicity. Any constant that could have been used as an AIC multiplier, including one times, would have to have been chosen and adhered to, as there is no reference standard to enforce an absolute scale. However, adhering to a standard definition is not arbitrary in the sense that there is room for one and only one definition, or "convention," for a quantity, like AIC, that is defined only on a relative scale. Also see AIC assumption #3, below.
The second answer to this question pertains to the specifics of AIC tradeoff between goodness-of-fit and positing simplicity irrespective of how its constant multiplier would have been chosen. That is, what actually effects the "tradeoff"? One of the things that effects this, is to degree of freedom readjust for the number of parameters in a model, this led to defining an "new" AIC called AIC$_c$ as follows:
$$\begin{align}AIC_c &= AIC + \frac{2k(k + 1)}{n - k - 1}\\
&= \frac{2kn}{n-k-1} - 2 \ln{(L)}\end{align} \,,$$
where $n$ is the sample size. Since the weighting is now slightly different when comparing models having different numbers of parameters, AIC$_c$ selects models differently than AIC itself, and identically as AIC when the two models are different but have the same number of parameters.
Other methods will also select models differently, for example, "The BIC [sic, Bayesian information criterion] generally penalizes free parameters more strongly than the Akaike information criterion, though it depends..." ANOVA would also penalize supernumerary parameters using partial probabilities of the indispensability of parameter values differently, and in some circumstances would be preferable to AIC use. In general, any method of assessment of appropriateness of a model will have its advantages and disadvantages. My advice would be to test the performance of any model selection method for its application to the data regression methodology more vigorously than testing the models themselves. Any reason to doubt? Yup, care should be taken when constructing or selecting any model test to select methods that are methodologically appropriate. AIC is useful for a subset of model evaluations, for that see Q3, next. For example, extracting information with model A may be best performed with regression method 1, and for model B with regression method 2, where model B and method 2 sometimes yields non-physical answers, and where neither regression method is MLR, where the residuals are a multi-period waveform with two distinct frequencies for either model and the reviewer asks "Why don't you calculate AIC?"
Q3 How does this relate to information theory:
MLR assumption #1. AIC is predicated upon the assumptions of maximum likelihood (MLR) applicability to a regression problem. There is only one circumstance in which ordinary least squares regression and maximum likelihood regression have been pointed out to me as being the same. That would be when the residuals from ordinary least squares (OLS) linear regression are normally distributed, and MLR has a Gaussian loss function. In other cases of OLS linear regression, for nonlinear OLS regression, and non-Gaussian loss functions, MLR and OLS may differ. There are many other regression targets than OLS or MLR or even goodness of fit and frequently a good answer has little to do with either, e.g., for most inverse problems. There are highly cited attempts (e.g., 1100 times) to use generalize AIC for quasi-likelihood so that the dependence on maximum likelihood regression is relaxed to admit more general loss functions. Moreover, MLR for Student's-t, although not in closed form, is robustly convergent. Since Student-t residual distributions are both more common and more general than, as well as inclusive of, Gaussian conditions, I see no special reason to use the Gaussian assumption for AIC.
MLR assumption #2. MLR is an attempt to quantify goodness of fit. It is sometimes applied when it is not appropriate. For example, for trimmed range data, when the model used is not trimmed. Goodness-of-fit is all fine and good if we have complete information coverage. In time series, we do not usually have fast enough information to understand fully what physical events transpire initially or our models may not be complete enough to examine very early data. Even more troubling is that one often cannot test goodness-of-fit at very late times, for lack of data. Thus, goodness-of-fit may only be modelling 30% of the area fit under the curve, and in that case, we are judging an extrapolated model on the basis of where the data is, and we are not examining what that means. In order to extrapolate, we need to look not only at the goodness of fit of 'amounts' but also the derivatives of those amounts failing which we have no "goodness" of extrapolation. Thus, fit techniques like B-splines find use because they can more smoothly predict what the data is when the derivatives are fit, or alternatively inverse problem treatments, e.g., ill-posed integral treatment over the whole model range, like error propagation adaptive Tikhonov regularization.
Another complicated concern, the data can tell us what we should be doing with it. What we need for goodness-of-fit (when appropriate), is to have the residuals that are distances in the sense that a standard deviation is a distance. That is, goodness-of-fit would not make much sense if a residual that is twice as long as a single standard deviation were not also of length two standard deviations. Selection of data transforms should be investigated prior to applying any model selection/regression method. If the data has proportional type error, typically taking the logarithm before selecting a regression is not inappropriate, as it then transforms standard deviations into distances. Alternatively, we can alter the norm to be minimized to accommodate fitting proportional data. The same would apply for Poisson error structure, we can either take the square root of the data to normalize the error, or alter our norm for fitting. There are problems that are much more complicated or even intractable if we cannot alter the norm for fitting, e.g., Poisson counting statistics from nuclear decay when the radionuclide decay introduces an exponential time-based association between the counting data and the actual mass that would have been emanating those counts had there been no decay. Why? If we decay back-correct the count rates, we no longer have Poisson statistics, and residuals (or errors) from the square-root of corrected counts are no longer distances. If we then want to perform a goodness-of-fit test of decay corrected data (e.g., AIC), we would have to do it in some way that is unknown to my humble self. Open question to the readership, if we insist on using MLR, can we alter its norm to account for the error type of the data (desirable), or must we always transform the data to allow MLR usage (not as useful)? Note, AIC does not compare regression methods for a single model, it compares different models for the same regression method.
AIC assumption #1. It would seem that MLR is not restricted to normal residuals, for example, see this question about MLR and Student's-t. Next, let us assume that MLR is appropriate to our problem so that we track its use for comparing AIC values in theory. Next we assume that have 1) complete information, 2) the same type of distribution of residuals (e.g., both normal, both Student's-t) for at least 2 models. That is, we have an accident that two models should now have the type of distribution of residuals. Could that happen? Yes, probably, but certainly not always.
AIC assumption #2. AIC relates the negative logarithm of the quantity (number of parameters in the model divided by the Kullback-Leibler divergence). Is this assumption necessary? In the general loss functions paper a different "divergence" is used. This leads us to question if that other measure is more general than K-L divergence, why are we not using it for AIC as well?
The mismatched information for AIC from Kullback-Leibler divergence is "Although ... often intuited as a way of measuring the distance between probability distributions, the Kullback–Leibler divergence is not a true metric." We shall see why shortly.
The K-L argument gets to the point where the difference between two things the model (P) and the data (Q) are
$$D_{\mathrm{KL}}(P\|Q) = \int_X \log\!\left(\frac{{\rm d}P}{{\rm d}Q}\right) \frac{{\rm d}P}{{\rm d}Q} \, {\rm d}Q \,,$$
which we recognize as the entropy of ''P'' relative to ''Q''.
AIC assumption #3. Most formulas involving the Kullback–Leibler divergence hold regardless of the base of the logarithm. The constant multiplier might have more meaning if AIC were relating more than one data set at at time. As it stands when comparing methods, if $AIC_{data,model 1}<AIC_{data,model 2}$ then any positive number times that will still be $<$. Since it is arbitrary, setting the constant to a specific value as a matter of definition is also not inappropriate.
AIC assumption #4. That would be that AIC measures Shannon entropy or self information." What we need to know is "Is entropy what we need for a metric of information?"
To understand what "self-information" is, it behooves us to normalize information in a physical context, any one will do. Yes, I want a measure of information to have properties that are physical. So what would that look like in a more general context?
The Gibbs free-energy equation ($\Delta G = ΔH – TΔS$) relates the change in energy to the change in enthalpy minus the absolute temperature times the change in entropy. Temperature is an example of a successful type of normalized information content, because if one hot and one cold brick are placed in contact with each other in a thermally closed environment, then heat will flow between them. Now, if we jump at this without thinking too hard, we say that heat is the information. But is it the relative information that predicts behaviour of a system. Information flows until equilibrium is reached, but equilibrium of what? Temperature, that's what, not heat as in particle velocity of certain particle masses, I am not talking about molecular temperature, I am talking about gross temperature of two bricks which may have different masses, made of different materials, having different densities etc., and none of that do I have to know, all I need to know is that the gross temperature is what equilibrates. Thus if one brick is hotter, then it has more relative information content, and when colder, less.
Now, if I am told one brick has more entropy than the other, so what? That, by itself, will not predict if it will gain or lose entropy when placed in contact with another brick. So, is entropy alone a useful measure of information? Yes, but only if we are comparing the same brick to itself thus the term "self-information."
From that comes the last restriction: To use K-L divergence all bricks must be identical. Thus, what makes AIC an atypical index is that it is not portable between data sets (e.g., different bricks), which is not an especially desirable property that might be addressed by normalizing information content. Is K-L divergence linear? Maybe yes, maybe no. However, that does not matter, we do not need to assume linearity to use AIC, and, for example, entropy itself I do not think is linearly related to temperature. In other words, we do not need a linear metric to use entropy calculations.
It has been said that, "In itself, the value of the AIC for a given data set has no meaning." On the optimistic side models that have close results can be differentiated by smoothing to establish confidence intervals, and much much more.
|
What does the Akaike Information Criterion (AIC) score of a model mean?
This question by caveman is popular, but there were no attempted answers for months until my controversial one. It may be that the actual answer below is not, in itself, controversial, merely that th
|
6,867
|
What does the Akaike Information Criterion (AIC) score of a model mean?
|
AIC is an estimate of twice the model-driven additive term to the expected Kullback-Leibler divergence between the true distribution $f$ and the approximating parametric model $g$.
K-L divergence is a topic in information theory and works intuitively (though not rigorously) as a measure of distance between two probability distributions. In my explanation below, I'm referencing these slides from Shuhua Hu. This answer still needs a citation for the "key result."
The K-L divergence between the true model $f$ and approximating model $g_{\theta}$ is
$$ d(f, g_{\theta}) = \int f(x) \log(f(x)) dx -\int f(x) \log(g_{\theta}(x)) dx$$
Since the truth is unknown, data $y$ is generated from $f$ and maximum likelihood estimation yields estimator $\hat{\theta}(y)$. Replacing $\theta$ with $\hat{\theta}(y)$ in the equations above means that both the second term in the K-L divergence formula as well as the K-L divergence itself are now random variables. The "key result" in the slides is that the average of the second additive term with respect to $y$ can be estimated by a simple function of the likelihood function $L$ (evaluated at the MLE), and $k$, the dimension of $\theta$:
$$ -\text{E}_y\left[\int f(x) \log(g_{\hat{\theta}(y)}(x)) \, dx \right] \approx -\log(L(\hat{\theta}(y))) + k.$$
AIC is defined as twice the expectation above (HT @Carl), and smaller (more negative) values correspond to a smaller estimated K-L divergences between the true distribution $f$ and the modeled distribution $g_{\hat{\theta}(y)}$.
|
What does the Akaike Information Criterion (AIC) score of a model mean?
|
AIC is an estimate of twice the model-driven additive term to the expected Kullback-Leibler divergence between the true distribution $f$ and the approximating parametric model $g$.
K-L divergence is a
|
What does the Akaike Information Criterion (AIC) score of a model mean?
AIC is an estimate of twice the model-driven additive term to the expected Kullback-Leibler divergence between the true distribution $f$ and the approximating parametric model $g$.
K-L divergence is a topic in information theory and works intuitively (though not rigorously) as a measure of distance between two probability distributions. In my explanation below, I'm referencing these slides from Shuhua Hu. This answer still needs a citation for the "key result."
The K-L divergence between the true model $f$ and approximating model $g_{\theta}$ is
$$ d(f, g_{\theta}) = \int f(x) \log(f(x)) dx -\int f(x) \log(g_{\theta}(x)) dx$$
Since the truth is unknown, data $y$ is generated from $f$ and maximum likelihood estimation yields estimator $\hat{\theta}(y)$. Replacing $\theta$ with $\hat{\theta}(y)$ in the equations above means that both the second term in the K-L divergence formula as well as the K-L divergence itself are now random variables. The "key result" in the slides is that the average of the second additive term with respect to $y$ can be estimated by a simple function of the likelihood function $L$ (evaluated at the MLE), and $k$, the dimension of $\theta$:
$$ -\text{E}_y\left[\int f(x) \log(g_{\hat{\theta}(y)}(x)) \, dx \right] \approx -\log(L(\hat{\theta}(y))) + k.$$
AIC is defined as twice the expectation above (HT @Carl), and smaller (more negative) values correspond to a smaller estimated K-L divergences between the true distribution $f$ and the modeled distribution $g_{\hat{\theta}(y)}$.
|
What does the Akaike Information Criterion (AIC) score of a model mean?
AIC is an estimate of twice the model-driven additive term to the expected Kullback-Leibler divergence between the true distribution $f$ and the approximating parametric model $g$.
K-L divergence is a
|
6,868
|
What does the Akaike Information Criterion (AIC) score of a model mean?
|
A simple point of view for your first two questions is that the AIC is related to the expected out-of-sample error rate of the maximum likelihood model. The AIC criterion is based on the relationship (Elements of Statistical Learning equation 7.27)
$$
-2 \, \mathrm{E}[\ln \mathrm{Pr}(D|\theta)] \approx -\frac{2}{N} \, \mathrm{E}[\ln L_{m,D}] + \frac{2k_m}{N} = \frac{1}{N} E[\mathrm{AIC}_{m,D}]
$$
where, following your notation, $k_m$ is the number of parameters in the model $m$ whose maximum likelihood value is $L_{m,D}$.
The term on the left is the expected out-of-sample "error" rate of the maximum likelihood model $m = \{ \theta \}$, using the log of the probability as the error metric. The -2 factor is the traditional correction used to construct the deviance (useful because in certain situations it follows a chi-square distribution).
The right hand consists of the in-sample "error" rate estimated from the maximized log-likelihood, plus the term $2k_m/N$ correcting for the optimism of the maximized log-likelihood, which has the freedom to overfit the data somewhat.
Thus, the AIC is an estimate of the out-of-sample "error" rate (deviance) times $N$.
|
What does the Akaike Information Criterion (AIC) score of a model mean?
|
A simple point of view for your first two questions is that the AIC is related to the expected out-of-sample error rate of the maximum likelihood model. The AIC criterion is based on the relationship
|
What does the Akaike Information Criterion (AIC) score of a model mean?
A simple point of view for your first two questions is that the AIC is related to the expected out-of-sample error rate of the maximum likelihood model. The AIC criterion is based on the relationship (Elements of Statistical Learning equation 7.27)
$$
-2 \, \mathrm{E}[\ln \mathrm{Pr}(D|\theta)] \approx -\frac{2}{N} \, \mathrm{E}[\ln L_{m,D}] + \frac{2k_m}{N} = \frac{1}{N} E[\mathrm{AIC}_{m,D}]
$$
where, following your notation, $k_m$ is the number of parameters in the model $m$ whose maximum likelihood value is $L_{m,D}$.
The term on the left is the expected out-of-sample "error" rate of the maximum likelihood model $m = \{ \theta \}$, using the log of the probability as the error metric. The -2 factor is the traditional correction used to construct the deviance (useful because in certain situations it follows a chi-square distribution).
The right hand consists of the in-sample "error" rate estimated from the maximized log-likelihood, plus the term $2k_m/N$ correcting for the optimism of the maximized log-likelihood, which has the freedom to overfit the data somewhat.
Thus, the AIC is an estimate of the out-of-sample "error" rate (deviance) times $N$.
|
What does the Akaike Information Criterion (AIC) score of a model mean?
A simple point of view for your first two questions is that the AIC is related to the expected out-of-sample error rate of the maximum likelihood model. The AIC criterion is based on the relationship
|
6,869
|
How to derive the standard error of linear regression coefficient
|
3rd comment above: I've already understand how it comes. But still a question: in my post, the standard error has (n−2), where according to your answer, it doesn't, why?
In my post, it is found that
$$
\widehat{\text{se}}(\hat{b}) = \sqrt{\frac{n \hat{\sigma}^2}{n\sum x_i^2 - (\sum x_i)^2}}.
$$
The denominator can be written as
$$
n \sum_i (x_i - \bar{x})^2
$$
Thus,
$$
\widehat{\text{se}}(\hat{b}) = \sqrt{\frac{\hat{\sigma}^2}{\sum_i (x_i - \bar{x})^2}}
$$
With
$$
\hat{\sigma}^2 = \frac{1}{n-2} \sum_i \hat{\epsilon}_i^2
$$
i.e. the Mean Square Error (MSE) in the ANOVA table, we end up with your expression for $\widehat{\text{se}}(\hat{b})$. The $n-2$ term accounts for the loss of 2 degrees of freedom in the estimation of the intercept and the slope.
|
How to derive the standard error of linear regression coefficient
|
3rd comment above: I've already understand how it comes. But still a question: in my post, the standard error has (n−2), where according to your answer, it doesn't, why?
In my post, it is found that
|
How to derive the standard error of linear regression coefficient
3rd comment above: I've already understand how it comes. But still a question: in my post, the standard error has (n−2), where according to your answer, it doesn't, why?
In my post, it is found that
$$
\widehat{\text{se}}(\hat{b}) = \sqrt{\frac{n \hat{\sigma}^2}{n\sum x_i^2 - (\sum x_i)^2}}.
$$
The denominator can be written as
$$
n \sum_i (x_i - \bar{x})^2
$$
Thus,
$$
\widehat{\text{se}}(\hat{b}) = \sqrt{\frac{\hat{\sigma}^2}{\sum_i (x_i - \bar{x})^2}}
$$
With
$$
\hat{\sigma}^2 = \frac{1}{n-2} \sum_i \hat{\epsilon}_i^2
$$
i.e. the Mean Square Error (MSE) in the ANOVA table, we end up with your expression for $\widehat{\text{se}}(\hat{b})$. The $n-2$ term accounts for the loss of 2 degrees of freedom in the estimation of the intercept and the slope.
|
How to derive the standard error of linear regression coefficient
3rd comment above: I've already understand how it comes. But still a question: in my post, the standard error has (n−2), where according to your answer, it doesn't, why?
In my post, it is found that
|
6,870
|
How to derive the standard error of linear regression coefficient
|
another way of thinking about the n-2 df is that it's because we use 2 means to estimate the slope coefficient (the mean of Y and X)
df from Wikipedia: "...In general, the degrees of freedom of an estimate of a parameter are equal to the number of independent scores that go into the estimate minus the number of parameters used as intermediate steps in the estimation of the parameter itself ."
|
How to derive the standard error of linear regression coefficient
|
another way of thinking about the n-2 df is that it's because we use 2 means to estimate the slope coefficient (the mean of Y and X)
df from Wikipedia: "...In general, the degrees of freedom of an est
|
How to derive the standard error of linear regression coefficient
another way of thinking about the n-2 df is that it's because we use 2 means to estimate the slope coefficient (the mean of Y and X)
df from Wikipedia: "...In general, the degrees of freedom of an estimate of a parameter are equal to the number of independent scores that go into the estimate minus the number of parameters used as intermediate steps in the estimation of the parameter itself ."
|
How to derive the standard error of linear regression coefficient
another way of thinking about the n-2 df is that it's because we use 2 means to estimate the slope coefficient (the mean of Y and X)
df from Wikipedia: "...In general, the degrees of freedom of an est
|
6,871
|
Why is Mantel's test preferred over Moran's I?
|
Mantel test and Moran's I refer to two very different concepts.
The reason for using Moran's I is the question of spatial autocorrelation: correlation of a variable with itself through space. One uses Moran's I when wants to know to which extent the occurrence of an event in an areal unit makes more likely or unlikely the occurrence of an event in a neighboring areal unit. In other words (using your example): if there is a noisy crow on a tree, how likely or unlikely are there other noisy crows in the neighborhood? The null hypothesis for Moran's I is no spatial autocorrelation in the variable of interest.
The reason for using the Mantel test is the question of similarities or dissimilarities between variables. One uses the Mantel test when wants to know whether samples that are similar in terms of the predictor (space) variables also tend to be similar in terms of the dependent (species) variable. To put it simply: Are samples that are close together also compositionally similar and are samples that are spatially distant from each other also compositionally dissimilar? Using your example: it tests whether quiet crows are located near other quiet crows, while noisy crows have noisy neighbors. The null hypothesis is no relationship between spatial location and the DV.
Besides this, the partial Mantel test allows comparing two variables while controlling for a third one.
For example, one needs the Mantel test when compares
Two groups of organisms, which form the same set of sample units;
Community structure before and after disturbance;
Genetic/ecological distance and geographic distance.
Here is a good discussion on the Mantel test and its application.
(Edited in response to Ladislav Nado's new examples)
If I may guess, the reason for your confusion is that you keep thinking of space and noise in your examples either as of two continuous variables, or as of one distance matrix (position in space) and one continuous variable (noise). In fact, to analyze similarities between two such variables, one should think of both of them as distance matrices. That is:
one matrix (for example, for space) describes the differences for each pair of geographic coordinates. Value for 2 crows sitting next to each other is lower than the value for crows sitting far apart;
another matrix (for environmental, genetic, or any other structure) describes the differences between measured outcomes at given points. The value for 2 crows with a similar level of noise (it doesn't matter if they are quiet or noisy--it's just a measure of similarity!) is lower than the value for a pair of crows with dissimilar levels of noise.
Then the Mantel test computes the cross-product of the corresponding values in these two matrices. Let me underline again that the Mantel statistic is the correlation between two distance matrices and is not equivalent to the correlation between the variables, used to form those matrices.
Now let's take two structures you showed in pictures A and B.
In picture A, the distance in each pair of crows corresponds to similarities in their level of noise. Crows with small differences in their level of noise (each quiet crow vs. another quiet crow, each noisy crow vs. another noisy crow) stay close, while each and every pair of crows with big difference in their level of noise (a quiet crow vs. a noisy crow) stay away from each other. The Mantel test correctly shows that there is a spatial correlation between the two matrices.
In picture B, however, the distance between crows does not correspond to the similarities in their level of noise. While all noisy crows stay together, quiet crows may or may not stay close. In fact, the distance in some pairs of dissimilar crows (one quiet+one noisy) is smaller than the distance for some pairs of similar crows (when both are quiet).
There is no evidence in picture B that if a researcher picks up two similar crows at random, they would be neighbors. There is no evidence that if a researcher picks up two neighboring (or not so distant) crows at random, they would be similar. Hence, the initial claim that On both plots the hypothesis valid is incorrect. The structure as in picture B shows no spatial correlation between the two matrices and accordingly fails the Mantel test.
Of course, different types of structures (with one or more clusters of similar objects or without clear cluster borders at all) exist in reality. And the Mantel test is perfectly applicable and very useful for testing what it tests. If I may recommend another good reading, this article uses real data and discusses Moran's I, Geary's c, and the Mantel test in quite simple and understandable terms.
Hope everything is slightly more clear now; though, I can expand this explanation if you feel like there is still something missing.
|
Why is Mantel's test preferred over Moran's I?
|
Mantel test and Moran's I refer to two very different concepts.
The reason for using Moran's I is the question of spatial autocorrelation: correlation of a variable with itself through space. One us
|
Why is Mantel's test preferred over Moran's I?
Mantel test and Moran's I refer to two very different concepts.
The reason for using Moran's I is the question of spatial autocorrelation: correlation of a variable with itself through space. One uses Moran's I when wants to know to which extent the occurrence of an event in an areal unit makes more likely or unlikely the occurrence of an event in a neighboring areal unit. In other words (using your example): if there is a noisy crow on a tree, how likely or unlikely are there other noisy crows in the neighborhood? The null hypothesis for Moran's I is no spatial autocorrelation in the variable of interest.
The reason for using the Mantel test is the question of similarities or dissimilarities between variables. One uses the Mantel test when wants to know whether samples that are similar in terms of the predictor (space) variables also tend to be similar in terms of the dependent (species) variable. To put it simply: Are samples that are close together also compositionally similar and are samples that are spatially distant from each other also compositionally dissimilar? Using your example: it tests whether quiet crows are located near other quiet crows, while noisy crows have noisy neighbors. The null hypothesis is no relationship between spatial location and the DV.
Besides this, the partial Mantel test allows comparing two variables while controlling for a third one.
For example, one needs the Mantel test when compares
Two groups of organisms, which form the same set of sample units;
Community structure before and after disturbance;
Genetic/ecological distance and geographic distance.
Here is a good discussion on the Mantel test and its application.
(Edited in response to Ladislav Nado's new examples)
If I may guess, the reason for your confusion is that you keep thinking of space and noise in your examples either as of two continuous variables, or as of one distance matrix (position in space) and one continuous variable (noise). In fact, to analyze similarities between two such variables, one should think of both of them as distance matrices. That is:
one matrix (for example, for space) describes the differences for each pair of geographic coordinates. Value for 2 crows sitting next to each other is lower than the value for crows sitting far apart;
another matrix (for environmental, genetic, or any other structure) describes the differences between measured outcomes at given points. The value for 2 crows with a similar level of noise (it doesn't matter if they are quiet or noisy--it's just a measure of similarity!) is lower than the value for a pair of crows with dissimilar levels of noise.
Then the Mantel test computes the cross-product of the corresponding values in these two matrices. Let me underline again that the Mantel statistic is the correlation between two distance matrices and is not equivalent to the correlation between the variables, used to form those matrices.
Now let's take two structures you showed in pictures A and B.
In picture A, the distance in each pair of crows corresponds to similarities in their level of noise. Crows with small differences in their level of noise (each quiet crow vs. another quiet crow, each noisy crow vs. another noisy crow) stay close, while each and every pair of crows with big difference in their level of noise (a quiet crow vs. a noisy crow) stay away from each other. The Mantel test correctly shows that there is a spatial correlation between the two matrices.
In picture B, however, the distance between crows does not correspond to the similarities in their level of noise. While all noisy crows stay together, quiet crows may or may not stay close. In fact, the distance in some pairs of dissimilar crows (one quiet+one noisy) is smaller than the distance for some pairs of similar crows (when both are quiet).
There is no evidence in picture B that if a researcher picks up two similar crows at random, they would be neighbors. There is no evidence that if a researcher picks up two neighboring (or not so distant) crows at random, they would be similar. Hence, the initial claim that On both plots the hypothesis valid is incorrect. The structure as in picture B shows no spatial correlation between the two matrices and accordingly fails the Mantel test.
Of course, different types of structures (with one or more clusters of similar objects or without clear cluster borders at all) exist in reality. And the Mantel test is perfectly applicable and very useful for testing what it tests. If I may recommend another good reading, this article uses real data and discusses Moran's I, Geary's c, and the Mantel test in quite simple and understandable terms.
Hope everything is slightly more clear now; though, I can expand this explanation if you feel like there is still something missing.
|
Why is Mantel's test preferred over Moran's I?
Mantel test and Moran's I refer to two very different concepts.
The reason for using Moran's I is the question of spatial autocorrelation: correlation of a variable with itself through space. One us
|
6,872
|
Should we address multiple comparisons adjustments when using confidence intervals?
|
An excellent topic which is, sadly, not given enough attention.
When discussing multiple parameters and confidence intervals, a distinction should be made between simultaneous inference and selective inference. Ref.[2] gives an excellent demonstration of the matter.
Simultaneous confidence intervals mean that all the parameters are covered with $1-\alpha$ confidence.
Selective confidence intervals mean that a subset of selected parameters are covered.
These two concepts can be combined:
Say you construct intervals only on parameters for which you rejected the null hypothesis. You are clearly dealing with selective inference. You may want to guarantee simultaneous coverage of selected parameters, or marginal coverage of selected parameters. The former would be the counterpart of FWER control, and the latter of FDR control.
Now more to the point:
Not all testing procedures have their accompanying intervals.
For FWER procedures and their accompanying intervals, see [3]. Sadly, this reference is a bit outdated.
For the interval counterpart of BH FDR control, see [1] and an application in [4] (which also includes a brief review of the matter).
Please note that this is a fresh and active research field so that you can expect more results in the near future.
[1] Benjamini, Y., and D. Yekutieli. “False Discovery Rate-Adjusted Multiple Confidence Intervals for Selected Parameters.” Journal of the American Statistical Association 100, no. 469 (2005): 71–81.
[2] Cox, D. R. “A Remark on Multiple Comparison Methods.” Technometrics 7, no. 2 (1965): 223–24.
[3] Hochberg, Y., and A. C. Tamhane. Multiple Comparison Procedures. New York, NY, USA: John Wiley & Sons, Inc., 1987.
[4] Rosenblatt, J. D., and Y. Benjamini. “Selective Correlations; Not Voodoo.” NeuroImage 103 (December 2014): 401–10.
|
Should we address multiple comparisons adjustments when using confidence intervals?
|
An excellent topic which is, sadly, not given enough attention.
When discussing multiple parameters and confidence intervals, a distinction should be made between simultaneous inference and selective
|
Should we address multiple comparisons adjustments when using confidence intervals?
An excellent topic which is, sadly, not given enough attention.
When discussing multiple parameters and confidence intervals, a distinction should be made between simultaneous inference and selective inference. Ref.[2] gives an excellent demonstration of the matter.
Simultaneous confidence intervals mean that all the parameters are covered with $1-\alpha$ confidence.
Selective confidence intervals mean that a subset of selected parameters are covered.
These two concepts can be combined:
Say you construct intervals only on parameters for which you rejected the null hypothesis. You are clearly dealing with selective inference. You may want to guarantee simultaneous coverage of selected parameters, or marginal coverage of selected parameters. The former would be the counterpart of FWER control, and the latter of FDR control.
Now more to the point:
Not all testing procedures have their accompanying intervals.
For FWER procedures and their accompanying intervals, see [3]. Sadly, this reference is a bit outdated.
For the interval counterpart of BH FDR control, see [1] and an application in [4] (which also includes a brief review of the matter).
Please note that this is a fresh and active research field so that you can expect more results in the near future.
[1] Benjamini, Y., and D. Yekutieli. “False Discovery Rate-Adjusted Multiple Confidence Intervals for Selected Parameters.” Journal of the American Statistical Association 100, no. 469 (2005): 71–81.
[2] Cox, D. R. “A Remark on Multiple Comparison Methods.” Technometrics 7, no. 2 (1965): 223–24.
[3] Hochberg, Y., and A. C. Tamhane. Multiple Comparison Procedures. New York, NY, USA: John Wiley & Sons, Inc., 1987.
[4] Rosenblatt, J. D., and Y. Benjamini. “Selective Correlations; Not Voodoo.” NeuroImage 103 (December 2014): 401–10.
|
Should we address multiple comparisons adjustments when using confidence intervals?
An excellent topic which is, sadly, not given enough attention.
When discussing multiple parameters and confidence intervals, a distinction should be made between simultaneous inference and selective
|
6,873
|
Should we address multiple comparisons adjustments when using confidence intervals?
|
I would never adjust confidence intervals for multiple testing. I am not a big fan of p-values, because I believe that estimating parameters is a better use of statistics than testing hypotheses which are never exactly true. However I concede that hypothesis testing has its value, in say a randomised controlled trial where at least one can argue that asymptotically, if a treatment doesn't work, the null hypothesis is true. However as I have said elsewhere [1], usually this involves having one primary outcome. However, confidence intervals, in the frequentist definition, don't involve hypotheses and so don't need adjustment for other, potentially irrelevant, comparisons. Suppose I was testing phenotypes associated with a particular gene, say height and blood pressure. I'd like to know how big the difference in height is between those with and without the gene, and how well I have estimated it. I don't see that the fact that I also measured blood pressure has anything to do with it. Where it could matter is that if these two were the only significant ones from hundreds we tested. Then it is likely that the differences are, by chance, larger than the expected counterfactual experiments where we only measured height and blood pressure, but did it hundreds of experiments. However in those circumstances, no simple adjustment would work, and better to give the unadjusted estimate but come clean as to how you got these comparisons. We have also published some reults on overlapping confidence intervals.[2]
[1] Campbell MJ and Swinscow TDV (2009) Statistics at Square One. 11th ed Oxford; BMJ Books Blackwell Publishing
[2]Julious SA, Campbell MJ, Walters SJ (2007) Predicting where future means will lie based on the results of the current trial. Contemporary Clinical Trials, 28, 352-357.
|
Should we address multiple comparisons adjustments when using confidence intervals?
|
I would never adjust confidence intervals for multiple testing. I am not a big fan of p-values, because I believe that estimating parameters is a better use of statistics than testing hypotheses which
|
Should we address multiple comparisons adjustments when using confidence intervals?
I would never adjust confidence intervals for multiple testing. I am not a big fan of p-values, because I believe that estimating parameters is a better use of statistics than testing hypotheses which are never exactly true. However I concede that hypothesis testing has its value, in say a randomised controlled trial where at least one can argue that asymptotically, if a treatment doesn't work, the null hypothesis is true. However as I have said elsewhere [1], usually this involves having one primary outcome. However, confidence intervals, in the frequentist definition, don't involve hypotheses and so don't need adjustment for other, potentially irrelevant, comparisons. Suppose I was testing phenotypes associated with a particular gene, say height and blood pressure. I'd like to know how big the difference in height is between those with and without the gene, and how well I have estimated it. I don't see that the fact that I also measured blood pressure has anything to do with it. Where it could matter is that if these two were the only significant ones from hundreds we tested. Then it is likely that the differences are, by chance, larger than the expected counterfactual experiments where we only measured height and blood pressure, but did it hundreds of experiments. However in those circumstances, no simple adjustment would work, and better to give the unadjusted estimate but come clean as to how you got these comparisons. We have also published some reults on overlapping confidence intervals.[2]
[1] Campbell MJ and Swinscow TDV (2009) Statistics at Square One. 11th ed Oxford; BMJ Books Blackwell Publishing
[2]Julious SA, Campbell MJ, Walters SJ (2007) Predicting where future means will lie based on the results of the current trial. Contemporary Clinical Trials, 28, 352-357.
|
Should we address multiple comparisons adjustments when using confidence intervals?
I would never adjust confidence intervals for multiple testing. I am not a big fan of p-values, because I believe that estimating parameters is a better use of statistics than testing hypotheses which
|
6,874
|
Link Anomaly Detection in Temporal Network
|
You should first come up with your definition of anomaly-score for a new node(see section 3.1, 3.2). Fortunately, the correspondence between a new post(in their case) and a new node(in your case) is almost one-to-one, since we are only interested in the set of nodes(users) that the node(post) is related to.
Thus, we can characterise a new node by the number of edges/connections k it has, and the set V of the other nodes it is connected to. Therefore, equations (1)-(4) could be written in a similar fashion. Then, you could use the Chinese Restaurant process, as described at the end of subsection 3.1., after introducing a new parameter $\gamma$. Now, given that you have obtained the probabilities (3), you can obtain the link-anomaly score (7).
Ask further, if you have difficulties to follow the steps described in subsection 3.4., where SDNML is applied.
|
Link Anomaly Detection in Temporal Network
|
You should first come up with your definition of anomaly-score for a new node(see section 3.1, 3.2). Fortunately, the correspondence between a new post(in their case) and a new node(in your case) is a
|
Link Anomaly Detection in Temporal Network
You should first come up with your definition of anomaly-score for a new node(see section 3.1, 3.2). Fortunately, the correspondence between a new post(in their case) and a new node(in your case) is almost one-to-one, since we are only interested in the set of nodes(users) that the node(post) is related to.
Thus, we can characterise a new node by the number of edges/connections k it has, and the set V of the other nodes it is connected to. Therefore, equations (1)-(4) could be written in a similar fashion. Then, you could use the Chinese Restaurant process, as described at the end of subsection 3.1., after introducing a new parameter $\gamma$. Now, given that you have obtained the probabilities (3), you can obtain the link-anomaly score (7).
Ask further, if you have difficulties to follow the steps described in subsection 3.4., where SDNML is applied.
|
Link Anomaly Detection in Temporal Network
You should first come up with your definition of anomaly-score for a new node(see section 3.1, 3.2). Fortunately, the correspondence between a new post(in their case) and a new node(in your case) is a
|
6,875
|
What is the reason the log transformation is used with right-skewed distributions?
|
Economists (like me) love the log transformation. We especially love it in regression models, like this:
\begin{align}
\ln{Y_i} &= \beta_1 + \beta_2 \ln{X_i} + \epsilon_i
\end{align}
Why do we love it so much? Here is the list of reasons I give students when I lecture on it:
It respects the positivity of $Y$. Many times in real-world applications in economics and elsewhere, $Y$ is, by nature, a positive number. It might be a price, a tax rate, a quantity produced, a cost of production, spending on some category of goods, etc. The predicted values from an untransformed linear regression may be negative. The predicted values from a log-transformed regression can never be negative. They are $\widehat{Y}_j=\exp{\left(\beta_1 + \beta_2 \ln{X_j}\right)} \cdot \frac{1}{N} \sum \exp{\left(e_i\right)}$ (See an earlier answer of mine for derivation).
The log-log functional form is surprisingly flexible. Notice:
\begin{align}
\ln{Y_i} &= \beta_1 + \beta_2 \ln{X_i} + \epsilon_i \\
Y_i &= \exp{\left(\beta_1 + \beta_2 \ln{X_i}\right)}\cdot\exp{\left(\epsilon_i\right)}\\
Y_i &= \left(X_i\right)^{\beta_2}\exp{\left(\beta_1\right)}\cdot\exp{\left(\epsilon_i\right)}\\
\end{align}
Which gives us:
That's a lot of different shapes. A line (whose slope would be determined by $\exp{\left(\beta_1\right)}$, so which can have any positive slope), a hyperbola, a parabola, and a "square-root-like" shape. I've drawn it with $\beta_1=0$ and $\epsilon=0$, but in a real application neither of these would be true, so that the slope and the height of the curves at $X=1$ would be controlled by those rather than set at 1.
As TrynnaDoStat mentions, the log-log form "draws in" big values which often makes the data easier to look at and sometimes normalizes the variance across observations.
The coefficient $\beta_2$ is interpreted as an elasticity. It is the percentage increase in $Y$ from a one percent increase in $X$.
If $X$ is a dummy variable, you include it without logging it. In this case, $\beta_2$ is the percent difference in $Y$ between the $X=1$ category and the $X=0$ category.
If $X$ is time, again you include it without logging it, typically. In this case, $\beta_2$ is the growth rate in $Y$---measured in whatever time units $X$ is measured in. If $X$ is years, then the coefficient is annual growth rate in $Y$, for example.
The slope coefficient, $\beta_2$, becomes scale-invariant. This means, on the one hand, that it has no units, and, on the other hand, that if you re-scale (i.e. change the units of) $X$ or $Y$, it will have absolutely no effect on the estimated value of $\beta_2$. Well, at least with OLS and other related estimators.
If your data are log-normally distributed, then the log transformation makes them normally distributed. Normally distributed data have lots going for them.
Statisticians generally find economists over-enthusiastic about this particular transformation of the data. This, I think, is because they judge my point 8 and the second half of my point 3 to be very important. Thus, in cases where the data are not
log-normally distributed or where logging the data does not result in the transformed data having equal variance across observations, a statistician will tend not to like the transformation very much. The economist is likely to plunge ahead anyway since what we really like about the transformation are points 1,2,and 4-7.
|
What is the reason the log transformation is used with right-skewed distributions?
|
Economists (like me) love the log transformation. We especially love it in regression models, like this:
\begin{align}
\ln{Y_i} &= \beta_1 + \beta_2 \ln{X_i} + \epsilon_i
\end{align}
Why do we love i
|
What is the reason the log transformation is used with right-skewed distributions?
Economists (like me) love the log transformation. We especially love it in regression models, like this:
\begin{align}
\ln{Y_i} &= \beta_1 + \beta_2 \ln{X_i} + \epsilon_i
\end{align}
Why do we love it so much? Here is the list of reasons I give students when I lecture on it:
It respects the positivity of $Y$. Many times in real-world applications in economics and elsewhere, $Y$ is, by nature, a positive number. It might be a price, a tax rate, a quantity produced, a cost of production, spending on some category of goods, etc. The predicted values from an untransformed linear regression may be negative. The predicted values from a log-transformed regression can never be negative. They are $\widehat{Y}_j=\exp{\left(\beta_1 + \beta_2 \ln{X_j}\right)} \cdot \frac{1}{N} \sum \exp{\left(e_i\right)}$ (See an earlier answer of mine for derivation).
The log-log functional form is surprisingly flexible. Notice:
\begin{align}
\ln{Y_i} &= \beta_1 + \beta_2 \ln{X_i} + \epsilon_i \\
Y_i &= \exp{\left(\beta_1 + \beta_2 \ln{X_i}\right)}\cdot\exp{\left(\epsilon_i\right)}\\
Y_i &= \left(X_i\right)^{\beta_2}\exp{\left(\beta_1\right)}\cdot\exp{\left(\epsilon_i\right)}\\
\end{align}
Which gives us:
That's a lot of different shapes. A line (whose slope would be determined by $\exp{\left(\beta_1\right)}$, so which can have any positive slope), a hyperbola, a parabola, and a "square-root-like" shape. I've drawn it with $\beta_1=0$ and $\epsilon=0$, but in a real application neither of these would be true, so that the slope and the height of the curves at $X=1$ would be controlled by those rather than set at 1.
As TrynnaDoStat mentions, the log-log form "draws in" big values which often makes the data easier to look at and sometimes normalizes the variance across observations.
The coefficient $\beta_2$ is interpreted as an elasticity. It is the percentage increase in $Y$ from a one percent increase in $X$.
If $X$ is a dummy variable, you include it without logging it. In this case, $\beta_2$ is the percent difference in $Y$ between the $X=1$ category and the $X=0$ category.
If $X$ is time, again you include it without logging it, typically. In this case, $\beta_2$ is the growth rate in $Y$---measured in whatever time units $X$ is measured in. If $X$ is years, then the coefficient is annual growth rate in $Y$, for example.
The slope coefficient, $\beta_2$, becomes scale-invariant. This means, on the one hand, that it has no units, and, on the other hand, that if you re-scale (i.e. change the units of) $X$ or $Y$, it will have absolutely no effect on the estimated value of $\beta_2$. Well, at least with OLS and other related estimators.
If your data are log-normally distributed, then the log transformation makes them normally distributed. Normally distributed data have lots going for them.
Statisticians generally find economists over-enthusiastic about this particular transformation of the data. This, I think, is because they judge my point 8 and the second half of my point 3 to be very important. Thus, in cases where the data are not
log-normally distributed or where logging the data does not result in the transformed data having equal variance across observations, a statistician will tend not to like the transformation very much. The economist is likely to plunge ahead anyway since what we really like about the transformation are points 1,2,and 4-7.
|
What is the reason the log transformation is used with right-skewed distributions?
Economists (like me) love the log transformation. We especially love it in regression models, like this:
\begin{align}
\ln{Y_i} &= \beta_1 + \beta_2 \ln{X_i} + \epsilon_i
\end{align}
Why do we love i
|
6,876
|
What is the reason the log transformation is used with right-skewed distributions?
|
First let's see what typically happens when we take logs of something that's right skew.
The top row contains histograms for samples from three different, increasingly skewed distributions.
The bottom row contains histograms for their logs.
You can see that the center case ($y$) has been transformed to something close to symmetry, while the more mildly right skew case ($x$) is now somewhat left skew. One the other hand, the most skew variable ($z$) is still (slightly) right skew, even after taking logs.
If we wanted our distributions to look more symmetric, and perhaps more normal, the transformation clearly improved the second and third case. We can see that this might help at least sometimes to reduce the amount of right-skewness.
[However, a note of caution; in many cases you may be better not trying to achieve symmetry but rather in considering a more suitable model for your variables. Sometimes log transformations make sense regardless of distributional considerations, and often when that's the case, you happen to get greater symmetry at the same time, which is nice but rarely the central goal.]
So why does it work?
Note that when we're looking at a picture of the distributional shape, we're not considering the mean or the standard deviation - that just affects the labels on the axis.
So we can imagine looking at some kind of "standardized" variables (while remaining positive, all have similar location and spread, say)
Taking logs "pulls in" more extreme values on the right (high values) relative to the median, while values at the far left (low values) tend to get stretched back, further away from the median.
In the first diagram, $x$, $y$ and $z$ all have means near 178, all have medians close to 150, and their logs all have medians near 5.
When we looks at the original data, a value at the far right - say around 750 - is sitting far above the median. In the case of $y$, it's 5 interquartile ranges above the median.
But when we take logs, it gets pulled back toward the median; after taking logs it's only about 2 interquartile ranges above the median.
Meanwhile a low value like 30 (only 4 values in the sample of size 1000 are below it) is a bit less than one interquartile range below the median of $y$. When we take logs, it's again about two interquartile ranges below the new median.
It's no accident that the ratio of 750/150 and 150/30 are both 5 when both log(750) and log(30) ended up about the same distance away from the median of log(y). That's how logs work - converting constant ratios to constant differences.
It's not always the case that the log will help noticeably. For example if you take say a lognormal random variable and shift it substantially to the right (i.e. add a large constant to it) so that the mean became large relative to the standard deviation, then taking the log of that would make very little difference to the shape. It would be less skew - but barely.
But other transformations - the square root, say - will also pull large values in like that. Why are logs in particular, more popular?
I touched on one reason just at the end of the previous part - constant ratios tend to constant differences. This makes logs relatively easy to interpret, since constant percentage changes (like a 20% increase to every one of a set of numbers) become a constant shift. So a decrease of $-0.162$ in the natural log is a 15% decrease in the original numbers, no matter how big the original number is.
A lot of economic and financial data behaves like this, for example (constant or near-constant effects on the percentage scale). The log scale makes a lot of sense in that case. Moreover, as a result of that percentage-scale effect. the spread of values tends to be larger as the mean increases - and taking logs also tends to stabilize the spread. That's usually more important than normality. Indeed, all three distributions in the original diagram come from families where the standard deviation will increase with the mean, and in each case taking logs stabilizes variance. [This doesn't happen with all right skewed data, though. It's just very common in the sort of data that crops up in particular application areas.]
There are also times when the square root will make things more symmetric, but it tends to happen with less skewed distributions than I use in my examples here.
We could (fairly easily) construct another set of three more mildly right-skew examples, where the square root made one left skew, one symmetric and the third was still right-skew (but a bit less skew than before).
What about left-skewed distributions?
If you applied the log transformation to a symmetric distribution, it will tend to make it left-skew for the same reason it often makes a right skew one more symmetric - see the related discussion here.
Correspondingly, if you apply the log-transformation to something that's already left skew, it will tend to make it even more left skew, pulling the things above the median in even more tightly, and stretching things below the median down even harder.
So the log transformation wouldn't be helpful then.
See also power transformations/Tukey's ladder. Distributions that are left skew may be made more symmetric by taking a power (greater than 1 -- squaring say), or by exponentiating. If it has an obvious upper bound, one might subtract observations from the upper bound (giving a right skewed result) and then attempt to transform that.
Sometimes, transformation just doesn't seem to help. Why not?
Here's two common issues, but they're not exhaustive.
(i) The impact of shifting
Sometimes taking logs (for example) seems to work quite well on a right skewed distribution but another time it doesn't seem to work at all with a distribution that's not even as skewed as the first one. This may seem counterintuitive given the diagrams above.
Here's the kicker. While adding a constant to a variable doesn't change its skewness, it very much changes the impact of a power-type transformation (such as those on the Tukey-ladder), including the log-transform. The more you shift it up the less the effect of a transformation like log or square root.
Because of this sort of effect, you can easily have two variables that have exactly the same skewness, and find that taking logs will work nicely on one and barely improve things at all on the other. The same goes for square roots, and so forth.
(ii) Discreteness
With a discrete variable, a transformation can move the probability spikes around, but the values that are together will always stay the same (all the values at 1 go to whatever 1 transforms to). A monotonic transformation, including log and square root, will leave them in the same order, to boot.
For example, if you had say $70\%$ of the distribution at $1$, $20\%$ at $2$ and the rest spread across higher values, then no matter which monotonic transformation you apply*, the two lowest values would still have $70\%$ and $20\%$ of the values respectively. Squashing up the $10\%$ that's in the far right tail just won't help much.
* I will take as read that you don't use transformations that "lose" values, for what I hope are obvious reasons. So no $\log(0)$'s for example.
|
What is the reason the log transformation is used with right-skewed distributions?
|
First let's see what typically happens when we take logs of something that's right skew.
The top row contains histograms for samples from three different, increasingly skewed distributions.
The bottom
|
What is the reason the log transformation is used with right-skewed distributions?
First let's see what typically happens when we take logs of something that's right skew.
The top row contains histograms for samples from three different, increasingly skewed distributions.
The bottom row contains histograms for their logs.
You can see that the center case ($y$) has been transformed to something close to symmetry, while the more mildly right skew case ($x$) is now somewhat left skew. One the other hand, the most skew variable ($z$) is still (slightly) right skew, even after taking logs.
If we wanted our distributions to look more symmetric, and perhaps more normal, the transformation clearly improved the second and third case. We can see that this might help at least sometimes to reduce the amount of right-skewness.
[However, a note of caution; in many cases you may be better not trying to achieve symmetry but rather in considering a more suitable model for your variables. Sometimes log transformations make sense regardless of distributional considerations, and often when that's the case, you happen to get greater symmetry at the same time, which is nice but rarely the central goal.]
So why does it work?
Note that when we're looking at a picture of the distributional shape, we're not considering the mean or the standard deviation - that just affects the labels on the axis.
So we can imagine looking at some kind of "standardized" variables (while remaining positive, all have similar location and spread, say)
Taking logs "pulls in" more extreme values on the right (high values) relative to the median, while values at the far left (low values) tend to get stretched back, further away from the median.
In the first diagram, $x$, $y$ and $z$ all have means near 178, all have medians close to 150, and their logs all have medians near 5.
When we looks at the original data, a value at the far right - say around 750 - is sitting far above the median. In the case of $y$, it's 5 interquartile ranges above the median.
But when we take logs, it gets pulled back toward the median; after taking logs it's only about 2 interquartile ranges above the median.
Meanwhile a low value like 30 (only 4 values in the sample of size 1000 are below it) is a bit less than one interquartile range below the median of $y$. When we take logs, it's again about two interquartile ranges below the new median.
It's no accident that the ratio of 750/150 and 150/30 are both 5 when both log(750) and log(30) ended up about the same distance away from the median of log(y). That's how logs work - converting constant ratios to constant differences.
It's not always the case that the log will help noticeably. For example if you take say a lognormal random variable and shift it substantially to the right (i.e. add a large constant to it) so that the mean became large relative to the standard deviation, then taking the log of that would make very little difference to the shape. It would be less skew - but barely.
But other transformations - the square root, say - will also pull large values in like that. Why are logs in particular, more popular?
I touched on one reason just at the end of the previous part - constant ratios tend to constant differences. This makes logs relatively easy to interpret, since constant percentage changes (like a 20% increase to every one of a set of numbers) become a constant shift. So a decrease of $-0.162$ in the natural log is a 15% decrease in the original numbers, no matter how big the original number is.
A lot of economic and financial data behaves like this, for example (constant or near-constant effects on the percentage scale). The log scale makes a lot of sense in that case. Moreover, as a result of that percentage-scale effect. the spread of values tends to be larger as the mean increases - and taking logs also tends to stabilize the spread. That's usually more important than normality. Indeed, all three distributions in the original diagram come from families where the standard deviation will increase with the mean, and in each case taking logs stabilizes variance. [This doesn't happen with all right skewed data, though. It's just very common in the sort of data that crops up in particular application areas.]
There are also times when the square root will make things more symmetric, but it tends to happen with less skewed distributions than I use in my examples here.
We could (fairly easily) construct another set of three more mildly right-skew examples, where the square root made one left skew, one symmetric and the third was still right-skew (but a bit less skew than before).
What about left-skewed distributions?
If you applied the log transformation to a symmetric distribution, it will tend to make it left-skew for the same reason it often makes a right skew one more symmetric - see the related discussion here.
Correspondingly, if you apply the log-transformation to something that's already left skew, it will tend to make it even more left skew, pulling the things above the median in even more tightly, and stretching things below the median down even harder.
So the log transformation wouldn't be helpful then.
See also power transformations/Tukey's ladder. Distributions that are left skew may be made more symmetric by taking a power (greater than 1 -- squaring say), or by exponentiating. If it has an obvious upper bound, one might subtract observations from the upper bound (giving a right skewed result) and then attempt to transform that.
Sometimes, transformation just doesn't seem to help. Why not?
Here's two common issues, but they're not exhaustive.
(i) The impact of shifting
Sometimes taking logs (for example) seems to work quite well on a right skewed distribution but another time it doesn't seem to work at all with a distribution that's not even as skewed as the first one. This may seem counterintuitive given the diagrams above.
Here's the kicker. While adding a constant to a variable doesn't change its skewness, it very much changes the impact of a power-type transformation (such as those on the Tukey-ladder), including the log-transform. The more you shift it up the less the effect of a transformation like log or square root.
Because of this sort of effect, you can easily have two variables that have exactly the same skewness, and find that taking logs will work nicely on one and barely improve things at all on the other. The same goes for square roots, and so forth.
(ii) Discreteness
With a discrete variable, a transformation can move the probability spikes around, but the values that are together will always stay the same (all the values at 1 go to whatever 1 transforms to). A monotonic transformation, including log and square root, will leave them in the same order, to boot.
For example, if you had say $70\%$ of the distribution at $1$, $20\%$ at $2$ and the rest spread across higher values, then no matter which monotonic transformation you apply*, the two lowest values would still have $70\%$ and $20\%$ of the values respectively. Squashing up the $10\%$ that's in the far right tail just won't help much.
* I will take as read that you don't use transformations that "lose" values, for what I hope are obvious reasons. So no $\log(0)$'s for example.
|
What is the reason the log transformation is used with right-skewed distributions?
First let's see what typically happens when we take logs of something that's right skew.
The top row contains histograms for samples from three different, increasingly skewed distributions.
The bottom
|
6,877
|
What is the reason the log transformation is used with right-skewed distributions?
|
The log function essentially de-emphasizes very large values. Look at the image below which shows $y = ln(x)$. Notice how large values on the $x$-axis are relatively smaller on the y-axis.
Now, in a right-skewed distribution you have a few very large values. The log transformation essentially reels these values into the center of the distribution making it look more like a Normal distribution.
|
What is the reason the log transformation is used with right-skewed distributions?
|
The log function essentially de-emphasizes very large values. Look at the image below which shows $y = ln(x)$. Notice how large values on the $x$-axis are relatively smaller on the y-axis.
Now, in a
|
What is the reason the log transformation is used with right-skewed distributions?
The log function essentially de-emphasizes very large values. Look at the image below which shows $y = ln(x)$. Notice how large values on the $x$-axis are relatively smaller on the y-axis.
Now, in a right-skewed distribution you have a few very large values. The log transformation essentially reels these values into the center of the distribution making it look more like a Normal distribution.
|
What is the reason the log transformation is used with right-skewed distributions?
The log function essentially de-emphasizes very large values. Look at the image below which shows $y = ln(x)$. Notice how large values on the $x$-axis are relatively smaller on the y-axis.
Now, in a
|
6,878
|
What is the reason the log transformation is used with right-skewed distributions?
|
All of these answers are sales pitches for the natural log transformation. There are caveats to its use, caveats that are generalizable to any and all transformations. As a general rule, all mathematical transformations reshape the PDF of the underlying raw variables whether acting to compress, expand, invert, rescale, whatever. The biggest challenge this presents from a purely practical point of view is that, when used in regression models where predictions are a key model output, transformations of the dependent variable, Y-hat, are subject to potentially significant retransformation bias. Note that natural log transformations are not immune to this bias, they're just not as impacted by it as some other, similar acting transformations. There are papers offering solutions for this bias but they really don't work very well. In my opinion, you're on much safer ground not messing with trying to transform Y at all and finding robust functional forms that allow you to retain the original metric. For instance, besides the natural log, there are other transformations that compress the tail of skewed and kurtotic variables such as the inverse hyperbolic sine or Lambert's W. Both of these transformations work very well in generating symmetric PDFs and, therefore, Gaussian-like errors, from heavy-tailed information, but watch out for the bias when you try to bring the predictions back into the original scale for the DV, Y. It can be ugly.
|
What is the reason the log transformation is used with right-skewed distributions?
|
All of these answers are sales pitches for the natural log transformation. There are caveats to its use, caveats that are generalizable to any and all transformations. As a general rule, all mathemati
|
What is the reason the log transformation is used with right-skewed distributions?
All of these answers are sales pitches for the natural log transformation. There are caveats to its use, caveats that are generalizable to any and all transformations. As a general rule, all mathematical transformations reshape the PDF of the underlying raw variables whether acting to compress, expand, invert, rescale, whatever. The biggest challenge this presents from a purely practical point of view is that, when used in regression models where predictions are a key model output, transformations of the dependent variable, Y-hat, are subject to potentially significant retransformation bias. Note that natural log transformations are not immune to this bias, they're just not as impacted by it as some other, similar acting transformations. There are papers offering solutions for this bias but they really don't work very well. In my opinion, you're on much safer ground not messing with trying to transform Y at all and finding robust functional forms that allow you to retain the original metric. For instance, besides the natural log, there are other transformations that compress the tail of skewed and kurtotic variables such as the inverse hyperbolic sine or Lambert's W. Both of these transformations work very well in generating symmetric PDFs and, therefore, Gaussian-like errors, from heavy-tailed information, but watch out for the bias when you try to bring the predictions back into the original scale for the DV, Y. It can be ugly.
|
What is the reason the log transformation is used with right-skewed distributions?
All of these answers are sales pitches for the natural log transformation. There are caveats to its use, caveats that are generalizable to any and all transformations. As a general rule, all mathemati
|
6,879
|
What is the reason the log transformation is used with right-skewed distributions?
|
Many interesting points have been made. A few more?
1) I would suggest that another issue with linear regression is that the 'left hand side' of the regression equation is E(y) : the expected value. If the error distribution is not symmetrical, then merits for the study of the expected value are weak. The expected value is not of central interest when the errors are asymmetrical. One could explore quantile regression instead. Then the study of, say, the median, or other percentage points might be worthy even if the errors are asymmetrical.
2) If one elects to transform the response variable, then one may wish to transform one of more of the explanatory variables with the same function. For example, if one has a 'final' outcome as response, then one might have a 'baseline' outcome as an explanatory variable. For interpretation, it makes sense the transform 'final' and 'baseline' with the same function.
3) The main argument for transforming an explanatory variable is often around the linearity of the response - explanatory relationship. These days, one can consider other options like restricted cubic splines or fractional polynomials for the explanatory variable. There is certainly often a certain clarity if linearity can be found though.
|
What is the reason the log transformation is used with right-skewed distributions?
|
Many interesting points have been made. A few more?
1) I would suggest that another issue with linear regression is that the 'left hand side' of the regression equation is E(y) : the expected value. I
|
What is the reason the log transformation is used with right-skewed distributions?
Many interesting points have been made. A few more?
1) I would suggest that another issue with linear regression is that the 'left hand side' of the regression equation is E(y) : the expected value. If the error distribution is not symmetrical, then merits for the study of the expected value are weak. The expected value is not of central interest when the errors are asymmetrical. One could explore quantile regression instead. Then the study of, say, the median, or other percentage points might be worthy even if the errors are asymmetrical.
2) If one elects to transform the response variable, then one may wish to transform one of more of the explanatory variables with the same function. For example, if one has a 'final' outcome as response, then one might have a 'baseline' outcome as an explanatory variable. For interpretation, it makes sense the transform 'final' and 'baseline' with the same function.
3) The main argument for transforming an explanatory variable is often around the linearity of the response - explanatory relationship. These days, one can consider other options like restricted cubic splines or fractional polynomials for the explanatory variable. There is certainly often a certain clarity if linearity can be found though.
|
What is the reason the log transformation is used with right-skewed distributions?
Many interesting points have been made. A few more?
1) I would suggest that another issue with linear regression is that the 'left hand side' of the regression equation is E(y) : the expected value. I
|
6,880
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
Here are a few basic options, but like you, I can't say that I'm entirely happy with my current system.
Avoid using the viewer:
I.e., Use the command line tools to browse the data
head and tail for showing initial and final rows
str for an overview of variable types
dplyr::glimpse() for an overview of variable types of all columns
basic extraction tools like [,1:5] to show the first five colums
Use a pager to display and navigate the data (e.g., page(foo, "print")) possibly
in conjunction with some variable extraction tools. This works fairly well on Linux, which uses less. I'm not sure how it goes on Windows or Mac.
Export to spreadsheet software:
I quite like browsing data in Excel when it's set up as a table.
It's easy to sort, filter, and highlight. See here for the function that I use to open a data.frame in a spreadsheet.
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
Here are a few basic options, but like you, I can't say that I'm entirely happy with my current system.
Avoid using the viewer:
I.e., Use the command line tools to browse the data
head and tail for s
|
Is there a good browser/viewer to see an R dataset (.rda file)
Here are a few basic options, but like you, I can't say that I'm entirely happy with my current system.
Avoid using the viewer:
I.e., Use the command line tools to browse the data
head and tail for showing initial and final rows
str for an overview of variable types
dplyr::glimpse() for an overview of variable types of all columns
basic extraction tools like [,1:5] to show the first five colums
Use a pager to display and navigate the data (e.g., page(foo, "print")) possibly
in conjunction with some variable extraction tools. This works fairly well on Linux, which uses less. I'm not sure how it goes on Windows or Mac.
Export to spreadsheet software:
I quite like browsing data in Excel when it's set up as a table.
It's easy to sort, filter, and highlight. See here for the function that I use to open a data.frame in a spreadsheet.
|
Is there a good browser/viewer to see an R dataset (.rda file)
Here are a few basic options, but like you, I can't say that I'm entirely happy with my current system.
Avoid using the viewer:
I.e., Use the command line tools to browse the data
head and tail for s
|
6,881
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
I recommend highly the R Package googleVis, R bindings to the Google Visualization API. The Package authors are Markus Gesmann and Diego de Castillo.
The data frame viewer in googleVis is astonishingly simple to use.
These guys have done great work because googleVis is straightforward to use, though the Google Visualization API is not.
googleVis is available from CRAN.
The function in googleVis for rendering a data frame as a styled HTML table is gvisTable().
Calling this function, passing in an R data frame render R data frames as interactive HTML tables in a form that's both dashboard-quality and functional.
A few features of googleVis/gvisTable i have found particularly good:
to maintain responsiveness as the number of rows increases,
user-specified parameter values for pagination (using arrow
buttons); if you don't want pagination, you can access rows outside
of the view via a scroll bar on the right hand side of the table,
according to parameters specified in the gvisTable() function call
column-wise sort by clicking on the column header
the gvisTable call returns HTML, so it's portable, and though i haven't used this feature, the entire table can be styled the way that any HTML table is styled, with CSS (first assigning classes to the relevant selector)
To use, just import the googleVis Package, call gvisTable() passing in your data frame and bind that result (which is a gvis object) to a variable; then call plot on that gvis instance:
library(googleVis)
gvt = gvisTable(DF)
plot(gvt)
You can also pass in a number of parameters, though you do this via a single argument to gvisTable, options, which is an R list, e.g.,
gvt = gvisTable(DF, options=list(page='enable', height=300))
Of course, you can use your own CSS to get any fine-grained styling you wish.
When plot is called on a gvis object, a browser window will open and the table will be will be loaded using Flash
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
I recommend highly the R Package googleVis, R bindings to the Google Visualization API. The Package authors are Markus Gesmann and Diego de Castillo.
The data frame viewer in googleVis is astonishing
|
Is there a good browser/viewer to see an R dataset (.rda file)
I recommend highly the R Package googleVis, R bindings to the Google Visualization API. The Package authors are Markus Gesmann and Diego de Castillo.
The data frame viewer in googleVis is astonishingly simple to use.
These guys have done great work because googleVis is straightforward to use, though the Google Visualization API is not.
googleVis is available from CRAN.
The function in googleVis for rendering a data frame as a styled HTML table is gvisTable().
Calling this function, passing in an R data frame render R data frames as interactive HTML tables in a form that's both dashboard-quality and functional.
A few features of googleVis/gvisTable i have found particularly good:
to maintain responsiveness as the number of rows increases,
user-specified parameter values for pagination (using arrow
buttons); if you don't want pagination, you can access rows outside
of the view via a scroll bar on the right hand side of the table,
according to parameters specified in the gvisTable() function call
column-wise sort by clicking on the column header
the gvisTable call returns HTML, so it's portable, and though i haven't used this feature, the entire table can be styled the way that any HTML table is styled, with CSS (first assigning classes to the relevant selector)
To use, just import the googleVis Package, call gvisTable() passing in your data frame and bind that result (which is a gvis object) to a variable; then call plot on that gvis instance:
library(googleVis)
gvt = gvisTable(DF)
plot(gvt)
You can also pass in a number of parameters, though you do this via a single argument to gvisTable, options, which is an R list, e.g.,
gvt = gvisTable(DF, options=list(page='enable', height=300))
Of course, you can use your own CSS to get any fine-grained styling you wish.
When plot is called on a gvis object, a browser window will open and the table will be will be loaded using Flash
|
Is there a good browser/viewer to see an R dataset (.rda file)
I recommend highly the R Package googleVis, R bindings to the Google Visualization API. The Package authors are Markus Gesmann and Diego de Castillo.
The data frame viewer in googleVis is astonishing
|
6,882
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
RStudio (RStudio.org) has a built-in data frame viewer that's pretty good. Luckily it's read-only. RStudio is very easy to install once you've installed a recent version of R. If using Linux first install the r-base package.
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
RStudio (RStudio.org) has a built-in data frame viewer that's pretty good. Luckily it's read-only. RStudio is very easy to install once you've installed a recent version of R. If using Linux first
|
Is there a good browser/viewer to see an R dataset (.rda file)
RStudio (RStudio.org) has a built-in data frame viewer that's pretty good. Luckily it's read-only. RStudio is very easy to install once you've installed a recent version of R. If using Linux first install the r-base package.
|
Is there a good browser/viewer to see an R dataset (.rda file)
RStudio (RStudio.org) has a built-in data frame viewer that's pretty good. Luckily it's read-only. RStudio is very easy to install once you've installed a recent version of R. If using Linux first
|
6,883
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
Here are some other thoughts (although I am always reluctant to leave Emacs):
Deducer (with JGR) allows to view a data.frame with a combined variable/data view (à la SPSS).
J Fox's Rcmdr also offers edit/viewing facilities, although in an X11 environment.
J Verzani's Poor Man Gui (pmg) only allows for quick preview for data.frame and other R objects. Don't know much about Rattle capabilities.
Below are two screenshots when viewing a 704 by 348 data.frame (loaded as an RData) with Deducer (top) and Rcmdr (bottom).
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
Here are some other thoughts (although I am always reluctant to leave Emacs):
Deducer (with JGR) allows to view a data.frame with a combined variable/data view (à la SPSS).
J Fox's Rcmdr also offers
|
Is there a good browser/viewer to see an R dataset (.rda file)
Here are some other thoughts (although I am always reluctant to leave Emacs):
Deducer (with JGR) allows to view a data.frame with a combined variable/data view (à la SPSS).
J Fox's Rcmdr also offers edit/viewing facilities, although in an X11 environment.
J Verzani's Poor Man Gui (pmg) only allows for quick preview for data.frame and other R objects. Don't know much about Rattle capabilities.
Below are two screenshots when viewing a 704 by 348 data.frame (loaded as an RData) with Deducer (top) and Rcmdr (bottom).
|
Is there a good browser/viewer to see an R dataset (.rda file)
Here are some other thoughts (although I am always reluctant to leave Emacs):
Deducer (with JGR) allows to view a data.frame with a combined variable/data view (à la SPSS).
J Fox's Rcmdr also offers
|
6,884
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
You can get View() to display all of your data in RStudio. The trick is that you need to use the command syntax utils::View() instead. (For slightly more information, see my answer on Stack Overflow here: R View() does not display all columns of data frame.)
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
You can get View() to display all of your data in RStudio. The trick is that you need to use the command syntax utils::View() instead. (For slightly more information, see my answer on Stack Overflow
|
Is there a good browser/viewer to see an R dataset (.rda file)
You can get View() to display all of your data in RStudio. The trick is that you need to use the command syntax utils::View() instead. (For slightly more information, see my answer on Stack Overflow here: R View() does not display all columns of data frame.)
|
Is there a good browser/viewer to see an R dataset (.rda file)
You can get View() to display all of your data in RStudio. The trick is that you need to use the command syntax utils::View() instead. (For slightly more information, see my answer on Stack Overflow
|
6,885
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
Recently I started to keep the data in a sqlite database, access the database directly from R using sqldf and view / edit with a database tool named tksqlite
Another option is to export the data and view / edit with Google Refine
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
Recently I started to keep the data in a sqlite database, access the database directly from R using sqldf and view / edit with a database tool named tksqlite
Another option is to export the data and v
|
Is there a good browser/viewer to see an R dataset (.rda file)
Recently I started to keep the data in a sqlite database, access the database directly from R using sqldf and view / edit with a database tool named tksqlite
Another option is to export the data and view / edit with Google Refine
|
Is there a good browser/viewer to see an R dataset (.rda file)
Recently I started to keep the data in a sqlite database, access the database directly from R using sqldf and view / edit with a database tool named tksqlite
Another option is to export the data and v
|
6,886
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
The datatable function from DT package creates HTML tables. You can nicely view wide tables.
|
Is there a good browser/viewer to see an R dataset (.rda file)
|
The datatable function from DT package creates HTML tables. You can nicely view wide tables.
|
Is there a good browser/viewer to see an R dataset (.rda file)
The datatable function from DT package creates HTML tables. You can nicely view wide tables.
|
Is there a good browser/viewer to see an R dataset (.rda file)
The datatable function from DT package creates HTML tables. You can nicely view wide tables.
|
6,887
|
What does kernel size mean?
|
Deep neural networks, more concretely convolutional neural networks (CNN), are basically a stack of layers which are defined by the action of a number of filters on the input. Those filters are usually called kernels.
For example, the kernels in the convolutional layer, are the convolutional filters. Actually no convolution is performed, but a cross-correlation. The kernel size here refers to the widthxheight of the filter mask.
The max pooling layer, for example, returns the pixel with maximum value from a set of pixels within a mask (kernel). That kernel is swept across the input, subsampling it.
So nothing to do with the concept of kernels in support vector machines or regularization networks. You can think of them as feature extractors.
|
What does kernel size mean?
|
Deep neural networks, more concretely convolutional neural networks (CNN), are basically a stack of layers which are defined by the action of a number of filters on the input. Those filters are usuall
|
What does kernel size mean?
Deep neural networks, more concretely convolutional neural networks (CNN), are basically a stack of layers which are defined by the action of a number of filters on the input. Those filters are usually called kernels.
For example, the kernels in the convolutional layer, are the convolutional filters. Actually no convolution is performed, but a cross-correlation. The kernel size here refers to the widthxheight of the filter mask.
The max pooling layer, for example, returns the pixel with maximum value from a set of pixels within a mask (kernel). That kernel is swept across the input, subsampling it.
So nothing to do with the concept of kernels in support vector machines or regularization networks. You can think of them as feature extractors.
|
What does kernel size mean?
Deep neural networks, more concretely convolutional neural networks (CNN), are basically a stack of layers which are defined by the action of a number of filters on the input. Those filters are usuall
|
6,888
|
What does kernel size mean?
|
As you can see above, the kernel, also known as kernel matrix is the function in between and its size, here 3, is the kernel size(where kernel width equals kernel hight).
Note that the kernel does not necessarily to be symmetric, and we can verify that by quoting this text from the doc of Conv2D in Tensorflow:
kernel_size: An integer or tuple/list of 2 integers, specifying the height and width of the 2D convolution window. Can be a single integer to specify the same value for all spatial dimensions.
But usually, we just make the width and height equal, and if not the kernel size should be a tuple of 2. The kernel can be unsymmetric for instance in Conv1D(see this example, and the kernel size can be more than 2 numbers, for example (4, 4, 3) in the example bellow Conv3D:
The awesome gifs come from here and here.
|
What does kernel size mean?
|
As you can see above, the kernel, also known as kernel matrix is the function in between and its size, here 3, is the kernel size(where kernel width equals kernel hight).
Note that the kernel does no
|
What does kernel size mean?
As you can see above, the kernel, also known as kernel matrix is the function in between and its size, here 3, is the kernel size(where kernel width equals kernel hight).
Note that the kernel does not necessarily to be symmetric, and we can verify that by quoting this text from the doc of Conv2D in Tensorflow:
kernel_size: An integer or tuple/list of 2 integers, specifying the height and width of the 2D convolution window. Can be a single integer to specify the same value for all spatial dimensions.
But usually, we just make the width and height equal, and if not the kernel size should be a tuple of 2. The kernel can be unsymmetric for instance in Conv1D(see this example, and the kernel size can be more than 2 numbers, for example (4, 4, 3) in the example bellow Conv3D:
The awesome gifs come from here and here.
|
What does kernel size mean?
As you can see above, the kernel, also known as kernel matrix is the function in between and its size, here 3, is the kernel size(where kernel width equals kernel hight).
Note that the kernel does no
|
6,889
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
I recently made a little in browser app that you can use to play with these ideas: Scatterplot Smoothers (*).
Here's some data I made up, with a low degree polynomial fit
It's clear that the quadratic polynomial is just not flexible enough to give a good fit to the data. We have regions of very high bias, between $0.6$ and $0.85$ all the data is below the fit, and after $0.85$ all the data is above the curve.
To rid ourselves of bias, we can increase the degree of the curve to three, but the problem remains, the cubic curve is still too rigid
So we continue to increase the degree, but now we incur the opposite problem
This curve tracks the data too closely, and has a tendency to fly off in directions not so well borne out by general patterns in the data. This is where regularization comes in. With the same degree curve (ten) and some well chosen regularization
We get a really nice fit!
It's worth a little focus on one aspect of well chosen above. When you are fitting polynomials to data you have a discrete set of choices for degree. If a degree three curve is underfit and a degree four curve is overfit, you have nowhere to go in the middle. Regularization solves this problem, as it gives you a continuous range of complexity parameters to play with.
how do you claim "We get a really nice fit!". For me they all look the same, namely, inconclusive. Which rational are you using to decide what is a nice and a bad fit?
Fair point.
The assumption I'm making here is that a well fit model should have no discernable pattern in the residuals. Now, I'm not plotting the residuals, so you have to do a little bit of work when looking at the pictures, but you should be able to use your imagination.
In the first picture, with the quadratic curve fit to the data, I can see the following pattern in the residuals
From 0.0 to 0.3 they are about evenly placed above and below the curve.
From 0.3 to about 0.55 all the data points are above the curve.
From 0.55 to about 0.85 all the data points are below the curve.
From 0.85 on, they are all above the curve again.
I'd refer to these behaviours as local bias, there are regions where the curve is not well approximating the conditional mean of the data.
Compare this to the last fit, with the cubic spline. I can't pick out any regions by eye where the fit does not look like it's running precisely through the center of mass of the data points. This is generally (though imprecisely) what I mean by a good fit.
Final Note: Take all this as illustration. In practice, I do not recommend using polynomial basis expansions for any degree higher than $2$. Their problems are well discussed elsewhere, but, for example:
Their behaviour at the boundaries of your data can be very chaotic,
even with regularization.
They are not local in any sense. Changing your data in one place can significantly affect the fit in a very different place.
Instead, in a situation like you describe, I recommend using natural cubic splines along with regularization, which give the best compromise between flexibility and stability. You can see for yourself by fitting some splines in the app.
(*) I believe this only works in Chrome and Firefox due to my use of some modern javascript features (and overall laziness to fix it in Safari and IE). The source code is here, if you are interested.
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
I recently made a little in browser app that you can use to play with these ideas: Scatterplot Smoothers (*).
Here's some data I made up, with a low degree polynomial fit
It's clear that the quadrati
|
Why use regularisation in polynomial regression instead of lowering the degree?
I recently made a little in browser app that you can use to play with these ideas: Scatterplot Smoothers (*).
Here's some data I made up, with a low degree polynomial fit
It's clear that the quadratic polynomial is just not flexible enough to give a good fit to the data. We have regions of very high bias, between $0.6$ and $0.85$ all the data is below the fit, and after $0.85$ all the data is above the curve.
To rid ourselves of bias, we can increase the degree of the curve to three, but the problem remains, the cubic curve is still too rigid
So we continue to increase the degree, but now we incur the opposite problem
This curve tracks the data too closely, and has a tendency to fly off in directions not so well borne out by general patterns in the data. This is where regularization comes in. With the same degree curve (ten) and some well chosen regularization
We get a really nice fit!
It's worth a little focus on one aspect of well chosen above. When you are fitting polynomials to data you have a discrete set of choices for degree. If a degree three curve is underfit and a degree four curve is overfit, you have nowhere to go in the middle. Regularization solves this problem, as it gives you a continuous range of complexity parameters to play with.
how do you claim "We get a really nice fit!". For me they all look the same, namely, inconclusive. Which rational are you using to decide what is a nice and a bad fit?
Fair point.
The assumption I'm making here is that a well fit model should have no discernable pattern in the residuals. Now, I'm not plotting the residuals, so you have to do a little bit of work when looking at the pictures, but you should be able to use your imagination.
In the first picture, with the quadratic curve fit to the data, I can see the following pattern in the residuals
From 0.0 to 0.3 they are about evenly placed above and below the curve.
From 0.3 to about 0.55 all the data points are above the curve.
From 0.55 to about 0.85 all the data points are below the curve.
From 0.85 on, they are all above the curve again.
I'd refer to these behaviours as local bias, there are regions where the curve is not well approximating the conditional mean of the data.
Compare this to the last fit, with the cubic spline. I can't pick out any regions by eye where the fit does not look like it's running precisely through the center of mass of the data points. This is generally (though imprecisely) what I mean by a good fit.
Final Note: Take all this as illustration. In practice, I do not recommend using polynomial basis expansions for any degree higher than $2$. Their problems are well discussed elsewhere, but, for example:
Their behaviour at the boundaries of your data can be very chaotic,
even with regularization.
They are not local in any sense. Changing your data in one place can significantly affect the fit in a very different place.
Instead, in a situation like you describe, I recommend using natural cubic splines along with regularization, which give the best compromise between flexibility and stability. You can see for yourself by fitting some splines in the app.
(*) I believe this only works in Chrome and Firefox due to my use of some modern javascript features (and overall laziness to fix it in Safari and IE). The source code is here, if you are interested.
|
Why use regularisation in polynomial regression instead of lowering the degree?
I recently made a little in browser app that you can use to play with these ideas: Scatterplot Smoothers (*).
Here's some data I made up, with a low degree polynomial fit
It's clear that the quadrati
|
6,890
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
No, it isn't the same. Compare, for example, a second-order polynomial without regularization to a fourth-order polynomial with it. The latter can posit big coefficients for the third and fourth powers so long as this seems to increase predictive accuracy, according to whatever procedure is used to choose the penalty size for the regularization procedure (probably cross-validation). This shows that one of the benefits of regularization is that it allows you to automatically adjust model complexity to strike a balance between overfitting and underfitting.
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
No, it isn't the same. Compare, for example, a second-order polynomial without regularization to a fourth-order polynomial with it. The latter can posit big coefficients for the third and fourth power
|
Why use regularisation in polynomial regression instead of lowering the degree?
No, it isn't the same. Compare, for example, a second-order polynomial without regularization to a fourth-order polynomial with it. The latter can posit big coefficients for the third and fourth powers so long as this seems to increase predictive accuracy, according to whatever procedure is used to choose the penalty size for the regularization procedure (probably cross-validation). This shows that one of the benefits of regularization is that it allows you to automatically adjust model complexity to strike a balance between overfitting and underfitting.
|
Why use regularisation in polynomial regression instead of lowering the degree?
No, it isn't the same. Compare, for example, a second-order polynomial without regularization to a fourth-order polynomial with it. The latter can posit big coefficients for the third and fourth power
|
6,891
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
For polynomials even small changes in coefficients can make a difference for the higher exponents.
$L_2$ regularization ( least squares ) usually encourages many small coefficients but none exactly 0 and therefore the higher order monomials are able to make a difference.
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
For polynomials even small changes in coefficients can make a difference for the higher exponents.
$L_2$ regularization ( least squares ) usually encourages many small coefficients but none exactly 0
|
Why use regularisation in polynomial regression instead of lowering the degree?
For polynomials even small changes in coefficients can make a difference for the higher exponents.
$L_2$ regularization ( least squares ) usually encourages many small coefficients but none exactly 0 and therefore the higher order monomials are able to make a difference.
|
Why use regularisation in polynomial regression instead of lowering the degree?
For polynomials even small changes in coefficients can make a difference for the higher exponents.
$L_2$ regularization ( least squares ) usually encourages many small coefficients but none exactly 0
|
6,892
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
All the answers are great and I have similar simulations with Matt to give you another example to show why complex model with regularization is usually better than simple model.
I made a analogy to have intuitive explanation.
Case 1 you only have a high school student with limited knowledge (a simple model without regularization)
Case 2 you have a graduate student but restrict him/her to only use high school knowledge to solve problems. (complex model with regularization)
If two persons are solving the same problem, usually the graduate students would work better solution, because the experience and insights about the knowledge.
Figure 1 is showing 4 fittings to the same data. 4 fittings are line, parabola, 3rd order model and 5th order model. You can observe the 5th order model may have overfitting problem.
On the other hand, in the second experiment, we will use 5th order model with different level of regularization. Compare last one with the second order model. (two models are highlighted) you will find the last one is similar (roughly have the same model complexity) to parabola, but slightly more flexible to the data well.
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
All the answers are great and I have similar simulations with Matt to give you another example to show why complex model with regularization is usually better than simple model.
I made a analogy to ha
|
Why use regularisation in polynomial regression instead of lowering the degree?
All the answers are great and I have similar simulations with Matt to give you another example to show why complex model with regularization is usually better than simple model.
I made a analogy to have intuitive explanation.
Case 1 you only have a high school student with limited knowledge (a simple model without regularization)
Case 2 you have a graduate student but restrict him/her to only use high school knowledge to solve problems. (complex model with regularization)
If two persons are solving the same problem, usually the graduate students would work better solution, because the experience and insights about the knowledge.
Figure 1 is showing 4 fittings to the same data. 4 fittings are line, parabola, 3rd order model and 5th order model. You can observe the 5th order model may have overfitting problem.
On the other hand, in the second experiment, we will use 5th order model with different level of regularization. Compare last one with the second order model. (two models are highlighted) you will find the last one is similar (roughly have the same model complexity) to parabola, but slightly more flexible to the data well.
|
Why use regularisation in polynomial regression instead of lowering the degree?
All the answers are great and I have similar simulations with Matt to give you another example to show why complex model with regularization is usually better than simple model.
I made a analogy to ha
|
6,893
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
Model Complexity (model flexibility) is about representing the structures hidden in the data. To take an example of polynomial curve fitting, a higher-order polynomial (say, parabola/quadratic) provides more flexibility to represent the hidden structures compared to a lower-order one (say, line/linear) if there is indeed a hidden parabolic structure (that we found using EDA).
So, where does Regularization come in?
The observations/outcomes of a random experiment are noisy (we assume gaussian noise as a good approximation). When we use a higher-order polynomial, the higher the polynomial, the more the training points that lie exactly on the fitted curve. But, this results in poor generalization and the test set results are disappointing.
When we examine the coefficients of the higher order polynomials, they carry very high values. What has happened is that even though the model is flexible, it has tuned itself to the gaussian noise, so much so that the fitted curve oscillates rapidly near the ends of intervals between data points. So, during testing, a slight off-x results in a big off-y.
Regularization helps in keeping these coefficients at lower values, hence, the curve is smooth. We now have less training points on the curve, more training error, but less test error, means, better generalization (less Overfitting).
The choice between higher order polynomial and regularization is not that of excluding one for the other, but that of striking a balance between how higher the polynomial can be without losing too much on generalization.
When we talk about order of polynomial and regularization in the context of generalization/less-overfitting, there is a third lever that can reduce the overfitting caused by a higher-order polynomial. This lever is 'size of data'. More data helps in accommodating a higher-order polynomial.
References:
1 Pattern Recognition and Machine Learning - Christopher Bishop
|
Why use regularisation in polynomial regression instead of lowering the degree?
|
Model Complexity (model flexibility) is about representing the structures hidden in the data. To take an example of polynomial curve fitting, a higher-order polynomial (say, parabola/quadratic) provid
|
Why use regularisation in polynomial regression instead of lowering the degree?
Model Complexity (model flexibility) is about representing the structures hidden in the data. To take an example of polynomial curve fitting, a higher-order polynomial (say, parabola/quadratic) provides more flexibility to represent the hidden structures compared to a lower-order one (say, line/linear) if there is indeed a hidden parabolic structure (that we found using EDA).
So, where does Regularization come in?
The observations/outcomes of a random experiment are noisy (we assume gaussian noise as a good approximation). When we use a higher-order polynomial, the higher the polynomial, the more the training points that lie exactly on the fitted curve. But, this results in poor generalization and the test set results are disappointing.
When we examine the coefficients of the higher order polynomials, they carry very high values. What has happened is that even though the model is flexible, it has tuned itself to the gaussian noise, so much so that the fitted curve oscillates rapidly near the ends of intervals between data points. So, during testing, a slight off-x results in a big off-y.
Regularization helps in keeping these coefficients at lower values, hence, the curve is smooth. We now have less training points on the curve, more training error, but less test error, means, better generalization (less Overfitting).
The choice between higher order polynomial and regularization is not that of excluding one for the other, but that of striking a balance between how higher the polynomial can be without losing too much on generalization.
When we talk about order of polynomial and regularization in the context of generalization/less-overfitting, there is a third lever that can reduce the overfitting caused by a higher-order polynomial. This lever is 'size of data'. More data helps in accommodating a higher-order polynomial.
References:
1 Pattern Recognition and Machine Learning - Christopher Bishop
|
Why use regularisation in polynomial regression instead of lowering the degree?
Model Complexity (model flexibility) is about representing the structures hidden in the data. To take an example of polynomial curve fitting, a higher-order polynomial (say, parabola/quadratic) provid
|
6,894
|
Area under curve of ROC vs. overall accuracy
|
AUC (based on ROC) and overall accuracy seems not the same concept.
Overall accuracy is based on one specific cutpoint, while ROC tries all of the cutpoint and plots the sensitivity and specificity.
So when we compare the overall accuracy, we are comparing the accuracy based on some cutpoint. The overall accuracy varies from different cutpoint.
|
Area under curve of ROC vs. overall accuracy
|
AUC (based on ROC) and overall accuracy seems not the same concept.
Overall accuracy is based on one specific cutpoint, while ROC tries all of the cutpoint and plots the sensitivity and specificity.
S
|
Area under curve of ROC vs. overall accuracy
AUC (based on ROC) and overall accuracy seems not the same concept.
Overall accuracy is based on one specific cutpoint, while ROC tries all of the cutpoint and plots the sensitivity and specificity.
So when we compare the overall accuracy, we are comparing the accuracy based on some cutpoint. The overall accuracy varies from different cutpoint.
|
Area under curve of ROC vs. overall accuracy
AUC (based on ROC) and overall accuracy seems not the same concept.
Overall accuracy is based on one specific cutpoint, while ROC tries all of the cutpoint and plots the sensitivity and specificity.
S
|
6,895
|
Area under curve of ROC vs. overall accuracy
|
While the two statistics measures are likely to be correlated, they measure different qualities of the classifier.
AUROC
The area under the curve (AUC) is equal to the probability that a classifier will rank a randomly chosen positive instance higher than a randomly chosen negative example. It measures the classifiers skill in ranking a set of patterns according to the degree to which they belong to the positive class, but without actually assigning patterns to classes.
The overall accuracy also depends on the ability of the classifier to rank patterns, but also on its ability to select a threshold in the ranking used to assign patterns to the positive class if above the threshold and to the negative class if below.
Thus the classifier with the higher AUROC statistic (all things being equal) is likely to also have a higher overall accuracy as the ranking of patterns (which AUROC measures) is beneficial to both AUROC and overall accuracy. However, if one classifier ranks patterns well, but selects the threshold badly, it can have a high AUROC but a poor overall accuracy.
Practical Use
In practice, I like to collect the overall accuracy, the AUROC and if the classifier estimates the probability of class membership, the cross-entropy or predictive information. Then I have a metric that measures its raw ability to perform a hard classification (assuming false-positive and false-negative misclassification costs are equal and the class frequencies in the sample are the same as those in operational use - a big assumption!), a metric that measures the ability to rank patterns and a metric that measures how well the ranking is calibrated as a probability.
For many tasks, the operational misclassification costs are unknown or variable, or the operational class frequencies are different to those in the training sample or are variable. In that case, the overall accuracy is often fairly meaningless and the AUROC is a better indicator of performance and ideally we want a classifier that outputs well-calibrated probabilities, so that we can compensate for these issues in operational use. Essentially which metric is important depends on the problem we are trying to solve.
|
Area under curve of ROC vs. overall accuracy
|
While the two statistics measures are likely to be correlated, they measure different qualities of the classifier.
AUROC
The area under the curve (AUC) is equal to the probability that a classifier wi
|
Area under curve of ROC vs. overall accuracy
While the two statistics measures are likely to be correlated, they measure different qualities of the classifier.
AUROC
The area under the curve (AUC) is equal to the probability that a classifier will rank a randomly chosen positive instance higher than a randomly chosen negative example. It measures the classifiers skill in ranking a set of patterns according to the degree to which they belong to the positive class, but without actually assigning patterns to classes.
The overall accuracy also depends on the ability of the classifier to rank patterns, but also on its ability to select a threshold in the ranking used to assign patterns to the positive class if above the threshold and to the negative class if below.
Thus the classifier with the higher AUROC statistic (all things being equal) is likely to also have a higher overall accuracy as the ranking of patterns (which AUROC measures) is beneficial to both AUROC and overall accuracy. However, if one classifier ranks patterns well, but selects the threshold badly, it can have a high AUROC but a poor overall accuracy.
Practical Use
In practice, I like to collect the overall accuracy, the AUROC and if the classifier estimates the probability of class membership, the cross-entropy or predictive information. Then I have a metric that measures its raw ability to perform a hard classification (assuming false-positive and false-negative misclassification costs are equal and the class frequencies in the sample are the same as those in operational use - a big assumption!), a metric that measures the ability to rank patterns and a metric that measures how well the ranking is calibrated as a probability.
For many tasks, the operational misclassification costs are unknown or variable, or the operational class frequencies are different to those in the training sample or are variable. In that case, the overall accuracy is often fairly meaningless and the AUROC is a better indicator of performance and ideally we want a classifier that outputs well-calibrated probabilities, so that we can compensate for these issues in operational use. Essentially which metric is important depends on the problem we are trying to solve.
|
Area under curve of ROC vs. overall accuracy
While the two statistics measures are likely to be correlated, they measure different qualities of the classifier.
AUROC
The area under the curve (AUC) is equal to the probability that a classifier wi
|
6,896
|
Area under curve of ROC vs. overall accuracy
|
Is AUC really very useful metric?
I would say expected cost is more appropriate measure.
Then you would have a cost A for all False Positives and cost B for all False Negatives. It might easily be that other class is relative more expensive than other. Of course if you have costs for false classification in the various sub-groups then it would be even more powerful metric.
By plotting cut-off in the x-axis and expected cost on then y-axis you can see which cut-off point minimizes expected cost.
Formally you have a loss-function Loss(cut-off|data,cost) which you try to minimize.
|
Area under curve of ROC vs. overall accuracy
|
Is AUC really very useful metric?
I would say expected cost is more appropriate measure.
Then you would have a cost A for all False Positives and cost B for all False Negatives. It might easily be tha
|
Area under curve of ROC vs. overall accuracy
Is AUC really very useful metric?
I would say expected cost is more appropriate measure.
Then you would have a cost A for all False Positives and cost B for all False Negatives. It might easily be that other class is relative more expensive than other. Of course if you have costs for false classification in the various sub-groups then it would be even more powerful metric.
By plotting cut-off in the x-axis and expected cost on then y-axis you can see which cut-off point minimizes expected cost.
Formally you have a loss-function Loss(cut-off|data,cost) which you try to minimize.
|
Area under curve of ROC vs. overall accuracy
Is AUC really very useful metric?
I would say expected cost is more appropriate measure.
Then you would have a cost A for all False Positives and cost B for all False Negatives. It might easily be tha
|
6,897
|
Area under curve of ROC vs. overall accuracy
|
Like all the answers have been posted: ROC and accuracy are fundamentally two different concepts.
Generally speaking, ROC describes the discriminative power of a classifier independent of class distribution and unequal prediction error costs (false positive and false negative cost).
Metric like accuracy is calculated based on the class distribution of test dataset or cross-validation, but this ratio may change when you apply the classifier to real life data, because the underlying class distribution has been changed or is unknown. On the other hand, TP rate and FP rate which are used to construct AUC will be not be affected by class distribution shifting.
|
Area under curve of ROC vs. overall accuracy
|
Like all the answers have been posted: ROC and accuracy are fundamentally two different concepts.
Generally speaking, ROC describes the discriminative power of a classifier independent of class distri
|
Area under curve of ROC vs. overall accuracy
Like all the answers have been posted: ROC and accuracy are fundamentally two different concepts.
Generally speaking, ROC describes the discriminative power of a classifier independent of class distribution and unequal prediction error costs (false positive and false negative cost).
Metric like accuracy is calculated based on the class distribution of test dataset or cross-validation, but this ratio may change when you apply the classifier to real life data, because the underlying class distribution has been changed or is unknown. On the other hand, TP rate and FP rate which are used to construct AUC will be not be affected by class distribution shifting.
|
Area under curve of ROC vs. overall accuracy
Like all the answers have been posted: ROC and accuracy are fundamentally two different concepts.
Generally speaking, ROC describes the discriminative power of a classifier independent of class distri
|
6,898
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
|
The linear model (or "ordinary least squares") still has its unbiasedness property in this case.
In the face of heteroskedasticity in error terms, you still have unbiased parameter estimates but you get a biased estimate of the covariance matrix: your inference (i.e. parameter tests and confidence intervals) could be incorrect. The common fix is to use a robust method for computing the covariance matrix aka standard errors. Which one you use is somewhat domain-dependent but White's method is a start.
And for completeness, serial correlation of error terms is worse as it will lead to biased parameter estimates.
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
|
The linear model (or "ordinary least squares") still has its unbiasedness property in this case.
In the face of heteroskedasticity in error terms, you still have unbiased parameter estimates but you g
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
The linear model (or "ordinary least squares") still has its unbiasedness property in this case.
In the face of heteroskedasticity in error terms, you still have unbiased parameter estimates but you get a biased estimate of the covariance matrix: your inference (i.e. parameter tests and confidence intervals) could be incorrect. The common fix is to use a robust method for computing the covariance matrix aka standard errors. Which one you use is somewhat domain-dependent but White's method is a start.
And for completeness, serial correlation of error terms is worse as it will lead to biased parameter estimates.
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
The linear model (or "ordinary least squares") still has its unbiasedness property in this case.
In the face of heteroskedasticity in error terms, you still have unbiased parameter estimates but you g
|
6,899
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
|
Homoscedasticity is one of the Gauss Markov assumptions that are required for OLS to be the best linear unbiased estimator (BLUE).
The Gauss-Markov Theorem is telling us that the least squares estimator for the coefficients $\beta$ is unbiased and has minimum variance among all unbiased linear estimators, given that we fulfill all Gauss-Markov assumptions. You can find more information on the Gauss-Markov Theorem including the mathematical proof of the theorem here. Additionally, you can find a complete list of the OLS assumptions including explanations what happens in case they are violated here.
Briefly summarizing the information from the websites above, heteroscedasticity does not introduce a bias in the estimates of your coefficients. However, given heteroscedasticity, you are not able to properly estimate the variance-covariance matrix. Hence, the standard errors of the coefficients are wrong. This means that one cannot compute any t-statistics and p-values and consequently hypothesis testing is not possible. Overall, under heteroscedasticity OLS loses its efficiency and is not BLUE anymore.
However, heteroscedasticity is not the end of the world. Fortunately, correcting for heteroscedasticity is not difficult. The sandwich estimator allows you to estimate consistent standard errors for the coefficients. Nevertheless, computing the standard errors via the sandwich estimator comes at a cost. The estimator is not very efficient and standard errors might be very large. One way to gain back some of the efficiency is to cluster standard errors if possible.
You can find more detailed information on this subject on the websites I referred above.
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
|
Homoscedasticity is one of the Gauss Markov assumptions that are required for OLS to be the best linear unbiased estimator (BLUE).
The Gauss-Markov Theorem is telling us that the least squares estima
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
Homoscedasticity is one of the Gauss Markov assumptions that are required for OLS to be the best linear unbiased estimator (BLUE).
The Gauss-Markov Theorem is telling us that the least squares estimator for the coefficients $\beta$ is unbiased and has minimum variance among all unbiased linear estimators, given that we fulfill all Gauss-Markov assumptions. You can find more information on the Gauss-Markov Theorem including the mathematical proof of the theorem here. Additionally, you can find a complete list of the OLS assumptions including explanations what happens in case they are violated here.
Briefly summarizing the information from the websites above, heteroscedasticity does not introduce a bias in the estimates of your coefficients. However, given heteroscedasticity, you are not able to properly estimate the variance-covariance matrix. Hence, the standard errors of the coefficients are wrong. This means that one cannot compute any t-statistics and p-values and consequently hypothesis testing is not possible. Overall, under heteroscedasticity OLS loses its efficiency and is not BLUE anymore.
However, heteroscedasticity is not the end of the world. Fortunately, correcting for heteroscedasticity is not difficult. The sandwich estimator allows you to estimate consistent standard errors for the coefficients. Nevertheless, computing the standard errors via the sandwich estimator comes at a cost. The estimator is not very efficient and standard errors might be very large. One way to gain back some of the efficiency is to cluster standard errors if possible.
You can find more detailed information on this subject on the websites I referred above.
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
Homoscedasticity is one of the Gauss Markov assumptions that are required for OLS to be the best linear unbiased estimator (BLUE).
The Gauss-Markov Theorem is telling us that the least squares estima
|
6,900
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
|
Absence of homoscedasticity may give unreliable standard error estimates of the parameters. Parameter estimates are unbiased. But the estimates may not efficient(not BLUE). You can find some more in the following link
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
|
Absence of homoscedasticity may give unreliable standard error estimates of the parameters. Parameter estimates are unbiased. But the estimates may not efficient(not BLUE). You can find some more in
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
Absence of homoscedasticity may give unreliable standard error estimates of the parameters. Parameter estimates are unbiased. But the estimates may not efficient(not BLUE). You can find some more in the following link
|
What are the dangers of violating the homoscedasticity assumption for linear regression?
Absence of homoscedasticity may give unreliable standard error estimates of the parameters. Parameter estimates are unbiased. But the estimates may not efficient(not BLUE). You can find some more in
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.