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
|
|---|---|---|---|---|---|---|
14,101
|
Why we use log function for cross entropy?
|
For binary classification one way to encode the probability of an output is $p^y(1-p)^{1-y}$, if y is encoded as 0 or 1. This is the likelihood function and it’s meaning is with probability p we output 0 and with probability 1-p if output is 1.
Now you have a sample and you want to find p which best fits your data. One way is to find the maximum likelihood estimator. If your observations are independent your mle is found by maximizing the likelihood over the whole sample. This is the product of individual likelihoods $\pi_{i=1}^n p^{y_i}(1-p)^{y_i-1}$. But this is hard to use. Because of that one transform likelihood with logs. The transformation is monotonous and you get rid of products and obtain sums which are more tractable. Apply logs and get your expression.
Why not use your encoding instead? I think there is no reason why not. The question is which are the properties of your estimator? The first formulation uses likelihood and mle which has some theory behind which includes the fact that your estimator is efficient. The second formulation is not used often, don’t know any example of encoding the probability like that which does not exclude your approach.
|
Why we use log function for cross entropy?
|
For binary classification one way to encode the probability of an output is $p^y(1-p)^{1-y}$, if y is encoded as 0 or 1. This is the likelihood function and it’s meaning is with probability p we outpu
|
Why we use log function for cross entropy?
For binary classification one way to encode the probability of an output is $p^y(1-p)^{1-y}$, if y is encoded as 0 or 1. This is the likelihood function and it’s meaning is with probability p we output 0 and with probability 1-p if output is 1.
Now you have a sample and you want to find p which best fits your data. One way is to find the maximum likelihood estimator. If your observations are independent your mle is found by maximizing the likelihood over the whole sample. This is the product of individual likelihoods $\pi_{i=1}^n p^{y_i}(1-p)^{y_i-1}$. But this is hard to use. Because of that one transform likelihood with logs. The transformation is monotonous and you get rid of products and obtain sums which are more tractable. Apply logs and get your expression.
Why not use your encoding instead? I think there is no reason why not. The question is which are the properties of your estimator? The first formulation uses likelihood and mle which has some theory behind which includes the fact that your estimator is efficient. The second formulation is not used often, don’t know any example of encoding the probability like that which does not exclude your approach.
|
Why we use log function for cross entropy?
For binary classification one way to encode the probability of an output is $p^y(1-p)^{1-y}$, if y is encoded as 0 or 1. This is the likelihood function and it’s meaning is with probability p we outpu
|
14,102
|
Why we use log function for cross entropy?
|
I was also looking for an explanation and found one reason I find intuitive here:
It heavily penalizes predications that are confident and wrong.
Check this graph, it shows the range of possible log loss values given a true observation:
The Log Loss increases rapidly as the predicted probability approaches 0(wrong prediction).
|
Why we use log function for cross entropy?
|
I was also looking for an explanation and found one reason I find intuitive here:
It heavily penalizes predications that are confident and wrong.
Check this graph, it shows the range of possible log
|
Why we use log function for cross entropy?
I was also looking for an explanation and found one reason I find intuitive here:
It heavily penalizes predications that are confident and wrong.
Check this graph, it shows the range of possible log loss values given a true observation:
The Log Loss increases rapidly as the predicted probability approaches 0(wrong prediction).
|
Why we use log function for cross entropy?
I was also looking for an explanation and found one reason I find intuitive here:
It heavily penalizes predications that are confident and wrong.
Check this graph, it shows the range of possible log
|
14,103
|
What *is* an Artificial Neural Network?
|
Jürgen Schmidhuber, "Deep Learning in Neural Networks: An Overview" traces the history of key concepts in neural networks and deep learning. In his view, neural networks would appear to encompass essentially any model which can be characterized as a directed graph where each node represents some computational unit. Schmidhuber is a prominent neural networks researcher, and wrote the original paper on LSTM networks with Sepp Hochreiter.
Which modifiable components of a learning system are responsible for its success or failure? What changes to them improve performance? This has been called the fundamental credit assignment problem (Minsky, 1963). There are general credit assignment methods for universal problem solvers that are time-optimal in various theoretical senses (Sec. 6.8). The present survey, however, will focus on the narrower, but now commercially important, subfield of Deep Learning (DL) in Artificial Neural Networks (NNs).
A standard neural network (NN) consists of many simple, connected processors called neurons, each producing a sequence of real-valued activations. Input neurons get activated through sensors perceiving the environment, other neurons get activated through weighted connections from previously active neurons (details in Sec. 2). Some neurons may influence the environment by triggering actions. Learning or credit assignment is about finding weights that make the NN exhibit desired behavior, such as driving a car. Depending on the problem and how the neurons are connected, such behavior may require long causal chains of computational stages (Sec. 3), where each stage transforms (often in a non-linear way) the aggregate activation of the network. Deep Learning is about accurately assigning credit across many such stages.
Shallow NN-like models with few such stages have been around for many decades if not centuries (Sec. 5.1). Models with several successive nonlinear layers of neurons date back at least to the 1960s (Sec. 5.3) and 1970s (Sec. 5.5). An efficient gradient descent method for teacher-based Supervised Learning (SL) in discrete, differentiable networks of arbitrary depth called backpropagation (BP) was developed in the 1960s and 1970s, and applied to NNs in 1981 (Sec. 5.5). BP-based training of deep NNs with many layers, however, had been found to be difficult in practice by the late 1980s (Sec. 5.6), and had become an explicit research subject by the early 1990s (Sec. 5.9). DL became practically feasible to some extent through the help of Unsupervised Learning (UL), e.g., Sec. 5.10 (1991), Sec. 5.15 (2006). The 1990s and 2000s also saw many improvements of purely supervised DL (Sec. 5). In the new millennium, deep NNs have finally attracted wide-spread attention, mainly by outperforming alternative machine learning methods such as kernel machines (Vapnik, 1995; Scholkopf et al., 1998) in numerous important applications. In fact, since 2009, supervised deep NNs have won many official international pattern recognition competitions (e.g., Sec. 5.17, 5.19, 5.21, 5.22), achieving the first superhuman visual pattern recognition results in limited domains (Sec. 5.19, 2011). Deep NNs also have become relevant for the more general field of Reinforcement Learning (RL) where there is no supervising teacher (Sec. 6).
On the other hand, I'm not sure that it's necessarily profitable to try and construct a taxonomy of mutually-exclusive buckets for machine learning strategies. I think we can say that there are perspectives from which models can be viewed as neural networks. I don't think that perspective is necessarily the best or useful in all contexts. For example, I'm still planning to refer to random forests and gradient boosted trees as "tree ensembles" instead of abstracting away their distinctions and calling them "neural network trees". Moreover, Schmidhuber distinguishes NNs from kernel machines -- even though kernel machines have some connections to NNs -- when he writes "In the new millennium, deep NNs have finally attracted wide-spread attention, mainly by outperforming alternative machine learning methods such as kernel machines ... in numerous important applications. "
|
What *is* an Artificial Neural Network?
|
Jürgen Schmidhuber, "Deep Learning in Neural Networks: An Overview" traces the history of key concepts in neural networks and deep learning. In his view, neural networks would appear to encompass esse
|
What *is* an Artificial Neural Network?
Jürgen Schmidhuber, "Deep Learning in Neural Networks: An Overview" traces the history of key concepts in neural networks and deep learning. In his view, neural networks would appear to encompass essentially any model which can be characterized as a directed graph where each node represents some computational unit. Schmidhuber is a prominent neural networks researcher, and wrote the original paper on LSTM networks with Sepp Hochreiter.
Which modifiable components of a learning system are responsible for its success or failure? What changes to them improve performance? This has been called the fundamental credit assignment problem (Minsky, 1963). There are general credit assignment methods for universal problem solvers that are time-optimal in various theoretical senses (Sec. 6.8). The present survey, however, will focus on the narrower, but now commercially important, subfield of Deep Learning (DL) in Artificial Neural Networks (NNs).
A standard neural network (NN) consists of many simple, connected processors called neurons, each producing a sequence of real-valued activations. Input neurons get activated through sensors perceiving the environment, other neurons get activated through weighted connections from previously active neurons (details in Sec. 2). Some neurons may influence the environment by triggering actions. Learning or credit assignment is about finding weights that make the NN exhibit desired behavior, such as driving a car. Depending on the problem and how the neurons are connected, such behavior may require long causal chains of computational stages (Sec. 3), where each stage transforms (often in a non-linear way) the aggregate activation of the network. Deep Learning is about accurately assigning credit across many such stages.
Shallow NN-like models with few such stages have been around for many decades if not centuries (Sec. 5.1). Models with several successive nonlinear layers of neurons date back at least to the 1960s (Sec. 5.3) and 1970s (Sec. 5.5). An efficient gradient descent method for teacher-based Supervised Learning (SL) in discrete, differentiable networks of arbitrary depth called backpropagation (BP) was developed in the 1960s and 1970s, and applied to NNs in 1981 (Sec. 5.5). BP-based training of deep NNs with many layers, however, had been found to be difficult in practice by the late 1980s (Sec. 5.6), and had become an explicit research subject by the early 1990s (Sec. 5.9). DL became practically feasible to some extent through the help of Unsupervised Learning (UL), e.g., Sec. 5.10 (1991), Sec. 5.15 (2006). The 1990s and 2000s also saw many improvements of purely supervised DL (Sec. 5). In the new millennium, deep NNs have finally attracted wide-spread attention, mainly by outperforming alternative machine learning methods such as kernel machines (Vapnik, 1995; Scholkopf et al., 1998) in numerous important applications. In fact, since 2009, supervised deep NNs have won many official international pattern recognition competitions (e.g., Sec. 5.17, 5.19, 5.21, 5.22), achieving the first superhuman visual pattern recognition results in limited domains (Sec. 5.19, 2011). Deep NNs also have become relevant for the more general field of Reinforcement Learning (RL) where there is no supervising teacher (Sec. 6).
On the other hand, I'm not sure that it's necessarily profitable to try and construct a taxonomy of mutually-exclusive buckets for machine learning strategies. I think we can say that there are perspectives from which models can be viewed as neural networks. I don't think that perspective is necessarily the best or useful in all contexts. For example, I'm still planning to refer to random forests and gradient boosted trees as "tree ensembles" instead of abstracting away their distinctions and calling them "neural network trees". Moreover, Schmidhuber distinguishes NNs from kernel machines -- even though kernel machines have some connections to NNs -- when he writes "In the new millennium, deep NNs have finally attracted wide-spread attention, mainly by outperforming alternative machine learning methods such as kernel machines ... in numerous important applications. "
|
What *is* an Artificial Neural Network?
Jürgen Schmidhuber, "Deep Learning in Neural Networks: An Overview" traces the history of key concepts in neural networks and deep learning. In his view, neural networks would appear to encompass esse
|
14,104
|
What *is* an Artificial Neural Network?
|
If you want a basic definition of an ANN, you might say that it's a directed-graphical-model, where inputs and outputs are processed at each node via an activation function, and most of the time gradient descent is used to train it. So the question really becomes: what models out there can be expressed as graphical models?
I'm not an expert but, I believe theoretically some ANNs can be shown to be Turing complete, which means that they should be able to do any possible set of calculations (with a possible infinite number of resources, mind you).
I'm also going to interpret your question in the following way:
For any given model, can I slap together an ANN model to emulate that
model, as close as possible, and in a reasonable amount of time?
A vanilla neural network can emulate a decision tree, by using heaviside step-activations. The problem is that such unit activations have zero gradient, so normal gradient descent won't work. You might say, "no problem, just use a modified form of gradient descent." However, that's still not enough. For a better example, take something like XGBOOST, which isn't just gradient-boosted forests. There's a whole lot of extra work that goes into choosing split points, pruning, optimizing for speed, etc. Maybe after enough modifications you can make a similar-looking ANN, but it's not at all clear that such an ANN would perform at least as well, nor if it's optimized to do the job.
I think that's an important point, because while it might be theoretically satisfying to conclude that ANNs can do anything, practically this might be completely useless. For example, you could try making an ANN using ReLu activations to approximate $f(x)=e^{x}$, but that's just plain dumb, as considerably more efficient and accurate methods are at your disposal.
|
What *is* an Artificial Neural Network?
|
If you want a basic definition of an ANN, you might say that it's a directed-graphical-model, where inputs and outputs are processed at each node via an activation function, and most of the time gradi
|
What *is* an Artificial Neural Network?
If you want a basic definition of an ANN, you might say that it's a directed-graphical-model, where inputs and outputs are processed at each node via an activation function, and most of the time gradient descent is used to train it. So the question really becomes: what models out there can be expressed as graphical models?
I'm not an expert but, I believe theoretically some ANNs can be shown to be Turing complete, which means that they should be able to do any possible set of calculations (with a possible infinite number of resources, mind you).
I'm also going to interpret your question in the following way:
For any given model, can I slap together an ANN model to emulate that
model, as close as possible, and in a reasonable amount of time?
A vanilla neural network can emulate a decision tree, by using heaviside step-activations. The problem is that such unit activations have zero gradient, so normal gradient descent won't work. You might say, "no problem, just use a modified form of gradient descent." However, that's still not enough. For a better example, take something like XGBOOST, which isn't just gradient-boosted forests. There's a whole lot of extra work that goes into choosing split points, pruning, optimizing for speed, etc. Maybe after enough modifications you can make a similar-looking ANN, but it's not at all clear that such an ANN would perform at least as well, nor if it's optimized to do the job.
I think that's an important point, because while it might be theoretically satisfying to conclude that ANNs can do anything, practically this might be completely useless. For example, you could try making an ANN using ReLu activations to approximate $f(x)=e^{x}$, but that's just plain dumb, as considerably more efficient and accurate methods are at your disposal.
|
What *is* an Artificial Neural Network?
If you want a basic definition of an ANN, you might say that it's a directed-graphical-model, where inputs and outputs are processed at each node via an activation function, and most of the time gradi
|
14,105
|
What *is* an Artificial Neural Network?
|
Perhaps, a more accurate name for ANNs is "differentiable networks", i.e. complex parametrized functions that can be optimized using gradient descent or its variant. This is a very general definition that emphasizes differentiability, but doesn't tell anything about principal ideas, tasks that it's suited for, underlying mathematical framework, etc.
Note that differentiability is a trait, not necessary the main. For example, SVM can be trained using gradient descent and thus exhibits properties of a neural/differentiable network, but the main idea is in data separation using hyperplanes. Variational autoencoder uses MLPs for encoder and decoder, but the function you optimize comes from Bayesian statistics, and so on.
There's also a few models that are often referred to as neural networks but don't use GD for learning. A good example is RBM. My guess is that the label "neural network" was attached to it mostly for historical reasons - eventually, RBM's creator is Geoffrey Hinton, and Hinton is a neural network guy, right? However, if you analyze the model you'll see that RBM's structure is a Markov net, energy-based cost function comes from statistical physics of the beginning of 20th centenary and MCMC/Gibbs sampling have been developing in parallel and totally independently from neural networks.
|
What *is* an Artificial Neural Network?
|
Perhaps, a more accurate name for ANNs is "differentiable networks", i.e. complex parametrized functions that can be optimized using gradient descent or its variant. This is a very general definition
|
What *is* an Artificial Neural Network?
Perhaps, a more accurate name for ANNs is "differentiable networks", i.e. complex parametrized functions that can be optimized using gradient descent or its variant. This is a very general definition that emphasizes differentiability, but doesn't tell anything about principal ideas, tasks that it's suited for, underlying mathematical framework, etc.
Note that differentiability is a trait, not necessary the main. For example, SVM can be trained using gradient descent and thus exhibits properties of a neural/differentiable network, but the main idea is in data separation using hyperplanes. Variational autoencoder uses MLPs for encoder and decoder, but the function you optimize comes from Bayesian statistics, and so on.
There's also a few models that are often referred to as neural networks but don't use GD for learning. A good example is RBM. My guess is that the label "neural network" was attached to it mostly for historical reasons - eventually, RBM's creator is Geoffrey Hinton, and Hinton is a neural network guy, right? However, if you analyze the model you'll see that RBM's structure is a Markov net, energy-based cost function comes from statistical physics of the beginning of 20th centenary and MCMC/Gibbs sampling have been developing in parallel and totally independently from neural networks.
|
What *is* an Artificial Neural Network?
Perhaps, a more accurate name for ANNs is "differentiable networks", i.e. complex parametrized functions that can be optimized using gradient descent or its variant. This is a very general definition
|
14,106
|
What *is* an Artificial Neural Network?
|
I might try to postulate some things that help to define a Neural Network.
A computation (directed) graph with adjustable parameters.
Said parameters can be adjusted to conform to data (real or simulated).
An objective function to be optimized is involved implicitly or explicitly. It can be global or local on parameters.
I'm pretty sure this covers all neural networks in common use today and also some esoteric ones.
It's agnostic to the optimization (if we imposed gradient-based optimization, then evolved networks wouldn't be neural networks).
It doesn't mention neurons/nodes or layers (some neural networks today are hardly described by these terms), but I guess we could incorporate that and be a bit more restrictive.
|
What *is* an Artificial Neural Network?
|
I might try to postulate some things that help to define a Neural Network.
A computation (directed) graph with adjustable parameters.
Said parameters can be adjusted to conform to data (real or simul
|
What *is* an Artificial Neural Network?
I might try to postulate some things that help to define a Neural Network.
A computation (directed) graph with adjustable parameters.
Said parameters can be adjusted to conform to data (real or simulated).
An objective function to be optimized is involved implicitly or explicitly. It can be global or local on parameters.
I'm pretty sure this covers all neural networks in common use today and also some esoteric ones.
It's agnostic to the optimization (if we imposed gradient-based optimization, then evolved networks wouldn't be neural networks).
It doesn't mention neurons/nodes or layers (some neural networks today are hardly described by these terms), but I guess we could incorporate that and be a bit more restrictive.
|
What *is* an Artificial Neural Network?
I might try to postulate some things that help to define a Neural Network.
A computation (directed) graph with adjustable parameters.
Said parameters can be adjusted to conform to data (real or simul
|
14,107
|
Relationship between Hessian Matrix and Covariance Matrix
|
You should first check out this: Basic question about Fisher Information matrix and relationship to Hessian and standard errors.
Suppose we have a statistical model (family of distributions) $\{f_{\theta}: \theta \in \Theta\}$. In the most general case we have $\mathrm{dim}(\Theta) = d$, so this family is parameterized by $\theta = (\theta_1, \dots, \theta_d)^T$. Under certain regularity conditions, we have
$$I_{i,j}(\theta) = -E_{\theta}\left[\frac{\partial^2 l(X; \theta)}{\partial\theta_i\partial\theta_j}\right] = -E_\theta\left[H_{i,j}(l(X;\theta))\right],$$
where $I_{i,j}$ is a Fisher Information matrix (as a function of $\theta$) and $X$ is the observed value (sample)
$$l(X; \theta) = \ln(f_{\theta}(X)),\text{ for some } \theta \in \Theta.$$
So Fisher Information matrix is a negated expected value of Hesian of the log-probability under some $\theta$
Now let's say we want to estimate some vector function of the unknown parameter $\psi(\theta)$. Usually it is desired that the estimator $T(X) = (T_1(X), \dots, T_d(X))$ should be unbiased, i.e.
$$\forall_{\theta \in \Theta}\ E_{\theta}[T(X)] = \psi(\theta).$$
Cramer Rao Lower Bound states that for every unbiased $T(X)$ the $\mathrm{cov}_{\theta}(T(X))$ satisfies
$$\mathrm{cov}_{\theta}(T(X)) \ge \frac{\partial\psi(\theta)}{\partial\theta}I^{-1}(\theta)\left(\frac{\partial\psi(\theta)}{\partial\theta}\right)^T = B(\theta),$$
where the notation $A \ge B$ for matrices $A, B$ means that $A - B$ is positive semi-definite. Further, $\frac{\partial\psi(\theta)}{\partial\theta}$ denotes the Jacobian matrix $J_{i,j}(\psi)$. Note that if we estimate $\theta$, that is $\psi(\theta) = \theta$, above simplifies to
$$\mathrm{cov}_{\theta}(T(X)) \ge I^{-1}(\theta).$$
But what does it tell us really? For example, recall that
$$\mathrm{var}_{\theta}(T_i(X)) = [\mathrm{cov}_{\theta}(T(X))]_{i,i}$$
and that for every positive semi-definite matrix $A$ diagonal elements are non-negative
$$\forall_i\ A_{i,i} \ge 0.$$
From above we can conclude that the variance of each estimated element is bounded by diagonal elements of matrix $B(\theta)$
$$\forall_i\ \mathrm{var}_{\theta}(T_i(X)) \ge [B(\theta)]_{i,i}$$
So CRLB doesn't tell us the variance of our estimator, but wheter or not our estimator is optimal, i.e., if it has lowest covariance among all unbiased estimators.
|
Relationship between Hessian Matrix and Covariance Matrix
|
You should first check out this: Basic question about Fisher Information matrix and relationship to Hessian and standard errors.
Suppose we have a statistical model (family of distributions) $\{f_{\th
|
Relationship between Hessian Matrix and Covariance Matrix
You should first check out this: Basic question about Fisher Information matrix and relationship to Hessian and standard errors.
Suppose we have a statistical model (family of distributions) $\{f_{\theta}: \theta \in \Theta\}$. In the most general case we have $\mathrm{dim}(\Theta) = d$, so this family is parameterized by $\theta = (\theta_1, \dots, \theta_d)^T$. Under certain regularity conditions, we have
$$I_{i,j}(\theta) = -E_{\theta}\left[\frac{\partial^2 l(X; \theta)}{\partial\theta_i\partial\theta_j}\right] = -E_\theta\left[H_{i,j}(l(X;\theta))\right],$$
where $I_{i,j}$ is a Fisher Information matrix (as a function of $\theta$) and $X$ is the observed value (sample)
$$l(X; \theta) = \ln(f_{\theta}(X)),\text{ for some } \theta \in \Theta.$$
So Fisher Information matrix is a negated expected value of Hesian of the log-probability under some $\theta$
Now let's say we want to estimate some vector function of the unknown parameter $\psi(\theta)$. Usually it is desired that the estimator $T(X) = (T_1(X), \dots, T_d(X))$ should be unbiased, i.e.
$$\forall_{\theta \in \Theta}\ E_{\theta}[T(X)] = \psi(\theta).$$
Cramer Rao Lower Bound states that for every unbiased $T(X)$ the $\mathrm{cov}_{\theta}(T(X))$ satisfies
$$\mathrm{cov}_{\theta}(T(X)) \ge \frac{\partial\psi(\theta)}{\partial\theta}I^{-1}(\theta)\left(\frac{\partial\psi(\theta)}{\partial\theta}\right)^T = B(\theta),$$
where the notation $A \ge B$ for matrices $A, B$ means that $A - B$ is positive semi-definite. Further, $\frac{\partial\psi(\theta)}{\partial\theta}$ denotes the Jacobian matrix $J_{i,j}(\psi)$. Note that if we estimate $\theta$, that is $\psi(\theta) = \theta$, above simplifies to
$$\mathrm{cov}_{\theta}(T(X)) \ge I^{-1}(\theta).$$
But what does it tell us really? For example, recall that
$$\mathrm{var}_{\theta}(T_i(X)) = [\mathrm{cov}_{\theta}(T(X))]_{i,i}$$
and that for every positive semi-definite matrix $A$ diagonal elements are non-negative
$$\forall_i\ A_{i,i} \ge 0.$$
From above we can conclude that the variance of each estimated element is bounded by diagonal elements of matrix $B(\theta)$
$$\forall_i\ \mathrm{var}_{\theta}(T_i(X)) \ge [B(\theta)]_{i,i}$$
So CRLB doesn't tell us the variance of our estimator, but wheter or not our estimator is optimal, i.e., if it has lowest covariance among all unbiased estimators.
|
Relationship between Hessian Matrix and Covariance Matrix
You should first check out this: Basic question about Fisher Information matrix and relationship to Hessian and standard errors.
Suppose we have a statistical model (family of distributions) $\{f_{\th
|
14,108
|
Generating samples from singular Gaussian distribution
|
The singular Gaussian distribution is the push-forward of a nonsingular distribution in a lower-dimensional space. Geometrically, you can take a standard Normal distribution, rescale it, rotate it, and embed it isometrically into an affine subspace of a higher dimensional space. Algebraically, this is done by means of a Singular Value Decomposition (SVD) or its equivalent.
Let $\Sigma$ be the covariance matrix and $\mu$ the mean in $\mathbb{R}^n$. Because $\Sigma$ is non-negative definite and symmetric, the SVD will take the form
$$\Sigma = U \Lambda^2 U^\prime$$
for an orthogonal matrix $U\in O(n)$ and a diagonal matrix $\Lambda$. $\Lambda$ will have $m$ nonzero entries, $0\le m \le n$.
Let $X$ have a standard Normal distribution in $\mathbb{R}^m$: that is, each of its $m$ components is a standard Normal distribution with zero mean and unit variance. Abusing notation a little, extend the components of $X$ with $n-m$ zeros to make it an $n$-vector. Then $U\Lambda X$ is in $\mathbb{R}^n$ and we may compute
$$\text{Cov}(U\Lambda X) = U \Lambda\text{Cov}(X) \Lambda^\prime U^\prime = U \Lambda^2 U^\prime = \Sigma.$$
Consequently
$$Y = \mu + U\Lambda X$$
has the intended Gaussian distribution in $\mathbb{R}^n$.
It is of interest that this works when $n=m$: that is to say, this is a (standard) method to generate multivariate Normal vectors, in any dimension, for any given mean $\mu$ and covariance $\Sigma$ by using a univariate generator of standard Normal values.
As an example, here are two views of a thousand simulated points for which $n=3$ and $m=2$:
The second view, from edge-on, demonstrates the singularity of the distribution. The R code that produced these figures follows the preceding mathematical exposition.
#
# Specify a Normal distribution.
#
mu <- c(5, 5, 5)
Sigma <- matrix(c(1, 2, 1,
2, 3, 1,
1, 1, 0), 3)
#
# Analyze the covariance.
#
n <- dim(Sigma)[1]
s <- svd((Sigma + t(Sigma))/2) # Guarantee symmetry
s$d <- abs(zapsmall(s$d))
m <- sum(s$d > 0)
#$
# Generate a standard Normal `x` in R^m.
#
n.sample <- 1e3 # Number of points to generate
x <- matrix(rnorm(m*n.sample), nrow=m)
#
# Embed `x` in R^n and apply the square root of Sigma obtained from its SVD.
#
x <- rbind(x, matrix(0, nrow=n-m, ncol=n.sample))
y <- s$u %*% diag(sqrt(s$d)) %*% x + mu
#
# Plot the results (presuming n==3).
#
library(rgl)
plot3d(t(y), type="s", size=1, aspect=TRUE,
xlab="Y1", ylab="Y2", zlab="Y3", box=FALSE,
col="Orange")
|
Generating samples from singular Gaussian distribution
|
The singular Gaussian distribution is the push-forward of a nonsingular distribution in a lower-dimensional space. Geometrically, you can take a standard Normal distribution, rescale it, rotate it, a
|
Generating samples from singular Gaussian distribution
The singular Gaussian distribution is the push-forward of a nonsingular distribution in a lower-dimensional space. Geometrically, you can take a standard Normal distribution, rescale it, rotate it, and embed it isometrically into an affine subspace of a higher dimensional space. Algebraically, this is done by means of a Singular Value Decomposition (SVD) or its equivalent.
Let $\Sigma$ be the covariance matrix and $\mu$ the mean in $\mathbb{R}^n$. Because $\Sigma$ is non-negative definite and symmetric, the SVD will take the form
$$\Sigma = U \Lambda^2 U^\prime$$
for an orthogonal matrix $U\in O(n)$ and a diagonal matrix $\Lambda$. $\Lambda$ will have $m$ nonzero entries, $0\le m \le n$.
Let $X$ have a standard Normal distribution in $\mathbb{R}^m$: that is, each of its $m$ components is a standard Normal distribution with zero mean and unit variance. Abusing notation a little, extend the components of $X$ with $n-m$ zeros to make it an $n$-vector. Then $U\Lambda X$ is in $\mathbb{R}^n$ and we may compute
$$\text{Cov}(U\Lambda X) = U \Lambda\text{Cov}(X) \Lambda^\prime U^\prime = U \Lambda^2 U^\prime = \Sigma.$$
Consequently
$$Y = \mu + U\Lambda X$$
has the intended Gaussian distribution in $\mathbb{R}^n$.
It is of interest that this works when $n=m$: that is to say, this is a (standard) method to generate multivariate Normal vectors, in any dimension, for any given mean $\mu$ and covariance $\Sigma$ by using a univariate generator of standard Normal values.
As an example, here are two views of a thousand simulated points for which $n=3$ and $m=2$:
The second view, from edge-on, demonstrates the singularity of the distribution. The R code that produced these figures follows the preceding mathematical exposition.
#
# Specify a Normal distribution.
#
mu <- c(5, 5, 5)
Sigma <- matrix(c(1, 2, 1,
2, 3, 1,
1, 1, 0), 3)
#
# Analyze the covariance.
#
n <- dim(Sigma)[1]
s <- svd((Sigma + t(Sigma))/2) # Guarantee symmetry
s$d <- abs(zapsmall(s$d))
m <- sum(s$d > 0)
#$
# Generate a standard Normal `x` in R^m.
#
n.sample <- 1e3 # Number of points to generate
x <- matrix(rnorm(m*n.sample), nrow=m)
#
# Embed `x` in R^n and apply the square root of Sigma obtained from its SVD.
#
x <- rbind(x, matrix(0, nrow=n-m, ncol=n.sample))
y <- s$u %*% diag(sqrt(s$d)) %*% x + mu
#
# Plot the results (presuming n==3).
#
library(rgl)
plot3d(t(y), type="s", size=1, aspect=TRUE,
xlab="Y1", ylab="Y2", zlab="Y3", box=FALSE,
col="Orange")
|
Generating samples from singular Gaussian distribution
The singular Gaussian distribution is the push-forward of a nonsingular distribution in a lower-dimensional space. Geometrically, you can take a standard Normal distribution, rescale it, rotate it, a
|
14,109
|
Why is Functional Data Analysis (FDA) not as popular?
|
As someone with almost zero knowledge in FDA but who has recently started reading and thinking about it, here are some of my thoughts on why FDA is not so popular these days. Please take them with a grain of salt as I am far from being an expert :
Most of the Data Science problems people are interested in solving "do not care" about the nature of the data. What I mean is, when trying to do a task such as e.g. regression, classification, or clustering, statisticians will go for the methods that yield the best models for a minimal computational cost. Depending on context, what the definition of "best" is, the available information etc, one may choose different methods which themselves may rely on different possible representations of the data, such as vectors, matrices, graphs, smooth manifolds, functions... Therefore, when a dataset can be nicely represented as a tensor that you can plug into a CNN with solid guarantees on model performance, why would you bother picking the functional representation ?
On the other hand, there are problems where you are trying to infer information on the functions you sample from themselves, in that specific case there is no way around using FDA (see here for some examples).
That brings me to my next point : Functional Data, in practice, is always stored as a (high-dimensional) finite-dimensional object, so the FDA paradigm is never really needed. Indeed, even if the data is in practice a set of realisations of a function depending on continuous parameter(s), which typically would be space and/or time, what you actually have stored in your computer is a discretised version of it. Although it is true that when the "mesh size" is sufficiently small, you are close to dealing with "real" functional data such as e.g. Random Fields, Stocks prices, Video recordings etc... It works fine in practice to consider that data as high (but finite) dimensional objects.
And here is, imo, the most crucial point : There are plenty of non-FDA specific algorithms that perform very well on functional data. There are indeed countless examples of successful processing of all kinds of functional data such as Video recordings, audio recordings, satellite imagery and many more. On the other hand, there hasn't been, as far as I know, many (or any) big breakthroughs results justifying the superiority of FDA-specific methods for functional dataover more conventional ones outside of specific context. All hope is definitely not lost, as there definitely are a few theoretical arguments here and there suggesting that the FDA framework can be far superior to the finite-dimensional one in some cases, such as this paper by Delaigle and Hall : Achieving near perfect classification for functional data (2012) which shows that "perfect classification" is possible for functional data under very mild assumptions whereas it is definitely not the case in the finite-dimensional setting. In practice however, it seems that dimensionality reduction + classical methods works just fine.
Lastly, I think another factor is that the mathematical knowledge required to be able to contribute to research in FDA tends to be outside of the expertise of most statisticians. Indeed, the proposed algorithms in the literature often rely on rather deep results in Functional Analysis that many statisticians might not be too familiar with, and there are other issues such as, e.g., defining a meaningful measure on a space of functions which are more profound and less likely to interest statisticians who are generally more experts in stuff like Linear Algebra, Optimization, Concentration Inequalities, VC-Theory etc... I think it is kind of the same with Topological Data Analysis (although it seems to be gaining a lot of traction recently) : the ideas are very promising, but require a deep knowledge in pure maths concepts such as homology, Betti numbers or Euler characteristic... to be applied and further improved, which is a knowledge many statisticians do not have.
Even though I said all that, I do believe there is plenty of interesting things to do in that subfield and its full potential hasn't been reached at all. I have mostly read papers related to the problems I am interested in, so I don't have much to recommend, but I have read some of Hsing and Eubank and find it pretty great so far. I also found this review by Wang, Chiou and Müller to be pretty comprehensive to get a rough idea of the current state-of-the-art.
|
Why is Functional Data Analysis (FDA) not as popular?
|
As someone with almost zero knowledge in FDA but who has recently started reading and thinking about it, here are some of my thoughts on why FDA is not so popular these days. Please take them with a g
|
Why is Functional Data Analysis (FDA) not as popular?
As someone with almost zero knowledge in FDA but who has recently started reading and thinking about it, here are some of my thoughts on why FDA is not so popular these days. Please take them with a grain of salt as I am far from being an expert :
Most of the Data Science problems people are interested in solving "do not care" about the nature of the data. What I mean is, when trying to do a task such as e.g. regression, classification, or clustering, statisticians will go for the methods that yield the best models for a minimal computational cost. Depending on context, what the definition of "best" is, the available information etc, one may choose different methods which themselves may rely on different possible representations of the data, such as vectors, matrices, graphs, smooth manifolds, functions... Therefore, when a dataset can be nicely represented as a tensor that you can plug into a CNN with solid guarantees on model performance, why would you bother picking the functional representation ?
On the other hand, there are problems where you are trying to infer information on the functions you sample from themselves, in that specific case there is no way around using FDA (see here for some examples).
That brings me to my next point : Functional Data, in practice, is always stored as a (high-dimensional) finite-dimensional object, so the FDA paradigm is never really needed. Indeed, even if the data is in practice a set of realisations of a function depending on continuous parameter(s), which typically would be space and/or time, what you actually have stored in your computer is a discretised version of it. Although it is true that when the "mesh size" is sufficiently small, you are close to dealing with "real" functional data such as e.g. Random Fields, Stocks prices, Video recordings etc... It works fine in practice to consider that data as high (but finite) dimensional objects.
And here is, imo, the most crucial point : There are plenty of non-FDA specific algorithms that perform very well on functional data. There are indeed countless examples of successful processing of all kinds of functional data such as Video recordings, audio recordings, satellite imagery and many more. On the other hand, there hasn't been, as far as I know, many (or any) big breakthroughs results justifying the superiority of FDA-specific methods for functional dataover more conventional ones outside of specific context. All hope is definitely not lost, as there definitely are a few theoretical arguments here and there suggesting that the FDA framework can be far superior to the finite-dimensional one in some cases, such as this paper by Delaigle and Hall : Achieving near perfect classification for functional data (2012) which shows that "perfect classification" is possible for functional data under very mild assumptions whereas it is definitely not the case in the finite-dimensional setting. In practice however, it seems that dimensionality reduction + classical methods works just fine.
Lastly, I think another factor is that the mathematical knowledge required to be able to contribute to research in FDA tends to be outside of the expertise of most statisticians. Indeed, the proposed algorithms in the literature often rely on rather deep results in Functional Analysis that many statisticians might not be too familiar with, and there are other issues such as, e.g., defining a meaningful measure on a space of functions which are more profound and less likely to interest statisticians who are generally more experts in stuff like Linear Algebra, Optimization, Concentration Inequalities, VC-Theory etc... I think it is kind of the same with Topological Data Analysis (although it seems to be gaining a lot of traction recently) : the ideas are very promising, but require a deep knowledge in pure maths concepts such as homology, Betti numbers or Euler characteristic... to be applied and further improved, which is a knowledge many statisticians do not have.
Even though I said all that, I do believe there is plenty of interesting things to do in that subfield and its full potential hasn't been reached at all. I have mostly read papers related to the problems I am interested in, so I don't have much to recommend, but I have read some of Hsing and Eubank and find it pretty great so far. I also found this review by Wang, Chiou and Müller to be pretty comprehensive to get a rough idea of the current state-of-the-art.
|
Why is Functional Data Analysis (FDA) not as popular?
As someone with almost zero knowledge in FDA but who has recently started reading and thinking about it, here are some of my thoughts on why FDA is not so popular these days. Please take them with a g
|
14,110
|
Why is Functional Data Analysis (FDA) not as popular?
|
FDA was late to the party and benefits against established applications are at times incremental. In many cases, "standard longitudinal data techniques" check most boxes already. FDA does provide some unique advantages on specific use cases (e.g. working with density functions or covariance surfaces as the unit of analysis) but those are specialised and rather recent applications.
|
Why is Functional Data Analysis (FDA) not as popular?
|
FDA was late to the party and benefits against established applications are at times incremental. In many cases, "standard longitudinal data techniques" check most boxes already. FDA does provide some
|
Why is Functional Data Analysis (FDA) not as popular?
FDA was late to the party and benefits against established applications are at times incremental. In many cases, "standard longitudinal data techniques" check most boxes already. FDA does provide some unique advantages on specific use cases (e.g. working with density functions or covariance surfaces as the unit of analysis) but those are specialised and rather recent applications.
|
Why is Functional Data Analysis (FDA) not as popular?
FDA was late to the party and benefits against established applications are at times incremental. In many cases, "standard longitudinal data techniques" check most boxes already. FDA does provide some
|
14,111
|
What is the connection between partial least squares, reduced rank regression, and principal component regression?
|
These are three different methods, and none of them can be seen as a special case of another.
Formally, if $\mathbf X$ and $\mathbf Y$ are centered predictor ($n \times p$) and response ($n\times q$) datasets and if we look for the first pair of axes, $\mathbf w \in \mathbb R^p$ for $\mathbf X$ and $\mathbf v \in \mathbb R^q$ for $\mathbf Y$, then these methods maximize the following quantities:
\begin{align}
\mathrm{PCA:}&\quad \operatorname{Var}(\mathbf{Xw}) \\
\mathrm{RRR:}&\quad \phantom{\operatorname{Var}(\mathbf {Xw})\cdot{}}\operatorname{Corr}^2(\mathbf{Xw},\mathbf {Yv})\cdot\operatorname{Var}(\mathbf{Yv}) \\
\mathrm{PLS:}&\quad \operatorname{Var}(\mathbf{Xw})\cdot\operatorname{Corr}^2(\mathbf{Xw},\mathbf {Yv})\cdot\operatorname{Var}(\mathbf {Yv}) = \operatorname{Cov}^2(\mathbf{Xw},\mathbf {Yv})\\
\mathrm{CCA:}&\quad \phantom{\operatorname{Var}(\mathbf {Xw})\cdot {}}\operatorname{Corr}^2(\mathbf {Xw},\mathbf {Yv})
\end{align}
(I added canonical correlation analysis (CCA) to this list.)
I suspect that the confusion might be because in SAS all three methods seem to be implemented via the same function PROC PLS with different parameters. So it might seem that all three methods are special cases of PLS because that's how the SAS function is named. This is, however, just an unfortunate naming. In reality, PLS, RRR, and PCR are three different methods that just happen to be implemented in SAS in one function that for some reason is called PLS.
Both tutorials that you linked to are actually very clear about that. Page 6 of the presentation tutorial states objectives of all three methods and does not say PLS "becomes" RRR or PCR, contrary to what you claimed in your question. Similarly, the SAS documentation explains that three methods are different, giving formulas and intuition:
[P]rincipal components regression selects factors that explain as much predictor variation as possible, reduced rank regression selects factors that explain as much response variation as possible, and partial least squares balances the two objectives, seeking for factors that explain both response and predictor variation.
There is even a figure in the SAS documentation showing a nice toy example where three methods give different solutions. In this toy example there are two predictors $x_1$ and $x_2$ and one response variable $y$. The direction in $X$ that is most correlated with $y$ happens to be orthogonal to the direction of maximal variance in $X$. Hence PC1 is orthogonal to the first RRR axis, and PLS axis is somewhere in between.
One can add a ridge penalty to the RRR lost function obtaining ridge reduced-rank regression, or RRRR. This will pull the regression axis towards the PC1 direction, somewhat similar to what PLS is doing. However, the cost function for RRRR cannot be written in a PLS form, so they remain different.
Note that when there is only one predictor variable $y$, CCA = RRR = usual regression.
|
What is the connection between partial least squares, reduced rank regression, and principal compone
|
These are three different methods, and none of them can be seen as a special case of another.
Formally, if $\mathbf X$ and $\mathbf Y$ are centered predictor ($n \times p$) and response ($n\times q$)
|
What is the connection between partial least squares, reduced rank regression, and principal component regression?
These are three different methods, and none of them can be seen as a special case of another.
Formally, if $\mathbf X$ and $\mathbf Y$ are centered predictor ($n \times p$) and response ($n\times q$) datasets and if we look for the first pair of axes, $\mathbf w \in \mathbb R^p$ for $\mathbf X$ and $\mathbf v \in \mathbb R^q$ for $\mathbf Y$, then these methods maximize the following quantities:
\begin{align}
\mathrm{PCA:}&\quad \operatorname{Var}(\mathbf{Xw}) \\
\mathrm{RRR:}&\quad \phantom{\operatorname{Var}(\mathbf {Xw})\cdot{}}\operatorname{Corr}^2(\mathbf{Xw},\mathbf {Yv})\cdot\operatorname{Var}(\mathbf{Yv}) \\
\mathrm{PLS:}&\quad \operatorname{Var}(\mathbf{Xw})\cdot\operatorname{Corr}^2(\mathbf{Xw},\mathbf {Yv})\cdot\operatorname{Var}(\mathbf {Yv}) = \operatorname{Cov}^2(\mathbf{Xw},\mathbf {Yv})\\
\mathrm{CCA:}&\quad \phantom{\operatorname{Var}(\mathbf {Xw})\cdot {}}\operatorname{Corr}^2(\mathbf {Xw},\mathbf {Yv})
\end{align}
(I added canonical correlation analysis (CCA) to this list.)
I suspect that the confusion might be because in SAS all three methods seem to be implemented via the same function PROC PLS with different parameters. So it might seem that all three methods are special cases of PLS because that's how the SAS function is named. This is, however, just an unfortunate naming. In reality, PLS, RRR, and PCR are three different methods that just happen to be implemented in SAS in one function that for some reason is called PLS.
Both tutorials that you linked to are actually very clear about that. Page 6 of the presentation tutorial states objectives of all three methods and does not say PLS "becomes" RRR or PCR, contrary to what you claimed in your question. Similarly, the SAS documentation explains that three methods are different, giving formulas and intuition:
[P]rincipal components regression selects factors that explain as much predictor variation as possible, reduced rank regression selects factors that explain as much response variation as possible, and partial least squares balances the two objectives, seeking for factors that explain both response and predictor variation.
There is even a figure in the SAS documentation showing a nice toy example where three methods give different solutions. In this toy example there are two predictors $x_1$ and $x_2$ and one response variable $y$. The direction in $X$ that is most correlated with $y$ happens to be orthogonal to the direction of maximal variance in $X$. Hence PC1 is orthogonal to the first RRR axis, and PLS axis is somewhere in between.
One can add a ridge penalty to the RRR lost function obtaining ridge reduced-rank regression, or RRRR. This will pull the regression axis towards the PC1 direction, somewhat similar to what PLS is doing. However, the cost function for RRRR cannot be written in a PLS form, so they remain different.
Note that when there is only one predictor variable $y$, CCA = RRR = usual regression.
|
What is the connection between partial least squares, reduced rank regression, and principal compone
These are three different methods, and none of them can be seen as a special case of another.
Formally, if $\mathbf X$ and $\mathbf Y$ are centered predictor ($n \times p$) and response ($n\times q$)
|
14,112
|
How much data do you need for a convolutional neural network?
|
In order to figure out whether or not more data will be helpful, you should compare the performance of your algorithm on the training data (i.e. the data used to train the neural network) to its performance on testing data (i.e. data the neural network did not "see" in training).
A good thing to check would be the error (or accuracy) on each set as a function of iteration number. There are two possibilities for the outcome of this:
1) The training error converges to a value significantly lower than than the testing error. If this is the case, the performance of your algorithm will almost certainly improve with more data.
2) The training error and the testing error converge to about the same value (with the training error still probably being slightly lower than the testing error). In this case additional data by itself will not help your algorithm. If you need better performance than you are getting at this point, you should try either adding more neurons to your hidden layers, or adding more hidden layers. If enough hidden units are added, you will find your testing error will become noticeably higher than the training error, and more data will help at that point.
For a more thorough and helpful introduction to how to make these decisions, I highly recommend Andrew Ng's Coursera course, particularly the "Evaluating a learning algorithm" and "Bias vs. Variance" lessons.
|
How much data do you need for a convolutional neural network?
|
In order to figure out whether or not more data will be helpful, you should compare the performance of your algorithm on the training data (i.e. the data used to train the neural network) to its perfo
|
How much data do you need for a convolutional neural network?
In order to figure out whether or not more data will be helpful, you should compare the performance of your algorithm on the training data (i.e. the data used to train the neural network) to its performance on testing data (i.e. data the neural network did not "see" in training).
A good thing to check would be the error (or accuracy) on each set as a function of iteration number. There are two possibilities for the outcome of this:
1) The training error converges to a value significantly lower than than the testing error. If this is the case, the performance of your algorithm will almost certainly improve with more data.
2) The training error and the testing error converge to about the same value (with the training error still probably being slightly lower than the testing error). In this case additional data by itself will not help your algorithm. If you need better performance than you are getting at this point, you should try either adding more neurons to your hidden layers, or adding more hidden layers. If enough hidden units are added, you will find your testing error will become noticeably higher than the training error, and more data will help at that point.
For a more thorough and helpful introduction to how to make these decisions, I highly recommend Andrew Ng's Coursera course, particularly the "Evaluating a learning algorithm" and "Bias vs. Variance" lessons.
|
How much data do you need for a convolutional neural network?
In order to figure out whether or not more data will be helpful, you should compare the performance of your algorithm on the training data (i.e. the data used to train the neural network) to its perfo
|
14,113
|
How much data do you need for a convolutional neural network?
|
The naive answer is that always more data are needed.
Iterating over the same dataset saying for more epochs helps you to "refine" the result but you don't improve the result as much as having more data.
As an example i'm training a convnet to do sentence modelling and to test if i need more data i tried to split my training dataset in smaller subset and trying to test it.
Using the whole dataset and training for 10 iteration i obtained 93% accuracy on my benchmark and it keep improving. Instead when i iterated on the 10% of the dataset for 100 iteration i obtained a 85%.
So always try to have more data but if you can't, doing more epochs can be a nice trade-of but in the end your model converges better if you fed the network with always new data.
|
How much data do you need for a convolutional neural network?
|
The naive answer is that always more data are needed.
Iterating over the same dataset saying for more epochs helps you to "refine" the result but you don't improve the result as much as having more da
|
How much data do you need for a convolutional neural network?
The naive answer is that always more data are needed.
Iterating over the same dataset saying for more epochs helps you to "refine" the result but you don't improve the result as much as having more data.
As an example i'm training a convnet to do sentence modelling and to test if i need more data i tried to split my training dataset in smaller subset and trying to test it.
Using the whole dataset and training for 10 iteration i obtained 93% accuracy on my benchmark and it keep improving. Instead when i iterated on the 10% of the dataset for 100 iteration i obtained a 85%.
So always try to have more data but if you can't, doing more epochs can be a nice trade-of but in the end your model converges better if you fed the network with always new data.
|
How much data do you need for a convolutional neural network?
The naive answer is that always more data are needed.
Iterating over the same dataset saying for more epochs helps you to "refine" the result but you don't improve the result as much as having more da
|
14,114
|
How much data do you need for a convolutional neural network?
|
I guess the most important thing is that the samples in your data are well spread, because no matter how much data you have, more data would always be better.
After all, if you try to learn to distinguish between cat and dog pictures, you can't expect your model to perform well if you only feed it cat images.
As suggested in the answer by Kevin L, it makes sense to consider the difference between training error and testing error. If your testing data is independent from your training data, this gives an indication as to how well your model generalises to the data that is unavailable.
Something I would like to add to that is the fact that a large difference between training and testing error only tells you that your model does not generalise well, i.e. you are overfitting on the training data. More data will probably help, because now the network also needs to model the extra data points, hence cannot overfit that much anymore. However, it might be more worthwhile to change your model such that it generalises better. This chapter from an excellent book explains what types of regularisation exist and how they can be applied in networks to get better generalisation.
If you were looking for a more quantitive measure, I recently found this question on quora. It is about an auto-encoder, but I guess it should also be applicable to your example. I have no idea whether this is correct (please let me know), but I would reason that for instance for MNIST, one could argue that you try to reduce images with a maximum of 28 * 28 * 8 * 10 000 = 62 720 000 bits entropy to ten classes in one-hot encoding with 10 * 10 * 10 000 = 1 000 000 bits of entropy. Because we are only interested in the 1 000 000 bits of entropy at the output, we can say that with 1 000 000 parameters, each parameter represents a single bit, which is 1e-4 bit per sample. This means you would need more data. Or you have too much parameters, because e.g. with 100 parameters, you have 10 000 bits per parameter and therefore 1 bit per sample. However, I would like to emphasise once again that it is the first time I have seen something like this and if anyone could confirm this, I would be grateful.
|
How much data do you need for a convolutional neural network?
|
I guess the most important thing is that the samples in your data are well spread, because no matter how much data you have, more data would always be better.
After all, if you try to learn to disting
|
How much data do you need for a convolutional neural network?
I guess the most important thing is that the samples in your data are well spread, because no matter how much data you have, more data would always be better.
After all, if you try to learn to distinguish between cat and dog pictures, you can't expect your model to perform well if you only feed it cat images.
As suggested in the answer by Kevin L, it makes sense to consider the difference between training error and testing error. If your testing data is independent from your training data, this gives an indication as to how well your model generalises to the data that is unavailable.
Something I would like to add to that is the fact that a large difference between training and testing error only tells you that your model does not generalise well, i.e. you are overfitting on the training data. More data will probably help, because now the network also needs to model the extra data points, hence cannot overfit that much anymore. However, it might be more worthwhile to change your model such that it generalises better. This chapter from an excellent book explains what types of regularisation exist and how they can be applied in networks to get better generalisation.
If you were looking for a more quantitive measure, I recently found this question on quora. It is about an auto-encoder, but I guess it should also be applicable to your example. I have no idea whether this is correct (please let me know), but I would reason that for instance for MNIST, one could argue that you try to reduce images with a maximum of 28 * 28 * 8 * 10 000 = 62 720 000 bits entropy to ten classes in one-hot encoding with 10 * 10 * 10 000 = 1 000 000 bits of entropy. Because we are only interested in the 1 000 000 bits of entropy at the output, we can say that with 1 000 000 parameters, each parameter represents a single bit, which is 1e-4 bit per sample. This means you would need more data. Or you have too much parameters, because e.g. with 100 parameters, you have 10 000 bits per parameter and therefore 1 bit per sample. However, I would like to emphasise once again that it is the first time I have seen something like this and if anyone could confirm this, I would be grateful.
|
How much data do you need for a convolutional neural network?
I guess the most important thing is that the samples in your data are well spread, because no matter how much data you have, more data would always be better.
After all, if you try to learn to disting
|
14,115
|
How much data do you need for a convolutional neural network?
|
Another method generally used to figure out if your network has learned enough features is to visualize the initial filters. If the network is well trained it should display a smooth filter. A noisy filter generally indicates that the network hasn't been trained enough or that it has been overfit.
For more info read this page.
|
How much data do you need for a convolutional neural network?
|
Another method generally used to figure out if your network has learned enough features is to visualize the initial filters. If the network is well trained it should display a smooth filter. A noisy f
|
How much data do you need for a convolutional neural network?
Another method generally used to figure out if your network has learned enough features is to visualize the initial filters. If the network is well trained it should display a smooth filter. A noisy filter generally indicates that the network hasn't been trained enough or that it has been overfit.
For more info read this page.
|
How much data do you need for a convolutional neural network?
Another method generally used to figure out if your network has learned enough features is to visualize the initial filters. If the network is well trained it should display a smooth filter. A noisy f
|
14,116
|
Free internet or downloadable resources for sample size calculations
|
Power analysis refers to analytical procedures that attempt to determine the power of a statistical test (i.e., the probability of rejecting a false null hypothesis) or the sample size (i.e., $N$) required to achieve a given power. You can search Cross Validated for more information about power analysis by clicking here: power-analysis, here: power, or possibly here sample-size.
Free software for power analyses:
G*Power
PS: Power and sample size calculator
Optimal Design software - statistical power analysis for multi-level and longitudinal research
Websites with free sample size calculators:
Russ Lenth has a java-based web app
Michael Friendly has a power analysis / sample size calculator for ANOVA designs
Rollin Brant's webpage for comparing two proportions
OpenEpi has sample size/power calculators for basic epidemiological study designs.
webpower a web based interface for power analyses (based on the package listed below) for people who don't use R
Open source programming languages with power analysis libraries / modules:
R packages:
pwr is the oldest power-analysis library; some introductory info can be found on Quick-R
PoweR: Computation of power and level tables for hypothesis tests
Power2Stage: Power and Sample size distribution of 2-stage BE studies via simulations
powerAnalysis: Power analysis in experimental design
powerGWASinteraction: Power Calculations for Interactions for GWAS
powerMediation: Power/Sample size calculation for mediation analysis, simple linear regression, logistic regression, or longitudinal study
powerpkg: Power analyses for the affected sib pair and the TDT design
powerSurvEpi: Power and sample size calculation for survival analysis of epidemiological studies
PowerTOST: Power and Sample size based on two one-sided t-tests (TOST) for (bio)equivalence studies
longpower: Power and sample size for linear model of longitudinal data
webpower: "a collection of tools for conducting both basic and advanced statistical power analysis" (also a website)
There is a Python module, statsmodels, that can run some power analyses. There is some information here.
|
Free internet or downloadable resources for sample size calculations
|
Power analysis refers to analytical procedures that attempt to determine the power of a statistical test (i.e., the probability of rejecting a false null hypothesis) or the sample size (i.e., $N$) req
|
Free internet or downloadable resources for sample size calculations
Power analysis refers to analytical procedures that attempt to determine the power of a statistical test (i.e., the probability of rejecting a false null hypothesis) or the sample size (i.e., $N$) required to achieve a given power. You can search Cross Validated for more information about power analysis by clicking here: power-analysis, here: power, or possibly here sample-size.
Free software for power analyses:
G*Power
PS: Power and sample size calculator
Optimal Design software - statistical power analysis for multi-level and longitudinal research
Websites with free sample size calculators:
Russ Lenth has a java-based web app
Michael Friendly has a power analysis / sample size calculator for ANOVA designs
Rollin Brant's webpage for comparing two proportions
OpenEpi has sample size/power calculators for basic epidemiological study designs.
webpower a web based interface for power analyses (based on the package listed below) for people who don't use R
Open source programming languages with power analysis libraries / modules:
R packages:
pwr is the oldest power-analysis library; some introductory info can be found on Quick-R
PoweR: Computation of power and level tables for hypothesis tests
Power2Stage: Power and Sample size distribution of 2-stage BE studies via simulations
powerAnalysis: Power analysis in experimental design
powerGWASinteraction: Power Calculations for Interactions for GWAS
powerMediation: Power/Sample size calculation for mediation analysis, simple linear regression, logistic regression, or longitudinal study
powerpkg: Power analyses for the affected sib pair and the TDT design
powerSurvEpi: Power and sample size calculation for survival analysis of epidemiological studies
PowerTOST: Power and Sample size based on two one-sided t-tests (TOST) for (bio)equivalence studies
longpower: Power and sample size for linear model of longitudinal data
webpower: "a collection of tools for conducting both basic and advanced statistical power analysis" (also a website)
There is a Python module, statsmodels, that can run some power analyses. There is some information here.
|
Free internet or downloadable resources for sample size calculations
Power analysis refers to analytical procedures that attempt to determine the power of a statistical test (i.e., the probability of rejecting a false null hypothesis) or the sample size (i.e., $N$) req
|
14,117
|
What is the "$R^2$" value given in the summary of a coxph model in R
|
Using getS3method("summary","coxph") you can look at how it is calculated.
The relevant code lines are the following:
logtest <- -2 * (cox$loglik[1] - cox$loglik[2])
rval$rsq <- c(rsq = 1 - exp(-logtest/cox$n), maxrsq = 1 -
exp(2 * cox$loglik[1]/cox$n))
Here cox$loglik is "a vector of length 2 containing the log-likelihood with the initial values and with the final values of the coefficients" (see ?coxph.object) and cox$n is "number of observations used in the fit".
|
What is the "$R^2$" value given in the summary of a coxph model in R
|
Using getS3method("summary","coxph") you can look at how it is calculated.
The relevant code lines are the following:
logtest <- -2 * (cox$loglik[1] - cox$loglik[2])
rval$rsq <- c(rsq = 1 - exp(-logte
|
What is the "$R^2$" value given in the summary of a coxph model in R
Using getS3method("summary","coxph") you can look at how it is calculated.
The relevant code lines are the following:
logtest <- -2 * (cox$loglik[1] - cox$loglik[2])
rval$rsq <- c(rsq = 1 - exp(-logtest/cox$n), maxrsq = 1 -
exp(2 * cox$loglik[1]/cox$n))
Here cox$loglik is "a vector of length 2 containing the log-likelihood with the initial values and with the final values of the coefficients" (see ?coxph.object) and cox$n is "number of observations used in the fit".
|
What is the "$R^2$" value given in the summary of a coxph model in R
Using getS3method("summary","coxph") you can look at how it is calculated.
The relevant code lines are the following:
logtest <- -2 * (cox$loglik[1] - cox$loglik[2])
rval$rsq <- c(rsq = 1 - exp(-logte
|
14,118
|
What is the "$R^2$" value given in the summary of a coxph model in R
|
Dividing by $n$ the number of observations in the summary of coxph is wrong, it should be the number of uncensored events; see O'Quigley et al. (2005) Explained randomness in proportional hazards models Statistics in Medicine p. 479-489.
|
What is the "$R^2$" value given in the summary of a coxph model in R
|
Dividing by $n$ the number of observations in the summary of coxph is wrong, it should be the number of uncensored events; see O'Quigley et al. (2005) Explained randomness in proportional hazards mode
|
What is the "$R^2$" value given in the summary of a coxph model in R
Dividing by $n$ the number of observations in the summary of coxph is wrong, it should be the number of uncensored events; see O'Quigley et al. (2005) Explained randomness in proportional hazards models Statistics in Medicine p. 479-489.
|
What is the "$R^2$" value given in the summary of a coxph model in R
Dividing by $n$ the number of observations in the summary of coxph is wrong, it should be the number of uncensored events; see O'Quigley et al. (2005) Explained randomness in proportional hazards mode
|
14,119
|
If I repeat every sample observation in a linear regression model and rerun the regression how would the result be affected? [duplicate]
|
Conceptually, you are adding no "new" information, but you "know" that information more precisely.
This would therefore result in the same regression coefficients, with smaller standard errors.
For example, in Stata, the expand x function duplicates each observation x times.
sysuse auto, clear
regress mpg weight length
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0038515 .001586 -2.43 0.018 -.0070138 -.0006891
length | -.0795935 .0553577 -1.44 0.155 -.1899736 .0307867
_cons | 47.88487 6.08787 7.87 0.000 35.746 60.02374
------------------------------------------------------------------------------
expand 5
regress mpg weight length
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0038515 .0006976 -5.52 0.000 -.0052232 -.0024797
length | -.0795935 .0243486 -3.27 0.001 -.1274738 -.0317131
_cons | 47.88487 2.677698 17.88 0.000 42.61932 53.15043
------------------------------------------------------------------------------
As you can see, formerly insignifcant coefficients (length) become statistically significant in the expanded model, representing the precision with which you "know" what you know.
|
If I repeat every sample observation in a linear regression model and rerun the regression how would
|
Conceptually, you are adding no "new" information, but you "know" that information more precisely.
This would therefore result in the same regression coefficients, with smaller standard errors.
For ex
|
If I repeat every sample observation in a linear regression model and rerun the regression how would the result be affected? [duplicate]
Conceptually, you are adding no "new" information, but you "know" that information more precisely.
This would therefore result in the same regression coefficients, with smaller standard errors.
For example, in Stata, the expand x function duplicates each observation x times.
sysuse auto, clear
regress mpg weight length
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0038515 .001586 -2.43 0.018 -.0070138 -.0006891
length | -.0795935 .0553577 -1.44 0.155 -.1899736 .0307867
_cons | 47.88487 6.08787 7.87 0.000 35.746 60.02374
------------------------------------------------------------------------------
expand 5
regress mpg weight length
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0038515 .0006976 -5.52 0.000 -.0052232 -.0024797
length | -.0795935 .0243486 -3.27 0.001 -.1274738 -.0317131
_cons | 47.88487 2.677698 17.88 0.000 42.61932 53.15043
------------------------------------------------------------------------------
As you can see, formerly insignifcant coefficients (length) become statistically significant in the expanded model, representing the precision with which you "know" what you know.
|
If I repeat every sample observation in a linear regression model and rerun the regression how would
Conceptually, you are adding no "new" information, but you "know" that information more precisely.
This would therefore result in the same regression coefficients, with smaller standard errors.
For ex
|
14,120
|
If I repeat every sample observation in a linear regression model and rerun the regression how would the result be affected? [duplicate]
|
Ordinary linear regression solves the problem $$w^* = \mbox{argmin}_w ||Xw - y||^2$$ where $X$ is the matrix of predictors and $y$ is the response. If you repeat each sample $M$ times, it would leave the objective function to be minimized unchanged (except for a multiplicative factor $M$). Therefore the weight vector that is optimum for the larger problem would be the same as for the original smaller problem.
|
If I repeat every sample observation in a linear regression model and rerun the regression how would
|
Ordinary linear regression solves the problem $$w^* = \mbox{argmin}_w ||Xw - y||^2$$ where $X$ is the matrix of predictors and $y$ is the response. If you repeat each sample $M$ times, it would leave
|
If I repeat every sample observation in a linear regression model and rerun the regression how would the result be affected? [duplicate]
Ordinary linear regression solves the problem $$w^* = \mbox{argmin}_w ||Xw - y||^2$$ where $X$ is the matrix of predictors and $y$ is the response. If you repeat each sample $M$ times, it would leave the objective function to be minimized unchanged (except for a multiplicative factor $M$). Therefore the weight vector that is optimum for the larger problem would be the same as for the original smaller problem.
|
If I repeat every sample observation in a linear regression model and rerun the regression how would
Ordinary linear regression solves the problem $$w^* = \mbox{argmin}_w ||Xw - y||^2$$ where $X$ is the matrix of predictors and $y$ is the response. If you repeat each sample $M$ times, it would leave
|
14,121
|
When to use weighted Euclidean distance and how to determine the weights to use?
|
Weights for standardisation
The setup you have is a variant of Mahalanobis distance. So when $w$ is the reciprocal of each measurement's variance you are effectively putting all the measurements on the same scale. This implies you think that the variation in each is equally 'important' but that some are measured in units that are not immediately comparable.
Weights for importance
You are free to put anything you like as weights, including measures of 'importance' (although you may want to standardise before importance weighting if the measurement units differ).
An example may help clarify the issues: consider the idea of estimating ideological 'distances' between political actors. In this application $x$ and $b$ might be the positions of two actors on the $i$-th issue, and $w_i$ the salience of that issue. For example, $b_i$ might be the status quo position on some dimension, from which various actor's positions differ. In this application one would certainly prefer to measure rather than assert both salience and position. Either way, large weights will make differences on non-salient issues have less effect on the overall distance between actors if they are computed according to your first equation. Notice also that in this version we implicitly assume no relevant covariance among positions, which is a fairly strong claim.
Focusing now on question 2: In the application I just described the justification for the weighting and distances grounds out in game theoretic assumptions about transitive preference structures and suchlike. Ultimately, these are the only reasons it is 'appropriate' to compute distances this way. Without them we've just got a bunch of numbers that obey the triangle inequality.
Weights as implicit measurement
On the covariance theme, it might be helpful to think of your problem as one of identifying the relevant subspace within which distances make substantive sense, on the assumption that many of the measurements you have actually measure similar things. A measurement model, e.g. factor analysis, would project everything via weighted combination into a common space wherein distances could be computed. But, again, we'd have to know the context of your research to say whether that would make sense.
|
When to use weighted Euclidean distance and how to determine the weights to use?
|
Weights for standardisation
The setup you have is a variant of Mahalanobis distance. So when $w$ is the reciprocal of each measurement's variance you are effectively putting all the measurements on t
|
When to use weighted Euclidean distance and how to determine the weights to use?
Weights for standardisation
The setup you have is a variant of Mahalanobis distance. So when $w$ is the reciprocal of each measurement's variance you are effectively putting all the measurements on the same scale. This implies you think that the variation in each is equally 'important' but that some are measured in units that are not immediately comparable.
Weights for importance
You are free to put anything you like as weights, including measures of 'importance' (although you may want to standardise before importance weighting if the measurement units differ).
An example may help clarify the issues: consider the idea of estimating ideological 'distances' between political actors. In this application $x$ and $b$ might be the positions of two actors on the $i$-th issue, and $w_i$ the salience of that issue. For example, $b_i$ might be the status quo position on some dimension, from which various actor's positions differ. In this application one would certainly prefer to measure rather than assert both salience and position. Either way, large weights will make differences on non-salient issues have less effect on the overall distance between actors if they are computed according to your first equation. Notice also that in this version we implicitly assume no relevant covariance among positions, which is a fairly strong claim.
Focusing now on question 2: In the application I just described the justification for the weighting and distances grounds out in game theoretic assumptions about transitive preference structures and suchlike. Ultimately, these are the only reasons it is 'appropriate' to compute distances this way. Without them we've just got a bunch of numbers that obey the triangle inequality.
Weights as implicit measurement
On the covariance theme, it might be helpful to think of your problem as one of identifying the relevant subspace within which distances make substantive sense, on the assumption that many of the measurements you have actually measure similar things. A measurement model, e.g. factor analysis, would project everything via weighted combination into a common space wherein distances could be computed. But, again, we'd have to know the context of your research to say whether that would make sense.
|
When to use weighted Euclidean distance and how to determine the weights to use?
Weights for standardisation
The setup you have is a variant of Mahalanobis distance. So when $w$ is the reciprocal of each measurement's variance you are effectively putting all the measurements on t
|
14,122
|
What methods can be used to determine the Order of Integration of a time series?
|
There are a number of statistical tests (known as "unit root tests") for dealing with this problem. The most popular is probably the "Augmented Dickey-Fuller" (ADF) test, although the Phillips-Perron (PP) test and the KPSS test are also widely used.
Both the ADF and PP tests are based on a null hypothesis of a unit root (i.e., an I(1) series). The KPSS test is based on a null hypothesis of stationarity (i.e., an I(0) series). Consequently, the KPSS test can give quite different results from the ADF or PP tests.
|
What methods can be used to determine the Order of Integration of a time series?
|
There are a number of statistical tests (known as "unit root tests") for dealing with this problem. The most popular is probably the "Augmented Dickey-Fuller" (ADF) test, although the Phillips-Perron
|
What methods can be used to determine the Order of Integration of a time series?
There are a number of statistical tests (known as "unit root tests") for dealing with this problem. The most popular is probably the "Augmented Dickey-Fuller" (ADF) test, although the Phillips-Perron (PP) test and the KPSS test are also widely used.
Both the ADF and PP tests are based on a null hypothesis of a unit root (i.e., an I(1) series). The KPSS test is based on a null hypothesis of stationarity (i.e., an I(0) series). Consequently, the KPSS test can give quite different results from the ADF or PP tests.
|
What methods can be used to determine the Order of Integration of a time series?
There are a number of statistical tests (known as "unit root tests") for dealing with this problem. The most popular is probably the "Augmented Dickey-Fuller" (ADF) test, although the Phillips-Perron
|
14,123
|
What methods can be used to determine the Order of Integration of a time series?
|
Also, for some elaborate discussion (including bashing of ADF / PP / KPSS :) you might want to have a look at the book by Maddala and Kim:
http://www.amazon.com/Cointegration-Structural-Change-Themes-Econometrics/dp/0521587824
Quite extensive and not very easy to read sometimes, but a useful reference.
|
What methods can be used to determine the Order of Integration of a time series?
|
Also, for some elaborate discussion (including bashing of ADF / PP / KPSS :) you might want to have a look at the book by Maddala and Kim:
http://www.amazon.com/Cointegration-Structural-Change-Themes-
|
What methods can be used to determine the Order of Integration of a time series?
Also, for some elaborate discussion (including bashing of ADF / PP / KPSS :) you might want to have a look at the book by Maddala and Kim:
http://www.amazon.com/Cointegration-Structural-Change-Themes-Econometrics/dp/0521587824
Quite extensive and not very easy to read sometimes, but a useful reference.
|
What methods can be used to determine the Order of Integration of a time series?
Also, for some elaborate discussion (including bashing of ADF / PP / KPSS :) you might want to have a look at the book by Maddala and Kim:
http://www.amazon.com/Cointegration-Structural-Change-Themes-
|
14,124
|
Elastic/ridge/lasso analysis, what then?
|
These methods--the lasso and elastic net--were born out of the problems of both feature selection and prediction. It's through these two lenses that I think an explanation can be found.
Matthew Gunn nicely explains in his reply that these two goals are distinct and often taken up by different people. However, fortunately for us, the methods we're interested in can perform well in both arenas.
Feature Selection
First, let's talk about feature selection. We should first motivate the elastic net from the perspective of the lasso. That is, to quote Hastie and Zou, "If there is a group of variables among which the pairwise correlations are very high, then the lasso tends to select only one variable from the group and does not care which one is selected." This is a problem, for instance, because it means that we're not likely to find an element of the true support using the lasso--just one highly correlated with it. (The paper mentions that this is proven in the LARS paper, which I haven't read yet.) The difficulty of support recovery in the presence of correlation is also pointed out by Wainwright, who showed (in theorem 2a) that the probability of support recovery is bounded above by $0.5$ when there's high correlation between the true support and it's complement.
Now, the l2 penalty in the elastic net encourages features which have coefficients treated as indistinguishable by just the loss and l1 penalty to have equal estimated coefficient. We can loosely see this by noticing that $(a,b) = \arg\min_{a',b': c = |a'| + |b'|} (a')^2 + (b')^2$ satisfies $|a| = |b|$. Due to this, the elastic net makes it so that we're less likely to 'accidentally' make vanish a coefficient estimate which is in the true support. That is, the true support is more likely to be contained within the estimated support. That's good! It does mean there's more false discoveries, but that's a price that most people are willing to pay.
As an aside, it's worth pointing out that the fact that highly correlated features will tend to have very similar coefficient estimates makes it so that we can detect groupings of features within the estimated support which influence the response similarly.
Prediction
Now, we move on to prediction. As Matthew Gunn points out, choosing tuning parameters through cross validation creates an aim to choose a model with minimal prediction error. Since any model selected by the lasso can be selected by the elastic net (by taking $\alpha = 1$), it makes some sense that the elastic net is able to find a model that predicts better than the lasso.
Lederer, Yu, and Gaynanova show, under no assumptions whatsoever on the features, that the lasso and elastic net can both have their l2 prediction error bounded by the same quantity. It's not necessarily true that their bound is tight, but this might be interesting to note since oracle inequalities seem to be a standard way in statistical literature to quantify the predictive performance of estimators--perhaps since the distributions are so complicated! It's also worth noting that Lederer (1)(2) has some papers on lasso predictions in the presence of correlated features.
Summary
In summary, the problems of interest are the true support being within the estimated support and prediction. For support recovery, there's rigorously proven guarantees (through Wainwright) that the lasso selects the correct features to be in the model under assumptions of low correlation between the true support and it's complement. However, in the presence of correlation, we can fall back to the elastic net to be more likely to select the features in the true support to be among all that it selects. (Note that we have to carefully select the tuning parameters here.) And, for prediction when we choose the tuning parameter through cross validation, it makes intuitive sense that the elastic net should perform better than the lasso--especially in the presence of correlation.
Putting aside prediction and some formality, what did we learn? We learned about the true support.
Confidence Intervals
It's worth pointing out that a lot has changed in the past 2 years in regards to valid inference for the lasso. In particular, the work by Lee, Sun, Sun, and Taylor provides exact inference for the coefficients of the lasso conditional on the given model being selected. (Results on inference in lasso for the true coefficients was around at the time of OP's post, and they're well summarized in the linked paper.)
|
Elastic/ridge/lasso analysis, what then?
|
These methods--the lasso and elastic net--were born out of the problems of both feature selection and prediction. It's through these two lenses that I think an explanation can be found.
Matthew Gunn n
|
Elastic/ridge/lasso analysis, what then?
These methods--the lasso and elastic net--were born out of the problems of both feature selection and prediction. It's through these two lenses that I think an explanation can be found.
Matthew Gunn nicely explains in his reply that these two goals are distinct and often taken up by different people. However, fortunately for us, the methods we're interested in can perform well in both arenas.
Feature Selection
First, let's talk about feature selection. We should first motivate the elastic net from the perspective of the lasso. That is, to quote Hastie and Zou, "If there is a group of variables among which the pairwise correlations are very high, then the lasso tends to select only one variable from the group and does not care which one is selected." This is a problem, for instance, because it means that we're not likely to find an element of the true support using the lasso--just one highly correlated with it. (The paper mentions that this is proven in the LARS paper, which I haven't read yet.) The difficulty of support recovery in the presence of correlation is also pointed out by Wainwright, who showed (in theorem 2a) that the probability of support recovery is bounded above by $0.5$ when there's high correlation between the true support and it's complement.
Now, the l2 penalty in the elastic net encourages features which have coefficients treated as indistinguishable by just the loss and l1 penalty to have equal estimated coefficient. We can loosely see this by noticing that $(a,b) = \arg\min_{a',b': c = |a'| + |b'|} (a')^2 + (b')^2$ satisfies $|a| = |b|$. Due to this, the elastic net makes it so that we're less likely to 'accidentally' make vanish a coefficient estimate which is in the true support. That is, the true support is more likely to be contained within the estimated support. That's good! It does mean there's more false discoveries, but that's a price that most people are willing to pay.
As an aside, it's worth pointing out that the fact that highly correlated features will tend to have very similar coefficient estimates makes it so that we can detect groupings of features within the estimated support which influence the response similarly.
Prediction
Now, we move on to prediction. As Matthew Gunn points out, choosing tuning parameters through cross validation creates an aim to choose a model with minimal prediction error. Since any model selected by the lasso can be selected by the elastic net (by taking $\alpha = 1$), it makes some sense that the elastic net is able to find a model that predicts better than the lasso.
Lederer, Yu, and Gaynanova show, under no assumptions whatsoever on the features, that the lasso and elastic net can both have their l2 prediction error bounded by the same quantity. It's not necessarily true that their bound is tight, but this might be interesting to note since oracle inequalities seem to be a standard way in statistical literature to quantify the predictive performance of estimators--perhaps since the distributions are so complicated! It's also worth noting that Lederer (1)(2) has some papers on lasso predictions in the presence of correlated features.
Summary
In summary, the problems of interest are the true support being within the estimated support and prediction. For support recovery, there's rigorously proven guarantees (through Wainwright) that the lasso selects the correct features to be in the model under assumptions of low correlation between the true support and it's complement. However, in the presence of correlation, we can fall back to the elastic net to be more likely to select the features in the true support to be among all that it selects. (Note that we have to carefully select the tuning parameters here.) And, for prediction when we choose the tuning parameter through cross validation, it makes intuitive sense that the elastic net should perform better than the lasso--especially in the presence of correlation.
Putting aside prediction and some formality, what did we learn? We learned about the true support.
Confidence Intervals
It's worth pointing out that a lot has changed in the past 2 years in regards to valid inference for the lasso. In particular, the work by Lee, Sun, Sun, and Taylor provides exact inference for the coefficients of the lasso conditional on the given model being selected. (Results on inference in lasso for the true coefficients was around at the time of OP's post, and they're well summarized in the linked paper.)
|
Elastic/ridge/lasso analysis, what then?
These methods--the lasso and elastic net--were born out of the problems of both feature selection and prediction. It's through these two lenses that I think an explanation can be found.
Matthew Gunn n
|
14,125
|
Elastic/ridge/lasso analysis, what then?
|
What you're doing with elastic, ridge, or lasso, using cross-validation to choose regularization parameters, is fitting some linear form to optimize prediction. Why these particular regularization parameters? Because they work best for prediction on new data. Shrinking coefficient estimates towards zero, introducing bias, (as is done in either Ridge or Lasso) can reduce overfitting and shrink variance. The idea is for your penalty parameters to strike the right balance in order to optimize prediction on new data.
Imagine the data generating process is:
$$ y_i = f(\mathbf{x}_i, \beta) + \epsilon_i$$
Let $\hat{\beta}$ be our estimate of parameters $\beta$, and let $\hat{y}_j$ be our forecast for observation $j$
How should you present your results? It depends what your underlying research question is! You may want to step back and think deeply about what question you're trying to answer. What does your audience care about? What are you trying to do?
Prediction?
Estimate coefficients?
Variable selection?
It's important to distinguish between two types of research questions:
Questions where you predominantly care about prediction, that is you care about $\hat{y}_j$
Questions where you predominantly care about parameter estimates $\hat{\beta}$.
Off the shelf machine learning techniques can be extremely powerful for the former, $\hat{y}$ prediction problems. As you appear to be recognizing though, standard off the shelf machine learning techniques may be extremely problematic for $\hat{\beta}$, parameter estimate problems:
In a high dimensional setting, many different parameterization will give you the same predictions $\hat{y}$. If number of parameters $k$ is high relative to the number of observations $n$, you may not be able to estimate any individual parameter well.
Algorithms trained on different folds may have significantly different parameter estimates.
The emphasis in machine learning is on prediction, not consistently estimating causal effects. (This contrasts with econometrics where typically the main issue is in consistently estimating causal effects). Prediction, estimating some functional form, is different than estimating causation. Police levels may be a good predictor of crime levels, and this doesn't mean police cause crime.
And as you recognize, there may be issues in interpreting why some machine learning parameterization works. Is your audience comfortable with a prediction black box? Or is how prediction works central to your question?
Lasso and Ridge: classic reasons to use them
You can use elastic net for classic machine learning, prediction problems, situations where your main concern is $\hat{y}$. In some sense regularization allows you to include more predictors but still keep overfitting under control.
You can use regularization to prevent overfitting. Eg. ridge regression in the context of polynomial curve fitting can work quite nicely.
As @Benjamin points out in his answer, Lasso can also be used for variable selection. Under certain regularity conditions, Lasso will consistently select the appropriate model: irrelevant coefficients will be set to zero.
The $L_1$ and $L_2$ penalties, of Lasso and Ridge respectively, bias the coefficient estimates toward zero. If the bias is big, this could be a serious issue if you're trying to interpret coefficient estimates. And to get standard error estimates, you need to do something like bootstrapping; there aren't simple closed form solutions (that I'm aware of). Ridge, lasso, and elastic net have similarities to regular OLS regression, but the regularization and variable selection make inference quite different...
What I keep coming back to is that it's quite difficult to interpret the results of running ridge regression, lasso, or elastic net without some more context of what you're trying to figure out!
Prof. Sendhil Mullainathan gave a talk on machine learning at the January, 2017 AFA meeting which motivated parts of this post.
|
Elastic/ridge/lasso analysis, what then?
|
What you're doing with elastic, ridge, or lasso, using cross-validation to choose regularization parameters, is fitting some linear form to optimize prediction. Why these particular regularization par
|
Elastic/ridge/lasso analysis, what then?
What you're doing with elastic, ridge, or lasso, using cross-validation to choose regularization parameters, is fitting some linear form to optimize prediction. Why these particular regularization parameters? Because they work best for prediction on new data. Shrinking coefficient estimates towards zero, introducing bias, (as is done in either Ridge or Lasso) can reduce overfitting and shrink variance. The idea is for your penalty parameters to strike the right balance in order to optimize prediction on new data.
Imagine the data generating process is:
$$ y_i = f(\mathbf{x}_i, \beta) + \epsilon_i$$
Let $\hat{\beta}$ be our estimate of parameters $\beta$, and let $\hat{y}_j$ be our forecast for observation $j$
How should you present your results? It depends what your underlying research question is! You may want to step back and think deeply about what question you're trying to answer. What does your audience care about? What are you trying to do?
Prediction?
Estimate coefficients?
Variable selection?
It's important to distinguish between two types of research questions:
Questions where you predominantly care about prediction, that is you care about $\hat{y}_j$
Questions where you predominantly care about parameter estimates $\hat{\beta}$.
Off the shelf machine learning techniques can be extremely powerful for the former, $\hat{y}$ prediction problems. As you appear to be recognizing though, standard off the shelf machine learning techniques may be extremely problematic for $\hat{\beta}$, parameter estimate problems:
In a high dimensional setting, many different parameterization will give you the same predictions $\hat{y}$. If number of parameters $k$ is high relative to the number of observations $n$, you may not be able to estimate any individual parameter well.
Algorithms trained on different folds may have significantly different parameter estimates.
The emphasis in machine learning is on prediction, not consistently estimating causal effects. (This contrasts with econometrics where typically the main issue is in consistently estimating causal effects). Prediction, estimating some functional form, is different than estimating causation. Police levels may be a good predictor of crime levels, and this doesn't mean police cause crime.
And as you recognize, there may be issues in interpreting why some machine learning parameterization works. Is your audience comfortable with a prediction black box? Or is how prediction works central to your question?
Lasso and Ridge: classic reasons to use them
You can use elastic net for classic machine learning, prediction problems, situations where your main concern is $\hat{y}$. In some sense regularization allows you to include more predictors but still keep overfitting under control.
You can use regularization to prevent overfitting. Eg. ridge regression in the context of polynomial curve fitting can work quite nicely.
As @Benjamin points out in his answer, Lasso can also be used for variable selection. Under certain regularity conditions, Lasso will consistently select the appropriate model: irrelevant coefficients will be set to zero.
The $L_1$ and $L_2$ penalties, of Lasso and Ridge respectively, bias the coefficient estimates toward zero. If the bias is big, this could be a serious issue if you're trying to interpret coefficient estimates. And to get standard error estimates, you need to do something like bootstrapping; there aren't simple closed form solutions (that I'm aware of). Ridge, lasso, and elastic net have similarities to regular OLS regression, but the regularization and variable selection make inference quite different...
What I keep coming back to is that it's quite difficult to interpret the results of running ridge regression, lasso, or elastic net without some more context of what you're trying to figure out!
Prof. Sendhil Mullainathan gave a talk on machine learning at the January, 2017 AFA meeting which motivated parts of this post.
|
Elastic/ridge/lasso analysis, what then?
What you're doing with elastic, ridge, or lasso, using cross-validation to choose regularization parameters, is fitting some linear form to optimize prediction. Why these particular regularization par
|
14,126
|
Test for difference between 2 empirical discrete distributions
|
The Kolmogorov-Smirnov can still be used, but if you use the tabulated critical values it will be conservative (which is only a problem because it pushes down your power curve). Better to get the permutation distribution of the statistic, so that your significance levels are what you choose them to be. This will only make a big difference if there are a lot of ties. This change is really easy to implement. (But the K-S test isn't the only possible such comparison; if one is computing permutation distributions anyway, there are other possibilities.)
Edit: Alexis kindly supplies a reference in comments below,
"Article detailing exact distribution of K-S test statistic when accounting for ties:
Schröer, G., & Trenkler, D. (1995). Exact and randomization distributions of Kolmogorov-Smirnov tests two or three samples. Computational Statistics & Data Analysis, 20, 185–202."
I have not yet had a chance to look at it, but it sounds directly relevant and I thought I should highlight its existence for anyone not inclined to read the valuable comments.
vanilla chi-square goodness of fit tests for discrete data are generally, to my mind, a really bad idea. If the above potential loss of power stopped you using the K-S test, the problem with the chi-square is often much worse - it throws out the most critical information, which is the ordering among the categories (the observation values), deflating its power by spreading it across alternatives that don't consider the ordering, so that it's worse at detecting smooth alternatives -- like a shift of location and scale for example). Even with the bad effects of heavy ties above, the KS test in many cases still have better power (while still lowering the Type I error rate).
The chi-square can also be modified to take account of the ordering (partition the chisquare into linear, quadratic, cubic etc components via orthogonal polynomials and use only the low order few terms - 4 to 6 are common choices). Papers by Rayner and Best (and others) discuss this approach, which arises out of Neyman-Barton smooth tests. This is a good approach but if you don't have access to software for it, it may take a little setting up.
Either modified approach should be fine, but if you're not going to modify either approach, it's not necessarily the case that the chi-square will be better than the KS test -- in some situations it might be better ... or it may be substantially worse.
If the ties are light (i.e. there are lots of different values taken by the data), I'd consider the KS as-is. If they're moderate, I'd look to calculate the permutation distribution. If they're very heavy (i.e. the data only take a few different values), the plain chi-square may be competitive.
|
Test for difference between 2 empirical discrete distributions
|
The Kolmogorov-Smirnov can still be used, but if you use the tabulated critical values it will be conservative (which is only a problem because it pushes down your power curve). Better to get the perm
|
Test for difference between 2 empirical discrete distributions
The Kolmogorov-Smirnov can still be used, but if you use the tabulated critical values it will be conservative (which is only a problem because it pushes down your power curve). Better to get the permutation distribution of the statistic, so that your significance levels are what you choose them to be. This will only make a big difference if there are a lot of ties. This change is really easy to implement. (But the K-S test isn't the only possible such comparison; if one is computing permutation distributions anyway, there are other possibilities.)
Edit: Alexis kindly supplies a reference in comments below,
"Article detailing exact distribution of K-S test statistic when accounting for ties:
Schröer, G., & Trenkler, D. (1995). Exact and randomization distributions of Kolmogorov-Smirnov tests two or three samples. Computational Statistics & Data Analysis, 20, 185–202."
I have not yet had a chance to look at it, but it sounds directly relevant and I thought I should highlight its existence for anyone not inclined to read the valuable comments.
vanilla chi-square goodness of fit tests for discrete data are generally, to my mind, a really bad idea. If the above potential loss of power stopped you using the K-S test, the problem with the chi-square is often much worse - it throws out the most critical information, which is the ordering among the categories (the observation values), deflating its power by spreading it across alternatives that don't consider the ordering, so that it's worse at detecting smooth alternatives -- like a shift of location and scale for example). Even with the bad effects of heavy ties above, the KS test in many cases still have better power (while still lowering the Type I error rate).
The chi-square can also be modified to take account of the ordering (partition the chisquare into linear, quadratic, cubic etc components via orthogonal polynomials and use only the low order few terms - 4 to 6 are common choices). Papers by Rayner and Best (and others) discuss this approach, which arises out of Neyman-Barton smooth tests. This is a good approach but if you don't have access to software for it, it may take a little setting up.
Either modified approach should be fine, but if you're not going to modify either approach, it's not necessarily the case that the chi-square will be better than the KS test -- in some situations it might be better ... or it may be substantially worse.
If the ties are light (i.e. there are lots of different values taken by the data), I'd consider the KS as-is. If they're moderate, I'd look to calculate the permutation distribution. If they're very heavy (i.e. the data only take a few different values), the plain chi-square may be competitive.
|
Test for difference between 2 empirical discrete distributions
The Kolmogorov-Smirnov can still be used, but if you use the tabulated critical values it will be conservative (which is only a problem because it pushes down your power curve). Better to get the perm
|
14,127
|
Can Hazard Ratio be translated into ratio of medians of survival time?
|
Your intuition is correct. The following relationship between survival functions holds:
$$
S_1(t)=S_0(t)^r
$$
where $r$ is the hazard ratio (see, e.g. the Wikipedia article Hazard ratio). From this we may show that your statement implies an exponential survival function.
Let us denote the medians by $M_r$, $M_1$ for two variables with hazard ratio $r$. Your statement implies
$$
M_r = M_0/r
$$
From the definition of the median, we get
$$
S_r(M_0/r)=0.5
$$
Then, we substitute the relationship between survival functions
$$
S_0(M_0/r)^r=0.5 \Rightarrow S_0(M_0/r) = 0.5^{1/r}
$$
This holds for any $r$, hence
$$
S_0(t) = 0.5^{t/M_0} = e^{t\frac{\log 0.5}{M_0}}
$$
Hence, if the statement in your question holds for arbitrary HR, the survival distribution must be exponential.
|
Can Hazard Ratio be translated into ratio of medians of survival time?
|
Your intuition is correct. The following relationship between survival functions holds:
$$
S_1(t)=S_0(t)^r
$$
where $r$ is the hazard ratio (see, e.g. the Wikipedia article Hazard ratio). From this we
|
Can Hazard Ratio be translated into ratio of medians of survival time?
Your intuition is correct. The following relationship between survival functions holds:
$$
S_1(t)=S_0(t)^r
$$
where $r$ is the hazard ratio (see, e.g. the Wikipedia article Hazard ratio). From this we may show that your statement implies an exponential survival function.
Let us denote the medians by $M_r$, $M_1$ for two variables with hazard ratio $r$. Your statement implies
$$
M_r = M_0/r
$$
From the definition of the median, we get
$$
S_r(M_0/r)=0.5
$$
Then, we substitute the relationship between survival functions
$$
S_0(M_0/r)^r=0.5 \Rightarrow S_0(M_0/r) = 0.5^{1/r}
$$
This holds for any $r$, hence
$$
S_0(t) = 0.5^{t/M_0} = e^{t\frac{\log 0.5}{M_0}}
$$
Hence, if the statement in your question holds for arbitrary HR, the survival distribution must be exponential.
|
Can Hazard Ratio be translated into ratio of medians of survival time?
Your intuition is correct. The following relationship between survival functions holds:
$$
S_1(t)=S_0(t)^r
$$
where $r$ is the hazard ratio (see, e.g. the Wikipedia article Hazard ratio). From this we
|
14,128
|
How to choose the right optimization algorithm?
|
Based on what you said: I assume you have to optimize for 50 variables; I also assume that you are having a situation that it is very expensive to find analytical derivatives (let alone get numericals out) and that your optimization is unconstrained.
Let me stress, you are a bit unluckily cause between 25-30 and 100 variables it is a bit of twilight zone when it comes to choosing between large or small scale optimization routines. Having said that though, nothing is lost.
Given that even first order derivative are expensive to get that kind off kills the idea of Newton's method. You might have some luck with Quasi-Newton (BFGS) though if your Hessian is slightly diagonal like to start with. C-G is usually a bit slower than BFGS so probably that won't be improve things a lot; use it if memory is also an issue (or just go for L-BFGS in that case).
Additionally given how slow it is to evaluate your function, a simple steepest descent/line search algorithm would be tortuously slow; same things goes with Simulated Annealing and other random search variants (I assume you don't have access to HMC and all that jazz).
So, when you need the best bang for your buck when it comes to a single function evaluation: Go with Powell's method and also test COBYLA; despite being a constrained optimization algorithm because it will internally linear approximate your function's gradient to speed up things, it will be able to take advantage of your function's linearity. Also definitely try NLopt for Python. They have a lot of gradient-free optimizers; try UOBYQA; it's Powell's brainchild also (Unconstrained Optimization BY Quadratic Approximations).
Very briefly : The N-CG algorithms depends on computing the Hessian, and your Hessian seems very expensive to compute. NLCG and BFGS don't require it although the might try to try compute it once in their first step.
I left out the simplex algorithm on purpose because it's a totally different beast; nothing to do with gradients as such. Try it but I can't really comment on it; it is really dependent on your problem's nature.
For a first good reference on numerical optimization C.T.Kelly's book Iterative Methods for Optimization will get you quite far, quite nicely.
|
How to choose the right optimization algorithm?
|
Based on what you said: I assume you have to optimize for 50 variables; I also assume that you are having a situation that it is very expensive to find analytical derivatives (let alone get numericals
|
How to choose the right optimization algorithm?
Based on what you said: I assume you have to optimize for 50 variables; I also assume that you are having a situation that it is very expensive to find analytical derivatives (let alone get numericals out) and that your optimization is unconstrained.
Let me stress, you are a bit unluckily cause between 25-30 and 100 variables it is a bit of twilight zone when it comes to choosing between large or small scale optimization routines. Having said that though, nothing is lost.
Given that even first order derivative are expensive to get that kind off kills the idea of Newton's method. You might have some luck with Quasi-Newton (BFGS) though if your Hessian is slightly diagonal like to start with. C-G is usually a bit slower than BFGS so probably that won't be improve things a lot; use it if memory is also an issue (or just go for L-BFGS in that case).
Additionally given how slow it is to evaluate your function, a simple steepest descent/line search algorithm would be tortuously slow; same things goes with Simulated Annealing and other random search variants (I assume you don't have access to HMC and all that jazz).
So, when you need the best bang for your buck when it comes to a single function evaluation: Go with Powell's method and also test COBYLA; despite being a constrained optimization algorithm because it will internally linear approximate your function's gradient to speed up things, it will be able to take advantage of your function's linearity. Also definitely try NLopt for Python. They have a lot of gradient-free optimizers; try UOBYQA; it's Powell's brainchild also (Unconstrained Optimization BY Quadratic Approximations).
Very briefly : The N-CG algorithms depends on computing the Hessian, and your Hessian seems very expensive to compute. NLCG and BFGS don't require it although the might try to try compute it once in their first step.
I left out the simplex algorithm on purpose because it's a totally different beast; nothing to do with gradients as such. Try it but I can't really comment on it; it is really dependent on your problem's nature.
For a first good reference on numerical optimization C.T.Kelly's book Iterative Methods for Optimization will get you quite far, quite nicely.
|
How to choose the right optimization algorithm?
Based on what you said: I assume you have to optimize for 50 variables; I also assume that you are having a situation that it is very expensive to find analytical derivatives (let alone get numericals
|
14,129
|
How to choose the right optimization algorithm?
|
Maybe you should get yourself an introductory book about numerical optimization. You will need to take into account your function in order to decide for the algorithm.
Among the algorithms you mention, important differences are whether the Jacobian
or Hessian is needed or only the function itself.
Considering that this is a statistics Q&A site and thus deals with random variables: make sure your function is deterministic can be evaluated in a way that yields continuous results over the search space.
|
How to choose the right optimization algorithm?
|
Maybe you should get yourself an introductory book about numerical optimization. You will need to take into account your function in order to decide for the algorithm.
Among the algorithms you mention
|
How to choose the right optimization algorithm?
Maybe you should get yourself an introductory book about numerical optimization. You will need to take into account your function in order to decide for the algorithm.
Among the algorithms you mention, important differences are whether the Jacobian
or Hessian is needed or only the function itself.
Considering that this is a statistics Q&A site and thus deals with random variables: make sure your function is deterministic can be evaluated in a way that yields continuous results over the search space.
|
How to choose the right optimization algorithm?
Maybe you should get yourself an introductory book about numerical optimization. You will need to take into account your function in order to decide for the algorithm.
Among the algorithms you mention
|
14,130
|
Time series and anomaly detection
|
Regarding your first question, I would recommend that you read this famous article (Clustering of Time Series Subsequences is Meaningless) before doing clustering on a time series. It is clearly written and illustrates many pitfalls that you want to avoid.
|
Time series and anomaly detection
|
Regarding your first question, I would recommend that you read this famous article (Clustering of Time Series Subsequences is Meaningless) before doing clustering on a time series. It is clearly writt
|
Time series and anomaly detection
Regarding your first question, I would recommend that you read this famous article (Clustering of Time Series Subsequences is Meaningless) before doing clustering on a time series. It is clearly written and illustrates many pitfalls that you want to avoid.
|
Time series and anomaly detection
Regarding your first question, I would recommend that you read this famous article (Clustering of Time Series Subsequences is Meaningless) before doing clustering on a time series. It is clearly writt
|
14,131
|
Time series and anomaly detection
|
Anomaly detection or "Intervention Detection" has been championd by G.C.Tiao and others. To do science is to search for repeated patterns.To detect anomalies is to identify values that do not follow repeated patterns. We learn from Newton "Whoever knows the ways of Nature will more easily notice her deviations and, on the other hand, whoever knows her deviations will more accurately describe her ways". One learns the rules by observing when the current rules fail. Consider the time series 1,9,1,9,1,9,5,9 . To identify the anomaly one needs to have a pattern. The "5" is as much an anomaly as "14" would be . To identifY the pattern simply use ARIMA and in this case the "anomaly" becomes obvious. Try different software/approaches and see which one suggests an ARIMA model of order 1,0,0 with a coefficient of -1.0 . Use google/search procedures to find "automatic arima" or "automatic intervention detection". You may be disappointed by free stuff as it might be worth what you pay for it. Writing it yourself might be interesting if you have a heavy time series background and a couple of years to waste.There are serious limitations to distance based methods http://www3.ntu.edu.sg/SCE/pakdd2006/tutorial/chawla_tutorial_pakddslides.pdf
|
Time series and anomaly detection
|
Anomaly detection or "Intervention Detection" has been championd by G.C.Tiao and others. To do science is to search for repeated patterns.To detect anomalies is to identify values that do not follow
|
Time series and anomaly detection
Anomaly detection or "Intervention Detection" has been championd by G.C.Tiao and others. To do science is to search for repeated patterns.To detect anomalies is to identify values that do not follow repeated patterns. We learn from Newton "Whoever knows the ways of Nature will more easily notice her deviations and, on the other hand, whoever knows her deviations will more accurately describe her ways". One learns the rules by observing when the current rules fail. Consider the time series 1,9,1,9,1,9,5,9 . To identify the anomaly one needs to have a pattern. The "5" is as much an anomaly as "14" would be . To identifY the pattern simply use ARIMA and in this case the "anomaly" becomes obvious. Try different software/approaches and see which one suggests an ARIMA model of order 1,0,0 with a coefficient of -1.0 . Use google/search procedures to find "automatic arima" or "automatic intervention detection". You may be disappointed by free stuff as it might be worth what you pay for it. Writing it yourself might be interesting if you have a heavy time series background and a couple of years to waste.There are serious limitations to distance based methods http://www3.ntu.edu.sg/SCE/pakdd2006/tutorial/chawla_tutorial_pakddslides.pdf
|
Time series and anomaly detection
Anomaly detection or "Intervention Detection" has been championd by G.C.Tiao and others. To do science is to search for repeated patterns.To detect anomalies is to identify values that do not follow
|
14,132
|
Time series and anomaly detection
|
For time series anomaly detection there can be multiple approaches. As you have said, if you are using ARIMA as the model, you can use MAPE or SMAPE as the error metric and use a confidence threshold using it. Anything falling beyond the CI band can be an anomaly. Similarly you can go for DBSCAN or statistical profiling based approaches. For more information you can go through these links:
https://towardsdatascience.com/effective-approaches-for-time-series-anomaly-detection-9485b40077f1
https://www.aditya-bhattacharya.com/?p=72&page=4
Let me know if it helps. :)
|
Time series and anomaly detection
|
For time series anomaly detection there can be multiple approaches. As you have said, if you are using ARIMA as the model, you can use MAPE or SMAPE as the error metric and use a confidence threshold
|
Time series and anomaly detection
For time series anomaly detection there can be multiple approaches. As you have said, if you are using ARIMA as the model, you can use MAPE or SMAPE as the error metric and use a confidence threshold using it. Anything falling beyond the CI band can be an anomaly. Similarly you can go for DBSCAN or statistical profiling based approaches. For more information you can go through these links:
https://towardsdatascience.com/effective-approaches-for-time-series-anomaly-detection-9485b40077f1
https://www.aditya-bhattacharya.com/?p=72&page=4
Let me know if it helps. :)
|
Time series and anomaly detection
For time series anomaly detection there can be multiple approaches. As you have said, if you are using ARIMA as the model, you can use MAPE or SMAPE as the error metric and use a confidence threshold
|
14,133
|
How does gradient boosting calculate probability estimates?
|
TL;DR: The log-odds for a sample is the sum of the weights of its terminal leafs. The probability of the sample belonging to class 1 is the inverse-logit transformation of the sum.
Analogously to logistic regression, the logistic function computes probabilities that are linear on the logit scale:
$$
z = Xw \\
\mathbb{P}(y=1|X) = \frac{1}{1 + \exp(-z)}
$$
Unlike logistic regression, the "features" in $X$ are constructed as the terminal nodes of an ensemble of decision trees using the boosting procedure. Each row of $X$ collects the terminal leafs for each sample; the row is a $T$-hot binary vector, for $T$ the number of trees. (Each XGBoost tree is generated according to a particular algorithm, but that's not relevant here.)
There are $n$ columns in $X$, one column for each terminal node. There is no expression for the total number of terminal nodes, because the number of nodes can vary between trees (and usually does, in my experience).
Each leaf in the tree has an associated "weight." That weight is recorded in $w$. To be conformable with $X$, there are $n$ elements in $w$. The weights themselves are derived from the gradient boosting procedure; see: In XGboost are weights estimated for each sample and then averaged
|
How does gradient boosting calculate probability estimates?
|
TL;DR: The log-odds for a sample is the sum of the weights of its terminal leafs. The probability of the sample belonging to class 1 is the inverse-logit transformation of the sum.
Analogously to log
|
How does gradient boosting calculate probability estimates?
TL;DR: The log-odds for a sample is the sum of the weights of its terminal leafs. The probability of the sample belonging to class 1 is the inverse-logit transformation of the sum.
Analogously to logistic regression, the logistic function computes probabilities that are linear on the logit scale:
$$
z = Xw \\
\mathbb{P}(y=1|X) = \frac{1}{1 + \exp(-z)}
$$
Unlike logistic regression, the "features" in $X$ are constructed as the terminal nodes of an ensemble of decision trees using the boosting procedure. Each row of $X$ collects the terminal leafs for each sample; the row is a $T$-hot binary vector, for $T$ the number of trees. (Each XGBoost tree is generated according to a particular algorithm, but that's not relevant here.)
There are $n$ columns in $X$, one column for each terminal node. There is no expression for the total number of terminal nodes, because the number of nodes can vary between trees (and usually does, in my experience).
Each leaf in the tree has an associated "weight." That weight is recorded in $w$. To be conformable with $X$, there are $n$ elements in $w$. The weights themselves are derived from the gradient boosting procedure; see: In XGboost are weights estimated for each sample and then averaged
|
How does gradient boosting calculate probability estimates?
TL;DR: The log-odds for a sample is the sum of the weights of its terminal leafs. The probability of the sample belonging to class 1 is the inverse-logit transformation of the sum.
Analogously to log
|
14,134
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
|
There are several reasons that can cause fluctuations in training loss over epochs. The main one though is the fact that almost all neural nets are trained with different forms of stochastic gradient descent. This is why batch_size parameter exists which determines how many samples you want to use to make one update to the model parameters. If you use all the samples for each update, you should see it decreasing and finally reaching a limit. Note that there are other reasons for the loss having some stochastic behavior.
This explains why we see oscillations. But in your case, it is more that normal I would say. Looking at your code, I see two possible sources.
Large network, small dataset: It seems you are training a relatively large network with 200K+ parameters with a very small number of samples, ~100. To put this into perspective, you want to learn 200K parameters or find a good local minimum in a 200K-D space using only 100 samples. Thus, you might end up just wandering around rather than locking down on a good local minima. (The wandering is also due to the second reason below).
Very small batch_size. You use very small batch_size. So it's like you are trusting every small portion of the data points. Let's say within your data points, you have a mislabeled sample. This sample when combined with 2-3 even properly labeled samples, can result in an update which does not decrease the global loss, but increase it, or throw it away from a local minima. When the batch_size is larger, such effects would be reduced. Along with other reasons, it's good to have batch_size higher than some minimum. Having it too large would also make training go slow. Therefore, batch_size should be treated as a hyperparameter.
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
|
There are several reasons that can cause fluctuations in training loss over epochs. The main one though is the fact that almost all neural nets are trained with different forms of stochastic gradient
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
There are several reasons that can cause fluctuations in training loss over epochs. The main one though is the fact that almost all neural nets are trained with different forms of stochastic gradient descent. This is why batch_size parameter exists which determines how many samples you want to use to make one update to the model parameters. If you use all the samples for each update, you should see it decreasing and finally reaching a limit. Note that there are other reasons for the loss having some stochastic behavior.
This explains why we see oscillations. But in your case, it is more that normal I would say. Looking at your code, I see two possible sources.
Large network, small dataset: It seems you are training a relatively large network with 200K+ parameters with a very small number of samples, ~100. To put this into perspective, you want to learn 200K parameters or find a good local minimum in a 200K-D space using only 100 samples. Thus, you might end up just wandering around rather than locking down on a good local minima. (The wandering is also due to the second reason below).
Very small batch_size. You use very small batch_size. So it's like you are trusting every small portion of the data points. Let's say within your data points, you have a mislabeled sample. This sample when combined with 2-3 even properly labeled samples, can result in an update which does not decrease the global loss, but increase it, or throw it away from a local minima. When the batch_size is larger, such effects would be reduced. Along with other reasons, it's good to have batch_size higher than some minimum. Having it too large would also make training go slow. Therefore, batch_size should be treated as a hyperparameter.
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
There are several reasons that can cause fluctuations in training loss over epochs. The main one though is the fact that almost all neural nets are trained with different forms of stochastic gradient
|
14,135
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
|
Your loss curve doesn't look so bad to me. It should definitely "fluctuate" up and down a bit, as long as the general trend is that it is going down - this makes sense.
Batch size will also play into how your network learns, so you might want to optimize that along with your learning rate. Also, I would plot the entire curve (until it reaches 100% accuracy/minimum loss). It sounds like you trained it for 800 epochs and are only showing the first 50 epochs - the whole curve will likely give a very different story.
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
|
Your loss curve doesn't look so bad to me. It should definitely "fluctuate" up and down a bit, as long as the general trend is that it is going down - this makes sense.
Batch size will also play into
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
Your loss curve doesn't look so bad to me. It should definitely "fluctuate" up and down a bit, as long as the general trend is that it is going down - this makes sense.
Batch size will also play into how your network learns, so you might want to optimize that along with your learning rate. Also, I would plot the entire curve (until it reaches 100% accuracy/minimum loss). It sounds like you trained it for 800 epochs and are only showing the first 50 epochs - the whole curve will likely give a very different story.
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
Your loss curve doesn't look so bad to me. It should definitely "fluctuate" up and down a bit, as long as the general trend is that it is going down - this makes sense.
Batch size will also play into
|
14,136
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
|
The fluctuations are normal within certain limits and depend on the fact that you use a heuristic method but in your case they are excessive. Despite all the performance takes a definite direction and therefore the system works. From the graphs you have posted, the problem depends on your data so it's a difficult training. If you have already tried to change the learning rate try to change training algorithm. You would agree to test your data: first compute the Bayes error rate using a KNN (use the trick regression in case you need), in this way you can check whether the input data contain all the information you need. Then try the LSTM without the validation or dropout to verify that it has the ability to achieve the result for you necessary. If the training algorithm is not suitable you should have the same problems even without the validation or dropout. Just at the end adjust the training and the validation size to get the best result in the test set.
Statistical learning theory is not a topic that can be talked about at one time, we must proceed step by step.
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
|
The fluctuations are normal within certain limits and depend on the fact that you use a heuristic method but in your case they are excessive. Despite all the performance takes a definite direction and
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
The fluctuations are normal within certain limits and depend on the fact that you use a heuristic method but in your case they are excessive. Despite all the performance takes a definite direction and therefore the system works. From the graphs you have posted, the problem depends on your data so it's a difficult training. If you have already tried to change the learning rate try to change training algorithm. You would agree to test your data: first compute the Bayes error rate using a KNN (use the trick regression in case you need), in this way you can check whether the input data contain all the information you need. Then try the LSTM without the validation or dropout to verify that it has the ability to achieve the result for you necessary. If the training algorithm is not suitable you should have the same problems even without the validation or dropout. Just at the end adjust the training and the validation size to get the best result in the test set.
Statistical learning theory is not a topic that can be talked about at one time, we must proceed step by step.
|
Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)
The fluctuations are normal within certain limits and depend on the fact that you use a heuristic method but in your case they are excessive. Despite all the performance takes a definite direction and
|
14,137
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
|
The starred step is valid because (a) $p$ and $q$ have the same zeroth and second moments and (b) $\log(p)$ is a polynomial function of the components of $\mathbf{x}$ whose terms have total degrees $0$ or $2$.
You need to know only two things about a multivariate normal distribution with zero mean:
$\log(p)$ is a quadratic function of $\mathbf{x}=(x_1,x_2,\ldots,x_n)$ with no linear terms. Specifically, there are constants $C$ and $p_{ij}$ for which $$\log(p(\mathbf{x}))=C + \sum_{i,j=1}^n p_{ij}\, x_i x_j.$$
(Of course $C$ and the $p_{ij}$ can be written in terms of $\Sigma$, but this detail does not matter.)
$\Sigma$ gives the second moments of the distribution. That is, $$\Sigma_{ij}=E_p(x_i x_j) = \int p(\mathbf{x})\, x_ix_j\, d\mathbf{x}.$$
We may use this information to work out an integral:
$$\eqalign{
& &\int(q(\mathbf{x}) - p(\mathbf{x}))\log(p(\mathbf{x}))d\mathbf{x} \\
&= &\int(q(\mathbf{x}) - p(\mathbf{x}))\left(C + \sum_{i,j=1}^n p_{ij}\, x_i x_j\right)d\mathbf{x}.
}$$
It breaks into the sum of two parts:
$\int(q(x) - p(x))C\, d\mathbf{x} = C\left(\int q(\mathbf{x}) d\mathbf{x} - \int p(\mathbf{x}) d\mathbf{x}\right) = C(1 - 1) = 0$, because both $q$ and $p$ are probability density functions.
$\int(q(\mathbf{x}) - p(\mathbf{x})) \sum_{i,j=1}^n p_{ij}\, x_i x_jd\mathbf{x} = \sum_{i,j=1}^n p_{ij}\int(q(\mathbf{x}) - p(\mathbf{x}))x_i x_jd\mathbf{x} = 0$ because each of the integrals on the right hand side, $\int q(\mathbf{x}) x_i x_jd\mathbf{x}$ and $\int p(\mathbf{x}) x_i x_jd\mathbf{x}$, has the same value (to wit, $\Sigma_{ij}$). This is what the remark "yield the same moments of the quadratic form" is intended to say.
The result follows immediately: since $\int(q(\mathbf{x}) - p(\mathbf{x}))\log(p(\mathbf{x}))d\mathbf{x}=0$, we conclude that $\int q(\mathbf{x})\log(p(\mathbf{x}))d\mathbf{x} = \int p(\mathbf{x})\log(p(\mathbf{x}))d\mathbf{x}.$
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
|
The starred step is valid because (a) $p$ and $q$ have the same zeroth and second moments and (b) $\log(p)$ is a polynomial function of the components of $\mathbf{x}$ whose terms have total degrees $0
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
The starred step is valid because (a) $p$ and $q$ have the same zeroth and second moments and (b) $\log(p)$ is a polynomial function of the components of $\mathbf{x}$ whose terms have total degrees $0$ or $2$.
You need to know only two things about a multivariate normal distribution with zero mean:
$\log(p)$ is a quadratic function of $\mathbf{x}=(x_1,x_2,\ldots,x_n)$ with no linear terms. Specifically, there are constants $C$ and $p_{ij}$ for which $$\log(p(\mathbf{x}))=C + \sum_{i,j=1}^n p_{ij}\, x_i x_j.$$
(Of course $C$ and the $p_{ij}$ can be written in terms of $\Sigma$, but this detail does not matter.)
$\Sigma$ gives the second moments of the distribution. That is, $$\Sigma_{ij}=E_p(x_i x_j) = \int p(\mathbf{x})\, x_ix_j\, d\mathbf{x}.$$
We may use this information to work out an integral:
$$\eqalign{
& &\int(q(\mathbf{x}) - p(\mathbf{x}))\log(p(\mathbf{x}))d\mathbf{x} \\
&= &\int(q(\mathbf{x}) - p(\mathbf{x}))\left(C + \sum_{i,j=1}^n p_{ij}\, x_i x_j\right)d\mathbf{x}.
}$$
It breaks into the sum of two parts:
$\int(q(x) - p(x))C\, d\mathbf{x} = C\left(\int q(\mathbf{x}) d\mathbf{x} - \int p(\mathbf{x}) d\mathbf{x}\right) = C(1 - 1) = 0$, because both $q$ and $p$ are probability density functions.
$\int(q(\mathbf{x}) - p(\mathbf{x})) \sum_{i,j=1}^n p_{ij}\, x_i x_jd\mathbf{x} = \sum_{i,j=1}^n p_{ij}\int(q(\mathbf{x}) - p(\mathbf{x}))x_i x_jd\mathbf{x} = 0$ because each of the integrals on the right hand side, $\int q(\mathbf{x}) x_i x_jd\mathbf{x}$ and $\int p(\mathbf{x}) x_i x_jd\mathbf{x}$, has the same value (to wit, $\Sigma_{ij}$). This is what the remark "yield the same moments of the quadratic form" is intended to say.
The result follows immediately: since $\int(q(\mathbf{x}) - p(\mathbf{x}))\log(p(\mathbf{x}))d\mathbf{x}=0$, we conclude that $\int q(\mathbf{x})\log(p(\mathbf{x}))d\mathbf{x} = \int p(\mathbf{x})\log(p(\mathbf{x}))d\mathbf{x}.$
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
The starred step is valid because (a) $p$ and $q$ have the same zeroth and second moments and (b) $\log(p)$ is a polynomial function of the components of $\mathbf{x}$ whose terms have total degrees $0
|
14,138
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
|
I think what happens is that in the integrals in both (4.27) and (4.28) you have $q(x)$ and $p(x)$ multiplying terms of the form $\sigma_{ij}x_ix_j$ (because $p(x)$ is a normal density, when you take the log you obtain just such kind of terms from the exponent plus constants). But then the condition in the theorem ensures that those terms multiplied by either $p(x)$ of $q(x)$ integrate to the same value.
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
|
I think what happens is that in the integrals in both (4.27) and (4.28) you have $q(x)$ and $p(x)$ multiplying terms of the form $\sigma_{ij}x_ix_j$ (because $p(x)$ is a normal density, when you take
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
I think what happens is that in the integrals in both (4.27) and (4.28) you have $q(x)$ and $p(x)$ multiplying terms of the form $\sigma_{ij}x_ix_j$ (because $p(x)$ is a normal density, when you take the log you obtain just such kind of terms from the exponent plus constants). But then the condition in the theorem ensures that those terms multiplied by either $p(x)$ of $q(x)$ integrate to the same value.
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
I think what happens is that in the integrals in both (4.27) and (4.28) you have $q(x)$ and $p(x)$ multiplying terms of the form $\sigma_{ij}x_ix_j$ (because $p(x)$ is a normal density, when you take
|
14,139
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
|
We can also verify the above result by solving the constrained optimization problem. For simplicity, let's prove for one dimensional random variable $X$ first (with $\Sigma=[\sigma^2]$ fixed, with $V(X) = E[(X-\mu)^2]=\sigma^2$, where $E[X]=\mu$), that can be generalized to multliple dimensions (random vectors). Let the pdf of $X$ be $p(.)$, then the constrained maximization problem becomes the following:
$\begin{align}
\underset{p}{maximize \;} H(p) & \\
s.t. \int{(x-\mu)^2p(x)dx} &=\sigma^2 \; \text{and}\\
\int{p(x)}dx=1
\end{align}$,
where entropy $H(p)=-\int{p(x)\log p(x)}dx$ and the integrals are evaluated over the range of $X$.
The Lagrangian
$\mathcal{L}(p(x), \lambda_1, \lambda_2)=-\int{p(x)\log p(x)}dx + \lambda_1\left( \int{(x-\mu)^2p(x)dx} - \sigma^2\right)+\lambda_2\left(\int{p(x)}dx-1\right)$
$\therefore \frac{\partial \mathcal{L}}{\partial p(x)}$
$=\int{\left(-(1+\log p(x))+\lambda_1(x-\mu)^2+\lambda_2\right)}dx = 0$, at a critical point
$\Rightarrow \log p(x) = \lambda_1(x-\mu)^2+\lambda_2-1$
$\Rightarrow p(x) = e^{-\lambda_1(x-\mu)^2+\lambda_2-1}$
$\Rightarrow p(x) \propto e^{-\lambda_1(x-\mu)^2}$, which is a Gaussian p.d,f.
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
|
We can also verify the above result by solving the constrained optimization problem. For simplicity, let's prove for one dimensional random variable $X$ first (with $\Sigma=[\sigma^2]$ fixed, with $V(
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
We can also verify the above result by solving the constrained optimization problem. For simplicity, let's prove for one dimensional random variable $X$ first (with $\Sigma=[\sigma^2]$ fixed, with $V(X) = E[(X-\mu)^2]=\sigma^2$, where $E[X]=\mu$), that can be generalized to multliple dimensions (random vectors). Let the pdf of $X$ be $p(.)$, then the constrained maximization problem becomes the following:
$\begin{align}
\underset{p}{maximize \;} H(p) & \\
s.t. \int{(x-\mu)^2p(x)dx} &=\sigma^2 \; \text{and}\\
\int{p(x)}dx=1
\end{align}$,
where entropy $H(p)=-\int{p(x)\log p(x)}dx$ and the integrals are evaluated over the range of $X$.
The Lagrangian
$\mathcal{L}(p(x), \lambda_1, \lambda_2)=-\int{p(x)\log p(x)}dx + \lambda_1\left( \int{(x-\mu)^2p(x)dx} - \sigma^2\right)+\lambda_2\left(\int{p(x)}dx-1\right)$
$\therefore \frac{\partial \mathcal{L}}{\partial p(x)}$
$=\int{\left(-(1+\log p(x))+\lambda_1(x-\mu)^2+\lambda_2\right)}dx = 0$, at a critical point
$\Rightarrow \log p(x) = \lambda_1(x-\mu)^2+\lambda_2-1$
$\Rightarrow p(x) = e^{-\lambda_1(x-\mu)^2+\lambda_2-1}$
$\Rightarrow p(x) \propto e^{-\lambda_1(x-\mu)^2}$, which is a Gaussian p.d,f.
|
Prove that the maximum entropy distribution with a fixed covariance matrix is a Gaussian
We can also verify the above result by solving the constrained optimization problem. For simplicity, let's prove for one dimensional random variable $X$ first (with $\Sigma=[\sigma^2]$ fixed, with $V(
|
14,140
|
What measure of training error to report for Random Forests?
|
To add to @Soren H. Welling's answer.
1. Is it generally accepted to report OOB training error as the training error measure for random forests?
No. OOB error on the trained model is not the same as training error. It can, however, serve as a measure of predictive accuracy.
2. Is it true that the traditional measure of training error is artificially low?
This is true if we are running a classification problem using default settings. The exact process is described in a forum post by Andy Liaw, who maintains the randomForest package in R, as follows:
For the most part, performance on training set is meaningless. (That's
the case for most algorithms, but especially so for RF.) In the default
(and recommended) setting, the trees are grown to the maximum size,
which means that quite likely there's only one data point in most
terminal nodes, and the prediction at the terminal nodes are determined
by the majority class in the node, or the lone data point. Suppose that
is the case all the time; i.e., in all trees all terminal nodes have
only one data point. A particular data point would be "in-bag" in about
64% of the trees in the forest, and every one of those trees has the
correct prediction for that data point. Even if all the trees where
that data points are out-of-bag gave the wrong prediction, by majority
vote of all trees, you still get the right answer in the end. Thus
basically the perfect prediction on train set for RF is "by design".
To avoid this behavior, one can set nodesize > 1 (so that the trees are not grown to maximum size) and/or set sampsize < 0.5N (so that fewer than 50% of trees are likely to contain a given point $(x_i,y_i)$.
3. If the traditional measure of training error is artificially low, then what two measures can I compare to check if the RF is overfitting?
If we run RF with nodesize = 1 and sampsize > 0.5, then the training error of the RF will always be near 0. In this case, the only way to tell if the model is overfitting is to keep some data as an independent validation set. We can then compare the 10-CV test error (or the OOB test error) to the error on the independent validation set. If the 10-CV test error is much lower than the error on the independent validation set, then the model may be overfitting.
|
What measure of training error to report for Random Forests?
|
To add to @Soren H. Welling's answer.
1. Is it generally accepted to report OOB training error as the training error measure for random forests?
No. OOB error on the trained model is not the same as t
|
What measure of training error to report for Random Forests?
To add to @Soren H. Welling's answer.
1. Is it generally accepted to report OOB training error as the training error measure for random forests?
No. OOB error on the trained model is not the same as training error. It can, however, serve as a measure of predictive accuracy.
2. Is it true that the traditional measure of training error is artificially low?
This is true if we are running a classification problem using default settings. The exact process is described in a forum post by Andy Liaw, who maintains the randomForest package in R, as follows:
For the most part, performance on training set is meaningless. (That's
the case for most algorithms, but especially so for RF.) In the default
(and recommended) setting, the trees are grown to the maximum size,
which means that quite likely there's only one data point in most
terminal nodes, and the prediction at the terminal nodes are determined
by the majority class in the node, or the lone data point. Suppose that
is the case all the time; i.e., in all trees all terminal nodes have
only one data point. A particular data point would be "in-bag" in about
64% of the trees in the forest, and every one of those trees has the
correct prediction for that data point. Even if all the trees where
that data points are out-of-bag gave the wrong prediction, by majority
vote of all trees, you still get the right answer in the end. Thus
basically the perfect prediction on train set for RF is "by design".
To avoid this behavior, one can set nodesize > 1 (so that the trees are not grown to maximum size) and/or set sampsize < 0.5N (so that fewer than 50% of trees are likely to contain a given point $(x_i,y_i)$.
3. If the traditional measure of training error is artificially low, then what two measures can I compare to check if the RF is overfitting?
If we run RF with nodesize = 1 and sampsize > 0.5, then the training error of the RF will always be near 0. In this case, the only way to tell if the model is overfitting is to keep some data as an independent validation set. We can then compare the 10-CV test error (or the OOB test error) to the error on the independent validation set. If the 10-CV test error is much lower than the error on the independent validation set, then the model may be overfitting.
|
What measure of training error to report for Random Forests?
To add to @Soren H. Welling's answer.
1. Is it generally accepted to report OOB training error as the training error measure for random forests?
No. OOB error on the trained model is not the same as t
|
14,141
|
What measure of training error to report for Random Forests?
|
[edited 21.7.15 8:31 AM CEST]
I suppose you used RF for classification. Because in this case, the algorithm produces fully grown trees with pure terminal nodes of only one target class.
predict(model, data=X_train)
This line of coding is like a dog chasing [~66% of] its own tail. The prediction of any training sample is the class of the training sample itself. For regression RF stops if node has 5 or less samples in it or if node is pure. Here prediction error will be small but not 0%.
In machine learning we often work with large hypothesis spaces. This means there will always be many not yet falsified hypothesis/explanations/models to data structure of our training set. In classical statistics is the hypothesis space often small and therefore the direct model-fit is informative accordingly to some assumed probability theory. In machine learning does the direct lack-of-fit relate to the bias of the model. Bias is the "inflexibility" of the model. It does not in anyway provide a approximation of generalization power(the ability to predict new events). For algorithmic models cross-validation is the best tool to approximate generalization power, as no theory is formulated. However, if model assumptions of independent sampling fail, the model may be useless anyhow, even when a well performed cross-validation suggested otherwise. In the end, the strongest proof is to satisfyingly predict a number external test-sets of various origin.
Back to CV: Out-of-bag is often a accepted type of CV. I would personally hold that OOB-CV provides similar results as 5-fold-CV, but this is a very small nuisance. If to compare let's say RF to SVM, then OOB-CV is not usefull as we would normally avoid to bag SVM. Instead then both SVM and RF would be embedded in the exact same cross-validation scheme e.g. 10-fold 10-repeats with matching partitions for each repeat. Any feature engineering steps would often also be needed to be cross-validated. If to keep things clean the entire data pipe-line could be embedded in the CV.
If you tune your model with your test-set(or cross-validation) you're again inflating your hypothesis space and the validated prediction performance is likely over-optimistic. Instead you will need a calibration-set(or calibration CV-loop) to tune and a test validation set(or validation CV-loop) to assess your final optimal model.
In the extreme sense, your validation score will only be unbiased if your never act on this result, when you see it. This is the paradox of validation, as why would we obtain a knowledge which is only true if you do not act on it. In practice the community willingly accepts some publication bias, where those researchers who got a over-optimistic validation at random are more likely to publish, than those who unluckily good a over-pessimistic validation. Therefore sometimes why can't reproduce others models.
|
What measure of training error to report for Random Forests?
|
[edited 21.7.15 8:31 AM CEST]
I suppose you used RF for classification. Because in this case, the algorithm produces fully grown trees with pure terminal nodes of only one target class.
predict(model
|
What measure of training error to report for Random Forests?
[edited 21.7.15 8:31 AM CEST]
I suppose you used RF for classification. Because in this case, the algorithm produces fully grown trees with pure terminal nodes of only one target class.
predict(model, data=X_train)
This line of coding is like a dog chasing [~66% of] its own tail. The prediction of any training sample is the class of the training sample itself. For regression RF stops if node has 5 or less samples in it or if node is pure. Here prediction error will be small but not 0%.
In machine learning we often work with large hypothesis spaces. This means there will always be many not yet falsified hypothesis/explanations/models to data structure of our training set. In classical statistics is the hypothesis space often small and therefore the direct model-fit is informative accordingly to some assumed probability theory. In machine learning does the direct lack-of-fit relate to the bias of the model. Bias is the "inflexibility" of the model. It does not in anyway provide a approximation of generalization power(the ability to predict new events). For algorithmic models cross-validation is the best tool to approximate generalization power, as no theory is formulated. However, if model assumptions of independent sampling fail, the model may be useless anyhow, even when a well performed cross-validation suggested otherwise. In the end, the strongest proof is to satisfyingly predict a number external test-sets of various origin.
Back to CV: Out-of-bag is often a accepted type of CV. I would personally hold that OOB-CV provides similar results as 5-fold-CV, but this is a very small nuisance. If to compare let's say RF to SVM, then OOB-CV is not usefull as we would normally avoid to bag SVM. Instead then both SVM and RF would be embedded in the exact same cross-validation scheme e.g. 10-fold 10-repeats with matching partitions for each repeat. Any feature engineering steps would often also be needed to be cross-validated. If to keep things clean the entire data pipe-line could be embedded in the CV.
If you tune your model with your test-set(or cross-validation) you're again inflating your hypothesis space and the validated prediction performance is likely over-optimistic. Instead you will need a calibration-set(or calibration CV-loop) to tune and a test validation set(or validation CV-loop) to assess your final optimal model.
In the extreme sense, your validation score will only be unbiased if your never act on this result, when you see it. This is the paradox of validation, as why would we obtain a knowledge which is only true if you do not act on it. In practice the community willingly accepts some publication bias, where those researchers who got a over-optimistic validation at random are more likely to publish, than those who unluckily good a over-pessimistic validation. Therefore sometimes why can't reproduce others models.
|
What measure of training error to report for Random Forests?
[edited 21.7.15 8:31 AM CEST]
I suppose you used RF for classification. Because in this case, the algorithm produces fully grown trees with pure terminal nodes of only one target class.
predict(model
|
14,142
|
Smoothing - when to use it and when not to?
|
Exponential Smoothing is a classic technique used in noncausal time series forecasting. As long as you only use it in straightforward forecasting and don't use in-sample smoothed fits as an input to another data mining or statistical algorithm, Briggs' critique does not apply. (Accordingly, I am skeptical about using it "to produce smoothed data for presentation", as Wikipedia says - this may well be misleading, by hiding the smoothed-away variability.)
Here is a textbook introduction to Exponential Smoothing.
And here is a (10-year-old, but still relevant) review article.
EDIT: there seems to be some doubt about the validity of Briggs' critique, possibly somewhat influenced by its packaging. I fully agree that Briggs' tone can be abrasive. However, I'd like to illustrate why I think he has a point.
Below, I'm simulating 10,000 pairs of time series, of 100 observations each. All series are white noise, with no correlation whatsoever. So running a standard correlation test should yield p values that are uniformly distributed on [0,1]. As it does (histogram on the left below).
However, suppose we first smooth each series and apply the correlation test to the smoothed data. Something surprising appears: since we have removed a lot of variability from the data, we get p values that are far too small. Our correlation test is heavily biased. So we will be too certain of any association between the original series, which is what Briggs is saying.
The question really hangs on whether we use the smoothed data for forecasting, in which case smoothing is valid, or whether we include it as an input in some analytical algorithm, in which case removing variability will simulate higher certainty in our data than is warranted. This unwarranted certainty in input data carries through to end results and needs to be accounted for, otherwise all inferences will be too certain. (And of course we will also get too small prediction intervals if we use a model based on "inflated certainty" for forecasting.)
n.series <- 1e4
n.time <- 1e2
p.corr <- p.corr.smoothed <- rep(NA,n.series)
set.seed(1)
for ( ii in 1:n.series ) {
A <- rnorm(n.time)
B <- rnorm(n.time)
p.corr[ii] <- cor.test(A,B)$p.value
p.corr.smoothed[ii] <- cor.test(lowess(A)$y,lowess(B)$y)$p.value
}
par(mfrow=c(1,2))
hist(p.corr,col="grey",xlab="",main="p values\nunsmoothed data")
hist(p.corr.smoothed,col="grey",xlab="",main="p values\nsmoothed data")
|
Smoothing - when to use it and when not to?
|
Exponential Smoothing is a classic technique used in noncausal time series forecasting. As long as you only use it in straightforward forecasting and don't use in-sample smoothed fits as an input to a
|
Smoothing - when to use it and when not to?
Exponential Smoothing is a classic technique used in noncausal time series forecasting. As long as you only use it in straightforward forecasting and don't use in-sample smoothed fits as an input to another data mining or statistical algorithm, Briggs' critique does not apply. (Accordingly, I am skeptical about using it "to produce smoothed data for presentation", as Wikipedia says - this may well be misleading, by hiding the smoothed-away variability.)
Here is a textbook introduction to Exponential Smoothing.
And here is a (10-year-old, but still relevant) review article.
EDIT: there seems to be some doubt about the validity of Briggs' critique, possibly somewhat influenced by its packaging. I fully agree that Briggs' tone can be abrasive. However, I'd like to illustrate why I think he has a point.
Below, I'm simulating 10,000 pairs of time series, of 100 observations each. All series are white noise, with no correlation whatsoever. So running a standard correlation test should yield p values that are uniformly distributed on [0,1]. As it does (histogram on the left below).
However, suppose we first smooth each series and apply the correlation test to the smoothed data. Something surprising appears: since we have removed a lot of variability from the data, we get p values that are far too small. Our correlation test is heavily biased. So we will be too certain of any association between the original series, which is what Briggs is saying.
The question really hangs on whether we use the smoothed data for forecasting, in which case smoothing is valid, or whether we include it as an input in some analytical algorithm, in which case removing variability will simulate higher certainty in our data than is warranted. This unwarranted certainty in input data carries through to end results and needs to be accounted for, otherwise all inferences will be too certain. (And of course we will also get too small prediction intervals if we use a model based on "inflated certainty" for forecasting.)
n.series <- 1e4
n.time <- 1e2
p.corr <- p.corr.smoothed <- rep(NA,n.series)
set.seed(1)
for ( ii in 1:n.series ) {
A <- rnorm(n.time)
B <- rnorm(n.time)
p.corr[ii] <- cor.test(A,B)$p.value
p.corr.smoothed[ii] <- cor.test(lowess(A)$y,lowess(B)$y)$p.value
}
par(mfrow=c(1,2))
hist(p.corr,col="grey",xlab="",main="p values\nunsmoothed data")
hist(p.corr.smoothed,col="grey",xlab="",main="p values\nsmoothed data")
|
Smoothing - when to use it and when not to?
Exponential Smoothing is a classic technique used in noncausal time series forecasting. As long as you only use it in straightforward forecasting and don't use in-sample smoothed fits as an input to a
|
14,143
|
Smoothing - when to use it and when not to?
|
Claiming that smoothing is inappropriate for a modeling analysis condemns it to having higher mean square error than it otherwise might. Mean square error or MSE can be decomposed into three terms, a square of a value called ``bias'', a variance, and some irreducible error. (This is shown in the citations below.) Excessively smoothed models have a high bias, even if they have low variance, and too rough models have high variances, and low bias.
There's nothing philosophical about this at all. It is a mathematical characterization. It does not depend upon the character of the noise or the character of the system.
See:
http://scott.fortmann-roe.com/docs/BiasVariance.html
https://galton.uchicago.edu/~lafferty/pdf/nonparam.pdf
http://www.inf.ed.ac.uk/teaching/courses/mlsc/Notes/Lecture4/BiasVariance.pdf
(This has the derivation of the decomposition.)
http://www.cs.columbia.edu/~blei/fogm/2015F/notes/regularized-regression.pdf
(Blei does the same in a different way, and brings in what happens when one tries to predict.)
Classical statistics almost always insisted upon unbiased estimates. In 1955, statistician Charles Stein of Stanford showed that there were combinations of unbiased estimators which had lower MSE for important special cases, notably what became called the JAMES-STEIN ESTIMATORS. Bradley Efron wrote a very approachable text about this revolution in insight: http://statweb.stanford.edu/~ckirby/brad/other/Article1977.pdf
|
Smoothing - when to use it and when not to?
|
Claiming that smoothing is inappropriate for a modeling analysis condemns it to having higher mean square error than it otherwise might. Mean square error or MSE can be decomposed into three terms, a
|
Smoothing - when to use it and when not to?
Claiming that smoothing is inappropriate for a modeling analysis condemns it to having higher mean square error than it otherwise might. Mean square error or MSE can be decomposed into three terms, a square of a value called ``bias'', a variance, and some irreducible error. (This is shown in the citations below.) Excessively smoothed models have a high bias, even if they have low variance, and too rough models have high variances, and low bias.
There's nothing philosophical about this at all. It is a mathematical characterization. It does not depend upon the character of the noise or the character of the system.
See:
http://scott.fortmann-roe.com/docs/BiasVariance.html
https://galton.uchicago.edu/~lafferty/pdf/nonparam.pdf
http://www.inf.ed.ac.uk/teaching/courses/mlsc/Notes/Lecture4/BiasVariance.pdf
(This has the derivation of the decomposition.)
http://www.cs.columbia.edu/~blei/fogm/2015F/notes/regularized-regression.pdf
(Blei does the same in a different way, and brings in what happens when one tries to predict.)
Classical statistics almost always insisted upon unbiased estimates. In 1955, statistician Charles Stein of Stanford showed that there were combinations of unbiased estimators which had lower MSE for important special cases, notably what became called the JAMES-STEIN ESTIMATORS. Bradley Efron wrote a very approachable text about this revolution in insight: http://statweb.stanford.edu/~ckirby/brad/other/Article1977.pdf
|
Smoothing - when to use it and when not to?
Claiming that smoothing is inappropriate for a modeling analysis condemns it to having higher mean square error than it otherwise might. Mean square error or MSE can be decomposed into three terms, a
|
14,144
|
Logistic Regression : How to obtain a saturated model
|
For each $y_i$, the fitted probability from the saturated model will be the same as $y_i$, either zero or one. As explained here, the likelihood of the saturated model is $1$. Therefore, the deviance of such model will be $-2\log(1/1) = 0$, on $0$ df. Here is an example from R:
y = c(1,1,1,0,0,0)
a <- factor(1:length(y))
fit <- glm(y~a,family=binomial)
summary(fit)
Deviance Residuals:
0 0 0 0 0 0
Null deviance: 8.3178e+00 on 5 degrees of freedom
Residual deviance: 2.5720e-10 on 0 degrees of freedom
The saturated model always has $n$ parameters where $n$ is the sample size. That's why the null deviance is always on $(n - 1)$ df, since the null model has only the intercept. E.g., if I add one replicate for each of the six factor levels, I will get the following:
> k2
[1] 1 2 3 4 5 6 1 2 3 4 5 6
Levels: 1 2 3 4 5 6
> y2
[1] 1 1 1 0 0 0 1 1 1 0 0 0
> fit3 = glm(y2 ~ k2, family = binomial)
> summary(fit3)
Null deviance: 1.6636e+01 on 11 degrees of freedom
Residual deviance: 5.1440e-10 on 6 degrees of freedom
Actually, it turns out that in R what the saturated model is depends on the form of input even if the data are exactly the same, which is not very nice. In particular, in the example above there are 12 observations and 6 factor levels, so the saturated model should have had 6 parameters, not 12. In general, a saturated model is defined as one where the number of parameters is equal to the number of distinct covariate patterns. I have no idea why R code "admitted" that factor k2 has 6 distinct levels, and yet the saturated model was fitted with 12 parameters.
Now, if we use exactly the same data in "binomial" form, we'll get a correct answer:
y_yes = 2 * c(1,1,1,0,0,0)
y_no = 2 * c(0,0,0,1,1,1)
x = factor(c(1:6))
> x
[1] 1 2 3 4 5 6
Levels: 1 2 3 4 5 6
> y_yes
[1] 2 2 2 0 0 0
> y_no
[1] 0 0 0 2 2 2
modelBinomialForm = glm(cbind(y_yes, y_no) ~ x, family=binomial)
Deviance Residuals:
[1] 0 0 0 0 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.490e+01 1.096e+05 0 1
x2 1.375e-08 1.550e+05 0 1
x3 1.355e-08 1.550e+05 0 1
x4 -4.980e+01 1.550e+05 0 1
x5 -4.980e+01 1.550e+05 0 1
x6 -4.980e+01 1.550e+05 0 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1.6636e+01 on 5 degrees of freedom
Residual deviance: 3.6749e-10 on 0 degrees of freedom
Now we see that the saturated model has 6 parameters and it coincides with the fitted model. Hence, the null deviance is on (6 - 1) = 5 df, and the residual deviance is on (6-6) = 0 df.
|
Logistic Regression : How to obtain a saturated model
|
For each $y_i$, the fitted probability from the saturated model will be the same as $y_i$, either zero or one. As explained here, the likelihood of the saturated model is $1$. Therefore, the deviance
|
Logistic Regression : How to obtain a saturated model
For each $y_i$, the fitted probability from the saturated model will be the same as $y_i$, either zero or one. As explained here, the likelihood of the saturated model is $1$. Therefore, the deviance of such model will be $-2\log(1/1) = 0$, on $0$ df. Here is an example from R:
y = c(1,1,1,0,0,0)
a <- factor(1:length(y))
fit <- glm(y~a,family=binomial)
summary(fit)
Deviance Residuals:
0 0 0 0 0 0
Null deviance: 8.3178e+00 on 5 degrees of freedom
Residual deviance: 2.5720e-10 on 0 degrees of freedom
The saturated model always has $n$ parameters where $n$ is the sample size. That's why the null deviance is always on $(n - 1)$ df, since the null model has only the intercept. E.g., if I add one replicate for each of the six factor levels, I will get the following:
> k2
[1] 1 2 3 4 5 6 1 2 3 4 5 6
Levels: 1 2 3 4 5 6
> y2
[1] 1 1 1 0 0 0 1 1 1 0 0 0
> fit3 = glm(y2 ~ k2, family = binomial)
> summary(fit3)
Null deviance: 1.6636e+01 on 11 degrees of freedom
Residual deviance: 5.1440e-10 on 6 degrees of freedom
Actually, it turns out that in R what the saturated model is depends on the form of input even if the data are exactly the same, which is not very nice. In particular, in the example above there are 12 observations and 6 factor levels, so the saturated model should have had 6 parameters, not 12. In general, a saturated model is defined as one where the number of parameters is equal to the number of distinct covariate patterns. I have no idea why R code "admitted" that factor k2 has 6 distinct levels, and yet the saturated model was fitted with 12 parameters.
Now, if we use exactly the same data in "binomial" form, we'll get a correct answer:
y_yes = 2 * c(1,1,1,0,0,0)
y_no = 2 * c(0,0,0,1,1,1)
x = factor(c(1:6))
> x
[1] 1 2 3 4 5 6
Levels: 1 2 3 4 5 6
> y_yes
[1] 2 2 2 0 0 0
> y_no
[1] 0 0 0 2 2 2
modelBinomialForm = glm(cbind(y_yes, y_no) ~ x, family=binomial)
Deviance Residuals:
[1] 0 0 0 0 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.490e+01 1.096e+05 0 1
x2 1.375e-08 1.550e+05 0 1
x3 1.355e-08 1.550e+05 0 1
x4 -4.980e+01 1.550e+05 0 1
x5 -4.980e+01 1.550e+05 0 1
x6 -4.980e+01 1.550e+05 0 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1.6636e+01 on 5 degrees of freedom
Residual deviance: 3.6749e-10 on 0 degrees of freedom
Now we see that the saturated model has 6 parameters and it coincides with the fitted model. Hence, the null deviance is on (6 - 1) = 5 df, and the residual deviance is on (6-6) = 0 df.
|
Logistic Regression : How to obtain a saturated model
For each $y_i$, the fitted probability from the saturated model will be the same as $y_i$, either zero or one. As explained here, the likelihood of the saturated model is $1$. Therefore, the deviance
|
14,145
|
How to understand the correlation coefficient formula?
|
In the comments, 15 ways to understand the correlation coefficent were suggested:
"Thirteen Ways to Look at the Correlation Coefficient" (Rodgers & Nicewander 1988)
Via covariance
Via circles
The 13 ways discussed in the Rodgers and Nicewander article (The American Statistician, February 1988) are
A Function of Raw Scores and Means,
$$r =\frac{\sum\left(X_i - \bar{X}\right)\left(Y_i - \bar{Y}\right)}{\sqrt{\sum\left(X_i-\bar{X}\right)^2\left(Y_i-\bar{Y}\right)^2}}.$$
Standardized Covariance,
$$r = s_{XY}/(s_Xs_Y)$$
where $s_{XY}$ is sample covariance and $s_X$ and $s_Y$ are sample standard deviations.
Standardized Slope of the Regression Line,
$$r = b_{Y\cdot X}\frac{s_X}{s_Y} = b_{X\cdot Y}\frac{s_Y}{s_X},$$
where $b_{Y\cdot X}$ and $b_{X \cdot Y}$ are the slopes of the regression lines.
The Geometric Mean of the Two Regression Slopes,
$$r = \pm \sqrt{b_{Y\cdot X}b_{X\cdot Y}}.$$
The Square Root of the Ratio of Two Variances (Proportion of Variability Accounted For),
$$r = \sqrt{\frac{\sum\left(Y_i - \hat{Y_i}\right)^2}{\sum\left(Y_i-\bar{Y}\right)^2}} = \sqrt{\frac{SS_{REG}}{SS_{TOT}}} = \frac{s_\hat{Y}}{s_Y}.$$
The Mean Cross-Product of Standardized Variables,
$$r = \sum z_X z_Y / N.$$
A Function of the Angle Between the Two Standardized Regression Lines. The two regression lines (of $Y$ vs. $X$ and $X$ vs. $Y$) are symmetric about the diagonal. Let the angle between the two lines be $\beta$. Then
$$r = \sec(\beta)\pm \tan(\beta).$$
A Function of the Angle Between the Two Variable Vectors,
$$r = \cos(\alpha).$$
A Rescaled Variance of the Difference Between Standardized Scores. Letting $z_Y - z_X$ be the difference between standardized $X$ and $Y$ variables for each observation,
$$r = 1 - s^2_{(z_Y - z_X)} / 2 = s^2_{(z_Y+z_X)}/2 - 1.$$
Estimated from the "Balloon" Rule,
$$r \approx \sqrt{1 - (h/H)^2}$$
where $H$ is the vertical range of the entire $X-Y$ scatterplot and $h$ is the range through the "center of the distribution on the $X$ axis" (that is, through the point of means).
In Relation to the Bivariate Ellipses of Isoconcentration,
$$r = \frac{D^2 - d^2}{D^2 + d^2}$$
where $D$ and $d$ are the major and minor axis lengths, respectively. $r$ also equals the slope of the tangent line of an isocontour (in standardized coordinates) at the point the contour crosses the vertical axis.
A Function of Test Statistics from Designed Experiments,
$$r = \frac{t}{\sqrt{t^2 + n-2}}$$
where $t$ is the test statistic in a two-independent sample $t$ test for a designed experiment with two treatment conditions (coded as $X=0, 1$) and $n$ is the combined total number of observations in the two treatment groups.
The Ratio of Two Means. Assume bivariate normality and standardize the variables. Select some arbitrarily large value $X_c$ of $X$. Then
$$r = \frac{\mathbb{E}(Y\,|\,X\gt X_c)}{\mathbb{E}(X\,|\,X\gt X_c)}.$$
(Most of this is verbatim, with very slight changes in some of the notation.)
Some other methods (perhaps original to this site) are
Via circles. $r$ is the slope of the regression line in standardized coordinates. This line can be characterized in various ways, including geometric ones, such as minimizing the total area of circles drawn between the line and the data points in a scatterplot.
By coloring rectangles. Covariance can be assessed by coloring rectangles in a scatterplot (that is, by summing signed areas of rectangles). When the scatterplot is standardized, the net amount of color--the total signed error--is $r$.
|
How to understand the correlation coefficient formula?
|
In the comments, 15 ways to understand the correlation coefficent were suggested:
"Thirteen Ways to Look at the Correlation Coefficient" (Rodgers & Nicewander 1988)
Via covariance
Via circles
The 1
|
How to understand the correlation coefficient formula?
In the comments, 15 ways to understand the correlation coefficent were suggested:
"Thirteen Ways to Look at the Correlation Coefficient" (Rodgers & Nicewander 1988)
Via covariance
Via circles
The 13 ways discussed in the Rodgers and Nicewander article (The American Statistician, February 1988) are
A Function of Raw Scores and Means,
$$r =\frac{\sum\left(X_i - \bar{X}\right)\left(Y_i - \bar{Y}\right)}{\sqrt{\sum\left(X_i-\bar{X}\right)^2\left(Y_i-\bar{Y}\right)^2}}.$$
Standardized Covariance,
$$r = s_{XY}/(s_Xs_Y)$$
where $s_{XY}$ is sample covariance and $s_X$ and $s_Y$ are sample standard deviations.
Standardized Slope of the Regression Line,
$$r = b_{Y\cdot X}\frac{s_X}{s_Y} = b_{X\cdot Y}\frac{s_Y}{s_X},$$
where $b_{Y\cdot X}$ and $b_{X \cdot Y}$ are the slopes of the regression lines.
The Geometric Mean of the Two Regression Slopes,
$$r = \pm \sqrt{b_{Y\cdot X}b_{X\cdot Y}}.$$
The Square Root of the Ratio of Two Variances (Proportion of Variability Accounted For),
$$r = \sqrt{\frac{\sum\left(Y_i - \hat{Y_i}\right)^2}{\sum\left(Y_i-\bar{Y}\right)^2}} = \sqrt{\frac{SS_{REG}}{SS_{TOT}}} = \frac{s_\hat{Y}}{s_Y}.$$
The Mean Cross-Product of Standardized Variables,
$$r = \sum z_X z_Y / N.$$
A Function of the Angle Between the Two Standardized Regression Lines. The two regression lines (of $Y$ vs. $X$ and $X$ vs. $Y$) are symmetric about the diagonal. Let the angle between the two lines be $\beta$. Then
$$r = \sec(\beta)\pm \tan(\beta).$$
A Function of the Angle Between the Two Variable Vectors,
$$r = \cos(\alpha).$$
A Rescaled Variance of the Difference Between Standardized Scores. Letting $z_Y - z_X$ be the difference between standardized $X$ and $Y$ variables for each observation,
$$r = 1 - s^2_{(z_Y - z_X)} / 2 = s^2_{(z_Y+z_X)}/2 - 1.$$
Estimated from the "Balloon" Rule,
$$r \approx \sqrt{1 - (h/H)^2}$$
where $H$ is the vertical range of the entire $X-Y$ scatterplot and $h$ is the range through the "center of the distribution on the $X$ axis" (that is, through the point of means).
In Relation to the Bivariate Ellipses of Isoconcentration,
$$r = \frac{D^2 - d^2}{D^2 + d^2}$$
where $D$ and $d$ are the major and minor axis lengths, respectively. $r$ also equals the slope of the tangent line of an isocontour (in standardized coordinates) at the point the contour crosses the vertical axis.
A Function of Test Statistics from Designed Experiments,
$$r = \frac{t}{\sqrt{t^2 + n-2}}$$
where $t$ is the test statistic in a two-independent sample $t$ test for a designed experiment with two treatment conditions (coded as $X=0, 1$) and $n$ is the combined total number of observations in the two treatment groups.
The Ratio of Two Means. Assume bivariate normality and standardize the variables. Select some arbitrarily large value $X_c$ of $X$. Then
$$r = \frac{\mathbb{E}(Y\,|\,X\gt X_c)}{\mathbb{E}(X\,|\,X\gt X_c)}.$$
(Most of this is verbatim, with very slight changes in some of the notation.)
Some other methods (perhaps original to this site) are
Via circles. $r$ is the slope of the regression line in standardized coordinates. This line can be characterized in various ways, including geometric ones, such as minimizing the total area of circles drawn between the line and the data points in a scatterplot.
By coloring rectangles. Covariance can be assessed by coloring rectangles in a scatterplot (that is, by summing signed areas of rectangles). When the scatterplot is standardized, the net amount of color--the total signed error--is $r$.
|
How to understand the correlation coefficient formula?
In the comments, 15 ways to understand the correlation coefficent were suggested:
"Thirteen Ways to Look at the Correlation Coefficient" (Rodgers & Nicewander 1988)
Via covariance
Via circles
The 1
|
14,146
|
What are efficient algorithms to compute singular value decomposition (SVD)?
|
The main work-horse behind the computation of SVD is the QR algorithm. Having said that there are many different algorithms to calculate the singular value decomposition of a generic $M$-by-$N$ matrix $A$. A great schematic on the issue available here (from the documentation of Intel's MKL) is the following:
As you see depending on your use case there are different approaches (the routine naming conventions can be found here). That is because, for example there are matrix forms where a Householder reduction can be more expensive than a Givens rotation (to name two "obvious" way of getting QR). A standard reference on the matter is Golub's and Van Loan's Matrix Computations (I would suggest using at least the 3rd edition). I have also found Å. Björck's Numerical Methods for Least Squares Problems very good resource on that matter; while SVD is not the primary focus of the book it helps contextualizing the use it.
If I have to give you one general advice on the matter is do not try to write your own SVD algorithms unless you have successfully taken a couple of classes on Numerical Linear Algebra already and you know what you are doing. I know it sounds counter-intuitive but really, there as a tonne of stuff that can go wrong and you ending up with (at best) sub-optimal implementations (if not wrong). There some very good free suites on the matter (eg. Eigen, Armadillo and Trilinos to name a few.)
|
What are efficient algorithms to compute singular value decomposition (SVD)?
|
The main work-horse behind the computation of SVD is the QR algorithm. Having said that there are many different algorithms to calculate the singular value decomposition of a generic $M$-by-$N$ matrix
|
What are efficient algorithms to compute singular value decomposition (SVD)?
The main work-horse behind the computation of SVD is the QR algorithm. Having said that there are many different algorithms to calculate the singular value decomposition of a generic $M$-by-$N$ matrix $A$. A great schematic on the issue available here (from the documentation of Intel's MKL) is the following:
As you see depending on your use case there are different approaches (the routine naming conventions can be found here). That is because, for example there are matrix forms where a Householder reduction can be more expensive than a Givens rotation (to name two "obvious" way of getting QR). A standard reference on the matter is Golub's and Van Loan's Matrix Computations (I would suggest using at least the 3rd edition). I have also found Å. Björck's Numerical Methods for Least Squares Problems very good resource on that matter; while SVD is not the primary focus of the book it helps contextualizing the use it.
If I have to give you one general advice on the matter is do not try to write your own SVD algorithms unless you have successfully taken a couple of classes on Numerical Linear Algebra already and you know what you are doing. I know it sounds counter-intuitive but really, there as a tonne of stuff that can go wrong and you ending up with (at best) sub-optimal implementations (if not wrong). There some very good free suites on the matter (eg. Eigen, Armadillo and Trilinos to name a few.)
|
What are efficient algorithms to compute singular value decomposition (SVD)?
The main work-horse behind the computation of SVD is the QR algorithm. Having said that there are many different algorithms to calculate the singular value decomposition of a generic $M$-by-$N$ matrix
|
14,147
|
What are the best ways to generate Bayesian prior estimates using beliefs of non-statisticians?
|
This is a good question. I'm going to use a simple example to illustrate my approach.
Suppose I am working with someone who needs to provide me priors on the mean and the variance for a gaussian likelihood. Something like
$$ y \sim \mathcal{N}(\mu, \sigma^2) $$
The question is: "What are this person's priors on $\mu$ and $\sigma^2$?"
For the mean I might ask "Gimme a range on what you think the expected value might be". They might say "between 20 and 30". I'm free to then interpret that as I may (perhaps as the IQR of the prior on $\mu$).
Now, I'll use R (or more likely Stan) to simulate possible scenarios in order to further narrow down what a realistic prior is. So for example, my colleague says $\mu$ is between 20 and 30. Now I have to decide on a prior for $\sigma$. So, I may show them the following and say "which of these four looks more realistic and why?"
They might say "the first is much to variable, and the last two are much to precise. The second looks more realistic, but it is too concentrated at 25!"
At this time, I'll go back and adjust the priors for the mean while narrowing in on a prior for the variance.
This is called a "prior predictive check" -- essentially sampling from the prior to make sure that the priors are actually reflective of what the state of the knowledge is. The process can be slow, but if your collaborators have no data or statistical expertise, then what can they expect of you? Not every parameter can be given a flat prior.
Stan code used to generate samples:
data{
real mu_mean;
real mu_sigma;
real sigma_alpha;
real sigma_beta;
}
generated quantities{
real mu = normal_rng(mu_mean, mu_sigma);
real sigma = gamma_rng(sigma_alpha, sigma_beta);
real y = normal_rng(mu, sigma);
}
R code used to generate figures
library(rstan)
library(tidyverse)
library(patchwork)
make_plot = function(x){
fit1 = sampling(scode, data = x, algorithm = 'Fixed_param', iter = 10000, chains =1 )
t1 = tibble(y = extract(fit1)$y)
p1 = t1 %>%
ggplot(aes(y))+
geom_histogram()+
xlim(0,50)
return(p1)
}
d1 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = 5, sigma_beta = 1)
d2 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = 3, sigma_beta = 1)
d3 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = 1, sigma_beta = 1)
d4 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = .1, sigma_beta = 2)
d = list(d1, d2, d3, d4)
y = map(d, make_plot)
reduce(y,`+`)
|
What are the best ways to generate Bayesian prior estimates using beliefs of non-statisticians?
|
This is a good question. I'm going to use a simple example to illustrate my approach.
Suppose I am working with someone who needs to provide me priors on the mean and the variance for a gaussian like
|
What are the best ways to generate Bayesian prior estimates using beliefs of non-statisticians?
This is a good question. I'm going to use a simple example to illustrate my approach.
Suppose I am working with someone who needs to provide me priors on the mean and the variance for a gaussian likelihood. Something like
$$ y \sim \mathcal{N}(\mu, \sigma^2) $$
The question is: "What are this person's priors on $\mu$ and $\sigma^2$?"
For the mean I might ask "Gimme a range on what you think the expected value might be". They might say "between 20 and 30". I'm free to then interpret that as I may (perhaps as the IQR of the prior on $\mu$).
Now, I'll use R (or more likely Stan) to simulate possible scenarios in order to further narrow down what a realistic prior is. So for example, my colleague says $\mu$ is between 20 and 30. Now I have to decide on a prior for $\sigma$. So, I may show them the following and say "which of these four looks more realistic and why?"
They might say "the first is much to variable, and the last two are much to precise. The second looks more realistic, but it is too concentrated at 25!"
At this time, I'll go back and adjust the priors for the mean while narrowing in on a prior for the variance.
This is called a "prior predictive check" -- essentially sampling from the prior to make sure that the priors are actually reflective of what the state of the knowledge is. The process can be slow, but if your collaborators have no data or statistical expertise, then what can they expect of you? Not every parameter can be given a flat prior.
Stan code used to generate samples:
data{
real mu_mean;
real mu_sigma;
real sigma_alpha;
real sigma_beta;
}
generated quantities{
real mu = normal_rng(mu_mean, mu_sigma);
real sigma = gamma_rng(sigma_alpha, sigma_beta);
real y = normal_rng(mu, sigma);
}
R code used to generate figures
library(rstan)
library(tidyverse)
library(patchwork)
make_plot = function(x){
fit1 = sampling(scode, data = x, algorithm = 'Fixed_param', iter = 10000, chains =1 )
t1 = tibble(y = extract(fit1)$y)
p1 = t1 %>%
ggplot(aes(y))+
geom_histogram()+
xlim(0,50)
return(p1)
}
d1 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = 5, sigma_beta = 1)
d2 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = 3, sigma_beta = 1)
d3 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = 1, sigma_beta = 1)
d4 = list(mu_mean = 25, mu_sigma = 1, sigma_alpha = .1, sigma_beta = 2)
d = list(d1, d2, d3, d4)
y = map(d, make_plot)
reduce(y,`+`)
|
What are the best ways to generate Bayesian prior estimates using beliefs of non-statisticians?
This is a good question. I'm going to use a simple example to illustrate my approach.
Suppose I am working with someone who needs to provide me priors on the mean and the variance for a gaussian like
|
14,148
|
What does "variational" mean?
|
It means using variational inference (at least for the first two).
In short, it's an method to approximate maximum likelihood when the probability density is complicated (and thus MLE is hard).
It uses Evidence Lower Bound (ELBO) as a proxy to ML:
$log(p(x)) \geq \mathbb{E}_q[log(p, Z)] - \mathbb{E}_q[log(q(Z))]$
Where $q$ is simpler distribution on hidden variables (denoted by $Z$) - for example variational autoencoders use normal distribution on encoder's output.
The name 'variational' comes most likely from the fact that it searches for distribution $q$ that optimizes ELBO, and this setup is kind of like in calculus of variations, a field that studies optimization over functions (for example, problems like: given a family of curves in 2D between two points, find one with smallest length).
There's a nice tutorial on variational inference by David Blei that you can check out if you want more concrete description.
EDIT:
Actually what I described is one type of VI: in general you could use different divergence (the one I described corresponds to using KL divergence $KL(q, p)$). For details see this paper, section 5.2 (VI with alternative divergences).
|
What does "variational" mean?
|
It means using variational inference (at least for the first two).
In short, it's an method to approximate maximum likelihood when the probability density is complicated (and thus MLE is hard).
It use
|
What does "variational" mean?
It means using variational inference (at least for the first two).
In short, it's an method to approximate maximum likelihood when the probability density is complicated (and thus MLE is hard).
It uses Evidence Lower Bound (ELBO) as a proxy to ML:
$log(p(x)) \geq \mathbb{E}_q[log(p, Z)] - \mathbb{E}_q[log(q(Z))]$
Where $q$ is simpler distribution on hidden variables (denoted by $Z$) - for example variational autoencoders use normal distribution on encoder's output.
The name 'variational' comes most likely from the fact that it searches for distribution $q$ that optimizes ELBO, and this setup is kind of like in calculus of variations, a field that studies optimization over functions (for example, problems like: given a family of curves in 2D between two points, find one with smallest length).
There's a nice tutorial on variational inference by David Blei that you can check out if you want more concrete description.
EDIT:
Actually what I described is one type of VI: in general you could use different divergence (the one I described corresponds to using KL divergence $KL(q, p)$). For details see this paper, section 5.2 (VI with alternative divergences).
|
What does "variational" mean?
It means using variational inference (at least for the first two).
In short, it's an method to approximate maximum likelihood when the probability density is complicated (and thus MLE is hard).
It use
|
14,149
|
What does "variational" mean?
|
You can find a good explanation in this source by Jason Eisner, where he cites:
The term variational is used because you pick the best q in Q -- the term derives from the "calculus of variations", which deals with optimization problems that pick the best function (in this case, a distribution q).
One way it occurs is when you try to optimize a Functional (a function $F$ that receives a function $q$ and returns a value, e.g. Entropy), so you try to find the best $q$ in a set of functions $Q$ that optimizes $F$.
|
What does "variational" mean?
|
You can find a good explanation in this source by Jason Eisner, where he cites:
The term variational is used because you pick the best q in Q -- the term derives from the "calculus of variations", whi
|
What does "variational" mean?
You can find a good explanation in this source by Jason Eisner, where he cites:
The term variational is used because you pick the best q in Q -- the term derives from the "calculus of variations", which deals with optimization problems that pick the best function (in this case, a distribution q).
One way it occurs is when you try to optimize a Functional (a function $F$ that receives a function $q$ and returns a value, e.g. Entropy), so you try to find the best $q$ in a set of functions $Q$ that optimizes $F$.
|
What does "variational" mean?
You can find a good explanation in this source by Jason Eisner, where he cites:
The term variational is used because you pick the best q in Q -- the term derives from the "calculus of variations", whi
|
14,150
|
Why do we care if an MA process is invertible?
|
Invertibility is not really a big deal because almost any Gaussian, non-invertible MA$(q)$ model can be changed to an invertible MA$(q)$ model representing the same process by changing the parameter values. This is mentioned in most textbooks for the MA(1) model but it is true more generally.
As an example, consider the MA(2) model
$$
z_t = (1-0.2B)(1-2B)w_t, \tag{1}
$$
where $w_t$ is white noise with variance $\sigma_w^2$. This is not an invertible model because $\theta(B)$ has one root equal to 0.5 inside the unit circle. However, consider the alternative MA(2) model obtained by changing this root to its reciprocal value of 2 such that model takes the form
$$
z_t = (1-0.2B)(1-0.5 B)w_t' \tag{2}
$$
where $w_t'$ has variance $\sigma_w'^2=4\sigma_w^2$. You can easily verify that models (1) and (2) both have the same autocovariance functions and hence specify the same distribution for the data if the process is Gaussian.
To make the model identifiable such that there is a one-to-one mapping from $\theta_1,\theta_2,\dots,\theta_q,\sigma_w^2$ to the distribution of the data, the parameter space is therefore by convention restricted to that of invertible models. This particular convention is preferred since the model then can be put directly in AR$(\infty)$ form with coefficients $\pi_1,\pi_2,\dots$ satisfying the simple difference equation $\theta(B)\pi_i=0$.
If we didn't impose this restriction on the parameter space, the likelihood function of an MA$(q)$ would in general have up to $2^q$ local optima (if the MA polynomial has $q$ distinct real roots) which is something we want to avoid.
You can always move roots from inside to outside the unit circle with a corresponding change in the white noise variance using the above technique, except in cases where the MA-polynomial has one or more roots exactly on the unit circle.
|
Why do we care if an MA process is invertible?
|
Invertibility is not really a big deal because almost any Gaussian, non-invertible MA$(q)$ model can be changed to an invertible MA$(q)$ model representing the same process by changing the parameter v
|
Why do we care if an MA process is invertible?
Invertibility is not really a big deal because almost any Gaussian, non-invertible MA$(q)$ model can be changed to an invertible MA$(q)$ model representing the same process by changing the parameter values. This is mentioned in most textbooks for the MA(1) model but it is true more generally.
As an example, consider the MA(2) model
$$
z_t = (1-0.2B)(1-2B)w_t, \tag{1}
$$
where $w_t$ is white noise with variance $\sigma_w^2$. This is not an invertible model because $\theta(B)$ has one root equal to 0.5 inside the unit circle. However, consider the alternative MA(2) model obtained by changing this root to its reciprocal value of 2 such that model takes the form
$$
z_t = (1-0.2B)(1-0.5 B)w_t' \tag{2}
$$
where $w_t'$ has variance $\sigma_w'^2=4\sigma_w^2$. You can easily verify that models (1) and (2) both have the same autocovariance functions and hence specify the same distribution for the data if the process is Gaussian.
To make the model identifiable such that there is a one-to-one mapping from $\theta_1,\theta_2,\dots,\theta_q,\sigma_w^2$ to the distribution of the data, the parameter space is therefore by convention restricted to that of invertible models. This particular convention is preferred since the model then can be put directly in AR$(\infty)$ form with coefficients $\pi_1,\pi_2,\dots$ satisfying the simple difference equation $\theta(B)\pi_i=0$.
If we didn't impose this restriction on the parameter space, the likelihood function of an MA$(q)$ would in general have up to $2^q$ local optima (if the MA polynomial has $q$ distinct real roots) which is something we want to avoid.
You can always move roots from inside to outside the unit circle with a corresponding change in the white noise variance using the above technique, except in cases where the MA-polynomial has one or more roots exactly on the unit circle.
|
Why do we care if an MA process is invertible?
Invertibility is not really a big deal because almost any Gaussian, non-invertible MA$(q)$ model can be changed to an invertible MA$(q)$ model representing the same process by changing the parameter v
|
14,151
|
Should I choose Random Forest regressor or classifier?
|
Use the Classifier. No, they are not both valid.
First, I really encourage you to read yourself into the topic of Regression vs Classification. Because using ML without knowing anything about it will give you wrong results which you won't realize. And that's quite dangerous... (it's a little bit like asking which way around you should hold your gun or if it doesn't matter)
Whether you use a classifier or a regressor only depends on the kind of problem you are solving. You have a binary classification problem, so use the classifier.
I could run randomforestregressor first and get back a set of estimated probabilities.
NO. You don't get probabilities from regression. It just tries to "extrapolate" the values you give (in this case only 0 and 1). This means values above 1 or below 0 are perfectly valid as a regression output as it does not expect only two discrete values as output (that's called classification!) but continuous values.
If you want to have the "probabilities" (be aware that these don't have to be well calibrated probabilities) for a certain point to belong to a certain class, train a classifier (so it learns to classify the data) and then use .predict_proba(), which then predicts the probability.
Just to mention it here: .predict vs .predict_proba (for a classifier!)
.predict just takes the .predict_proba output and changes everything to 0 below a certain threshold (usually 0.5) respectively to 1 above that threshold.
Remark: sure, internally, they are the very same except from the "last layer" etc.! Still, see them (or better the problem they are solving) as completely different!
|
Should I choose Random Forest regressor or classifier?
|
Use the Classifier. No, they are not both valid.
First, I really encourage you to read yourself into the topic of Regression vs Classification. Because using ML without knowing anything about it will
|
Should I choose Random Forest regressor or classifier?
Use the Classifier. No, they are not both valid.
First, I really encourage you to read yourself into the topic of Regression vs Classification. Because using ML without knowing anything about it will give you wrong results which you won't realize. And that's quite dangerous... (it's a little bit like asking which way around you should hold your gun or if it doesn't matter)
Whether you use a classifier or a regressor only depends on the kind of problem you are solving. You have a binary classification problem, so use the classifier.
I could run randomforestregressor first and get back a set of estimated probabilities.
NO. You don't get probabilities from regression. It just tries to "extrapolate" the values you give (in this case only 0 and 1). This means values above 1 or below 0 are perfectly valid as a regression output as it does not expect only two discrete values as output (that's called classification!) but continuous values.
If you want to have the "probabilities" (be aware that these don't have to be well calibrated probabilities) for a certain point to belong to a certain class, train a classifier (so it learns to classify the data) and then use .predict_proba(), which then predicts the probability.
Just to mention it here: .predict vs .predict_proba (for a classifier!)
.predict just takes the .predict_proba output and changes everything to 0 below a certain threshold (usually 0.5) respectively to 1 above that threshold.
Remark: sure, internally, they are the very same except from the "last layer" etc.! Still, see them (or better the problem they are solving) as completely different!
|
Should I choose Random Forest regressor or classifier?
Use the Classifier. No, they are not both valid.
First, I really encourage you to read yourself into the topic of Regression vs Classification. Because using ML without knowing anything about it will
|
14,152
|
Interpretation of ordinal logistic regression
|
You have perfectly confused odds and log odds. Log odds are the coefficients; odds are exponentiated coefficients. Besides, the odds interpretation goes the other way round. (I grew up with econometrics thinking about the limited dependent variables, and the odds interpretation of the ordinal regression is... uhm... amusing to me.) So your first statement should read, "As mpg increases by one unit, the odds of observing category 1 of carb vs. other 5 categories increase by 21%."
As far as the interpretation of the thresholds goes, you really have to plot all of the predicted curves to be able to say what the modal prediction is:
mpg <- seq(from=5, to=40, by=1)
xbeta <- mpg*(-0.2335)
logistic_cdf <- function(x) {
return( 1/(1+exp(-x) ) )
}
p1 <- logistic_cdf( -6.4706 - xbeta )
p2 <- logistic_cdf( -4.4158 - xbeta ) - logistic_cdf( -6.4706 - xbeta )
p3 <- logistic_cdf( -3.8508 - xbeta ) - logistic_cdf( -4.4158 - xbeta )
p4 <- logistic_cdf( -1.2829 - xbeta ) - logistic_cdf( -3.8508 - xbeta )
p6 <- logistic_cdf( -0.5544 - xbeta ) - logistic_cdf( -1.2829 - xbeta )
p8 <- 1 - logistic_cdf( -0.5544 - xbeta )
plot(mpg, p1, type='l', ylab='Prob')
lines(mpg, p2, col='red')
lines(mpg, p3, col='blue')
lines(mpg, p4, col='green')
lines(mpg, p6, col='purple')
lines(mpg, p8, col='brown')
legend("topleft", lty=1, col=c("black", "red", "blue", "green", "purple", "brown"),
legend=c("carb 1", "carb 2", "carb 3", "carb 4", "carb 5", "carb 6"))
The blue curve for the 3rd category never picked up, and neither did the purple curve for the 6th category. So if anything I would say that for values of mpg above 27 have, the most likely category is 1; between 18 and 27, category 2; between 4 and 18, category 4; and below 4, category 8. (I wonder what it is that you are studying -- commercial trucks? Most passenger cars these days should have mpg > 25). You may want to try to determine the intersection points more accurately.
I also noticed that you have these weird categories that go 1, 2, 3, 4, then 6 (skipping 5), then 8 (skipping 7). If 5 and 7 were missing by design, that's fine. If these are valid categories that carb just does not fall into, this is not good.
|
Interpretation of ordinal logistic regression
|
You have perfectly confused odds and log odds. Log odds are the coefficients; odds are exponentiated coefficients. Besides, the odds interpretation goes the other way round. (I grew up with econometri
|
Interpretation of ordinal logistic regression
You have perfectly confused odds and log odds. Log odds are the coefficients; odds are exponentiated coefficients. Besides, the odds interpretation goes the other way round. (I grew up with econometrics thinking about the limited dependent variables, and the odds interpretation of the ordinal regression is... uhm... amusing to me.) So your first statement should read, "As mpg increases by one unit, the odds of observing category 1 of carb vs. other 5 categories increase by 21%."
As far as the interpretation of the thresholds goes, you really have to plot all of the predicted curves to be able to say what the modal prediction is:
mpg <- seq(from=5, to=40, by=1)
xbeta <- mpg*(-0.2335)
logistic_cdf <- function(x) {
return( 1/(1+exp(-x) ) )
}
p1 <- logistic_cdf( -6.4706 - xbeta )
p2 <- logistic_cdf( -4.4158 - xbeta ) - logistic_cdf( -6.4706 - xbeta )
p3 <- logistic_cdf( -3.8508 - xbeta ) - logistic_cdf( -4.4158 - xbeta )
p4 <- logistic_cdf( -1.2829 - xbeta ) - logistic_cdf( -3.8508 - xbeta )
p6 <- logistic_cdf( -0.5544 - xbeta ) - logistic_cdf( -1.2829 - xbeta )
p8 <- 1 - logistic_cdf( -0.5544 - xbeta )
plot(mpg, p1, type='l', ylab='Prob')
lines(mpg, p2, col='red')
lines(mpg, p3, col='blue')
lines(mpg, p4, col='green')
lines(mpg, p6, col='purple')
lines(mpg, p8, col='brown')
legend("topleft", lty=1, col=c("black", "red", "blue", "green", "purple", "brown"),
legend=c("carb 1", "carb 2", "carb 3", "carb 4", "carb 5", "carb 6"))
The blue curve for the 3rd category never picked up, and neither did the purple curve for the 6th category. So if anything I would say that for values of mpg above 27 have, the most likely category is 1; between 18 and 27, category 2; between 4 and 18, category 4; and below 4, category 8. (I wonder what it is that you are studying -- commercial trucks? Most passenger cars these days should have mpg > 25). You may want to try to determine the intersection points more accurately.
I also noticed that you have these weird categories that go 1, 2, 3, 4, then 6 (skipping 5), then 8 (skipping 7). If 5 and 7 were missing by design, that's fine. If these are valid categories that carb just does not fall into, this is not good.
|
Interpretation of ordinal logistic regression
You have perfectly confused odds and log odds. Log odds are the coefficients; odds are exponentiated coefficients. Besides, the odds interpretation goes the other way round. (I grew up with econometri
|
14,153
|
Interpretation of ordinal logistic regression
|
In the ordered logit model, the odds form the ratio of the probability being in any category below a specific threshold vs. the probability being in a category above the same threshold (e.g., with three categories: Probability of being in category A or B vs. C, as well as the probability of being in category A vs. B or C).
This leads to the model logit P(Y <= k | x) = zeta_k - eta as specified in the description of polr(). Therefore, odds ratios can be build either for different categories or for different regressors. The latter, the more common one, compares odds for the same categories but different regressors and equals
$$\newcommand{\odds}{{\rm odds}}
\frac{\odds(y_a \le k \,|\,x_a)}{\odds(y_b \le k \,|\,x_b)}~=~ \exp(-(\eta_a - \eta_b)).$$
The odds ratio for different categories is defined as
$$\frac{\odds(y_i \le k \,|\,x_i)}{\odds(y_i \le m \,|\,x_i)}~=~ \exp(\zeta_k - \zeta_m),$$
whereby the ratio is independent of the regressors. This property leads to the alternative name proportional odds model.
In this simple, but maybe not very intuitive example, you could formulate: For an one unit increase in the regressor mpg, the odds of observing category 1 vs. observing any higher category (or the odds of observing any category below a certain threshold vs. observing any category above the same threshold) are multiplied by 1.26 or increased by 26% (exp(-(-0.233 - 0)) = 1.263). If you want to formulate an odds ratio of different categories, you could, e.g., say the odds of being in the category 1 vs. any category above compared to the odds of being in category 1 or 2 vs. any category above equals to exp((-6.470) - (-4.415)) = 0.128. Whereby the latter interpretation is not very helpful in this specific setup. An example of an odds ratio for different categories could be the odds of going to college compared to the odds of going to highschool.
Finally, you could be interested how much an explanatory variable must change to reach the next higher response category. For this you compare the interval length $(\zeta_k - \zeta_{k-1})$ with a fitted coefficient. This gives an idea how big the change in your respective regressor must be to move the response from category $k$ to the higher category.
|
Interpretation of ordinal logistic regression
|
In the ordered logit model, the odds form the ratio of the probability being in any category below a specific threshold vs. the probability being in a category above the same threshold (e.g., with thr
|
Interpretation of ordinal logistic regression
In the ordered logit model, the odds form the ratio of the probability being in any category below a specific threshold vs. the probability being in a category above the same threshold (e.g., with three categories: Probability of being in category A or B vs. C, as well as the probability of being in category A vs. B or C).
This leads to the model logit P(Y <= k | x) = zeta_k - eta as specified in the description of polr(). Therefore, odds ratios can be build either for different categories or for different regressors. The latter, the more common one, compares odds for the same categories but different regressors and equals
$$\newcommand{\odds}{{\rm odds}}
\frac{\odds(y_a \le k \,|\,x_a)}{\odds(y_b \le k \,|\,x_b)}~=~ \exp(-(\eta_a - \eta_b)).$$
The odds ratio for different categories is defined as
$$\frac{\odds(y_i \le k \,|\,x_i)}{\odds(y_i \le m \,|\,x_i)}~=~ \exp(\zeta_k - \zeta_m),$$
whereby the ratio is independent of the regressors. This property leads to the alternative name proportional odds model.
In this simple, but maybe not very intuitive example, you could formulate: For an one unit increase in the regressor mpg, the odds of observing category 1 vs. observing any higher category (or the odds of observing any category below a certain threshold vs. observing any category above the same threshold) are multiplied by 1.26 or increased by 26% (exp(-(-0.233 - 0)) = 1.263). If you want to formulate an odds ratio of different categories, you could, e.g., say the odds of being in the category 1 vs. any category above compared to the odds of being in category 1 or 2 vs. any category above equals to exp((-6.470) - (-4.415)) = 0.128. Whereby the latter interpretation is not very helpful in this specific setup. An example of an odds ratio for different categories could be the odds of going to college compared to the odds of going to highschool.
Finally, you could be interested how much an explanatory variable must change to reach the next higher response category. For this you compare the interval length $(\zeta_k - \zeta_{k-1})$ with a fitted coefficient. This gives an idea how big the change in your respective regressor must be to move the response from category $k$ to the higher category.
|
Interpretation of ordinal logistic regression
In the ordered logit model, the odds form the ratio of the probability being in any category below a specific threshold vs. the probability being in a category above the same threshold (e.g., with thr
|
14,154
|
Sampling model for crowdsourced data?
|
Short answer: This is a convenience sample. There is nothing you can do to justify it.
A somewhat longer answer: you are in the same boat as many social networks that run their internal surveys without having much idea as to who would respond to a one-question survey that would appear randomly on Facebook or Google+... except that unlike these giants, you don't have any data on those who did not respond. The survey and public opinion research community generally frown upon this type of work, as it is not at all clear how the results of these heavily biased sample can be generalized to the total population (if at all). You can attempt to reweight according to the known demographics, but then you will end up with a variation of weights from 1 for a person who only represent themselves to 1,000,000 assigned to the only 70+ male in the population who knows how to use a computer (and is likely not representative of the remaining 1,000,000 70+ males, anyway).
Additional reading: "How To Lie With Statistics" opens with a chapter on biased samples. If you can read it and not weep in frustration about your sample design, you can move on. If you rely on volunteers, your sample with be biased towards young and urban populations with better access to electronic gadgets. Likewise, "What is a Survey" booklet put together by Fritz Scheuren, past president of the American Statistical Association, opens up with the picture of Harry Truman whose victory could not have been predicted by the biased polling techniques that existed at the time.
There is some research on hard to reach populations. One well-known project was a study into the number of excess deaths in Iraq where geographical areas were sampled, and in each area, the local doctor would try to solicit interviews from every household in the city block. There's been mounting critique of this design, but however compromising it was, it still had its sampling component. See papers in Lancet (as you probably know, you cannot get any more prestigious in the medical world) http://dx.doi.org/10.1016/S0140-6736(04)17441-2 and http://dx.doi.org/10.1016/S0140-6736(06)69491-9.
|
Sampling model for crowdsourced data?
|
Short answer: This is a convenience sample. There is nothing you can do to justify it.
A somewhat longer answer: you are in the same boat as many social networks that run their internal surveys witho
|
Sampling model for crowdsourced data?
Short answer: This is a convenience sample. There is nothing you can do to justify it.
A somewhat longer answer: you are in the same boat as many social networks that run their internal surveys without having much idea as to who would respond to a one-question survey that would appear randomly on Facebook or Google+... except that unlike these giants, you don't have any data on those who did not respond. The survey and public opinion research community generally frown upon this type of work, as it is not at all clear how the results of these heavily biased sample can be generalized to the total population (if at all). You can attempt to reweight according to the known demographics, but then you will end up with a variation of weights from 1 for a person who only represent themselves to 1,000,000 assigned to the only 70+ male in the population who knows how to use a computer (and is likely not representative of the remaining 1,000,000 70+ males, anyway).
Additional reading: "How To Lie With Statistics" opens with a chapter on biased samples. If you can read it and not weep in frustration about your sample design, you can move on. If you rely on volunteers, your sample with be biased towards young and urban populations with better access to electronic gadgets. Likewise, "What is a Survey" booklet put together by Fritz Scheuren, past president of the American Statistical Association, opens up with the picture of Harry Truman whose victory could not have been predicted by the biased polling techniques that existed at the time.
There is some research on hard to reach populations. One well-known project was a study into the number of excess deaths in Iraq where geographical areas were sampled, and in each area, the local doctor would try to solicit interviews from every household in the city block. There's been mounting critique of this design, but however compromising it was, it still had its sampling component. See papers in Lancet (as you probably know, you cannot get any more prestigious in the medical world) http://dx.doi.org/10.1016/S0140-6736(04)17441-2 and http://dx.doi.org/10.1016/S0140-6736(06)69491-9.
|
Sampling model for crowdsourced data?
Short answer: This is a convenience sample. There is nothing you can do to justify it.
A somewhat longer answer: you are in the same boat as many social networks that run their internal surveys witho
|
14,155
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
|
In univariate interval estimation, the set of possible actions is the set of ordered pairs specifying the endpoints of the interval. Let an element of that set be represented by $(a, b),\text{ } a \le b$.
Highest posterior density intervals
Let the posterior density be $f(\theta)$. The highest posterior density intervals correspond to the loss function that penalizes an interval that fails to contain the true value and also penalizes intervals in proportion to their length:
$L_{HPD}(\theta, (a, b); k) = I(\theta \notin [a, b]) + k(b – a), \text{} 0 < k \le max_{\theta} f(\theta)$,
where $I(\cdot)$ is the indicator function. This gives the expected posterior loss
$\tilde{L}_{HPD}((a, b); k) = 1 - \Pr(a \le \theta \le b|D) + k(b – a)$.
Setting $\frac{\partial}{\partial a}\tilde{L}_{HPD} = \frac{\partial}{\partial b}\tilde{L}_{HPD} = 0$ yields the necessary condition for a local optimum in the interior of the parameter space: $f(a) = f(b) = k$ – exactly the rule for HPD intervals, as expected.
The form of $\tilde{L}_{HPD}((a, b); k)$ gives some insight into why HPD intervals are not invariant to a monotone increasing transformation $g(\theta)$ of the parameter. The $\theta$-space HPD interval transformed into $g(\theta)$ space is different from the $g(\theta)$-space HPD interval because the two intervals correspond to different loss functions: the $g(\theta)$-space HPD interval corresponds to a transformed length penalty $k(g(b) – g(a))$.
Quantile-based credible intervals
Consider point estimation with the loss function
$L_q(\theta, \hat{\theta};p) = p(\hat{\theta} - \theta)I(\theta < \hat{\theta}) + (1-p)(\theta - \hat{\theta})I(\theta \ge \hat{\theta}), \text{ } 0 \le p \le 1$.
The posterior expected loss is
$\tilde{L}_q(\hat{\theta};p)=p(\hat{\theta}-\text{E}(\theta|\theta < \hat{\theta}, D)) + (1 - p)(\text{E}(\theta | \theta \ge \hat{\theta}, D)-\hat{\theta})$.
Setting $\frac{d}{d\hat{\theta}}\tilde{L}_q=0$ yields the implicit equation
$\Pr(\theta < \hat{\theta}|D) = p$,
that is, the optimal $\hat{\theta}$ is the $(100p)$% quantile of the posterior distribution, as expected.
Thus to get quantile-based interval estimates, the loss function is
$L_{qCI}(\theta, (a,b); p_L, p_U) = L_q(\theta, a;p_L) + L_q(\theta, b;p_U)$.
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
|
In univariate interval estimation, the set of possible actions is the set of ordered pairs specifying the endpoints of the interval. Let an element of that set be represented by $(a, b),\text{ } a \le
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
In univariate interval estimation, the set of possible actions is the set of ordered pairs specifying the endpoints of the interval. Let an element of that set be represented by $(a, b),\text{ } a \le b$.
Highest posterior density intervals
Let the posterior density be $f(\theta)$. The highest posterior density intervals correspond to the loss function that penalizes an interval that fails to contain the true value and also penalizes intervals in proportion to their length:
$L_{HPD}(\theta, (a, b); k) = I(\theta \notin [a, b]) + k(b – a), \text{} 0 < k \le max_{\theta} f(\theta)$,
where $I(\cdot)$ is the indicator function. This gives the expected posterior loss
$\tilde{L}_{HPD}((a, b); k) = 1 - \Pr(a \le \theta \le b|D) + k(b – a)$.
Setting $\frac{\partial}{\partial a}\tilde{L}_{HPD} = \frac{\partial}{\partial b}\tilde{L}_{HPD} = 0$ yields the necessary condition for a local optimum in the interior of the parameter space: $f(a) = f(b) = k$ – exactly the rule for HPD intervals, as expected.
The form of $\tilde{L}_{HPD}((a, b); k)$ gives some insight into why HPD intervals are not invariant to a monotone increasing transformation $g(\theta)$ of the parameter. The $\theta$-space HPD interval transformed into $g(\theta)$ space is different from the $g(\theta)$-space HPD interval because the two intervals correspond to different loss functions: the $g(\theta)$-space HPD interval corresponds to a transformed length penalty $k(g(b) – g(a))$.
Quantile-based credible intervals
Consider point estimation with the loss function
$L_q(\theta, \hat{\theta};p) = p(\hat{\theta} - \theta)I(\theta < \hat{\theta}) + (1-p)(\theta - \hat{\theta})I(\theta \ge \hat{\theta}), \text{ } 0 \le p \le 1$.
The posterior expected loss is
$\tilde{L}_q(\hat{\theta};p)=p(\hat{\theta}-\text{E}(\theta|\theta < \hat{\theta}, D)) + (1 - p)(\text{E}(\theta | \theta \ge \hat{\theta}, D)-\hat{\theta})$.
Setting $\frac{d}{d\hat{\theta}}\tilde{L}_q=0$ yields the implicit equation
$\Pr(\theta < \hat{\theta}|D) = p$,
that is, the optimal $\hat{\theta}$ is the $(100p)$% quantile of the posterior distribution, as expected.
Thus to get quantile-based interval estimates, the loss function is
$L_{qCI}(\theta, (a,b); p_L, p_U) = L_q(\theta, a;p_L) + L_q(\theta, b;p_U)$.
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
In univariate interval estimation, the set of possible actions is the set of ordered pairs specifying the endpoints of the interval. Let an element of that set be represented by $(a, b),\text{ } a \le
|
14,156
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
|
Intervals of minimal size
One obvious choice of a loss function for interval selection (both Bayesian and frequentist) is to use the size of the intervals as measured in terms of the marginal distributions. Thus, start with the desired property or the loss function, and derive the intervals that are optimal. This tends not to be done, as is exemplified by the present question, even though it is possible.
For Bayesian credible sets, this corresponds to minimize the prior probability of the interval, or to maximize the relative belief, e.g., as outlined in Evans (2016). The size may also be used to select frequentist confidence sets (Schafer 2009). The two approaches are related and can be implemented fairly easily via decision rules that preferentially included decisions with large pointwise mutual information (Bartels 2017).
Bartels, C.,2017. Using prior knowledge in frequentist tests. figshare.
https://doi.org/10.6084/m9.figshare.4819597.v3
Evans, M., 2016. Measuring statistical evidence using relative belief. Computational and structural biotechnology journal, 14, pp.91-96.
Schafer, C.M. and Stark, P.B., 2009. Constructing confidence regions of optimal expected size. Journal of the American Statistical Association, 104(487), pp.1080-1089.
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
|
Intervals of minimal size
One obvious choice of a loss function for interval selection (both Bayesian and frequentist) is to use the size of the intervals as measured in terms of the marginal distribu
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
Intervals of minimal size
One obvious choice of a loss function for interval selection (both Bayesian and frequentist) is to use the size of the intervals as measured in terms of the marginal distributions. Thus, start with the desired property or the loss function, and derive the intervals that are optimal. This tends not to be done, as is exemplified by the present question, even though it is possible.
For Bayesian credible sets, this corresponds to minimize the prior probability of the interval, or to maximize the relative belief, e.g., as outlined in Evans (2016). The size may also be used to select frequentist confidence sets (Schafer 2009). The two approaches are related and can be implemented fairly easily via decision rules that preferentially included decisions with large pointwise mutual information (Bartels 2017).
Bartels, C.,2017. Using prior knowledge in frequentist tests. figshare.
https://doi.org/10.6084/m9.figshare.4819597.v3
Evans, M., 2016. Measuring statistical evidence using relative belief. Computational and structural biotechnology journal, 14, pp.91-96.
Schafer, C.M. and Stark, P.B., 2009. Constructing confidence regions of optimal expected size. Journal of the American Statistical Association, 104(487), pp.1080-1089.
|
What is the decision-theoretic justification for Bayesian credible interval procedures?
Intervals of minimal size
One obvious choice of a loss function for interval selection (both Bayesian and frequentist) is to use the size of the intervals as measured in terms of the marginal distribu
|
14,157
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
|
The bias variance trade-off is based on the breakdown of the mean square error:
$$MSE(\hat{y})=E[y-\hat{y}]^2=E[y-E[\hat{y}]]^2+E[\hat{y}-E[\hat{y}]]^2$$
One way to see the bias-variance trade of is what properties of the data set are used in the model fit. For the simple model, if we assume that OLS regression was used to fit the straight line, then only 4 numbers are used to fit the line:
The sample covariance between x and y
The sample variance of x
The sample mean of x
The sample mean of y
So, any graph which leads to the same 4 numbers above will lead to exactly the same fitted line (10 points, 100 points, 100000000 points). So in a sense it is insensitive to the particular sample observed. This means it will be "biased" because it effectively ignores part of the data. If that ignored part of the data happened to be important, then the predictions will be consistently in error. You will see this if you compare the fitted line using all data to the fitted lines obtained from removing one data point. They will tend to be quite stable.
Now the second model uses every scrap of data it can get, and fits the data as close as possible. Hence, the exact position of every data point matters, and so you can't shift the training data around without changing the fitted model like you can for OLS. Thus the model is very sensitive to the particular training set you have. The fitted model will be very different if you do the same drop-one data point plot.
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
|
The bias variance trade-off is based on the breakdown of the mean square error:
$$MSE(\hat{y})=E[y-\hat{y}]^2=E[y-E[\hat{y}]]^2+E[\hat{y}-E[\hat{y}]]^2$$
One way to see the bias-variance trade of is w
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
The bias variance trade-off is based on the breakdown of the mean square error:
$$MSE(\hat{y})=E[y-\hat{y}]^2=E[y-E[\hat{y}]]^2+E[\hat{y}-E[\hat{y}]]^2$$
One way to see the bias-variance trade of is what properties of the data set are used in the model fit. For the simple model, if we assume that OLS regression was used to fit the straight line, then only 4 numbers are used to fit the line:
The sample covariance between x and y
The sample variance of x
The sample mean of x
The sample mean of y
So, any graph which leads to the same 4 numbers above will lead to exactly the same fitted line (10 points, 100 points, 100000000 points). So in a sense it is insensitive to the particular sample observed. This means it will be "biased" because it effectively ignores part of the data. If that ignored part of the data happened to be important, then the predictions will be consistently in error. You will see this if you compare the fitted line using all data to the fitted lines obtained from removing one data point. They will tend to be quite stable.
Now the second model uses every scrap of data it can get, and fits the data as close as possible. Hence, the exact position of every data point matters, and so you can't shift the training data around without changing the fitted model like you can for OLS. Thus the model is very sensitive to the particular training set you have. The fitted model will be very different if you do the same drop-one data point plot.
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
The bias variance trade-off is based on the breakdown of the mean square error:
$$MSE(\hat{y})=E[y-\hat{y}]^2=E[y-E[\hat{y}]]^2+E[\hat{y}-E[\hat{y}]]^2$$
One way to see the bias-variance trade of is w
|
14,158
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
|
To summarize with what I think I know in a non-mathematical manner:
bias - your prediction is going to be incorrect when you use the simple model and that will happen on any dataset you use the model on. Your prediction is expected to be wrong
variance - if you use the complex model, you will get very different prediction based on whichever dataset you are using
This page has a pretty good explanation with diagrams similar to what you posted. (I skipped the top part though, just read the part with diagrams)
http://www.aiaccess.net/English/Glossaries/GlosMod/e_gm_bias_variance.htm
(mouseover shows a different sample in case you didn't notice!)
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
|
To summarize with what I think I know in a non-mathematical manner:
bias - your prediction is going to be incorrect when you use the simple model and that will happen on any dataset you use the model
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
To summarize with what I think I know in a non-mathematical manner:
bias - your prediction is going to be incorrect when you use the simple model and that will happen on any dataset you use the model on. Your prediction is expected to be wrong
variance - if you use the complex model, you will get very different prediction based on whichever dataset you are using
This page has a pretty good explanation with diagrams similar to what you posted. (I skipped the top part though, just read the part with diagrams)
http://www.aiaccess.net/English/Glossaries/GlosMod/e_gm_bias_variance.htm
(mouseover shows a different sample in case you didn't notice!)
|
Is there a graphical representation of bias-variance tradeoff in linear regression?
To summarize with what I think I know in a non-mathematical manner:
bias - your prediction is going to be incorrect when you use the simple model and that will happen on any dataset you use the model
|
14,159
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
The Goldstein .pdf @probabilityislogic linked is a great document. Here's a list of some references that discuss your particular question:
Harville, 1976: Extension of the Gauss-Markov Theorem to include the estimation of random effects.
Harville, 1977: Maximum likelihood approaches to variance component estimation and to related problems.
Laird and Ware, 1982: Random-effects models for longitudinal data.
McCulloch, 1997: Maximum likelihood algorithms for generalized linear mixed models.
The SAS User Guide excerpt for the MIXED procedure has some great information about covariance estimation and many more sources (starting on page 3968).
There are numerous quality textbooks on longitudinal/repeated measures data analysis, but here's one that goes into some detail about implementation in R (from the authors of lme4 and nlme):
Pinheiro and Bates, 2000: Mixed-Effects Models in S and S-PLUS.
EDIT: One more relevant paper: Lindstrom and Bates, 1988: Newton-Raphson and EM Algorithms for linear mixed-effects models for repeated-measures data.
EDIT 2: And another: Jennrich and Schluchter, 1986: Unbalanced Repeated-Measures Models with Structured Covariance Matrices.
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
The Goldstein .pdf @probabilityislogic linked is a great document. Here's a list of some references that discuss your particular question:
Harville, 1976: Extension of the Gauss-Markov Theorem to inc
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
The Goldstein .pdf @probabilityislogic linked is a great document. Here's a list of some references that discuss your particular question:
Harville, 1976: Extension of the Gauss-Markov Theorem to include the estimation of random effects.
Harville, 1977: Maximum likelihood approaches to variance component estimation and to related problems.
Laird and Ware, 1982: Random-effects models for longitudinal data.
McCulloch, 1997: Maximum likelihood algorithms for generalized linear mixed models.
The SAS User Guide excerpt for the MIXED procedure has some great information about covariance estimation and many more sources (starting on page 3968).
There are numerous quality textbooks on longitudinal/repeated measures data analysis, but here's one that goes into some detail about implementation in R (from the authors of lme4 and nlme):
Pinheiro and Bates, 2000: Mixed-Effects Models in S and S-PLUS.
EDIT: One more relevant paper: Lindstrom and Bates, 1988: Newton-Raphson and EM Algorithms for linear mixed-effects models for repeated-measures data.
EDIT 2: And another: Jennrich and Schluchter, 1986: Unbalanced Repeated-Measures Models with Structured Covariance Matrices.
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
The Goldstein .pdf @probabilityislogic linked is a great document. Here's a list of some references that discuss your particular question:
Harville, 1976: Extension of the Gauss-Markov Theorem to inc
|
14,160
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
Harvey Goldstein isn't a bad place to start.
As with most complex estimation methods, it varies with the software package. However, often what is done is in the following steps:
Pick an initial value for $D$ (say $D_0$) and $R$ (say $R_0$). Set $i=1$
Conditional on $D=D_{i-1}$ and $R=R_{i-1}$, estimate $\beta$ and $u$ and $\epsilon$. Call the estimates $\beta_i$ and $u_i$ and $\epsilon_i$.
Conditional on $\beta=\beta_i$ and $u=u_i$ and $\epsilon=\epsilon_i$, estimate $D$ and $R$. Call the estimates $D_i$ and $R_i$
Check for convergence. If not converged, set $i=i+1$ and return to step 2
One simple, and fast method is IGLS, which is based on iterating between two least squares procedures, and is described in detail in chapter two. Downside is that it doesn't work well for variance components close to zero.
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
Harvey Goldstein isn't a bad place to start.
As with most complex estimation methods, it varies with the software package. However, often what is done is in the following steps:
Pick an initial valu
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
Harvey Goldstein isn't a bad place to start.
As with most complex estimation methods, it varies with the software package. However, often what is done is in the following steps:
Pick an initial value for $D$ (say $D_0$) and $R$ (say $R_0$). Set $i=1$
Conditional on $D=D_{i-1}$ and $R=R_{i-1}$, estimate $\beta$ and $u$ and $\epsilon$. Call the estimates $\beta_i$ and $u_i$ and $\epsilon_i$.
Conditional on $\beta=\beta_i$ and $u=u_i$ and $\epsilon=\epsilon_i$, estimate $D$ and $R$. Call the estimates $D_i$ and $R_i$
Check for convergence. If not converged, set $i=i+1$ and return to step 2
One simple, and fast method is IGLS, which is based on iterating between two least squares procedures, and is described in detail in chapter two. Downside is that it doesn't work well for variance components close to zero.
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
Harvey Goldstein isn't a bad place to start.
As with most complex estimation methods, it varies with the software package. However, often what is done is in the following steps:
Pick an initial valu
|
14,161
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
The following article gives a closed form solution for D:
J. Shao, Mari Palta & Roger Qu, (1998), "Least squares estimation of regression parameters in mixed effects models with unmeasured covariates", Communications in Statistics - Theory and Methods, 27:6, 1487-1501, DOI:10.1080/03610929808832172
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
The following article gives a closed form solution for D:
J. Shao, Mari Palta & Roger Qu, (1998), "Least squares estimation of regression parameters in mixed effects models with unmeasured covariates
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
The following article gives a closed form solution for D:
J. Shao, Mari Palta & Roger Qu, (1998), "Least squares estimation of regression parameters in mixed effects models with unmeasured covariates", Communications in Statistics - Theory and Methods, 27:6, 1487-1501, DOI:10.1080/03610929808832172
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
The following article gives a closed form solution for D:
J. Shao, Mari Palta & Roger Qu, (1998), "Least squares estimation of regression parameters in mixed effects models with unmeasured covariates
|
14,162
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
two more references that could be useful Variance Components by Searle Et al and Lynch and Walsh Genetics and Analysis of Quantitative Traits . The Lynch and Walsh book gives a step by step algorithm if I recall right
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
|
two more references that could be useful Variance Components by Searle Et al and Lynch and Walsh Genetics and Analysis of Quantitative Traits . The Lynch and Walsh book gives a step by step algorithm
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
two more references that could be useful Variance Components by Searle Et al and Lynch and Walsh Genetics and Analysis of Quantitative Traits . The Lynch and Walsh book gives a step by step algorithm if I recall right
|
In practice how is the random effects covariance matrix calculated in a mixed effects model?
two more references that could be useful Variance Components by Searle Et al and Lynch and Walsh Genetics and Analysis of Quantitative Traits . The Lynch and Walsh book gives a step by step algorithm
|
14,163
|
Summary of "Large p, Small n" results
|
I don't know of a single paper, but I think the current book with the best survey of methods applicable to $p\gg n$ is still Friedman-Hastie-Tibshirani. It is very partial to shrinkage and lasso (I know from a common acquaintance that Vapnik was upset at the first edition of the book), but covers almost all common shrinkage methods and shows their connection to Boosting. Talking of Boosting, the survey of Buhlmann & Hothorn also shows the connection to shrinkage.
My impression is that, while classification and regression can be analyzed using the same theoretical framework, testing for high-dimensional data is different, since it's not used in conjunction with model selection procedures, but rather focuses on family-wise error rates. Not so sure about the best surveys there. Brad Efron has a ton of papers/surveys/book on his page. Read them all and let me know the one I should really read...
|
Summary of "Large p, Small n" results
|
I don't know of a single paper, but I think the current book with the best survey of methods applicable to $p\gg n$ is still Friedman-Hastie-Tibshirani. It is very partial to shrinkage and lasso (I kn
|
Summary of "Large p, Small n" results
I don't know of a single paper, but I think the current book with the best survey of methods applicable to $p\gg n$ is still Friedman-Hastie-Tibshirani. It is very partial to shrinkage and lasso (I know from a common acquaintance that Vapnik was upset at the first edition of the book), but covers almost all common shrinkage methods and shows their connection to Boosting. Talking of Boosting, the survey of Buhlmann & Hothorn also shows the connection to shrinkage.
My impression is that, while classification and regression can be analyzed using the same theoretical framework, testing for high-dimensional data is different, since it's not used in conjunction with model selection procedures, but rather focuses on family-wise error rates. Not so sure about the best surveys there. Brad Efron has a ton of papers/surveys/book on his page. Read them all and let me know the one I should really read...
|
Summary of "Large p, Small n" results
I don't know of a single paper, but I think the current book with the best survey of methods applicable to $p\gg n$ is still Friedman-Hastie-Tibshirani. It is very partial to shrinkage and lasso (I kn
|
14,164
|
Summary of "Large p, Small n" results
|
What do you mean by "result" theoretical result ? or numerical results ?
I like the reviews of Jianqing Fan see for example this one and this one on classification (lot of self citations).
Also there are non review paper that make rich review in introduction, see for example this one and this one.
|
Summary of "Large p, Small n" results
|
What do you mean by "result" theoretical result ? or numerical results ?
I like the reviews of Jianqing Fan see for example this one and this one on classification (lot of self citations).
Also ther
|
Summary of "Large p, Small n" results
What do you mean by "result" theoretical result ? or numerical results ?
I like the reviews of Jianqing Fan see for example this one and this one on classification (lot of self citations).
Also there are non review paper that make rich review in introduction, see for example this one and this one.
|
Summary of "Large p, Small n" results
What do you mean by "result" theoretical result ? or numerical results ?
I like the reviews of Jianqing Fan see for example this one and this one on classification (lot of self citations).
Also ther
|
14,165
|
Summary of "Large p, Small n" results
|
If you want a resume maybe this is the best you can get
http://www.springer.com/statistics/statistical+theory+and+methods/book/978-3-642-20191-2
|
Summary of "Large p, Small n" results
|
If you want a resume maybe this is the best you can get
http://www.springer.com/statistics/statistical+theory+and+methods/book/978-3-642-20191-2
|
Summary of "Large p, Small n" results
If you want a resume maybe this is the best you can get
http://www.springer.com/statistics/statistical+theory+and+methods/book/978-3-642-20191-2
|
Summary of "Large p, Small n" results
If you want a resume maybe this is the best you can get
http://www.springer.com/statistics/statistical+theory+and+methods/book/978-3-642-20191-2
|
14,166
|
Summary of "Large p, Small n" results
|
Chapter 18 of Hastie, Tibshirani, and Friedman (12th printing/second edition, this chapter wasn't in the first edition) is a nice overview with some interesting data sets. It's not quite as thorough as their treatment of older material, and a lot of the time they have to give somewhat heuristic explanations of why certain algorithms work better than others. I found it very useful coupled with reading papers for things you want to know more in-depth.
|
Summary of "Large p, Small n" results
|
Chapter 18 of Hastie, Tibshirani, and Friedman (12th printing/second edition, this chapter wasn't in the first edition) is a nice overview with some interesting data sets. It's not quite as thorough a
|
Summary of "Large p, Small n" results
Chapter 18 of Hastie, Tibshirani, and Friedman (12th printing/second edition, this chapter wasn't in the first edition) is a nice overview with some interesting data sets. It's not quite as thorough as their treatment of older material, and a lot of the time they have to give somewhat heuristic explanations of why certain algorithms work better than others. I found it very useful coupled with reading papers for things you want to know more in-depth.
|
Summary of "Large p, Small n" results
Chapter 18 of Hastie, Tibshirani, and Friedman (12th printing/second edition, this chapter wasn't in the first edition) is a nice overview with some interesting data sets. It's not quite as thorough a
|
14,167
|
Encoding of categorical variables with high cardinality
|
This link provides a very good summary and should be helpful. As you allude to, label-encoding should not be used for nominal variables at it introduces an artificial ordinality. Hashing is a potential alternative that is particularity suitable for features that have high cardinality.
You can also use a distributed representation, which has become very popular in the deep learning community. The most common example given for distributed representation is word embeddings in NLP. That is not to say you cannot utilise them in encoding other categorical features. Here is an example.
Finally, account number would not be a wise input as it is more a unique identifier rather than a generalisable (account) feature.
|
Encoding of categorical variables with high cardinality
|
This link provides a very good summary and should be helpful. As you allude to, label-encoding should not be used for nominal variables at it introduces an artificial ordinality. Hashing is a potentia
|
Encoding of categorical variables with high cardinality
This link provides a very good summary and should be helpful. As you allude to, label-encoding should not be used for nominal variables at it introduces an artificial ordinality. Hashing is a potential alternative that is particularity suitable for features that have high cardinality.
You can also use a distributed representation, which has become very popular in the deep learning community. The most common example given for distributed representation is word embeddings in NLP. That is not to say you cannot utilise them in encoding other categorical features. Here is an example.
Finally, account number would not be a wise input as it is more a unique identifier rather than a generalisable (account) feature.
|
Encoding of categorical variables with high cardinality
This link provides a very good summary and should be helpful. As you allude to, label-encoding should not be used for nominal variables at it introduces an artificial ordinality. Hashing is a potentia
|
14,168
|
Encoding of categorical variables with high cardinality
|
This might help Quantile Encoder: Tackling High Cardinality Categorical Features in Regression Problems: https://link.springer.com/chapter/10.1007%2F978-3-030-85529-1_14
The most well-known encoding for categorical features with low cardinality
is One Hot Encoding [1]. This produces orthogonal and equidistant vectors for
each category. However, when dealing with high cardinality categorical features,
one hot encoding suffers from several shortcomings [20]: (a) the dimension of
the input space increases with the cardinality of the encoded variable, (b) the
created features are sparse - in many cases, most of the encoded vectors hardly
appear in the data -, and (c) One Hot Encoding does not handle new and unseen
categories.
An alternative encoding technique is Label/Ordinal Encoding [3] which uses
a single column of integers to represent the different categorical values. These
are assumed to have no true order and integers are selected at random. This
encoding handles the problem of the high dimensional encoding found in One
Hot Encoding but imposes an artificial order of the categories. This makes it
harder for the model to extract meaningful information. For example, when
using a linear model, this effect prevents the algorithm from assigning a high
coefficient to this feature.
Alternatively, Target Encoding (or mean encoding) [15] works as an effective
solution to overcome the issue of high cardinality. In target encoding, categorical features are replaced with the mean target value of each respective category.
With this technique, the high cardinality problem is handled and categories are
ordered allowing for easy extraction of the information and model simplification.
The main drawback of Target Encoding appears when categories with few (even
only one) samples are replaced by values close to the desired target. This biases
the model to over-trust the target encoded feature and makes it prone to overfitting.
It is not your exact case but the introduction has a bit of lit review that can be helpful and the pitfalls of some of this techniques.
Also, in arxiv https://arxiv.org/abs/2105.13783
|
Encoding of categorical variables with high cardinality
|
This might help Quantile Encoder: Tackling High Cardinality Categorical Features in Regression Problems: https://link.springer.com/chapter/10.1007%2F978-3-030-85529-1_14
The most well-known encoding
|
Encoding of categorical variables with high cardinality
This might help Quantile Encoder: Tackling High Cardinality Categorical Features in Regression Problems: https://link.springer.com/chapter/10.1007%2F978-3-030-85529-1_14
The most well-known encoding for categorical features with low cardinality
is One Hot Encoding [1]. This produces orthogonal and equidistant vectors for
each category. However, when dealing with high cardinality categorical features,
one hot encoding suffers from several shortcomings [20]: (a) the dimension of
the input space increases with the cardinality of the encoded variable, (b) the
created features are sparse - in many cases, most of the encoded vectors hardly
appear in the data -, and (c) One Hot Encoding does not handle new and unseen
categories.
An alternative encoding technique is Label/Ordinal Encoding [3] which uses
a single column of integers to represent the different categorical values. These
are assumed to have no true order and integers are selected at random. This
encoding handles the problem of the high dimensional encoding found in One
Hot Encoding but imposes an artificial order of the categories. This makes it
harder for the model to extract meaningful information. For example, when
using a linear model, this effect prevents the algorithm from assigning a high
coefficient to this feature.
Alternatively, Target Encoding (or mean encoding) [15] works as an effective
solution to overcome the issue of high cardinality. In target encoding, categorical features are replaced with the mean target value of each respective category.
With this technique, the high cardinality problem is handled and categories are
ordered allowing for easy extraction of the information and model simplification.
The main drawback of Target Encoding appears when categories with few (even
only one) samples are replaced by values close to the desired target. This biases
the model to over-trust the target encoded feature and makes it prone to overfitting.
It is not your exact case but the introduction has a bit of lit review that can be helpful and the pitfalls of some of this techniques.
Also, in arxiv https://arxiv.org/abs/2105.13783
|
Encoding of categorical variables with high cardinality
This might help Quantile Encoder: Tackling High Cardinality Categorical Features in Regression Problems: https://link.springer.com/chapter/10.1007%2F978-3-030-85529-1_14
The most well-known encoding
|
14,169
|
Encoding of categorical variables with high cardinality
|
Zhubarb had a very nice answer. I just want to provide more details on embedding and hashing and add one common approach binning.
Starting with the binning, this is a very common approach used in many fields, the key idea is many data follows 80-20 rules, that even we have a feature with many values but most of the data will concentred in few values. One simple example is nationality. There are many nations in the world, but if we want to build a statistical model using nationality, we will not use / encoding all of them (there are many reasons behind this, but generally, we may have overfitting if we use all of them). Instead we will pick top nationalities, and bin others int Others category. Note that this approach is also widely used in Deep Learning, where a word will have OOV(out of vocabulary) label when it is in Other category. This is an interesting paper to read: How Large a Vocabulary Does Text Classification Need?, In this paper, the largest vocabulary size is 60K.
Embedding is a very nice idea from Deep Learning and NLP. Suppose we are building a model that vocabulary size is 60K, we do not want to do one hot embedding because the vector is very sparse and the distance between vectors are not meaningful. For example, if we encode the word cat into [0,0,....,1,0,0], a lot of space will be wasted (in real word if we use sparse vector instead of dense vector to store the data, it will still be OK, but sparse vector have its own computational challenges.). And the distance between the word "cat" and say "dog", will as same as the distance between cat and say "keyboard".
Embedding uses dense vector to do the encoding, and the general idea is the distance between the dense vectors will have meanings. For example, the distance between "cat" and "dog", will be much smaller than the distance between "cat" and "keyboard".
Hashing is another interesting idea, an example can be found in sklearn documentation here. The idea is we use hash functions to produce a fixed number of features. This approach will apply a hash function to the features to determine their column index in data / design matrices directly. The result is increased speed and reduced memory usage, at the expense of inspectability; the hasher does not remember what the input features looked like and has no inverse_transform method. In addition, there will be collisions if we set number of the output features small. (for example, the this trick make not be able to differentiate the word "cat" and "keyboard" as both of them mapped into same column index.)
|
Encoding of categorical variables with high cardinality
|
Zhubarb had a very nice answer. I just want to provide more details on embedding and hashing and add one common approach binning.
Starting with the binning, this is a very common approach used in many
|
Encoding of categorical variables with high cardinality
Zhubarb had a very nice answer. I just want to provide more details on embedding and hashing and add one common approach binning.
Starting with the binning, this is a very common approach used in many fields, the key idea is many data follows 80-20 rules, that even we have a feature with many values but most of the data will concentred in few values. One simple example is nationality. There are many nations in the world, but if we want to build a statistical model using nationality, we will not use / encoding all of them (there are many reasons behind this, but generally, we may have overfitting if we use all of them). Instead we will pick top nationalities, and bin others int Others category. Note that this approach is also widely used in Deep Learning, where a word will have OOV(out of vocabulary) label when it is in Other category. This is an interesting paper to read: How Large a Vocabulary Does Text Classification Need?, In this paper, the largest vocabulary size is 60K.
Embedding is a very nice idea from Deep Learning and NLP. Suppose we are building a model that vocabulary size is 60K, we do not want to do one hot embedding because the vector is very sparse and the distance between vectors are not meaningful. For example, if we encode the word cat into [0,0,....,1,0,0], a lot of space will be wasted (in real word if we use sparse vector instead of dense vector to store the data, it will still be OK, but sparse vector have its own computational challenges.). And the distance between the word "cat" and say "dog", will as same as the distance between cat and say "keyboard".
Embedding uses dense vector to do the encoding, and the general idea is the distance between the dense vectors will have meanings. For example, the distance between "cat" and "dog", will be much smaller than the distance between "cat" and "keyboard".
Hashing is another interesting idea, an example can be found in sklearn documentation here. The idea is we use hash functions to produce a fixed number of features. This approach will apply a hash function to the features to determine their column index in data / design matrices directly. The result is increased speed and reduced memory usage, at the expense of inspectability; the hasher does not remember what the input features looked like and has no inverse_transform method. In addition, there will be collisions if we set number of the output features small. (for example, the this trick make not be able to differentiate the word "cat" and "keyboard" as both of them mapped into same column index.)
|
Encoding of categorical variables with high cardinality
Zhubarb had a very nice answer. I just want to provide more details on embedding and hashing and add one common approach binning.
Starting with the binning, this is a very common approach used in many
|
14,170
|
The origin of the Wilkinson-style notation such as (1|id) for random effects in mixed models formulae in R
|
The notation | has been around in nlme docs since version 3.1-1 and that is probably late 1999; we can easily check that on CRAN nlme code archive. nlme does use this notation, for example try library(nlme); formula(Orthodont); the | comes up - so 2000's are off. So let's dig.... "Graphical Methods for Data with Multiple Levels of Nesting" Pinheiro & Bates (1997) where the groupedData constructor is introduced. And they say: "The formula in a grouped data object has the same pattern as the formula used in a call to a Trellis graphics function in S-PLUS, such as xyplot" Which.... makes sense as are P&B working in... Bell Labs (RIP) which developed the Trellis graphics system which actually used the operator | already to indicate groups. Which probably means... "The Visual Design and Control of Trellis Display" by Becker et al. (1996) has something to do with this. Notation is not introduced in this paper but it is the first electronic Trellis display reference I can find.
Essentially we need to dig-up visualisation literature at this point. Probably I would check Cleveland's book Visualizing Data (1993) and early works of Deepayan Sarkar (who developed lattice). Notice that the actual operator | (and ||) are true primitive operators as they are associated with OR operators, so it was just a matter of time till someone overloads them.
While not a full answer, I strongly suspect P&B checked their colleagues cool visualisation system (the plots in that 1996 paper are quite good for late 2010's standards) and realised that someone (Becker, Cleveland and Shyu) already did some work on this (maybe even discussed this with them at the time) and just followed up what was already there. I.e. the | operator originates in graphics notation. Trellis almost certainly used it; potential predecessors of Trellis may have done so too but their e-footprint is very hard to track.
In general, I think you might want this page on NLME: Software for mixed-effects models by Bell Labs for more historic information on nlme.
|
The origin of the Wilkinson-style notation such as (1|id) for random effects in mixed models formula
|
The notation | has been around in nlme docs since version 3.1-1 and that is probably late 1999; we can easily check that on CRAN nlme code archive. nlme does use this notation, for example try library
|
The origin of the Wilkinson-style notation such as (1|id) for random effects in mixed models formulae in R
The notation | has been around in nlme docs since version 3.1-1 and that is probably late 1999; we can easily check that on CRAN nlme code archive. nlme does use this notation, for example try library(nlme); formula(Orthodont); the | comes up - so 2000's are off. So let's dig.... "Graphical Methods for Data with Multiple Levels of Nesting" Pinheiro & Bates (1997) where the groupedData constructor is introduced. And they say: "The formula in a grouped data object has the same pattern as the formula used in a call to a Trellis graphics function in S-PLUS, such as xyplot" Which.... makes sense as are P&B working in... Bell Labs (RIP) which developed the Trellis graphics system which actually used the operator | already to indicate groups. Which probably means... "The Visual Design and Control of Trellis Display" by Becker et al. (1996) has something to do with this. Notation is not introduced in this paper but it is the first electronic Trellis display reference I can find.
Essentially we need to dig-up visualisation literature at this point. Probably I would check Cleveland's book Visualizing Data (1993) and early works of Deepayan Sarkar (who developed lattice). Notice that the actual operator | (and ||) are true primitive operators as they are associated with OR operators, so it was just a matter of time till someone overloads them.
While not a full answer, I strongly suspect P&B checked their colleagues cool visualisation system (the plots in that 1996 paper are quite good for late 2010's standards) and realised that someone (Becker, Cleveland and Shyu) already did some work on this (maybe even discussed this with them at the time) and just followed up what was already there. I.e. the | operator originates in graphics notation. Trellis almost certainly used it; potential predecessors of Trellis may have done so too but their e-footprint is very hard to track.
In general, I think you might want this page on NLME: Software for mixed-effects models by Bell Labs for more historic information on nlme.
|
The origin of the Wilkinson-style notation such as (1|id) for random effects in mixed models formula
The notation | has been around in nlme docs since version 3.1-1 and that is probably late 1999; we can easily check that on CRAN nlme code archive. nlme does use this notation, for example try library
|
14,171
|
Heavy-tailed errors in mixed-effects model
|
I took my own advice and tried this with some simulated data.
This isn't as complete an answer as it could be, but it's what's on my hard drive.
I simulated data...
...with heavy-tailed residuals
($\frac{\epsilon}{10} \sim \text{Student}(\nu=1)$).
If fit two models using brms, one with Gaussian residuals,
and one with Student residuals.
m_gauss = brm(y ~ x + (x|subject), data=data, file='fits/m_gauss')
m_student = brm(y ~ x + (x|subject), data=data, family=student,
file='fits/m_student')
In the Gaussian model, the fixed effects estimates are reasonable but noisy,
(see true parameters in simulation code below),
but sigma, the standard deviation of the residuals was estimated to around 60.
summary(m_gauss)
# Family: gaussian
# Links: mu = identity; sigma = identity
# Formula: y ~ x + (x | subject)
# Data: data (Number of observations: 100)
# Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
# total post-warmup samples = 4000
#
# Group-Level Effects:
# ~subject (Number of levels: 5)
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sd(Intercept) 67.72 21.63 38.27 123.54 1.00 1445 2154
# sd(x) 21.72 7.33 11.58 40.11 1.00 1477 2117
# cor(Intercept,x) -0.18 0.32 -0.73 0.48 1.00 1608 1368
#
# Population-Level Effects:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# Intercept 2.90 19.65 -35.38 43.25 1.00 1959 2204
# x -2.63 8.91 -19.36 16.19 1.00 1659 1678
#
# Family Specific Parameters:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sigma 67.02 5.08 57.84 77.94 1.00 3790 3177
The Student model gives consistent parameter estimates,
since the residuals are more-or-less symmetric,
but with reduced standard errors.
I was surprised by how small the change in standard error actually was here though.
It correctly estimates $\sigma$ (10) and $\nu$ (degrees of freedom: 1)
for the residuals.
summary(m_student)
# Family: student
# Links: mu = identity; sigma = identity; nu = identity
# Formula: y ~ x + (x | subject)
# Data: data (Number of observations: 100)
# Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
# total post-warmup samples = 4000
#
# Group-Level Effects:
# ~subject (Number of levels: 5)
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sd(Intercept) 57.54 18.26 33.76 103.21 1.00 1069 1677
# sd(x) 22.99 8.29 12.19 43.89 1.00 1292 1302
# cor(Intercept,x) -0.20 0.31 -0.73 0.45 1.00 2532 2419
#
# Population-Level Effects:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# Intercept 2.26 17.61 -32.62 39.11 1.00 1733 1873
# x -3.42 9.12 -20.50 15.38 1.00 1641 1263
#
# Family Specific Parameters:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sigma 10.46 1.75 7.34 14.23 1.00 2473 2692
# nu 1.24 0.18 1.01 1.68 1.00 2213 1412
Interestingly, the reduction in standard errors
for both the fixed and random effects leads to a considerable
increase in the precision of posterior predictive means
(that is, uncertainty about the location of the regression line,
shown below).
So, using a model that assumes Gaussian residuals when your data has heavy-tailed residuals inflates the standard error of your fixed effects, as well as of other parameters. This is largely because if the residuals are assumed to be Gaussian, they must come from a Gaussian distribution with a huge standard deviation, and so the data is treated as being very noisy.
Using a model that correctly specifies the heavy-tailed nature of the Gaussians (this is also what non-Bayesian robust regression does) largely solves this issue, and even though the standard errors for individual parameters don't change very much,
the cumulative effect on the estimated regression line is considerable!
Homogeneity of Variance
It's worth noting that even though all the residuals were drawn from the same distribution, the heavy tails mean that some groups will have lots of
outliers (e.g. group 4), while others won't (e.g. group 2).
Both models here assume that the residuals have the same variance in each group. This causes additional problems for the Gaussian model, since it's forced to conclude that even group 2, where the data are close to the regression line, has high residual variance, and so greater uncertainty.
In other words, the presence of outliers in some groups,
when not properly modelled using robust, heavy-tailed residual distribution,
increases uncertainty even about groups without outliers.
Code
library(tidyverse)
library(brms)
dir.create('fits')
theme_set(theme_classic(base_size = 18))
# Simulate some data
n_subj = 5
n_trials = 20
subj_intercepts = rnorm(n_subj, 0, 50) # Varying intercepts
subj_slopes = rnorm(n_subj, 0, 20) # Varying slopes
data = data.frame(subject = rep(1:n_subj, each=n_trials),
intercept = rep(subj_intercepts, each=n_trials),
slope = rep(subj_slopes, each=n_trials)) %>%
mutate(
x = rnorm(n(), 0, 10),
yhat = intercept + x*slope)
residuals = rt(nrow(data), df=1) * 10
hist(residuals, breaks = 50)
data$y = data$yhat + residuals
ggplot(data, aes(x, y, color=factor(subject))) +
geom_point() +
stat_smooth(method='lm', se=T) +
labs(x='x', y='y', color='Group') +
geom_hline(linetype='dashed', yintercept=0)
m_gauss = brm(y ~ x + (x|subject), data=data, file='fits/m_gauss')
m_student = brm(y ~ x + (x|subject), data=data,
family=student, file='fits/m_student')
summary(m_gauss)
summary(m_student)
fixef(m_gauss)
fixef(m_student)
pred_gauss = data.frame(fitted(m_gauss))
names(pred_gauss) = paste0('gauss_', c('b', 'se', 'low', 'high'))
pred_student = data.frame(fitted(m_student))
names(pred_student) = paste0('student_', c('b', 'se', 'low', 'high'))
pred_df = cbind(data, pred_gauss, pred_student) %>%
arrange(subject, x)
ggplot(pred_df, aes(x, gauss_b,
ymin=gauss_low, ymax=gauss_high,
color=factor(subject),
fill=factor(subject))) +
geom_path() + geom_ribbon(alpha=.2) +
labs(title='Gaussian Model', color='Subject', fill='Subject',
y='Estimates')
ggplot(pred_df, aes(x, student_b,
ymin=student_low, ymax=student_high,
color=factor(subject),
fill=factor(subject))) +
geom_path() + geom_ribbon(alpha=.2) +
labs(title='Heavy-tailed (Student) Model', color='Subject', fill='Subject',
y='Estimates')
|
Heavy-tailed errors in mixed-effects model
|
I took my own advice and tried this with some simulated data.
This isn't as complete an answer as it could be, but it's what's on my hard drive.
I simulated data...
...with heavy-tailed residuals
($\
|
Heavy-tailed errors in mixed-effects model
I took my own advice and tried this with some simulated data.
This isn't as complete an answer as it could be, but it's what's on my hard drive.
I simulated data...
...with heavy-tailed residuals
($\frac{\epsilon}{10} \sim \text{Student}(\nu=1)$).
If fit two models using brms, one with Gaussian residuals,
and one with Student residuals.
m_gauss = brm(y ~ x + (x|subject), data=data, file='fits/m_gauss')
m_student = brm(y ~ x + (x|subject), data=data, family=student,
file='fits/m_student')
In the Gaussian model, the fixed effects estimates are reasonable but noisy,
(see true parameters in simulation code below),
but sigma, the standard deviation of the residuals was estimated to around 60.
summary(m_gauss)
# Family: gaussian
# Links: mu = identity; sigma = identity
# Formula: y ~ x + (x | subject)
# Data: data (Number of observations: 100)
# Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
# total post-warmup samples = 4000
#
# Group-Level Effects:
# ~subject (Number of levels: 5)
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sd(Intercept) 67.72 21.63 38.27 123.54 1.00 1445 2154
# sd(x) 21.72 7.33 11.58 40.11 1.00 1477 2117
# cor(Intercept,x) -0.18 0.32 -0.73 0.48 1.00 1608 1368
#
# Population-Level Effects:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# Intercept 2.90 19.65 -35.38 43.25 1.00 1959 2204
# x -2.63 8.91 -19.36 16.19 1.00 1659 1678
#
# Family Specific Parameters:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sigma 67.02 5.08 57.84 77.94 1.00 3790 3177
The Student model gives consistent parameter estimates,
since the residuals are more-or-less symmetric,
but with reduced standard errors.
I was surprised by how small the change in standard error actually was here though.
It correctly estimates $\sigma$ (10) and $\nu$ (degrees of freedom: 1)
for the residuals.
summary(m_student)
# Family: student
# Links: mu = identity; sigma = identity; nu = identity
# Formula: y ~ x + (x | subject)
# Data: data (Number of observations: 100)
# Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
# total post-warmup samples = 4000
#
# Group-Level Effects:
# ~subject (Number of levels: 5)
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sd(Intercept) 57.54 18.26 33.76 103.21 1.00 1069 1677
# sd(x) 22.99 8.29 12.19 43.89 1.00 1292 1302
# cor(Intercept,x) -0.20 0.31 -0.73 0.45 1.00 2532 2419
#
# Population-Level Effects:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# Intercept 2.26 17.61 -32.62 39.11 1.00 1733 1873
# x -3.42 9.12 -20.50 15.38 1.00 1641 1263
#
# Family Specific Parameters:
# Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
# sigma 10.46 1.75 7.34 14.23 1.00 2473 2692
# nu 1.24 0.18 1.01 1.68 1.00 2213 1412
Interestingly, the reduction in standard errors
for both the fixed and random effects leads to a considerable
increase in the precision of posterior predictive means
(that is, uncertainty about the location of the regression line,
shown below).
So, using a model that assumes Gaussian residuals when your data has heavy-tailed residuals inflates the standard error of your fixed effects, as well as of other parameters. This is largely because if the residuals are assumed to be Gaussian, they must come from a Gaussian distribution with a huge standard deviation, and so the data is treated as being very noisy.
Using a model that correctly specifies the heavy-tailed nature of the Gaussians (this is also what non-Bayesian robust regression does) largely solves this issue, and even though the standard errors for individual parameters don't change very much,
the cumulative effect on the estimated regression line is considerable!
Homogeneity of Variance
It's worth noting that even though all the residuals were drawn from the same distribution, the heavy tails mean that some groups will have lots of
outliers (e.g. group 4), while others won't (e.g. group 2).
Both models here assume that the residuals have the same variance in each group. This causes additional problems for the Gaussian model, since it's forced to conclude that even group 2, where the data are close to the regression line, has high residual variance, and so greater uncertainty.
In other words, the presence of outliers in some groups,
when not properly modelled using robust, heavy-tailed residual distribution,
increases uncertainty even about groups without outliers.
Code
library(tidyverse)
library(brms)
dir.create('fits')
theme_set(theme_classic(base_size = 18))
# Simulate some data
n_subj = 5
n_trials = 20
subj_intercepts = rnorm(n_subj, 0, 50) # Varying intercepts
subj_slopes = rnorm(n_subj, 0, 20) # Varying slopes
data = data.frame(subject = rep(1:n_subj, each=n_trials),
intercept = rep(subj_intercepts, each=n_trials),
slope = rep(subj_slopes, each=n_trials)) %>%
mutate(
x = rnorm(n(), 0, 10),
yhat = intercept + x*slope)
residuals = rt(nrow(data), df=1) * 10
hist(residuals, breaks = 50)
data$y = data$yhat + residuals
ggplot(data, aes(x, y, color=factor(subject))) +
geom_point() +
stat_smooth(method='lm', se=T) +
labs(x='x', y='y', color='Group') +
geom_hline(linetype='dashed', yintercept=0)
m_gauss = brm(y ~ x + (x|subject), data=data, file='fits/m_gauss')
m_student = brm(y ~ x + (x|subject), data=data,
family=student, file='fits/m_student')
summary(m_gauss)
summary(m_student)
fixef(m_gauss)
fixef(m_student)
pred_gauss = data.frame(fitted(m_gauss))
names(pred_gauss) = paste0('gauss_', c('b', 'se', 'low', 'high'))
pred_student = data.frame(fitted(m_student))
names(pred_student) = paste0('student_', c('b', 'se', 'low', 'high'))
pred_df = cbind(data, pred_gauss, pred_student) %>%
arrange(subject, x)
ggplot(pred_df, aes(x, gauss_b,
ymin=gauss_low, ymax=gauss_high,
color=factor(subject),
fill=factor(subject))) +
geom_path() + geom_ribbon(alpha=.2) +
labs(title='Gaussian Model', color='Subject', fill='Subject',
y='Estimates')
ggplot(pred_df, aes(x, student_b,
ymin=student_low, ymax=student_high,
color=factor(subject),
fill=factor(subject))) +
geom_path() + geom_ribbon(alpha=.2) +
labs(title='Heavy-tailed (Student) Model', color='Subject', fill='Subject',
y='Estimates')
|
Heavy-tailed errors in mixed-effects model
I took my own advice and tried this with some simulated data.
This isn't as complete an answer as it could be, but it's what's on my hard drive.
I simulated data...
...with heavy-tailed residuals
($\
|
14,172
|
Heavy-tailed errors in mixed-effects model
|
Looking at models based on the t-distribution is potentially helpful as others wrote. However one reason to use the Gaussian assumption is that the Gaussian distribution minimises the Fisher-Information for given variance. This means that Gaussian parameters cannot be as precisely estimated as parameters of other distributions given the knowledge of the distribution. This is a good thing in the sense that using the Gaussian distribution is normally a conservative choice, as is also shown in the answer by Eoin. The larger uncertainty indicated by the Gaussian model may actually be realistic given that we don't know what the true distribution is.
Note that this argument technically doesn't apply to the $t_1$- and $t_2$-distribution, because these don't have existing variances. However your residuals do not look quite as evil as residuals of these tend to look.
If you run regressions, fitting Gaussians to heavy tailed distributions (even $t_1$ or $t_2$) will normally make confidence intervals and p-values larger, so if you have small p-values, these should still be reliable. It is far more dangerous to have outliers/heavy tails in the explanatory variables ("leverage points"), but as far as I understand your experiment, you don't have those.
|
Heavy-tailed errors in mixed-effects model
|
Looking at models based on the t-distribution is potentially helpful as others wrote. However one reason to use the Gaussian assumption is that the Gaussian distribution minimises the Fisher-Informati
|
Heavy-tailed errors in mixed-effects model
Looking at models based on the t-distribution is potentially helpful as others wrote. However one reason to use the Gaussian assumption is that the Gaussian distribution minimises the Fisher-Information for given variance. This means that Gaussian parameters cannot be as precisely estimated as parameters of other distributions given the knowledge of the distribution. This is a good thing in the sense that using the Gaussian distribution is normally a conservative choice, as is also shown in the answer by Eoin. The larger uncertainty indicated by the Gaussian model may actually be realistic given that we don't know what the true distribution is.
Note that this argument technically doesn't apply to the $t_1$- and $t_2$-distribution, because these don't have existing variances. However your residuals do not look quite as evil as residuals of these tend to look.
If you run regressions, fitting Gaussians to heavy tailed distributions (even $t_1$ or $t_2$) will normally make confidence intervals and p-values larger, so if you have small p-values, these should still be reliable. It is far more dangerous to have outliers/heavy tails in the explanatory variables ("leverage points"), but as far as I understand your experiment, you don't have those.
|
Heavy-tailed errors in mixed-effects model
Looking at models based on the t-distribution is potentially helpful as others wrote. However one reason to use the Gaussian assumption is that the Gaussian distribution minimises the Fisher-Informati
|
14,173
|
Post-hoc test for chi-square goodness-of-fit test
|
To my surprise a couple of searches didn't seem to turn up prior discussion of post hoc for goodness of fit; I expect there's probably one here somewhere, but since I can't locate it easily, I think it's reasonable to turn my comments into an answer, so that people can at least find this one using the same search terms I just used.
The pairwise comparisons you seek to do (conditional on only comparing the two groups involved) are sensible.
This amounts to taking group pairs and testing whether the proportion in one of the groups differs from 1/2 (a one-sample proportions test). This - as you suggest - can be done as a z-test (though binomial test and chi-square goodness of fit would also work).
Many of the usual approaches to dealing with the overall type I error rate should work here (including Bonferroni -- along with the usual issues that can come with it).
|
Post-hoc test for chi-square goodness-of-fit test
|
To my surprise a couple of searches didn't seem to turn up prior discussion of post hoc for goodness of fit; I expect there's probably one here somewhere, but since I can't locate it easily, I think i
|
Post-hoc test for chi-square goodness-of-fit test
To my surprise a couple of searches didn't seem to turn up prior discussion of post hoc for goodness of fit; I expect there's probably one here somewhere, but since I can't locate it easily, I think it's reasonable to turn my comments into an answer, so that people can at least find this one using the same search terms I just used.
The pairwise comparisons you seek to do (conditional on only comparing the two groups involved) are sensible.
This amounts to taking group pairs and testing whether the proportion in one of the groups differs from 1/2 (a one-sample proportions test). This - as you suggest - can be done as a z-test (though binomial test and chi-square goodness of fit would also work).
Many of the usual approaches to dealing with the overall type I error rate should work here (including Bonferroni -- along with the usual issues that can come with it).
|
Post-hoc test for chi-square goodness-of-fit test
To my surprise a couple of searches didn't seem to turn up prior discussion of post hoc for goodness of fit; I expect there's probably one here somewhere, but since I can't locate it easily, I think i
|
14,174
|
Post-hoc test for chi-square goodness-of-fit test
|
I've had the same issue (and was happy to find this post). I now also found a short note on the issue in Sheskin (2003: 225) that I just wanted to share:
"Another type of comparison that can be conducted is to contrast just two of the original six cells with one another. Specifically, let us assume we want to compare Cell l/Monday with Cell 2/Tuesday [...] Note that in the above example, since we employ only two cells, the probability for each cell will be π_i = 1/2. The expected frequency of each cell is obtained by multiplying π_i = 1/2 by the total number of observations in the two cells (which equals 34). As noted previously, in conducting a comparison such as the one above, a critical issue the researcher must address is what value of alpha to employ in evaluating the null hypothesis."
Sheskin, D.J. 2003. Handbook of Parametric and Nonparametric Statistical Procedures: Third Edition. CRC Press.
|
Post-hoc test for chi-square goodness-of-fit test
|
I've had the same issue (and was happy to find this post). I now also found a short note on the issue in Sheskin (2003: 225) that I just wanted to share:
"Another type of comparison that can be condu
|
Post-hoc test for chi-square goodness-of-fit test
I've had the same issue (and was happy to find this post). I now also found a short note on the issue in Sheskin (2003: 225) that I just wanted to share:
"Another type of comparison that can be conducted is to contrast just two of the original six cells with one another. Specifically, let us assume we want to compare Cell l/Monday with Cell 2/Tuesday [...] Note that in the above example, since we employ only two cells, the probability for each cell will be π_i = 1/2. The expected frequency of each cell is obtained by multiplying π_i = 1/2 by the total number of observations in the two cells (which equals 34). As noted previously, in conducting a comparison such as the one above, a critical issue the researcher must address is what value of alpha to employ in evaluating the null hypothesis."
Sheskin, D.J. 2003. Handbook of Parametric and Nonparametric Statistical Procedures: Third Edition. CRC Press.
|
Post-hoc test for chi-square goodness-of-fit test
I've had the same issue (and was happy to find this post). I now also found a short note on the issue in Sheskin (2003: 225) that I just wanted to share:
"Another type of comparison that can be condu
|
14,175
|
Seeking a Theoretical Understanding of Firth Logistic Regression
|
Firth's correction is equivalent to specifying Jeffrey's prior and seeking the mode of the posterior distribution. Roughly, it adds half of an observation to the data set assuming that the true values of the regression parameters are equal to zero.
Firth's paper is an example of a higher order asymptotics. The null order, so to say, is provided by the laws of large numbers: in large samples, $\hat \theta_n \approx \theta_0$ where $\theta_0$ is the true value. You may have learned that MLEs are asymptotically normal, roughly because they are based on nonlinear transformations of sums of i.i.d. variables (scores). This is the first order approximation: $\theta_n = \theta_0 + O(n^{-1/2}) = \theta_0 + v_1 n^{-1/2} + o(n^{-1/2})$ where $v_1$ is a normal variate with zero mean and variance $\sigma_1^2$ (or var-cov matrix) that is the inverse of Fisher information for single observation. The likelihood ratio test statistic is then asymptotically $n(\hat\theta_n - \theta_0)^2/\sigma_1^2 \sim \chi^2_1$ or whatever the multivariate extensions to inner products and inverse covariance matrices would be.
Higher order asymptotics tries to learn something about that next term $o(n^{-1/2})$, usually by teasing out the next term $O(n^{-1})$. That way, the estimates and test statistics can incorporate the small sample biases of the order of $1/n$ (if you see the paper that says "we have unbiased MLEs", these people probably don't know what they are talking about). The best known correction of this kind is Bartlett's correction for likelihood ratio tests. Firth's correction is of that order, too: it adds a fixed quantity $\frac12 \ln \det I(\theta)$ (top of p. 30) to the likelihood, and in large samples the relative contribution of that quantity disappears at the rate of $1/n$ dwarfed by the sample information.
|
Seeking a Theoretical Understanding of Firth Logistic Regression
|
Firth's correction is equivalent to specifying Jeffrey's prior and seeking the mode of the posterior distribution. Roughly, it adds half of an observation to the data set assuming that the true values
|
Seeking a Theoretical Understanding of Firth Logistic Regression
Firth's correction is equivalent to specifying Jeffrey's prior and seeking the mode of the posterior distribution. Roughly, it adds half of an observation to the data set assuming that the true values of the regression parameters are equal to zero.
Firth's paper is an example of a higher order asymptotics. The null order, so to say, is provided by the laws of large numbers: in large samples, $\hat \theta_n \approx \theta_0$ where $\theta_0$ is the true value. You may have learned that MLEs are asymptotically normal, roughly because they are based on nonlinear transformations of sums of i.i.d. variables (scores). This is the first order approximation: $\theta_n = \theta_0 + O(n^{-1/2}) = \theta_0 + v_1 n^{-1/2} + o(n^{-1/2})$ where $v_1$ is a normal variate with zero mean and variance $\sigma_1^2$ (or var-cov matrix) that is the inverse of Fisher information for single observation. The likelihood ratio test statistic is then asymptotically $n(\hat\theta_n - \theta_0)^2/\sigma_1^2 \sim \chi^2_1$ or whatever the multivariate extensions to inner products and inverse covariance matrices would be.
Higher order asymptotics tries to learn something about that next term $o(n^{-1/2})$, usually by teasing out the next term $O(n^{-1})$. That way, the estimates and test statistics can incorporate the small sample biases of the order of $1/n$ (if you see the paper that says "we have unbiased MLEs", these people probably don't know what they are talking about). The best known correction of this kind is Bartlett's correction for likelihood ratio tests. Firth's correction is of that order, too: it adds a fixed quantity $\frac12 \ln \det I(\theta)$ (top of p. 30) to the likelihood, and in large samples the relative contribution of that quantity disappears at the rate of $1/n$ dwarfed by the sample information.
|
Seeking a Theoretical Understanding of Firth Logistic Regression
Firth's correction is equivalent to specifying Jeffrey's prior and seeking the mode of the posterior distribution. Roughly, it adds half of an observation to the data set assuming that the true values
|
14,176
|
Criteria to set STL s.window width
|
The question is not about whether it is a monthly or a weekly data, but about how quickly the seasonality evolves. If you think the seasonal pattern is constant through time, you should set this parameter to a big value, so that you use the entire data to perform your analysis.
If on the other way round, the seasonal pattern evolves quickly, reduce this parameter to use only the recent data so that your analysis is not affected by old seasonal pattern that are not relevant anymore
This parameter is not linked to the time series frequency.
I also want recommend to read the original paper that explains all this very clearly
STL: A Seasonal-Trend Decomposition Procedure Based on Loess.
|
Criteria to set STL s.window width
|
The question is not about whether it is a monthly or a weekly data, but about how quickly the seasonality evolves. If you think the seasonal pattern is constant through time, you should set this param
|
Criteria to set STL s.window width
The question is not about whether it is a monthly or a weekly data, but about how quickly the seasonality evolves. If you think the seasonal pattern is constant through time, you should set this parameter to a big value, so that you use the entire data to perform your analysis.
If on the other way round, the seasonal pattern evolves quickly, reduce this parameter to use only the recent data so that your analysis is not affected by old seasonal pattern that are not relevant anymore
This parameter is not linked to the time series frequency.
I also want recommend to read the original paper that explains all this very clearly
STL: A Seasonal-Trend Decomposition Procedure Based on Loess.
|
Criteria to set STL s.window width
The question is not about whether it is a monthly or a weekly data, but about how quickly the seasonality evolves. If you think the seasonal pattern is constant through time, you should set this param
|
14,177
|
High variance of leave-one-out cross-validation
|
This question is probably going to end up being closed as a duplicate of Variance and bias in cross-validation: why does leave-one-out CV have higher variance?, but before it happens I think I will turn my comments into an answer.
I also do not fully understand how LOO can be unbiased, but have a high variance?
Consider a simple example. Let the true value of a parameter be $0.5$. An estimator that yields $0.49,0.51,0.49,0.51...$ is unbiased and has relatively low variance, but an estimator that yields $0.1,0.9,0.1,0.9...$ is also unbiased but has much higher variance.
Shouldn't the performance of the cross-validation be very stable (low variance) exactly because the training sets are almost identical?
You need to think about the variance across different realizations of the whole dataset. For a given dataset, leave-one-out cross-validation will indeed produce very similar models for each split because training sets are intersecting so much (as you correctly noticed), but these models can all together be far away from the true model; across datasets, they will be far away in different directions, hence high variance.
At least that's how I understand it. Please see linked threads for more discussion, and the referenced papers for even more discussion.
|
High variance of leave-one-out cross-validation
|
This question is probably going to end up being closed as a duplicate of Variance and bias in cross-validation: why does leave-one-out CV have higher variance?, but before it happens I think I will tu
|
High variance of leave-one-out cross-validation
This question is probably going to end up being closed as a duplicate of Variance and bias in cross-validation: why does leave-one-out CV have higher variance?, but before it happens I think I will turn my comments into an answer.
I also do not fully understand how LOO can be unbiased, but have a high variance?
Consider a simple example. Let the true value of a parameter be $0.5$. An estimator that yields $0.49,0.51,0.49,0.51...$ is unbiased and has relatively low variance, but an estimator that yields $0.1,0.9,0.1,0.9...$ is also unbiased but has much higher variance.
Shouldn't the performance of the cross-validation be very stable (low variance) exactly because the training sets are almost identical?
You need to think about the variance across different realizations of the whole dataset. For a given dataset, leave-one-out cross-validation will indeed produce very similar models for each split because training sets are intersecting so much (as you correctly noticed), but these models can all together be far away from the true model; across datasets, they will be far away in different directions, hence high variance.
At least that's how I understand it. Please see linked threads for more discussion, and the referenced papers for even more discussion.
|
High variance of leave-one-out cross-validation
This question is probably going to end up being closed as a duplicate of Variance and bias in cross-validation: why does leave-one-out CV have higher variance?, but before it happens I think I will tu
|
14,178
|
High variance of leave-one-out cross-validation
|
This high variance is with respect to the space of training sets. Here is why the LOOCV has high variance:
in LOOCV, we get prediction error for each observation, say observation i, using the whole observed dataset at hand except this observation. So, the predicted value for i is very dependent on the current dataset. Now assume we observe another independent dataset and fit a model on this new dataset. If we use this new model to get a predicted value for the observation i, the predicted value is potentially very different from the one evaluated by LOOCV (although correct on average (unbiased)).
This is the intuition behind the high variance of error prediction in LOOCV.
However, if you're using LOOCV to compare results of a model with different hyperparameters, I believe you can safely use LOOCV to estimate prediction errors, provided the true value of prediction error is not of your interest, that is, you just want to compare different models having the observed training set and you don't care about the actual true error to be estimated.
That said, as a rule of thumb, if you have a small sample, use LOOCV, otherwise, use k-fold CV with a smaller value for k.
|
High variance of leave-one-out cross-validation
|
This high variance is with respect to the space of training sets. Here is why the LOOCV has high variance:
in LOOCV, we get prediction error for each observation, say observation i, using the whole ob
|
High variance of leave-one-out cross-validation
This high variance is with respect to the space of training sets. Here is why the LOOCV has high variance:
in LOOCV, we get prediction error for each observation, say observation i, using the whole observed dataset at hand except this observation. So, the predicted value for i is very dependent on the current dataset. Now assume we observe another independent dataset and fit a model on this new dataset. If we use this new model to get a predicted value for the observation i, the predicted value is potentially very different from the one evaluated by LOOCV (although correct on average (unbiased)).
This is the intuition behind the high variance of error prediction in LOOCV.
However, if you're using LOOCV to compare results of a model with different hyperparameters, I believe you can safely use LOOCV to estimate prediction errors, provided the true value of prediction error is not of your interest, that is, you just want to compare different models having the observed training set and you don't care about the actual true error to be estimated.
That said, as a rule of thumb, if you have a small sample, use LOOCV, otherwise, use k-fold CV with a smaller value for k.
|
High variance of leave-one-out cross-validation
This high variance is with respect to the space of training sets. Here is why the LOOCV has high variance:
in LOOCV, we get prediction error for each observation, say observation i, using the whole ob
|
14,179
|
High variance of leave-one-out cross-validation
|
There are two "kinds" of variance in LOOCV. one is the variance in the result, and another is the variance in the model. Because there is not much randomness in training/validation splits, the result's variance is lower than the validation set approach. However, we use almost the same models(we have nearly the same data each time). Those models altogether might be pretty different than the actual model. In other words, if we use another dataset, those models are much different. So, LOOCV has a higher variance in the model.
|
High variance of leave-one-out cross-validation
|
There are two "kinds" of variance in LOOCV. one is the variance in the result, and another is the variance in the model. Because there is not much randomness in training/validation splits, the result'
|
High variance of leave-one-out cross-validation
There are two "kinds" of variance in LOOCV. one is the variance in the result, and another is the variance in the model. Because there is not much randomness in training/validation splits, the result's variance is lower than the validation set approach. However, we use almost the same models(we have nearly the same data each time). Those models altogether might be pretty different than the actual model. In other words, if we use another dataset, those models are much different. So, LOOCV has a higher variance in the model.
|
High variance of leave-one-out cross-validation
There are two "kinds" of variance in LOOCV. one is the variance in the result, and another is the variance in the model. Because there is not much randomness in training/validation splits, the result'
|
14,180
|
Machine learning classifiers big-O or complexity
|
Let $N$ = number of training examples, $d$ = dimensionality of the features and $c$ = number of classes.
Then training has complexities:
Naive Bayes is $O(Nd)$, all it needs to do is computing the frequency of every feature value $d_i$ for each class.
$k$-NN is in $\mathcal{O}(1)$ (some people even say it is non-existent, but space complexity of training is $\mathcal{O}(Nd)$ since you need to store the data which also takes time).
Nonlinear non-approximate SVM is $O(N^2)$ or $O(N^3)$ depending on the kernel. You can get a $O(N^3)$ down to $O(N^{2.3})$ with some tricks.
Approximate SVM is $O(NR)$ where R is number of iterations.
Testing complexities:
Naive Bayes is in $\mathcal{O}(cd)$ since you have to retrieve $d$ feature values for each of the $c$ classes.
$k$-NN is in $\mathcal{O}(Nd)$ since you have to compare the test point to every data point in your database.
Source: "Core Vector Machines: Fast SVM Training on Very Large Data Sets" -
http://machinelearning.wustl.edu/mlpapers/paper_files/TsangKC05.pdf
Sorry I don't know about the others.
|
Machine learning classifiers big-O or complexity
|
Let $N$ = number of training examples, $d$ = dimensionality of the features and $c$ = number of classes.
Then training has complexities:
Naive Bayes is $O(Nd)$, all it needs to do is computing the fr
|
Machine learning classifiers big-O or complexity
Let $N$ = number of training examples, $d$ = dimensionality of the features and $c$ = number of classes.
Then training has complexities:
Naive Bayes is $O(Nd)$, all it needs to do is computing the frequency of every feature value $d_i$ for each class.
$k$-NN is in $\mathcal{O}(1)$ (some people even say it is non-existent, but space complexity of training is $\mathcal{O}(Nd)$ since you need to store the data which also takes time).
Nonlinear non-approximate SVM is $O(N^2)$ or $O(N^3)$ depending on the kernel. You can get a $O(N^3)$ down to $O(N^{2.3})$ with some tricks.
Approximate SVM is $O(NR)$ where R is number of iterations.
Testing complexities:
Naive Bayes is in $\mathcal{O}(cd)$ since you have to retrieve $d$ feature values for each of the $c$ classes.
$k$-NN is in $\mathcal{O}(Nd)$ since you have to compare the test point to every data point in your database.
Source: "Core Vector Machines: Fast SVM Training on Very Large Data Sets" -
http://machinelearning.wustl.edu/mlpapers/paper_files/TsangKC05.pdf
Sorry I don't know about the others.
|
Machine learning classifiers big-O or complexity
Let $N$ = number of training examples, $d$ = dimensionality of the features and $c$ = number of classes.
Then training has complexities:
Naive Bayes is $O(Nd)$, all it needs to do is computing the fr
|
14,181
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
The reason that this function is important is indeed the normal distribution and its closely linked companion, the central limit theorem (we have some good explanations of the CLT in other questions here).
In statistics, the CLT can typically be used to compute probabilites approximately, making statements like "we are 95 % confident that..." possible (the meaning of "95 % confident" is often misunderstood, but that's a different matter).
The function $\exp\Big(-\frac{(x-\mu)^2}{2\sigma^2}\Big)$ is (a scaled version of) the density function of the normal distribution. If a random quantity can be modelled using the normal distribution, this function describes how likely different possible values of said quantity are. Outcomes in regions with high density are more likely than outcomes in regions with low density.
$\mu$ and $\sigma$ are parameters that determine the location and scale of the density function. It is symmetric about $\mu$, so changing $\mu$ means that you shift the function to the right or to the left. $\sigma$ determines the value of the density function at its maximum ($x=\mu$) and how quickly it goes to 0 as $x$ moves away from $\mu$. In that sense, changing $\sigma$ changes the scale of the function.
For the particular choice $\mu=0$ and $\sigma=1/\sqrt{2}$ the density is (proportional to) $e^{-x^2}$. This is not a particularly interesting choice of these parameters, but it has the benefit of yielding a density function that looks slightly simpler than all others.
On the other hand, we can go from $e^{-x^2}$ to any other normal density by the change-of-variables $x=\frac{u-\mu}{\sqrt{2}\sigma}$. The reason that your textbook says that $e^{-x^2}$, and not $\exp\Big(-\frac{(x-\mu)^2}{2\sigma^2}\Big)$, is a very important function is that $e^{-x^2}$ is simpler to write.
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
The reason that this function is important is indeed the normal distribution and its closely linked companion, the central limit theorem (we have some good explanations of the CLT in other questions h
|
What is the importance of the function $e^{-x^2}$ in statistics?
The reason that this function is important is indeed the normal distribution and its closely linked companion, the central limit theorem (we have some good explanations of the CLT in other questions here).
In statistics, the CLT can typically be used to compute probabilites approximately, making statements like "we are 95 % confident that..." possible (the meaning of "95 % confident" is often misunderstood, but that's a different matter).
The function $\exp\Big(-\frac{(x-\mu)^2}{2\sigma^2}\Big)$ is (a scaled version of) the density function of the normal distribution. If a random quantity can be modelled using the normal distribution, this function describes how likely different possible values of said quantity are. Outcomes in regions with high density are more likely than outcomes in regions with low density.
$\mu$ and $\sigma$ are parameters that determine the location and scale of the density function. It is symmetric about $\mu$, so changing $\mu$ means that you shift the function to the right or to the left. $\sigma$ determines the value of the density function at its maximum ($x=\mu$) and how quickly it goes to 0 as $x$ moves away from $\mu$. In that sense, changing $\sigma$ changes the scale of the function.
For the particular choice $\mu=0$ and $\sigma=1/\sqrt{2}$ the density is (proportional to) $e^{-x^2}$. This is not a particularly interesting choice of these parameters, but it has the benefit of yielding a density function that looks slightly simpler than all others.
On the other hand, we can go from $e^{-x^2}$ to any other normal density by the change-of-variables $x=\frac{u-\mu}{\sqrt{2}\sigma}$. The reason that your textbook says that $e^{-x^2}$, and not $\exp\Big(-\frac{(x-\mu)^2}{2\sigma^2}\Big)$, is a very important function is that $e^{-x^2}$ is simpler to write.
|
What is the importance of the function $e^{-x^2}$ in statistics?
The reason that this function is important is indeed the normal distribution and its closely linked companion, the central limit theorem (we have some good explanations of the CLT in other questions h
|
14,182
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
You are right, normal distribution or gaussian is a scaled and shifted $\exp (-x^2)$, so the importance of $\exp (-x^2)$ comes mostly from the fact that it is essentially the normal distribution.
And normal distribution is important mainly because ("under mild regularity conditions") the sum of many independent and identically distributed random variables approaches normal, when "many" approaches infinity.
Not everything is normally distributed. For example, your survey results may not be, at least if the responses are not even on the continuous scale but something like integers 1–5. But the mean of the results is normally distributed over repeated sampling, because the mean is just a scaled (normalized) sum, and the individual responses are independent of each other. Assuming the sample is large enough, of course, because strictly speaking, normality appears only when the size of the sample becomes infinite.
As you see from the example, normal distribution may appear as a result of the estimation or modeling process, even when the data is not normally distributed. Therefore normal distributions are everywhere in statistics. In bayesian statistics, many posterior distributions of parameters are approximately normal, or can be assumed to be.
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
You are right, normal distribution or gaussian is a scaled and shifted $\exp (-x^2)$, so the importance of $\exp (-x^2)$ comes mostly from the fact that it is essentially the normal distribution.
And
|
What is the importance of the function $e^{-x^2}$ in statistics?
You are right, normal distribution or gaussian is a scaled and shifted $\exp (-x^2)$, so the importance of $\exp (-x^2)$ comes mostly from the fact that it is essentially the normal distribution.
And normal distribution is important mainly because ("under mild regularity conditions") the sum of many independent and identically distributed random variables approaches normal, when "many" approaches infinity.
Not everything is normally distributed. For example, your survey results may not be, at least if the responses are not even on the continuous scale but something like integers 1–5. But the mean of the results is normally distributed over repeated sampling, because the mean is just a scaled (normalized) sum, and the individual responses are independent of each other. Assuming the sample is large enough, of course, because strictly speaking, normality appears only when the size of the sample becomes infinite.
As you see from the example, normal distribution may appear as a result of the estimation or modeling process, even when the data is not normally distributed. Therefore normal distributions are everywhere in statistics. In bayesian statistics, many posterior distributions of parameters are approximately normal, or can be assumed to be.
|
What is the importance of the function $e^{-x^2}$ in statistics?
You are right, normal distribution or gaussian is a scaled and shifted $\exp (-x^2)$, so the importance of $\exp (-x^2)$ comes mostly from the fact that it is essentially the normal distribution.
And
|
14,183
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
Unique feature of this function is that its spectrum density (Fourier transform) is the same as a function itself. This means that when it is properly scaled to be the probability density function (PDF), its moment generating function (MGF) and characteristic functions (CF) have the same form and scaling:
PDF: $\frac 1 {\sqrt{s\pi}}e^{-x^2/2}$, it is Gaussian (normal) PDF
MGF: $\frac 1 {\sqrt{s\pi}}e^{t^2/2}$
CF: $\frac 1 {\sqrt{s\pi}}e^{-t^2/2}$
This leads to an endless list of amazing implications. I'll give you my favorite: uncertainty principle in quantum mechanics.
As you may have heard in quantum mechanics the particle are represented by their wave functions $\psi(x)$. The square of the amplitude of the wave function $|\psi(x)|^2$ is basically a PDF, i.e. represents the probability of the particle being at the vicinity of $x$. Thus quantum mechanics is very intimately linked to theory of probability.
You may also have heard that in quantum mechanics it is impossible to detect both the location $x$ of a particle and its speed (momentum) $p$ exactly. If you know exactly where the particle is, you won't be able to determine it speed. If you know the speed at which a particle is moving, you won't know where it is. If you know spectral analysis, then you should know that a perfect sine wave is not local, it spans from $-\infty<x<\infty$. It's the same principle here.
This is captured in uncertainty principle, and sometimes it is approximately expressed as $\Delta x\Delta p\ge \frac{\hbar}{2}$. Here's the punchline: the quantity $\Delta x\Delta p$ is the smallest when the wave function of the particle $\psi(x)$ is represented by normal distribution PDF, i.e. your function! No wonder that it is also the probability distribution with maximum entropy among all with variance 1.
So, just trying to explain you one example I had to reference several fundamental concepts in probability theory and statistics PDF, CF, spectral analysis, entropy etc. That is because no matter what are you doing in statistics this function is lurking somewhere near by.
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
Unique feature of this function is that its spectrum density (Fourier transform) is the same as a function itself. This means that when it is properly scaled to be the probability density function (PD
|
What is the importance of the function $e^{-x^2}$ in statistics?
Unique feature of this function is that its spectrum density (Fourier transform) is the same as a function itself. This means that when it is properly scaled to be the probability density function (PDF), its moment generating function (MGF) and characteristic functions (CF) have the same form and scaling:
PDF: $\frac 1 {\sqrt{s\pi}}e^{-x^2/2}$, it is Gaussian (normal) PDF
MGF: $\frac 1 {\sqrt{s\pi}}e^{t^2/2}$
CF: $\frac 1 {\sqrt{s\pi}}e^{-t^2/2}$
This leads to an endless list of amazing implications. I'll give you my favorite: uncertainty principle in quantum mechanics.
As you may have heard in quantum mechanics the particle are represented by their wave functions $\psi(x)$. The square of the amplitude of the wave function $|\psi(x)|^2$ is basically a PDF, i.e. represents the probability of the particle being at the vicinity of $x$. Thus quantum mechanics is very intimately linked to theory of probability.
You may also have heard that in quantum mechanics it is impossible to detect both the location $x$ of a particle and its speed (momentum) $p$ exactly. If you know exactly where the particle is, you won't be able to determine it speed. If you know the speed at which a particle is moving, you won't know where it is. If you know spectral analysis, then you should know that a perfect sine wave is not local, it spans from $-\infty<x<\infty$. It's the same principle here.
This is captured in uncertainty principle, and sometimes it is approximately expressed as $\Delta x\Delta p\ge \frac{\hbar}{2}$. Here's the punchline: the quantity $\Delta x\Delta p$ is the smallest when the wave function of the particle $\psi(x)$ is represented by normal distribution PDF, i.e. your function! No wonder that it is also the probability distribution with maximum entropy among all with variance 1.
So, just trying to explain you one example I had to reference several fundamental concepts in probability theory and statistics PDF, CF, spectral analysis, entropy etc. That is because no matter what are you doing in statistics this function is lurking somewhere near by.
|
What is the importance of the function $e^{-x^2}$ in statistics?
Unique feature of this function is that its spectrum density (Fourier transform) is the same as a function itself. This means that when it is properly scaled to be the probability density function (PD
|
14,184
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more.
One version of CLT tells us that the distribution of averages of independent identically distributed random variables will start to look like the bell-shaped normal distribution as the number of variables in the sum ($n$) gets large. Formal mathematical convergence takes place under mild conditions on the distribution when the average is appropriately normalized. This will work for most population distributions of various shapes including gamma, triangular, uniform, beta, chi square and even discrete distributions like Bernoulli. This makes it easy to do inference on the mean of a distribution based on a random sample by testing hypotheses or constructing confidence intervals based on the approximating normal distribution. Because the variance of the sample mean goes to $0$ at a rate of $1/n$, the mean will actually converge to a degenerate distribution with all its probability mass at the population mean. So the appropriate normalization for convergence to a normal requires recentering and multiplication by $\sqrt{n}$. There are other statistics that come up that also converge to the normal. The fact that the normal distribution can be used to approximate the distribution of various test statistics is the reason for its prominence in statistics.
|
What is the importance of the function $e^{-x^2}$ in statistics?
|
Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more.
One version of CLT t
|
What is the importance of the function $e^{-x^2}$ in statistics?
Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more.
One version of CLT tells us that the distribution of averages of independent identically distributed random variables will start to look like the bell-shaped normal distribution as the number of variables in the sum ($n$) gets large. Formal mathematical convergence takes place under mild conditions on the distribution when the average is appropriately normalized. This will work for most population distributions of various shapes including gamma, triangular, uniform, beta, chi square and even discrete distributions like Bernoulli. This makes it easy to do inference on the mean of a distribution based on a random sample by testing hypotheses or constructing confidence intervals based on the approximating normal distribution. Because the variance of the sample mean goes to $0$ at a rate of $1/n$, the mean will actually converge to a degenerate distribution with all its probability mass at the population mean. So the appropriate normalization for convergence to a normal requires recentering and multiplication by $\sqrt{n}$. There are other statistics that come up that also converge to the normal. The fact that the normal distribution can be used to approximate the distribution of various test statistics is the reason for its prominence in statistics.
|
What is the importance of the function $e^{-x^2}$ in statistics?
Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more.
One version of CLT t
|
14,185
|
Goodness of fit for 2D histograms
|
OK, I've extensively revised this answer. I think rather than binning your data and comparing counts in each bin, the suggestion I'd buried in my original answer of fitting a 2d kernel density estimate and comparing them is a much better idea. Even better, there is a function kde.test() in Tarn Duong's ks package for R that does this easy as pie.
Check the documentation for kde.test for more details and the arguments you can tweak. But basically it does pretty much exactly what you want. The p value it returns is the probability of generating the two sets of data you are comparing under the null hypothesis that they were being generated from the same distribution . So the higher the p-value, the better the fit between A and B. See my example below where this easily picks up that B1 and A are different, but that B2 and A are plausibly the same (which is how they were generated).
# generate some data that at least looks a bit similar
generate <- function(n, displ=1, perturb=1){
BV <- rnorm(n, 1*displ, 0.4*perturb)
UB <- -2*displ + BV + exp(rnorm(n,0,.3*perturb))
data.frame(BV, UB)
}
set.seed(100)
A <- generate(300)
B1 <- generate(500, 0.9, 1.2)
B2 <- generate(100, 1, 1)
AandB <- rbind(A,B1, B2)
AandB$type <- rep(c("A", "B1", "B2"), c(300,500,100))
# plot
p <- ggplot(AandB, aes(x=BV, y=UB)) + facet_grid(~type) +
geom_smooth() + scale_y_reverse() + theme_grey(9)
win.graph(7,3)
p +geom_point(size=.7)
> library(ks)
> kde.test(x1=as.matrix(A), x2=as.matrix(B1))$pvalue
[1] 2.213532e-05
> kde.test(x1=as.matrix(A), x2=as.matrix(B2))$pvalue
[1] 0.5769637
MY ORIGINAL ANSWER BELOW, IS KEPT ONLY BECAUSE THERE ARE NOW LINKS TO IT FROM ELSEWHERE WHICH WON'T MAKE SENSE
First, there may be other ways of going about this.
Justel et al have put forward a multivariate extension of the Kolmogorov-Smirnov test of goodness of fit which I think could be used in your case, to test how well each set of modelled data fit to the original. I couldn't find an implementation of this (eg in R) but maybe I didn't look hard enough.
Alternatively, there may be a way to do this by fitting a copula to both the original data and to each set of modelled data, and then comparing those models. There are implementations of this approach in R and other places but I'm not especially familiar with them so have not tried.
But to address your question directly, the approach you have taken is a reasonable one. Several points suggest themselves:
Unless your data set is bigger than it looks I think a 100 x 100 grid is too many bins. Intuitively, I can imagine you concluding the various sets of data are more dissimilar than they are just because of the precision of your bins means you have lots of bins with low numbers of points in them, even when the data density is high. However this in the end is a matter of judgement. I would certainly check your results with different approaches to binning.
Once you have done your binning and you have converted your data into (in effect) a contingency table of counts with two columns and number of rows equal to number of bins (10,000 in your case), you have a standard problem of comparing two columns of counts. Either a Chi square test or fitting some kind of Poisson model would work but as you say there is awkwardness because of the large number of zero counts. Either of those models are normally fit by minimising the sum of squares of the difference, weighted by the inverse of the expected number of counts; when this approaches zero it can cause problems.
Edit - the rest of this answer I now no longer believe to be an appropriate approach.
I think Fisher's exact test may not be useful or appropriate in this situation, where the marginal totals of rows in the cross-tab are not fixed. It will give a plausible answer but I find it difficult to reconcile its use with its original derivation from experimental design. I'm leaving the original answer here so the comments and follow up question make sense. Plus, there might still be a way of answering the OP's desired approach of binning the data and comparing the bins by some test based on the mean absolute or squared differences. Such an approach would still use the $n_g\times 2$ cross-tab referred to below and test for independence ie looking for a result where column A had the same proportions as column B.
I suspect that a solution to the above problem would be to use Fisher's exact test, applying it to your $n_g \times 2$ cross tab, where $n_g$ is the total number of bins. Although a complete calculation is not likely to be practical because of the number of rows in your table, you can get good estimates of the p-value using Monte Carlo simulation (the R implementation of Fisher's test gives this as an option for tables that are bigger than 2 x 2 and I suspect so do other packages). These p-values are the probability that the second set of data (from one of your models) have the same distribution through your bins as the original. Hence the higher the p-value, the better the fit.
I simulated some data to look a bit like yours and found that this approach was quite effective at identifying which of my "B" sets of data were generated from the same process as "A" and which were slightly different. Certainly more effective than the naked eye.
With this approach testing the independence of variables in a $n_g \times 2$ contingency table, it doesn't matter that the number of points in A is different to those in B (although note that it is a problem if you use just the sum of absolute differences or squared differences, as you originally propose). However, it does matter that each of your versions of B has a different number of points. Basically, larger B data sets will have a tendency to return lower p-values. I can think of several possible solutions to this problem. 1. You could reduce all of your B sets of data to the same size (the size of the smallest of your B sets), by taking a random sample of that size from all the B sets that are bigger than that size. 2. You could first fit a two dimensional kernel density estimate to each of your B sets, and then simulate data from that estimate that is equal sizes. 3. you could use some kind of simulation to work out the relationship of p-values to size and use that to "correct" the p-values you get from the above procedure so they are comparable. There are probably other alternatives too. Which one you do will depend on how the B data were generated, how different the sizes are, etc.
Hope that helps.
|
Goodness of fit for 2D histograms
|
OK, I've extensively revised this answer. I think rather than binning your data and comparing counts in each bin, the suggestion I'd buried in my original answer of fitting a 2d kernel density estima
|
Goodness of fit for 2D histograms
OK, I've extensively revised this answer. I think rather than binning your data and comparing counts in each bin, the suggestion I'd buried in my original answer of fitting a 2d kernel density estimate and comparing them is a much better idea. Even better, there is a function kde.test() in Tarn Duong's ks package for R that does this easy as pie.
Check the documentation for kde.test for more details and the arguments you can tweak. But basically it does pretty much exactly what you want. The p value it returns is the probability of generating the two sets of data you are comparing under the null hypothesis that they were being generated from the same distribution . So the higher the p-value, the better the fit between A and B. See my example below where this easily picks up that B1 and A are different, but that B2 and A are plausibly the same (which is how they were generated).
# generate some data that at least looks a bit similar
generate <- function(n, displ=1, perturb=1){
BV <- rnorm(n, 1*displ, 0.4*perturb)
UB <- -2*displ + BV + exp(rnorm(n,0,.3*perturb))
data.frame(BV, UB)
}
set.seed(100)
A <- generate(300)
B1 <- generate(500, 0.9, 1.2)
B2 <- generate(100, 1, 1)
AandB <- rbind(A,B1, B2)
AandB$type <- rep(c("A", "B1", "B2"), c(300,500,100))
# plot
p <- ggplot(AandB, aes(x=BV, y=UB)) + facet_grid(~type) +
geom_smooth() + scale_y_reverse() + theme_grey(9)
win.graph(7,3)
p +geom_point(size=.7)
> library(ks)
> kde.test(x1=as.matrix(A), x2=as.matrix(B1))$pvalue
[1] 2.213532e-05
> kde.test(x1=as.matrix(A), x2=as.matrix(B2))$pvalue
[1] 0.5769637
MY ORIGINAL ANSWER BELOW, IS KEPT ONLY BECAUSE THERE ARE NOW LINKS TO IT FROM ELSEWHERE WHICH WON'T MAKE SENSE
First, there may be other ways of going about this.
Justel et al have put forward a multivariate extension of the Kolmogorov-Smirnov test of goodness of fit which I think could be used in your case, to test how well each set of modelled data fit to the original. I couldn't find an implementation of this (eg in R) but maybe I didn't look hard enough.
Alternatively, there may be a way to do this by fitting a copula to both the original data and to each set of modelled data, and then comparing those models. There are implementations of this approach in R and other places but I'm not especially familiar with them so have not tried.
But to address your question directly, the approach you have taken is a reasonable one. Several points suggest themselves:
Unless your data set is bigger than it looks I think a 100 x 100 grid is too many bins. Intuitively, I can imagine you concluding the various sets of data are more dissimilar than they are just because of the precision of your bins means you have lots of bins with low numbers of points in them, even when the data density is high. However this in the end is a matter of judgement. I would certainly check your results with different approaches to binning.
Once you have done your binning and you have converted your data into (in effect) a contingency table of counts with two columns and number of rows equal to number of bins (10,000 in your case), you have a standard problem of comparing two columns of counts. Either a Chi square test or fitting some kind of Poisson model would work but as you say there is awkwardness because of the large number of zero counts. Either of those models are normally fit by minimising the sum of squares of the difference, weighted by the inverse of the expected number of counts; when this approaches zero it can cause problems.
Edit - the rest of this answer I now no longer believe to be an appropriate approach.
I think Fisher's exact test may not be useful or appropriate in this situation, where the marginal totals of rows in the cross-tab are not fixed. It will give a plausible answer but I find it difficult to reconcile its use with its original derivation from experimental design. I'm leaving the original answer here so the comments and follow up question make sense. Plus, there might still be a way of answering the OP's desired approach of binning the data and comparing the bins by some test based on the mean absolute or squared differences. Such an approach would still use the $n_g\times 2$ cross-tab referred to below and test for independence ie looking for a result where column A had the same proportions as column B.
I suspect that a solution to the above problem would be to use Fisher's exact test, applying it to your $n_g \times 2$ cross tab, where $n_g$ is the total number of bins. Although a complete calculation is not likely to be practical because of the number of rows in your table, you can get good estimates of the p-value using Monte Carlo simulation (the R implementation of Fisher's test gives this as an option for tables that are bigger than 2 x 2 and I suspect so do other packages). These p-values are the probability that the second set of data (from one of your models) have the same distribution through your bins as the original. Hence the higher the p-value, the better the fit.
I simulated some data to look a bit like yours and found that this approach was quite effective at identifying which of my "B" sets of data were generated from the same process as "A" and which were slightly different. Certainly more effective than the naked eye.
With this approach testing the independence of variables in a $n_g \times 2$ contingency table, it doesn't matter that the number of points in A is different to those in B (although note that it is a problem if you use just the sum of absolute differences or squared differences, as you originally propose). However, it does matter that each of your versions of B has a different number of points. Basically, larger B data sets will have a tendency to return lower p-values. I can think of several possible solutions to this problem. 1. You could reduce all of your B sets of data to the same size (the size of the smallest of your B sets), by taking a random sample of that size from all the B sets that are bigger than that size. 2. You could first fit a two dimensional kernel density estimate to each of your B sets, and then simulate data from that estimate that is equal sizes. 3. you could use some kind of simulation to work out the relationship of p-values to size and use that to "correct" the p-values you get from the above procedure so they are comparable. There are probably other alternatives too. Which one you do will depend on how the B data were generated, how different the sizes are, etc.
Hope that helps.
|
Goodness of fit for 2D histograms
OK, I've extensively revised this answer. I think rather than binning your data and comparing counts in each bin, the suggestion I'd buried in my original answer of fitting a 2d kernel density estima
|
14,186
|
Predictive Modeling - Should we care about mixed modeling?
|
I have been wondering this myself, and here are my tentative conclusions. I would be happy if anyone could supplement/correct this with their knowledge and any references on this topic.
If you want to test hypotheses about logistic regression coefficients by checking statistical significance, you need to model the correlation across observations (or otherwise correct for non-independence) because otherwise your standard errors will be too small, at least when you are considering within-cluster effects. But regression coefficients are unbiased even with correlated observations, so it should be fine to use such a model for prediction.
In predictive modeling, you should not need to explicitly account for the correlation when training your model, whether you are using logistic regression or some other approach. However, if you want to use a holdout set for validation or computation of out-of-sample error, you would want to ensure that observations for each individual appeared only in one set, either training or validation but not both. Otherwise your model will be predicting for individuals it already has some information about and you're not getting a true read on the out-of-sample classification ability.
|
Predictive Modeling - Should we care about mixed modeling?
|
I have been wondering this myself, and here are my tentative conclusions. I would be happy if anyone could supplement/correct this with their knowledge and any references on this topic.
If you want to
|
Predictive Modeling - Should we care about mixed modeling?
I have been wondering this myself, and here are my tentative conclusions. I would be happy if anyone could supplement/correct this with their knowledge and any references on this topic.
If you want to test hypotheses about logistic regression coefficients by checking statistical significance, you need to model the correlation across observations (or otherwise correct for non-independence) because otherwise your standard errors will be too small, at least when you are considering within-cluster effects. But regression coefficients are unbiased even with correlated observations, so it should be fine to use such a model for prediction.
In predictive modeling, you should not need to explicitly account for the correlation when training your model, whether you are using logistic regression or some other approach. However, if you want to use a holdout set for validation or computation of out-of-sample error, you would want to ensure that observations for each individual appeared only in one set, either training or validation but not both. Otherwise your model will be predicting for individuals it already has some information about and you're not getting a true read on the out-of-sample classification ability.
|
Predictive Modeling - Should we care about mixed modeling?
I have been wondering this myself, and here are my tentative conclusions. I would be happy if anyone could supplement/correct this with their knowledge and any references on this topic.
If you want to
|
14,187
|
Notation conventions for random variables and their distributions
|
I like to say: a random variable assigns a number to each possible outcome of a random "experiment", where a random experiment is some well-defined process with an uncertain outcome.
$X^2$ is another random variable; whenever $X = x$, $X^2 = x^2$.
I would generally use lower cases letters as realizations of random variables. I wouldn't use $X_1$ this way; it would be another random variable.
I wouldn't talk about $n$ draws from a random variable. I would talk about $n$ draws from a distribution, which would give $n$ independent and identically distributed random variables, $X_1$, ..., $X_n$. I would generally write the $k$th order statistic not as $X_{kn}$ but as $X_{(k)}$, and note that it is a random variable.
You generally write $X \sim F$ to say $X$ is a random variable with distribution $F$.
I've never seen that notation for the mean of a distribution. I'd say $\mathbb{E} X$ where $X \sim F$.
I would just write $Y = \max(X_1, X_2)$ where $X_i \sim \text{iid } F$.
I guess either might be understood, but probably $[F(x)]^2$ is most clear, and while it's more cumbersome to type, it doesn't really take up much more space.
There's not generally a notation difference between discrete and continuous variables, except that you generally wouldn't choose $N$ to be a continuous random variable.
|
Notation conventions for random variables and their distributions
|
I like to say: a random variable assigns a number to each possible outcome of a random "experiment", where a random experiment is some well-defined process with an uncertain outcome.
$X^2$ is another
|
Notation conventions for random variables and their distributions
I like to say: a random variable assigns a number to each possible outcome of a random "experiment", where a random experiment is some well-defined process with an uncertain outcome.
$X^2$ is another random variable; whenever $X = x$, $X^2 = x^2$.
I would generally use lower cases letters as realizations of random variables. I wouldn't use $X_1$ this way; it would be another random variable.
I wouldn't talk about $n$ draws from a random variable. I would talk about $n$ draws from a distribution, which would give $n$ independent and identically distributed random variables, $X_1$, ..., $X_n$. I would generally write the $k$th order statistic not as $X_{kn}$ but as $X_{(k)}$, and note that it is a random variable.
You generally write $X \sim F$ to say $X$ is a random variable with distribution $F$.
I've never seen that notation for the mean of a distribution. I'd say $\mathbb{E} X$ where $X \sim F$.
I would just write $Y = \max(X_1, X_2)$ where $X_i \sim \text{iid } F$.
I guess either might be understood, but probably $[F(x)]^2$ is most clear, and while it's more cumbersome to type, it doesn't really take up much more space.
There's not generally a notation difference between discrete and continuous variables, except that you generally wouldn't choose $N$ to be a continuous random variable.
|
Notation conventions for random variables and their distributions
I like to say: a random variable assigns a number to each possible outcome of a random "experiment", where a random experiment is some well-defined process with an uncertain outcome.
$X^2$ is another
|
14,188
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
|
For the case of neural networks, this is a promising approach: WTTE-RNN - Less hacky churn prediction.
The essence of this method is to use a Recurrent Neural Network to predict parameters of a Weibull distribution at each time-step and optimize the network using a loss function that takes censoring into account.
The author also released his implementation on Github.
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
|
For the case of neural networks, this is a promising approach: WTTE-RNN - Less hacky churn prediction.
The essence of this method is to use a Recurrent Neural Network to predict parameters of a Weibul
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
For the case of neural networks, this is a promising approach: WTTE-RNN - Less hacky churn prediction.
The essence of this method is to use a Recurrent Neural Network to predict parameters of a Weibull distribution at each time-step and optimize the network using a loss function that takes censoring into account.
The author also released his implementation on Github.
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
For the case of neural networks, this is a promising approach: WTTE-RNN - Less hacky churn prediction.
The essence of this method is to use a Recurrent Neural Network to predict parameters of a Weibul
|
14,189
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
|
Have a look at these references:
https://www.stats.ox.ac.uk/pub/bdr/NNSM.pdf
http://pcwww.liv.ac.uk/~afgt/eleuteri_lyon07.pdf
Also note that traditional hazards-based models like Cox Proportional Hazards (CPH) are not designed to predict time-to-event, but rather to infer variables' impact (correlation) against i) observations of events and, hence ii) a survival curve. Why? Look at the CPH's MLE.
Hence, if you want to more directly predict something like "days till occurrence", CPH may not be advisable; other models may better serve your task as noted in the above two references.
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
|
Have a look at these references:
https://www.stats.ox.ac.uk/pub/bdr/NNSM.pdf
http://pcwww.liv.ac.uk/~afgt/eleuteri_lyon07.pdf
Also note that traditional hazards-based models like Cox Proportional Haza
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
Have a look at these references:
https://www.stats.ox.ac.uk/pub/bdr/NNSM.pdf
http://pcwww.liv.ac.uk/~afgt/eleuteri_lyon07.pdf
Also note that traditional hazards-based models like Cox Proportional Hazards (CPH) are not designed to predict time-to-event, but rather to infer variables' impact (correlation) against i) observations of events and, hence ii) a survival curve. Why? Look at the CPH's MLE.
Hence, if you want to more directly predict something like "days till occurrence", CPH may not be advisable; other models may better serve your task as noted in the above two references.
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
Have a look at these references:
https://www.stats.ox.ac.uk/pub/bdr/NNSM.pdf
http://pcwww.liv.ac.uk/~afgt/eleuteri_lyon07.pdf
Also note that traditional hazards-based models like Cox Proportional Haza
|
14,190
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
|
As @dsaxton said, you can build a discrete time model. You set it up to predict p(fail at this day given survived up to previous day). Your inputs are current day (in whatever representation you want) eg one hot encoding, integer,.. Spline... As well as any other independent variables you might want
So you create rows of data, for each sample that survived till time t-1, did it die at time t (0/1).
So now the probability of surviving up to time T is the product of p(don't die at time t given didn't die at t-1) for t=1 to T.
Ie you make T predictions from your model and then multiply together.
I would say the reason its not such an idea to directly predict time to failure is because of the hidden structure of the problem. Eg what do you input for machines that didn't fail. The underlying structure is effectively the independent events: fail at time t given didn't fail up to t-1. So eg if you assume it is constant, then your survival curve becomes an exponential (see hazard models)
Note in you case you could model at 10 minute interval or aggregate up the classification problem up to day level..
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
|
As @dsaxton said, you can build a discrete time model. You set it up to predict p(fail at this day given survived up to previous day). Your inputs are current day (in whatever representation you want
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
As @dsaxton said, you can build a discrete time model. You set it up to predict p(fail at this day given survived up to previous day). Your inputs are current day (in whatever representation you want) eg one hot encoding, integer,.. Spline... As well as any other independent variables you might want
So you create rows of data, for each sample that survived till time t-1, did it die at time t (0/1).
So now the probability of surviving up to time T is the product of p(don't die at time t given didn't die at t-1) for t=1 to T.
Ie you make T predictions from your model and then multiply together.
I would say the reason its not such an idea to directly predict time to failure is because of the hidden structure of the problem. Eg what do you input for machines that didn't fail. The underlying structure is effectively the independent events: fail at time t given didn't fail up to t-1. So eg if you assume it is constant, then your survival curve becomes an exponential (see hazard models)
Note in you case you could model at 10 minute interval or aggregate up the classification problem up to day level..
|
How can machine learning models (GBM, NN etc.) be used for survival analysis?
As @dsaxton said, you can build a discrete time model. You set it up to predict p(fail at this day given survived up to previous day). Your inputs are current day (in whatever representation you want
|
14,191
|
How to test whether a distribution follows a power law?
|
According to Clauset et al., this is how you test the power law tail with poweRlaw package:
Construct the power law distribution object. In this case, your data is discrete, so use the discrete version of the class
data <- c(100, 100, 10, 10, 10 ...)
data_pl <- displ$new(data)
Estimate the $x_{min}$ and the exponent $\alpha$ of the power law, and assign them to the power law object
est <- estimate_xmin(data_pl)
data_pl$xmin <- est$xmin
data_pl$pars <- est$pars
the last two line can be rewritten as one line
data_pl$xmin <- est
Also, at this point, you can see the KS statistic:
est$KS
KS statistic tells you how well power law distribution fits your data, but it doesn't tell you how likely your data is drawn from power law. So you also need a $p$ value. This is how you do it:
bs <- bootstrap_p(data_pl)
bs$p
This could take some time, so go and grab a cup of tea...
Assuming you get a $p$ value and it's greater than 0.05 or whatever your significant level is, you still need to exclude the possibility that no other alternative distribution fits the data better than power law. The poweRlaw package implements 3 other alternatives that you can compare with. Take log-normal for example:
data_alt <- dislnorm$new(data)
data_alt$xmin <- est$xmin
data_alt$pars <- estimate_pars(data_alt)
comp <- compare_distributions(data_pl, data_alt)
Note that the $x_{min}$ of log-normal distribution is set to that of power law, because compare_distributions function require the $x_{min}$s to be the same for both distributions. The comp object has two fields that's interesting: comp$test_statistic indicates which one is a better fit, with positive number meaning data_pl is better, and negative otherwise; comp$p_two_side meaning how significant is the difference.
Repeat this step with disexp, dispois classes to compare power law with those alternatives.
|
How to test whether a distribution follows a power law?
|
According to Clauset et al., this is how you test the power law tail with poweRlaw package:
Construct the power law distribution object. In this case, your data is discrete, so use the discrete versi
|
How to test whether a distribution follows a power law?
According to Clauset et al., this is how you test the power law tail with poweRlaw package:
Construct the power law distribution object. In this case, your data is discrete, so use the discrete version of the class
data <- c(100, 100, 10, 10, 10 ...)
data_pl <- displ$new(data)
Estimate the $x_{min}$ and the exponent $\alpha$ of the power law, and assign them to the power law object
est <- estimate_xmin(data_pl)
data_pl$xmin <- est$xmin
data_pl$pars <- est$pars
the last two line can be rewritten as one line
data_pl$xmin <- est
Also, at this point, you can see the KS statistic:
est$KS
KS statistic tells you how well power law distribution fits your data, but it doesn't tell you how likely your data is drawn from power law. So you also need a $p$ value. This is how you do it:
bs <- bootstrap_p(data_pl)
bs$p
This could take some time, so go and grab a cup of tea...
Assuming you get a $p$ value and it's greater than 0.05 or whatever your significant level is, you still need to exclude the possibility that no other alternative distribution fits the data better than power law. The poweRlaw package implements 3 other alternatives that you can compare with. Take log-normal for example:
data_alt <- dislnorm$new(data)
data_alt$xmin <- est$xmin
data_alt$pars <- estimate_pars(data_alt)
comp <- compare_distributions(data_pl, data_alt)
Note that the $x_{min}$ of log-normal distribution is set to that of power law, because compare_distributions function require the $x_{min}$s to be the same for both distributions. The comp object has two fields that's interesting: comp$test_statistic indicates which one is a better fit, with positive number meaning data_pl is better, and negative otherwise; comp$p_two_side meaning how significant is the difference.
Repeat this step with disexp, dispois classes to compare power law with those alternatives.
|
How to test whether a distribution follows a power law?
According to Clauset et al., this is how you test the power law tail with poweRlaw package:
Construct the power law distribution object. In this case, your data is discrete, so use the discrete versi
|
14,192
|
Understanding the variance of random effects in lmer() models
|
This is a classic one way anova. A very short answer to your question is that the variance component is made up of two terms.
$$\hat{\sigma}^2_{\alpha}=E\left[\frac{1}{48}\sum_{s=1}^{48} \alpha_s^2\right]= \frac{1}{48}\sum_{s=1}^{48}\hat{ \alpha }_s^2 +\frac{1}{48}\sum_{s=1}^{48}var(\hat{ \alpha }_s)$$
So the term you computed is the first term on the rhs (as random effects have mean zero). The second term depends on whether REML of ML is used, and the the sum of squared standard errors of your random effects.
|
Understanding the variance of random effects in lmer() models
|
This is a classic one way anova. A very short answer to your question is that the variance component is made up of two terms.
$$\hat{\sigma}^2_{\alpha}=E\left[\frac{1}{48}\sum_{s=1}^{48} \alpha_s^2\r
|
Understanding the variance of random effects in lmer() models
This is a classic one way anova. A very short answer to your question is that the variance component is made up of two terms.
$$\hat{\sigma}^2_{\alpha}=E\left[\frac{1}{48}\sum_{s=1}^{48} \alpha_s^2\right]= \frac{1}{48}\sum_{s=1}^{48}\hat{ \alpha }_s^2 +\frac{1}{48}\sum_{s=1}^{48}var(\hat{ \alpha }_s)$$
So the term you computed is the first term on the rhs (as random effects have mean zero). The second term depends on whether REML of ML is used, and the the sum of squared standard errors of your random effects.
|
Understanding the variance of random effects in lmer() models
This is a classic one way anova. A very short answer to your question is that the variance component is made up of two terms.
$$\hat{\sigma}^2_{\alpha}=E\left[\frac{1}{48}\sum_{s=1}^{48} \alpha_s^2\r
|
14,193
|
How to interpret a QQ-plot of p-values
|
This is an older question, but I found it helpful when trying to interpret QQPlots for the first time. I thought I'd add to these answers in case more people stumble across this in the future.
The thing I found a little tricky to understand is what are those points exactly? I found going to the code made it easy to figure out.
Here is some R code that I adapted from GWASTools::qqPlot that implements a QQPlot in 3 lines:
simpleQQPlot = function (observedPValues) {
plot(-log10(1:length(observedPValues)/length(observedPValues)),
-log10(sort(observedPValues)))
abline(0, 1, col = "red")
}
Here's an example. You have 5 p-values. simpleQQPlot will generate 5 corresponding pvalues from a uniform distribution between 0 and 1. These will be: .2 .4 .6 .8 and 1. So simpleQQPlot expects your lowest p-value to be around .2, and your highest to be around 1. simpleQQPlot will sort your pvalues and pair each to the corresponding generated value. So .2 will be paired with your lowest pvalue, 1 with your highest, and so on. Then, these paired values are plotted (after taking the negative logs), with X being the generated pvalue, and Y being the paired observed value. If your observed values were also pulled from a uniform distribution, then the points should roughly lie on the straight line. Because of the sorting, the points will always increase monotonically. So each subsequent point will have a greater X, and a greater than or equal Y. The jump between Y values depends on your data, but with the log transformation, you'll see a larger jump in X as you move further to the right.
So in the original example above, the 9,997th sorted p-value was around 5.2 but was expected to be around 4.1 if following a uniform distribution. (Note: I'm not actually sure how many p-values were plotted above--I just guessed 10k).
|
How to interpret a QQ-plot of p-values
|
This is an older question, but I found it helpful when trying to interpret QQPlots for the first time. I thought I'd add to these answers in case more people stumble across this in the future.
The thi
|
How to interpret a QQ-plot of p-values
This is an older question, but I found it helpful when trying to interpret QQPlots for the first time. I thought I'd add to these answers in case more people stumble across this in the future.
The thing I found a little tricky to understand is what are those points exactly? I found going to the code made it easy to figure out.
Here is some R code that I adapted from GWASTools::qqPlot that implements a QQPlot in 3 lines:
simpleQQPlot = function (observedPValues) {
plot(-log10(1:length(observedPValues)/length(observedPValues)),
-log10(sort(observedPValues)))
abline(0, 1, col = "red")
}
Here's an example. You have 5 p-values. simpleQQPlot will generate 5 corresponding pvalues from a uniform distribution between 0 and 1. These will be: .2 .4 .6 .8 and 1. So simpleQQPlot expects your lowest p-value to be around .2, and your highest to be around 1. simpleQQPlot will sort your pvalues and pair each to the corresponding generated value. So .2 will be paired with your lowest pvalue, 1 with your highest, and so on. Then, these paired values are plotted (after taking the negative logs), with X being the generated pvalue, and Y being the paired observed value. If your observed values were also pulled from a uniform distribution, then the points should roughly lie on the straight line. Because of the sorting, the points will always increase monotonically. So each subsequent point will have a greater X, and a greater than or equal Y. The jump between Y values depends on your data, but with the log transformation, you'll see a larger jump in X as you move further to the right.
So in the original example above, the 9,997th sorted p-value was around 5.2 but was expected to be around 4.1 if following a uniform distribution. (Note: I'm not actually sure how many p-values were plotted above--I just guessed 10k).
|
How to interpret a QQ-plot of p-values
This is an older question, but I found it helpful when trying to interpret QQPlots for the first time. I thought I'd add to these answers in case more people stumble across this in the future.
The thi
|
14,194
|
How to interpret a QQ-plot of p-values
|
A good reference on the analysis of p-value plots is [1].
The result you are seeing may be driven by the fact the signal/effects exist only at some subset of tests. These are driven above the acceptance bands. Rejecting only the p-value outside the bands can indeed be justified, but perhaps more importantly, you should decide what is the error criterion you want to control when selecting your selection procedure (FWER, FDR). You can consult [2] for that choice, and references therein for choosing the appropriate multiple testing procedure.
[1] Schweder, T., and E. Spjotvoll. “Plots of P-Values to Evaluate Many Tests Simultaneously.” Biometrika 69, no. 3 (December 1982): 493–502. doi:10.2307/2335984.
[2] Rosenblatt, Jonathan. “A Practitioner’s Guide to Multiple Testing Error Rates.” ArXiv e-print. Tel Aviv University, April 17, 2013. http://arxiv.org/abs/1304.4920.
|
How to interpret a QQ-plot of p-values
|
A good reference on the analysis of p-value plots is [1].
The result you are seeing may be driven by the fact the signal/effects exist only at some subset of tests. These are driven above the acceptan
|
How to interpret a QQ-plot of p-values
A good reference on the analysis of p-value plots is [1].
The result you are seeing may be driven by the fact the signal/effects exist only at some subset of tests. These are driven above the acceptance bands. Rejecting only the p-value outside the bands can indeed be justified, but perhaps more importantly, you should decide what is the error criterion you want to control when selecting your selection procedure (FWER, FDR). You can consult [2] for that choice, and references therein for choosing the appropriate multiple testing procedure.
[1] Schweder, T., and E. Spjotvoll. “Plots of P-Values to Evaluate Many Tests Simultaneously.” Biometrika 69, no. 3 (December 1982): 493–502. doi:10.2307/2335984.
[2] Rosenblatt, Jonathan. “A Practitioner’s Guide to Multiple Testing Error Rates.” ArXiv e-print. Tel Aviv University, April 17, 2013. http://arxiv.org/abs/1304.4920.
|
How to interpret a QQ-plot of p-values
A good reference on the analysis of p-value plots is [1].
The result you are seeing may be driven by the fact the signal/effects exist only at some subset of tests. These are driven above the acceptan
|
14,195
|
Combining two confidence intervals/point estimates
|
You could do a pooled estimate as follows. You can then use the pooled estimates to generate a combined confidence interval. Specifically, let:
$\bar{x_1} \sim N(\mu,\frac{\sigma^2}{n_1})$
$\bar{x_2} \sim N(\mu,\frac{\sigma^2}{n_2})$
Using the confidence intervals for the two cases, you can re-construct the standard errors for the estimates and replace the above with:
$\bar{x_1} \sim N(\mu,SE_1)$
$\bar{x_2} \sim N(\mu,SE_2)$
A pooled estimate would be:
$\bar{x} = \frac{n_1 \bar{x_1} + n_2 \bar{x_2}}{n_1 + n_2}$
Thus,
$\bar{x} \sim N(\mu,\frac{{n_1}^2 SE_1 + {n_2}^2 SE_2}{(n_1+n_2)^2})=N(\mu,\frac{\sigma^2}{n_1+n_2})$
|
Combining two confidence intervals/point estimates
|
You could do a pooled estimate as follows. You can then use the pooled estimates to generate a combined confidence interval. Specifically, let:
$\bar{x_1} \sim N(\mu,\frac{\sigma^2}{n_1})$
$\bar{x_2}
|
Combining two confidence intervals/point estimates
You could do a pooled estimate as follows. You can then use the pooled estimates to generate a combined confidence interval. Specifically, let:
$\bar{x_1} \sim N(\mu,\frac{\sigma^2}{n_1})$
$\bar{x_2} \sim N(\mu,\frac{\sigma^2}{n_2})$
Using the confidence intervals for the two cases, you can re-construct the standard errors for the estimates and replace the above with:
$\bar{x_1} \sim N(\mu,SE_1)$
$\bar{x_2} \sim N(\mu,SE_2)$
A pooled estimate would be:
$\bar{x} = \frac{n_1 \bar{x_1} + n_2 \bar{x_2}}{n_1 + n_2}$
Thus,
$\bar{x} \sim N(\mu,\frac{{n_1}^2 SE_1 + {n_2}^2 SE_2}{(n_1+n_2)^2})=N(\mu,\frac{\sigma^2}{n_1+n_2})$
|
Combining two confidence intervals/point estimates
You could do a pooled estimate as follows. You can then use the pooled estimates to generate a combined confidence interval. Specifically, let:
$\bar{x_1} \sim N(\mu,\frac{\sigma^2}{n_1})$
$\bar{x_2}
|
14,196
|
Combining two confidence intervals/point estimates
|
Sounds a lot like meta-analysis to me. Your assumption that the samples are from the same population means you can use fixed-effect meta-analysis (rather than random-effects meta-analysis). The generic inverse-variance method takes a set of independent estimates and their variances as input, so doesn't require the full data and works even if different estimators have been used for different samples. The combined estimate is then a weighted average of the separate estimates, weighting each estimate by the inverse of its variance. The variance of the combined estimate is the inverse of the sum of the weights (the inverses of the variances).
You want to work on a scale where the sampling distribution of the estimate is approximately normal, or at least a scale on which the confidence intervals are approximately symmetric, so a log transformed scale is usual for ratio estimates (risk ratios, odds ratios, rate ratios...). In other cases a variance-stabilising transformation would be useful, e.g. a square-root transformation for Poisson data, an arcsin-square-root transformation for binomial data, etc.
|
Combining two confidence intervals/point estimates
|
Sounds a lot like meta-analysis to me. Your assumption that the samples are from the same population means you can use fixed-effect meta-analysis (rather than random-effects meta-analysis). The generi
|
Combining two confidence intervals/point estimates
Sounds a lot like meta-analysis to me. Your assumption that the samples are from the same population means you can use fixed-effect meta-analysis (rather than random-effects meta-analysis). The generic inverse-variance method takes a set of independent estimates and their variances as input, so doesn't require the full data and works even if different estimators have been used for different samples. The combined estimate is then a weighted average of the separate estimates, weighting each estimate by the inverse of its variance. The variance of the combined estimate is the inverse of the sum of the weights (the inverses of the variances).
You want to work on a scale where the sampling distribution of the estimate is approximately normal, or at least a scale on which the confidence intervals are approximately symmetric, so a log transformed scale is usual for ratio estimates (risk ratios, odds ratios, rate ratios...). In other cases a variance-stabilising transformation would be useful, e.g. a square-root transformation for Poisson data, an arcsin-square-root transformation for binomial data, etc.
|
Combining two confidence intervals/point estimates
Sounds a lot like meta-analysis to me. Your assumption that the samples are from the same population means you can use fixed-effect meta-analysis (rather than random-effects meta-analysis). The generi
|
14,197
|
Combining two confidence intervals/point estimates
|
This is not unlike a stratified sample. So, pooling the samples for a point estimate and standard error seems like a reasonable approach. The two samples would be weighted by sample proportion.
|
Combining two confidence intervals/point estimates
|
This is not unlike a stratified sample. So, pooling the samples for a point estimate and standard error seems like a reasonable approach. The two samples would be weighted by sample proportion.
|
Combining two confidence intervals/point estimates
This is not unlike a stratified sample. So, pooling the samples for a point estimate and standard error seems like a reasonable approach. The two samples would be weighted by sample proportion.
|
Combining two confidence intervals/point estimates
This is not unlike a stratified sample. So, pooling the samples for a point estimate and standard error seems like a reasonable approach. The two samples would be weighted by sample proportion.
|
14,198
|
Combining two confidence intervals/point estimates
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
See paper:
K.M. Scott, X. Lu, C.M. Cavanaugh, J.S. Liu, Optimal methods for estimating kinetic isotope effects from different forms of the Rayleigh distillation equation, Geochimica et Cosmochimica Acta, Volume 68, Issue 3, 1 February 2004, Pages 433-442, ISSN 0016-7037, http://dx.doi.org/10.1016/S0016-7037(03)00459-9.
(http://www.sciencedirect.com/science/article/pii/S0016703703004599)
|
Combining two confidence intervals/point estimates
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
Combining two confidence intervals/point estimates
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
See paper:
K.M. Scott, X. Lu, C.M. Cavanaugh, J.S. Liu, Optimal methods for estimating kinetic isotope effects from different forms of the Rayleigh distillation equation, Geochimica et Cosmochimica Acta, Volume 68, Issue 3, 1 February 2004, Pages 433-442, ISSN 0016-7037, http://dx.doi.org/10.1016/S0016-7037(03)00459-9.
(http://www.sciencedirect.com/science/article/pii/S0016703703004599)
|
Combining two confidence intervals/point estimates
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
14,199
|
When an analytical Jacobian is available, is it better to approximate the Hessian by $J^TJ$, or by finite differences of the Jacobian?
|
GOOD question. First, recall where this approximation $H \approx J^T J$ comes from. Let $(x_i, y_i)$ be your data points, $f(\cdot)$ be your model and $\beta$ be the parameters of your model. Then the objective function of the non-linear least squares problem is $\frac{1}{2} r^T r$ where $r$ is the vector of the residuals, $r_i = y_i - f(x_i, \beta)$. The exact Hessian of the objective function is $H = J^T J + \sum r_i \nabla^2 r_i$. So the error in this approximation is $H - J^T J = \sum r_i \nabla^2 r_i$. It's a good approximation when the residuals, themselves, are small; or when the 2nd derivative of the residuals is small. Linear least squares can be considered a special case where the 2nd derivative of the residuals is zero.
As for finite difference approximation, it is relatively cheap. To compute a central difference, you'll need to evaluate the Jacobian an additional $2n$ times (a forward difference will cost you $n$ additional evaluations, so I wouldn't bother). The error of the central difference approximation is proportional to $\nabla^4 r$ and $h^2$, where $h$ is the step size. The optimal step size is $h \sim \epsilon^\frac{1}{3}$, where $\epsilon$ is machine precision. So unless the derivatives of the residuals are blowing up, it's pretty clear that the finite difference approximation should be a LOT better. I should point out that, while the computation is minimal, the bookkeeping is nontrivial. Each finite difference on the Jacobian will give you one row of the Hessian for each residual. You'll then have to reassemble the Hessian using the formula above.
There is, however, a 3rd option. If your solver uses a Quasi-Newton method (DFP, BFGS, Bryoden, etc.), it is already approximating the Hessian at each iteration. The approximation can be quite good, as it uses the objective function and gradient values from every iteration. Most solvers will give you access to the final Hessian estimate (or its inverse). If that's an option for you, I would use that as the Hessian estimate. It's already computed and it's probably going to be a pretty good estimate.
|
When an analytical Jacobian is available, is it better to approximate the Hessian by $J^TJ$, or by f
|
GOOD question. First, recall where this approximation $H \approx J^T J$ comes from. Let $(x_i, y_i)$ be your data points, $f(\cdot)$ be your model and $\beta$ be the parameters of your model. Then
|
When an analytical Jacobian is available, is it better to approximate the Hessian by $J^TJ$, or by finite differences of the Jacobian?
GOOD question. First, recall where this approximation $H \approx J^T J$ comes from. Let $(x_i, y_i)$ be your data points, $f(\cdot)$ be your model and $\beta$ be the parameters of your model. Then the objective function of the non-linear least squares problem is $\frac{1}{2} r^T r$ where $r$ is the vector of the residuals, $r_i = y_i - f(x_i, \beta)$. The exact Hessian of the objective function is $H = J^T J + \sum r_i \nabla^2 r_i$. So the error in this approximation is $H - J^T J = \sum r_i \nabla^2 r_i$. It's a good approximation when the residuals, themselves, are small; or when the 2nd derivative of the residuals is small. Linear least squares can be considered a special case where the 2nd derivative of the residuals is zero.
As for finite difference approximation, it is relatively cheap. To compute a central difference, you'll need to evaluate the Jacobian an additional $2n$ times (a forward difference will cost you $n$ additional evaluations, so I wouldn't bother). The error of the central difference approximation is proportional to $\nabla^4 r$ and $h^2$, where $h$ is the step size. The optimal step size is $h \sim \epsilon^\frac{1}{3}$, where $\epsilon$ is machine precision. So unless the derivatives of the residuals are blowing up, it's pretty clear that the finite difference approximation should be a LOT better. I should point out that, while the computation is minimal, the bookkeeping is nontrivial. Each finite difference on the Jacobian will give you one row of the Hessian for each residual. You'll then have to reassemble the Hessian using the formula above.
There is, however, a 3rd option. If your solver uses a Quasi-Newton method (DFP, BFGS, Bryoden, etc.), it is already approximating the Hessian at each iteration. The approximation can be quite good, as it uses the objective function and gradient values from every iteration. Most solvers will give you access to the final Hessian estimate (or its inverse). If that's an option for you, I would use that as the Hessian estimate. It's already computed and it's probably going to be a pretty good estimate.
|
When an analytical Jacobian is available, is it better to approximate the Hessian by $J^TJ$, or by f
GOOD question. First, recall where this approximation $H \approx J^T J$ comes from. Let $(x_i, y_i)$ be your data points, $f(\cdot)$ be your model and $\beta$ be the parameters of your model. Then
|
14,200
|
Observed information matrix is a consistent estimator of the expected information matrix?
|
$\newcommand{\convp}{\stackrel{P}{\longrightarrow}}$
I guess directly establishing some sort of uniform law of large numbers
is one possible approach.
Here is another.
We want to show that $\frac{J^N(\theta_{MLE})}{N} \convp I(\theta^*)$.
(As you said, we have by the WLLN that $\frac{J^N(\theta)}{N} \convp I(\theta)$. But this doesn't directly help us.)
One possible strategy is to show that
$$|I(\theta^*) - \frac{J^N(\theta^*)}{N}| \convp 0.$$
and
$$
|\frac{J^N(\theta_{MLE})}{N} - \frac{J^N(\theta^*)}{N}| \convp 0
$$
If both of the results are true, then we can combine them to get
$$
|I(\theta^*) - \frac{J^N(\theta_{MLE})}{N}| \convp 0,
$$
which is exactly what we want to show.
The first equation follows from the weak law of large numbers.
The second almost follows from the continuous mapping theorem, but unfortunately our function $g()$ that we want to apply the CMT to changes with $N$:
our $g$ is really $g_N(\theta) := \frac{J^N(\theta)}{N}$. So we
cannot use the CMT.
(Comment: If you
examine the proof of the CMT on Wikipedia,
notice that the set $B_\delta$ they define in their proof for us now
also depends on $n$. We essentially need some sort of equicontinuity at $\theta^*$
over our functions $g_N(\theta)$.)
Fortunately, if you assume that the family $\mathcal{G} = \{g_N | N=1,2,\ldots\}$
is stochastically equicontinuous at $\theta^*$, then it immediately
follows that for $\theta_{MLE} \convp \theta^*$,
\begin{align*}
|g_n(\theta_{MLE}) - g_n(\theta^*)| \convp 0.
\end{align*}
(See here: http://www.cs.berkeley.edu/~jordan/courses/210B-spring07/lectures/stat210b_lecture_12.pdf for a definition of stochastic equicontinuity at $\theta^*$, and a proof of the above fact.)
Therefore, assuming that $\mathcal{G}$ is SE at $\theta^*$, your desired result holds
true and the empirical Fisher information converges to the population Fisher information.
Now, the key question of course is, what sort of conditions do you need
to impose on $\mathcal{G}$ to get SE?
It looks like one way to do this is to establish a Lipshitz condition
on the entire class of functions $\mathcal{G}$ (see here: http://econ.duke.edu/uploads/media_items/uniform-convergence-and-stochastic-equicontinuity.original.pdf ).
|
Observed information matrix is a consistent estimator of the expected information matrix?
|
$\newcommand{\convp}{\stackrel{P}{\longrightarrow}}$
I guess directly establishing some sort of uniform law of large numbers
is one possible approach.
Here is another.
We want to show that $\frac{J^N(
|
Observed information matrix is a consistent estimator of the expected information matrix?
$\newcommand{\convp}{\stackrel{P}{\longrightarrow}}$
I guess directly establishing some sort of uniform law of large numbers
is one possible approach.
Here is another.
We want to show that $\frac{J^N(\theta_{MLE})}{N} \convp I(\theta^*)$.
(As you said, we have by the WLLN that $\frac{J^N(\theta)}{N} \convp I(\theta)$. But this doesn't directly help us.)
One possible strategy is to show that
$$|I(\theta^*) - \frac{J^N(\theta^*)}{N}| \convp 0.$$
and
$$
|\frac{J^N(\theta_{MLE})}{N} - \frac{J^N(\theta^*)}{N}| \convp 0
$$
If both of the results are true, then we can combine them to get
$$
|I(\theta^*) - \frac{J^N(\theta_{MLE})}{N}| \convp 0,
$$
which is exactly what we want to show.
The first equation follows from the weak law of large numbers.
The second almost follows from the continuous mapping theorem, but unfortunately our function $g()$ that we want to apply the CMT to changes with $N$:
our $g$ is really $g_N(\theta) := \frac{J^N(\theta)}{N}$. So we
cannot use the CMT.
(Comment: If you
examine the proof of the CMT on Wikipedia,
notice that the set $B_\delta$ they define in their proof for us now
also depends on $n$. We essentially need some sort of equicontinuity at $\theta^*$
over our functions $g_N(\theta)$.)
Fortunately, if you assume that the family $\mathcal{G} = \{g_N | N=1,2,\ldots\}$
is stochastically equicontinuous at $\theta^*$, then it immediately
follows that for $\theta_{MLE} \convp \theta^*$,
\begin{align*}
|g_n(\theta_{MLE}) - g_n(\theta^*)| \convp 0.
\end{align*}
(See here: http://www.cs.berkeley.edu/~jordan/courses/210B-spring07/lectures/stat210b_lecture_12.pdf for a definition of stochastic equicontinuity at $\theta^*$, and a proof of the above fact.)
Therefore, assuming that $\mathcal{G}$ is SE at $\theta^*$, your desired result holds
true and the empirical Fisher information converges to the population Fisher information.
Now, the key question of course is, what sort of conditions do you need
to impose on $\mathcal{G}$ to get SE?
It looks like one way to do this is to establish a Lipshitz condition
on the entire class of functions $\mathcal{G}$ (see here: http://econ.duke.edu/uploads/media_items/uniform-convergence-and-stochastic-equicontinuity.original.pdf ).
|
Observed information matrix is a consistent estimator of the expected information matrix?
$\newcommand{\convp}{\stackrel{P}{\longrightarrow}}$
I guess directly establishing some sort of uniform law of large numbers
is one possible approach.
Here is another.
We want to show that $\frac{J^N(
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.