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
10,001
Difference between samples, time steps and features in neural network
I found this just below the [samples, time_steps, features] you are concerned with. X = numpy.reshape(dataX, (len(dataX), seq_length, 1)) Samples - This is the len(dataX), or the amount of data points you have. Time steps - This is equivalent to the amount of time steps you run your recurrent neural network. If you want your network to have memory of 60 characters, this number should be 60. Features - this is the amount of features in every time step. If you are processing pictures, this is the amount of pixels. In this case you seem to have 1 feature per time step.
Difference between samples, time steps and features in neural network
I found this just below the [samples, time_steps, features] you are concerned with. X = numpy.reshape(dataX, (len(dataX), seq_length, 1)) Samples - This is the len(dataX), or the amount of data poin
Difference between samples, time steps and features in neural network I found this just below the [samples, time_steps, features] you are concerned with. X = numpy.reshape(dataX, (len(dataX), seq_length, 1)) Samples - This is the len(dataX), or the amount of data points you have. Time steps - This is equivalent to the amount of time steps you run your recurrent neural network. If you want your network to have memory of 60 characters, this number should be 60. Features - this is the amount of features in every time step. If you are processing pictures, this is the amount of pixels. In this case you seem to have 1 feature per time step.
Difference between samples, time steps and features in neural network I found this just below the [samples, time_steps, features] you are concerned with. X = numpy.reshape(dataX, (len(dataX), seq_length, 1)) Samples - This is the len(dataX), or the amount of data poin
10,002
Difference between samples, time steps and features in neural network
My answer with an example: ["hello this is xyz","how are you doing","great man..."] in this case "[samples, time steps, features]" means: sample: 3 because there are 3 elements in the list time steps: here you can take max_length = 4 length("hello this is xyz") = 4; length("how are you doing") = 4; length("great man...") = 2 (after removing punctuation "."). The reason of saying this is a time steps is, in first element "hello this is xyz" ==> t0("hello"), t1("this"), t2("is") and t3("xyz") features: the size of embedding for each words. e.g, "hello": 50D array, "this": 50D array and so on
Difference between samples, time steps and features in neural network
My answer with an example: ["hello this is xyz","how are you doing","great man..."] in this case "[samples, time steps, features]" means: sample: 3 because there are 3 elements in the list time step
Difference between samples, time steps and features in neural network My answer with an example: ["hello this is xyz","how are you doing","great man..."] in this case "[samples, time steps, features]" means: sample: 3 because there are 3 elements in the list time steps: here you can take max_length = 4 length("hello this is xyz") = 4; length("how are you doing") = 4; length("great man...") = 2 (after removing punctuation "."). The reason of saying this is a time steps is, in first element "hello this is xyz" ==> t0("hello"), t1("this"), t2("is") and t3("xyz") features: the size of embedding for each words. e.g, "hello": 50D array, "this": 50D array and so on
Difference between samples, time steps and features in neural network My answer with an example: ["hello this is xyz","how are you doing","great man..."] in this case "[samples, time steps, features]" means: sample: 3 because there are 3 elements in the list time step
10,003
Difference between samples, time steps and features in neural network
It's a bit too late but just in case; A Sample may refer to individual training examples. A “batch_size” variable is hence the count of samples you sent to the neural network. That is, how many different examples you feed at once to the neural network. TimeSteps are ticks of time. It is how long in time each of your samples is. For example, a sample can contain 128-time steps, where each time steps could be a 30th of a second for signal processing. In Natural Language Processing (NLP), a time step may be associated with a character, a word, or a sentence, depending on the setup. Features are simply the number of dimensions we feed at each time steps. For example in NLP, a word could be represented by 300 features using word2vec. In the case of signal processing, let’s pretend that your signal is 3D. That is, you have an X, a Y and a Z signal, such as an accelerometer’s measurements on each axis. This means you would have 3 features sent at each time step for each sample. By Guillaume
Difference between samples, time steps and features in neural network
It's a bit too late but just in case; A Sample may refer to individual training examples. A “batch_size” variable is hence the count of samples you sent to the neural network. That is, how many differ
Difference between samples, time steps and features in neural network It's a bit too late but just in case; A Sample may refer to individual training examples. A “batch_size” variable is hence the count of samples you sent to the neural network. That is, how many different examples you feed at once to the neural network. TimeSteps are ticks of time. It is how long in time each of your samples is. For example, a sample can contain 128-time steps, where each time steps could be a 30th of a second for signal processing. In Natural Language Processing (NLP), a time step may be associated with a character, a word, or a sentence, depending on the setup. Features are simply the number of dimensions we feed at each time steps. For example in NLP, a word could be represented by 300 features using word2vec. In the case of signal processing, let’s pretend that your signal is 3D. That is, you have an X, a Y and a Z signal, such as an accelerometer’s measurements on each axis. This means you would have 3 features sent at each time step for each sample. By Guillaume
Difference between samples, time steps and features in neural network It's a bit too late but just in case; A Sample may refer to individual training examples. A “batch_size” variable is hence the count of samples you sent to the neural network. That is, how many differ
10,004
What exactly is called "principal component" in PCA?
You are absolutely correct in observing that even though $\mathbf{u}$ (one of the eigenvectors of the covariance matrix, e.g. the first one) and $\mathbf{X}\mathbf{u}$ (projection of the data onto the 1-dimensional subspace spanned by $\mathbf{u}$) are two different things, both of them are often called "principal component", sometimes even in the same text. In most cases it is clear from the context what exactly is meant. In some rare cases, however, it can indeed be quite confusing, e.g. when some related techniques (such as sparse PCA or CCA) are discussed, where different directions $\mathbf{u}_i$ do not have to be orthogonal. In this case a statement like "components are orthogonal" has very different meanings depending on whether it refers to axes or projections. I would advocate calling $\mathbf{u}$ a "principal axis" or a "principal direction", and $\mathbf{X}\mathbf{u}$ a "principal component". I have also seen $\mathbf u$ called "principal component vector". I should mention that the alternative convention is to call $\mathbf u$ "principal component" and $\mathbf{Xu}$ "principal component scores". Summary of the two conventions: $$\begin{array}{c|c|c} & \text{Convention 1} & \text{Convention 2} \\ \hline \mathbf u & \begin{cases}\text{principal axis}\\ \text{principal direction}\\ \text{principal component vector}\end{cases} & \text{principal component} \\ \mathbf{Xu} & \text{principal component} & \text{principal component scores} \end{array}$$ Note: Only eigenvectors of the covariance matrix corresponding to non-zero eigenvalues can be called principal directions/components. If the covariance matrix is low rank, it will have one or more zero eigenvalues; corresponding eigenvectors (and corresponding projections that are constant zero) should not be called principal directions/components. See some discussion in my answer here.
What exactly is called "principal component" in PCA?
You are absolutely correct in observing that even though $\mathbf{u}$ (one of the eigenvectors of the covariance matrix, e.g. the first one) and $\mathbf{X}\mathbf{u}$ (projection of the data onto the
What exactly is called "principal component" in PCA? You are absolutely correct in observing that even though $\mathbf{u}$ (one of the eigenvectors of the covariance matrix, e.g. the first one) and $\mathbf{X}\mathbf{u}$ (projection of the data onto the 1-dimensional subspace spanned by $\mathbf{u}$) are two different things, both of them are often called "principal component", sometimes even in the same text. In most cases it is clear from the context what exactly is meant. In some rare cases, however, it can indeed be quite confusing, e.g. when some related techniques (such as sparse PCA or CCA) are discussed, where different directions $\mathbf{u}_i$ do not have to be orthogonal. In this case a statement like "components are orthogonal" has very different meanings depending on whether it refers to axes or projections. I would advocate calling $\mathbf{u}$ a "principal axis" or a "principal direction", and $\mathbf{X}\mathbf{u}$ a "principal component". I have also seen $\mathbf u$ called "principal component vector". I should mention that the alternative convention is to call $\mathbf u$ "principal component" and $\mathbf{Xu}$ "principal component scores". Summary of the two conventions: $$\begin{array}{c|c|c} & \text{Convention 1} & \text{Convention 2} \\ \hline \mathbf u & \begin{cases}\text{principal axis}\\ \text{principal direction}\\ \text{principal component vector}\end{cases} & \text{principal component} \\ \mathbf{Xu} & \text{principal component} & \text{principal component scores} \end{array}$$ Note: Only eigenvectors of the covariance matrix corresponding to non-zero eigenvalues can be called principal directions/components. If the covariance matrix is low rank, it will have one or more zero eigenvalues; corresponding eigenvectors (and corresponding projections that are constant zero) should not be called principal directions/components. See some discussion in my answer here.
What exactly is called "principal component" in PCA? You are absolutely correct in observing that even though $\mathbf{u}$ (one of the eigenvectors of the covariance matrix, e.g. the first one) and $\mathbf{X}\mathbf{u}$ (projection of the data onto the
10,005
probability of one random variable being greater than another
This question is now old enough that I can give you a solution without ruining your homework. As you have pointed out in your question, to compute this probability, you need to find the distribution of $D=X-Y$. One of the properties of the normal distribution is that any linear combination of independent normal random variables is also a normal random variable, so this establishes that $D \sim \mathcal{N}$, and it remains only to find the mean and variance of this random variable. You have correctly derived the mean, but incorrectly derived the variance. To obtain the mean and variance of $D$ we apply standard rules for the mean and variance of linear functions of random variables. Since the mean is a linear operator and the variance is a quadratic operator, we have: $$\mathbb{E}(D) = \mathbb{E}(X-Y) = \mathbb{E}(X) - \mathbb{E}(Y) = 1-2 = -1.$$ $$\mathbb{V}(D) = \mathbb{V}(X-Y) = \mathbb{V}(X) + (-1)^2 \mathbb{V}(Y) = 2+3 = 5.$$ Thus, you have the probability: $$\begin{equation} \begin{aligned} \mathbb{P}(X>Y) = \mathbb{P}(X-Y>0) &= \mathbb{P}(D>0) \\[6pt] &= \mathbb{P} \bigg( \frac{D+1}{\sqrt{5}} > \frac{0+1}{\sqrt{5}} \bigg) \\[6pt] &= 1-\Phi \bigg( \frac{0+1}{\sqrt{5}} \bigg) \\[6pt] &= 0.3273604, \\[6pt] \end{aligned} \end{equation}$$ where $\Phi$ denotes the cumulative distribution function for the standard normal distribution.
probability of one random variable being greater than another
This question is now old enough that I can give you a solution without ruining your homework. As you have pointed out in your question, to compute this probability, you need to find the distribution
probability of one random variable being greater than another This question is now old enough that I can give you a solution without ruining your homework. As you have pointed out in your question, to compute this probability, you need to find the distribution of $D=X-Y$. One of the properties of the normal distribution is that any linear combination of independent normal random variables is also a normal random variable, so this establishes that $D \sim \mathcal{N}$, and it remains only to find the mean and variance of this random variable. You have correctly derived the mean, but incorrectly derived the variance. To obtain the mean and variance of $D$ we apply standard rules for the mean and variance of linear functions of random variables. Since the mean is a linear operator and the variance is a quadratic operator, we have: $$\mathbb{E}(D) = \mathbb{E}(X-Y) = \mathbb{E}(X) - \mathbb{E}(Y) = 1-2 = -1.$$ $$\mathbb{V}(D) = \mathbb{V}(X-Y) = \mathbb{V}(X) + (-1)^2 \mathbb{V}(Y) = 2+3 = 5.$$ Thus, you have the probability: $$\begin{equation} \begin{aligned} \mathbb{P}(X>Y) = \mathbb{P}(X-Y>0) &= \mathbb{P}(D>0) \\[6pt] &= \mathbb{P} \bigg( \frac{D+1}{\sqrt{5}} > \frac{0+1}{\sqrt{5}} \bigg) \\[6pt] &= 1-\Phi \bigg( \frac{0+1}{\sqrt{5}} \bigg) \\[6pt] &= 0.3273604, \\[6pt] \end{aligned} \end{equation}$$ where $\Phi$ denotes the cumulative distribution function for the standard normal distribution.
probability of one random variable being greater than another This question is now old enough that I can give you a solution without ruining your homework. As you have pointed out in your question, to compute this probability, you need to find the distribution
10,006
probability of one random variable being greater than another
Ok, since this is homework, you get hints instead if straight answers. Rather than thinking about $P(X>Y)$ why not think about $P(X-Y>0)$. This is clearly the same probability yes? So now you just need to work out the distribution of $Z=X-Y$ Do you know how to do that? Edit Ok, so your problem is with the distribution of the difference. Try this: If $Y \sim N(1,2)$ then what is the distribution of $2Y$? Well, we double the mean and multiply the variance by $2^2$, so $Y \sim N(2,8)$. Notice that this ensures that the spread of the distribution (standard deviation) has doubled, which makes sense. Now you know how to add random variable so what happens if you do $Z = X + (-Y)$ instead? (In fact this is basically the same argument as pointed out in an older question by Dilip Sarwate: https://stats.stackexchange.com/a/31328/6633)
probability of one random variable being greater than another
Ok, since this is homework, you get hints instead if straight answers. Rather than thinking about $P(X>Y)$ why not think about $P(X-Y>0)$. This is clearly the same probability yes? So now you just n
probability of one random variable being greater than another Ok, since this is homework, you get hints instead if straight answers. Rather than thinking about $P(X>Y)$ why not think about $P(X-Y>0)$. This is clearly the same probability yes? So now you just need to work out the distribution of $Z=X-Y$ Do you know how to do that? Edit Ok, so your problem is with the distribution of the difference. Try this: If $Y \sim N(1,2)$ then what is the distribution of $2Y$? Well, we double the mean and multiply the variance by $2^2$, so $Y \sim N(2,8)$. Notice that this ensures that the spread of the distribution (standard deviation) has doubled, which makes sense. Now you know how to add random variable so what happens if you do $Z = X + (-Y)$ instead? (In fact this is basically the same argument as pointed out in an older question by Dilip Sarwate: https://stats.stackexchange.com/a/31328/6633)
probability of one random variable being greater than another Ok, since this is homework, you get hints instead if straight answers. Rather than thinking about $P(X>Y)$ why not think about $P(X-Y>0)$. This is clearly the same probability yes? So now you just n
10,007
probability of one random variable being greater than another
$D=X-Y$ is normal with mean $-1$ and variance $2+3$. Knowing the distribution of $D$, you can calculate required probability.
probability of one random variable being greater than another
$D=X-Y$ is normal with mean $-1$ and variance $2+3$. Knowing the distribution of $D$, you can calculate required probability.
probability of one random variable being greater than another $D=X-Y$ is normal with mean $-1$ and variance $2+3$. Knowing the distribution of $D$, you can calculate required probability.
probability of one random variable being greater than another $D=X-Y$ is normal with mean $-1$ and variance $2+3$. Knowing the distribution of $D$, you can calculate required probability.
10,008
probability of one random variable being greater than another
I think this should work. In general, suppose $X$ has distribution function $\mathbb{G}(x)$, and $Y$ has distribution function $\mathbb{H}(x)$ and $X$ and $Y$ are independent. We need to find the probability $P(X>Y)$. Now, for some constant $\alpha$, $P(Y<\alpha)=\mathbb{H}(\alpha)$. Therefore, $P(Y<X)=\int_{x}\mathbb{H}(\alpha)d\mathbb{G}(\alpha)$.
probability of one random variable being greater than another
I think this should work. In general, suppose $X$ has distribution function $\mathbb{G}(x)$, and $Y$ has distribution function $\mathbb{H}(x)$ and $X$ and $Y$ are independent. We need to find the pro
probability of one random variable being greater than another I think this should work. In general, suppose $X$ has distribution function $\mathbb{G}(x)$, and $Y$ has distribution function $\mathbb{H}(x)$ and $X$ and $Y$ are independent. We need to find the probability $P(X>Y)$. Now, for some constant $\alpha$, $P(Y<\alpha)=\mathbb{H}(\alpha)$. Therefore, $P(Y<X)=\int_{x}\mathbb{H}(\alpha)d\mathbb{G}(\alpha)$.
probability of one random variable being greater than another I think this should work. In general, suppose $X$ has distribution function $\mathbb{G}(x)$, and $Y$ has distribution function $\mathbb{H}(x)$ and $X$ and $Y$ are independent. We need to find the pro
10,009
What does it mean that AUC is a semi-proper scoring rule?
Let's start with an example. Say Alice is a track coach and wants to pick an athlete to represent the team in an upcoming sporting event, a 200m sprint. Naturally she wants to pick the fastest runner. A strictly proper scoring rule would be to nominate the fastest runner of the team over the 200m distance. This maximizes exactly what coach Alice wants in this situation. The athlete with the fastest expected performance gets selected - this is a fair discriminatory test. A proper scoring rule would be to pick an athlete who is able run 200m the fastest but the time is rounded to the nearest half of a second. The best athlete as well as potentially some other athletes will also be able to pass this test. All athletes who are selected this way are quite competitive but clearly this is not a perfect discriminatory test of speed. A semi-proper scoring rule would be to pick an athlete who is able run 200m below a competitive time threshold, e.g. 22 seconds. As before, the best athlete as well as some other athletes will also be able to pass this test. Similarly all athletes who are selected this way might be quite competitive but clearly not only this is not a perfect discriminatory test but it can also go horribly bad (if we pick a too lenient or too stringent time). Note that is not outright wrong. An improper scoring rule would be to pick the athlete with the strongest legs, e.g. who can squat the most weights. Certainly, any good sprinter probably has very strong legs but this test means that some guys from the weight-lifting team will excel here. Clearly a weight-lifter in a 200m race would be catastrophic! While somewhat trivialised the example above shows what takes place with the use of scoring rules. Alice was forecasting expected sprint time. Within the context of classification we forecast probabilities minimising the error of a probabilistic classifier. A strictly proper scoring rule, like the Brier score, guarantees that the best score will only be attained when we are as close to the true probabilities as possible. A proper scoring rule, like the continuous ranked probability score (CRPS), does not guarantee that the best score will only be attained by a classifier whose predictions are the closest to the true probabilities. Other candidate classifiers might attain CRPS scores that match that of the optimal classifier. A semi-proper scoring rule, like the AUC-ROC, not only does it not guarantee that the best performance will be attained by a classifier whose predictions are the closest to the true probabilities, but it is also (potentially) possible to improve on the values of AUC-ROC by moving the predicted probabilities away from their true values. Nevertheless, under certain conditions (eg. the class distribution is a priori known in the case of AUC-ROC) such rules can approximate a proper scoring rule. Byrne (2016) "A note on the use of empirical AUC for evaluating probabilistic forecasts" raises some interesting points regarding AUC-ROC. An improper scoring rule, like Accuracy, offers little to no connection to our original task of predicting probabilities as close as possible to the true probabilities. As we see semi-proper scoring rule is not perfect but it is not outright catastrophic either. It can be quite useful during prediction actually! Cagdas Ozgenc has a great example here where working with an improper/semi-proper rule is preferable to a strictly proper rule. In general, the term semi-proper scoring rule is not very common. It is associated with improper rules that can be nevertheless helpful (eg. AUC-ROC or MAE in probabilistic classification). Finally, notice something important. As sprinting is associated with strong legs, so is correct probabilistic classification with Accuracy. It is unlikely that a good sprinter will have weak legs and similarly it is unlikely that a good classifier will have bad Accuracy. Nevertheless, equating Accuracy with good classifier performance is like equating leg strength with good sprinting performance. Not completely unfounded but very plausible to lead to nonsensical results.
What does it mean that AUC is a semi-proper scoring rule?
Let's start with an example. Say Alice is a track coach and wants to pick an athlete to represent the team in an upcoming sporting event, a 200m sprint. Naturally she wants to pick the fastest runner.
What does it mean that AUC is a semi-proper scoring rule? Let's start with an example. Say Alice is a track coach and wants to pick an athlete to represent the team in an upcoming sporting event, a 200m sprint. Naturally she wants to pick the fastest runner. A strictly proper scoring rule would be to nominate the fastest runner of the team over the 200m distance. This maximizes exactly what coach Alice wants in this situation. The athlete with the fastest expected performance gets selected - this is a fair discriminatory test. A proper scoring rule would be to pick an athlete who is able run 200m the fastest but the time is rounded to the nearest half of a second. The best athlete as well as potentially some other athletes will also be able to pass this test. All athletes who are selected this way are quite competitive but clearly this is not a perfect discriminatory test of speed. A semi-proper scoring rule would be to pick an athlete who is able run 200m below a competitive time threshold, e.g. 22 seconds. As before, the best athlete as well as some other athletes will also be able to pass this test. Similarly all athletes who are selected this way might be quite competitive but clearly not only this is not a perfect discriminatory test but it can also go horribly bad (if we pick a too lenient or too stringent time). Note that is not outright wrong. An improper scoring rule would be to pick the athlete with the strongest legs, e.g. who can squat the most weights. Certainly, any good sprinter probably has very strong legs but this test means that some guys from the weight-lifting team will excel here. Clearly a weight-lifter in a 200m race would be catastrophic! While somewhat trivialised the example above shows what takes place with the use of scoring rules. Alice was forecasting expected sprint time. Within the context of classification we forecast probabilities minimising the error of a probabilistic classifier. A strictly proper scoring rule, like the Brier score, guarantees that the best score will only be attained when we are as close to the true probabilities as possible. A proper scoring rule, like the continuous ranked probability score (CRPS), does not guarantee that the best score will only be attained by a classifier whose predictions are the closest to the true probabilities. Other candidate classifiers might attain CRPS scores that match that of the optimal classifier. A semi-proper scoring rule, like the AUC-ROC, not only does it not guarantee that the best performance will be attained by a classifier whose predictions are the closest to the true probabilities, but it is also (potentially) possible to improve on the values of AUC-ROC by moving the predicted probabilities away from their true values. Nevertheless, under certain conditions (eg. the class distribution is a priori known in the case of AUC-ROC) such rules can approximate a proper scoring rule. Byrne (2016) "A note on the use of empirical AUC for evaluating probabilistic forecasts" raises some interesting points regarding AUC-ROC. An improper scoring rule, like Accuracy, offers little to no connection to our original task of predicting probabilities as close as possible to the true probabilities. As we see semi-proper scoring rule is not perfect but it is not outright catastrophic either. It can be quite useful during prediction actually! Cagdas Ozgenc has a great example here where working with an improper/semi-proper rule is preferable to a strictly proper rule. In general, the term semi-proper scoring rule is not very common. It is associated with improper rules that can be nevertheless helpful (eg. AUC-ROC or MAE in probabilistic classification). Finally, notice something important. As sprinting is associated with strong legs, so is correct probabilistic classification with Accuracy. It is unlikely that a good sprinter will have weak legs and similarly it is unlikely that a good classifier will have bad Accuracy. Nevertheless, equating Accuracy with good classifier performance is like equating leg strength with good sprinting performance. Not completely unfounded but very plausible to lead to nonsensical results.
What does it mean that AUC is a semi-proper scoring rule? Let's start with an example. Say Alice is a track coach and wants to pick an athlete to represent the team in an upcoming sporting event, a 200m sprint. Naturally she wants to pick the fastest runner.
10,010
Are line search methods used in deep learning? Why not?
Vanilla gradient descent can be made more reliable using line searches; I've written algorithms that do this and it makes for a very stable algorithm (although not necessarily fast). However, it makes almost no sense to do a line search for stochastic gradient methods. The reason I say this is that if we do a line search based on minimizing the full loss function, we've immediately lost one of the main motivations for doing stochastic methods; we now need to compute the full loss function for each update, which typically has computational cost comparable to computing the full first derivative. Given that we wanted to avoid computing the full gradient because of computational costs, it seems very unlikely that we want be okay with computing the full loss function. Alternatively, you might think of doing something like a line search based on your randomly sampled data point. However, this isn't a good idea either; this will tell you nothing about whether you have stepped too far (which is the main benefit of line searches). For example, suppose you are performing logistic regression. Then each outcome is simply a 0 or 1, and for any single sample, we trivially get perfect separation so the optimal solution for our regression parameters based on the sample of 1 is trivially $-\infty$ or $\infty$ by the Hauck Donner effect. That's not good. EDIT @DeltaIV points out that this also applies to mini-batch, not just individual samples.
Are line search methods used in deep learning? Why not?
Vanilla gradient descent can be made more reliable using line searches; I've written algorithms that do this and it makes for a very stable algorithm (although not necessarily fast). However, it make
Are line search methods used in deep learning? Why not? Vanilla gradient descent can be made more reliable using line searches; I've written algorithms that do this and it makes for a very stable algorithm (although not necessarily fast). However, it makes almost no sense to do a line search for stochastic gradient methods. The reason I say this is that if we do a line search based on minimizing the full loss function, we've immediately lost one of the main motivations for doing stochastic methods; we now need to compute the full loss function for each update, which typically has computational cost comparable to computing the full first derivative. Given that we wanted to avoid computing the full gradient because of computational costs, it seems very unlikely that we want be okay with computing the full loss function. Alternatively, you might think of doing something like a line search based on your randomly sampled data point. However, this isn't a good idea either; this will tell you nothing about whether you have stepped too far (which is the main benefit of line searches). For example, suppose you are performing logistic regression. Then each outcome is simply a 0 or 1, and for any single sample, we trivially get perfect separation so the optimal solution for our regression parameters based on the sample of 1 is trivially $-\infty$ or $\infty$ by the Hauck Donner effect. That's not good. EDIT @DeltaIV points out that this also applies to mini-batch, not just individual samples.
Are line search methods used in deep learning? Why not? Vanilla gradient descent can be made more reliable using line searches; I've written algorithms that do this and it makes for a very stable algorithm (although not necessarily fast). However, it make
10,011
Are line search methods used in deep learning? Why not?
The tutorials talk about gradient descent presumably because it is one of the simplest algorithms used for optimization, so it is easy to explain. Since most of such tutorials are rather brief, they focus on simple stuff. There are at least several popular optimization algorithms beyond simple gradient descent that are used for deep learning. Actually people often use different algorithms then gradient descent since they usually converge faster. Some of them have non-constant learning rate (e.g. decreasing over time). For review of such algorithms you can check the An overview of gradient descent optimization algorithms post by Sebastian Ruder (or the arXived paper).
Are line search methods used in deep learning? Why not?
The tutorials talk about gradient descent presumably because it is one of the simplest algorithms used for optimization, so it is easy to explain. Since most of such tutorials are rather brief, they f
Are line search methods used in deep learning? Why not? The tutorials talk about gradient descent presumably because it is one of the simplest algorithms used for optimization, so it is easy to explain. Since most of such tutorials are rather brief, they focus on simple stuff. There are at least several popular optimization algorithms beyond simple gradient descent that are used for deep learning. Actually people often use different algorithms then gradient descent since they usually converge faster. Some of them have non-constant learning rate (e.g. decreasing over time). For review of such algorithms you can check the An overview of gradient descent optimization algorithms post by Sebastian Ruder (or the arXived paper).
Are line search methods used in deep learning? Why not? The tutorials talk about gradient descent presumably because it is one of the simplest algorithms used for optimization, so it is easy to explain. Since most of such tutorials are rather brief, they f
10,012
Are line search methods used in deep learning? Why not?
This question was asked in early 2018, but if you still wait for an answer then: Yes, now there are some implementation of line search in DNN with good performances. See: https://arxiv.org/abs/1808.05160 (published in 2 journals) and more recently, by a different group: https://arxiv.org/abs/1905.09997 (published in ICML). It is important to note that instead of many claims: 1st, the theoretical results in the stochastic settings are not strong enough (for convex functions only, most DNN are highly nonconvex) and 2nd, implementation in DNN requires some modifications to suit with mini-batch practice (stochastic optimisation, while close, is not the same as mini-batch practice). P.S. The performances were done on CIFAR10 and CIFAR100. Now more resources and personnel needed to check with a larger range of datasets/DNN. You can also look at the Wikipedia page: https://en.wikipedia.org/wiki/Backtracking_line_search
Are line search methods used in deep learning? Why not?
This question was asked in early 2018, but if you still wait for an answer then: Yes, now there are some implementation of line search in DNN with good performances. See: https://arxiv.org/abs/1808.05
Are line search methods used in deep learning? Why not? This question was asked in early 2018, but if you still wait for an answer then: Yes, now there are some implementation of line search in DNN with good performances. See: https://arxiv.org/abs/1808.05160 (published in 2 journals) and more recently, by a different group: https://arxiv.org/abs/1905.09997 (published in ICML). It is important to note that instead of many claims: 1st, the theoretical results in the stochastic settings are not strong enough (for convex functions only, most DNN are highly nonconvex) and 2nd, implementation in DNN requires some modifications to suit with mini-batch practice (stochastic optimisation, while close, is not the same as mini-batch practice). P.S. The performances were done on CIFAR10 and CIFAR100. Now more resources and personnel needed to check with a larger range of datasets/DNN. You can also look at the Wikipedia page: https://en.wikipedia.org/wiki/Backtracking_line_search
Are line search methods used in deep learning? Why not? This question was asked in early 2018, but if you still wait for an answer then: Yes, now there are some implementation of line search in DNN with good performances. See: https://arxiv.org/abs/1808.05
10,013
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate]
I realize this is a year old post but its likely to come up again. There are many factors that play into this, I'd argue the most important is your hypothesis. So there is no clear answer but I generally follow these rules-of-thumb: 1) Type II is only when you don't have an interaction term. 2) Type I vs Type III to test the interaction term...I go Type I all the time reason is this Type I SS for dv ~ A + B + A*B depends on order so...its sequential SS(A) SS(B|A) SS(A*B|A B) This is great to test your interaction...but not great to test the main effects since the effect of B is dependent on A. Type II gets around this SS(A|B) SS(B|A) Which looks great to test your main effects IF there is no interaction term. Type III: SS(A| A*B B) SS(B| A*B A) Which given the most common hypotheses...doesn't seem very useful since most people are interested in the interaction term, not the main effects when an interaction term is present. So in this case I'd use Type-I to test the interaction term. If not significant I'd refit without the interaction term and use Type-II to test the main effects. warning: anova() in R is Type-I, to get Type-II (or III) use the Anova() in the car package.
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate]
I realize this is a year old post but its likely to come up again. There are many factors that play into this, I'd argue the most important is your hypothesis. So there is no clear answer but I genera
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate] I realize this is a year old post but its likely to come up again. There are many factors that play into this, I'd argue the most important is your hypothesis. So there is no clear answer but I generally follow these rules-of-thumb: 1) Type II is only when you don't have an interaction term. 2) Type I vs Type III to test the interaction term...I go Type I all the time reason is this Type I SS for dv ~ A + B + A*B depends on order so...its sequential SS(A) SS(B|A) SS(A*B|A B) This is great to test your interaction...but not great to test the main effects since the effect of B is dependent on A. Type II gets around this SS(A|B) SS(B|A) Which looks great to test your main effects IF there is no interaction term. Type III: SS(A| A*B B) SS(B| A*B A) Which given the most common hypotheses...doesn't seem very useful since most people are interested in the interaction term, not the main effects when an interaction term is present. So in this case I'd use Type-I to test the interaction term. If not significant I'd refit without the interaction term and use Type-II to test the main effects. warning: anova() in R is Type-I, to get Type-II (or III) use the Anova() in the car package.
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate] I realize this is a year old post but its likely to come up again. There are many factors that play into this, I'd argue the most important is your hypothesis. So there is no clear answer but I genera
10,014
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate]
I've never been a fan of Type III SS for ANOVA's so this is a biased recommendation. I believe you should select Type II in this case. In the Type I ANOVA order matters. So, whether you include iV1, or iV2 first makes a difference because the first (e.g. iV1) is compared to a model with just an intercept while the second is compared to a model with an intercept and the first. Try out switching the order they're in and you'll see the difference in main effect outcomes because your predictors are correlated. The Type III gets around this by assessing each predictor, including the interaction against a model including everything but that predictor. That sounds like a good idea until you try to consider what an interaction is without one of the main effects included. You're comparing the predictor to what is essentially a nonsensical model (I think one of your references sort of goes into this). (Furthermore, my recollection is that Type III is especially sensitive to missing cells (thus Type IV I believe).) Type II gets around the order issue in Type I and compares sensible models (unlike Type III). Main effects are tested with all other main effects in the model but not the interaction. Thus each main effect is easily interpreted as the unique contribution of that predictor. Note, all of the SS types discussed would get the same interaction effect in your case because it's assessed with all of the main effects included in each case.
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate]
I've never been a fan of Type III SS for ANOVA's so this is a biased recommendation. I believe you should select Type II in this case. In the Type I ANOVA order matters. So, whether you include iV1,
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate] I've never been a fan of Type III SS for ANOVA's so this is a biased recommendation. I believe you should select Type II in this case. In the Type I ANOVA order matters. So, whether you include iV1, or iV2 first makes a difference because the first (e.g. iV1) is compared to a model with just an intercept while the second is compared to a model with an intercept and the first. Try out switching the order they're in and you'll see the difference in main effect outcomes because your predictors are correlated. The Type III gets around this by assessing each predictor, including the interaction against a model including everything but that predictor. That sounds like a good idea until you try to consider what an interaction is without one of the main effects included. You're comparing the predictor to what is essentially a nonsensical model (I think one of your references sort of goes into this). (Furthermore, my recollection is that Type III is especially sensitive to missing cells (thus Type IV I believe).) Type II gets around the order issue in Type I and compares sensible models (unlike Type III). Main effects are tested with all other main effects in the model but not the interaction. Thus each main effect is easily interpreted as the unique contribution of that predictor. Note, all of the SS types discussed would get the same interaction effect in your case because it's assessed with all of the main effects included in each case.
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate] I've never been a fan of Type III SS for ANOVA's so this is a biased recommendation. I believe you should select Type II in this case. In the Type I ANOVA order matters. So, whether you include iV1,
10,015
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate]
I have recently made a decision : I will never use again an ANOVA sum-of-squares testing, except for the interaction. Why ? Because, in general, the hypothesis $H_0$ of the tests of the main effects are diffcult to interpet. Because we can do something really more instructive and interpretable: multiple comparisons with confidence intervals.
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate]
I have recently made a decision : I will never use again an ANOVA sum-of-squares testing, except for the interaction. Why ? Because, in general, the hypothesis $H_0$ of the tests of the main effects
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate] I have recently made a decision : I will never use again an ANOVA sum-of-squares testing, except for the interaction. Why ? Because, in general, the hypothesis $H_0$ of the tests of the main effects are diffcult to interpet. Because we can do something really more instructive and interpretable: multiple comparisons with confidence intervals.
Choice between Type-I, Type-II, or Type-III ANOVA [duplicate] I have recently made a decision : I will never use again an ANOVA sum-of-squares testing, except for the interaction. Why ? Because, in general, the hypothesis $H_0$ of the tests of the main effects
10,016
How to estimate how many people attended an event (say, a political rally)?
You could estimate the people per square meter (use a few areas, of at least a few square meters each to get a good estimate) and multiply this by the size of the area. Here is an article on this topic: How is Crowd Size estimated?
How to estimate how many people attended an event (say, a political rally)?
You could estimate the people per square meter (use a few areas, of at least a few square meters each to get a good estimate) and multiply this by the size of the area. Here is an article on this topi
How to estimate how many people attended an event (say, a political rally)? You could estimate the people per square meter (use a few areas, of at least a few square meters each to get a good estimate) and multiply this by the size of the area. Here is an article on this topic: How is Crowd Size estimated?
How to estimate how many people attended an event (say, a political rally)? You could estimate the people per square meter (use a few areas, of at least a few square meters each to get a good estimate) and multiply this by the size of the area. Here is an article on this topi
10,017
How to estimate how many people attended an event (say, a political rally)?
As a follow up to this question (thanks to all for the answers), Significance magazine just published an article about this very question (it's the cover story, to boot): "How many were there when it mattered? Estimating the sizes of crowds." September 2011, volume 8, issue 3, pages 104-107, by Ray Watson and Paul Yip. It looks like they are trying to post an electronic version at the link above, but it didn't work for me just now when I tried.
How to estimate how many people attended an event (say, a political rally)?
As a follow up to this question (thanks to all for the answers), Significance magazine just published an article about this very question (it's the cover story, to boot): "How many were there when it
How to estimate how many people attended an event (say, a political rally)? As a follow up to this question (thanks to all for the answers), Significance magazine just published an article about this very question (it's the cover story, to boot): "How many were there when it mattered? Estimating the sizes of crowds." September 2011, volume 8, issue 3, pages 104-107, by Ray Watson and Paul Yip. It looks like they are trying to post an electronic version at the link above, but it didn't work for me just now when I tried.
How to estimate how many people attended an event (say, a political rally)? As a follow up to this question (thanks to all for the answers), Significance magazine just published an article about this very question (it's the cover story, to boot): "How many were there when it
10,018
How to estimate how many people attended an event (say, a political rally)?
Tim's linked article is great, though I think the company that counts people in grids is making it out to be easier than it really is. In the local (DC) papers, I've seen quotes about Metro rider usage (except there were two other major events downtown the same day), attempts to count people at security checkpoints, grid square counting from aerial photos, quoting the numbers put on Park Service event applications, etc, none of which impress me in a large town with many things going on concurrently.
How to estimate how many people attended an event (say, a political rally)?
Tim's linked article is great, though I think the company that counts people in grids is making it out to be easier than it really is. In the local (DC) papers, I've seen quotes about Metro rider usag
How to estimate how many people attended an event (say, a political rally)? Tim's linked article is great, though I think the company that counts people in grids is making it out to be easier than it really is. In the local (DC) papers, I've seen quotes about Metro rider usage (except there were two other major events downtown the same day), attempts to count people at security checkpoints, grid square counting from aerial photos, quoting the numbers put on Park Service event applications, etc, none of which impress me in a large town with many things going on concurrently.
How to estimate how many people attended an event (say, a political rally)? Tim's linked article is great, though I think the company that counts people in grids is making it out to be easier than it really is. In the local (DC) papers, I've seen quotes about Metro rider usag
10,019
How to estimate how many people attended an event (say, a political rally)?
Mobile phone providers can count the number of phones in the area. Having an estimate of the mean number of phones/person good approximation can be calculated. This looks simple, so I assume it is in practice.
How to estimate how many people attended an event (say, a political rally)?
Mobile phone providers can count the number of phones in the area. Having an estimate of the mean number of phones/person good approximation can be calculated. This looks simple, so I assume it is in
How to estimate how many people attended an event (say, a political rally)? Mobile phone providers can count the number of phones in the area. Having an estimate of the mean number of phones/person good approximation can be calculated. This looks simple, so I assume it is in practice.
How to estimate how many people attended an event (say, a political rally)? Mobile phone providers can count the number of phones in the area. Having an estimate of the mean number of phones/person good approximation can be calculated. This looks simple, so I assume it is in
10,020
How to estimate how many people attended an event (say, a political rally)?
There are companies that specialize in counting people. For instance, www.lynce.es$^\dagger$ (I am not affiliated nor have any interest whatsoever in such company). They hung cameras over the groups they want to count, shoot pictures and actually count heads. They only make small adjustments when it comes to estimate people under trees or other objects which prevent direct vision. $\dagger$ The archived link can be found here.
How to estimate how many people attended an event (say, a political rally)?
There are companies that specialize in counting people. For instance, www.lynce.es$^\dagger$ (I am not affiliated nor have any interest whatsoever in such company). They hung cameras over the groups t
How to estimate how many people attended an event (say, a political rally)? There are companies that specialize in counting people. For instance, www.lynce.es$^\dagger$ (I am not affiliated nor have any interest whatsoever in such company). They hung cameras over the groups they want to count, shoot pictures and actually count heads. They only make small adjustments when it comes to estimate people under trees or other objects which prevent direct vision. $\dagger$ The archived link can be found here.
How to estimate how many people attended an event (say, a political rally)? There are companies that specialize in counting people. For instance, www.lynce.es$^\dagger$ (I am not affiliated nor have any interest whatsoever in such company). They hung cameras over the groups t
10,021
How to estimate how many people attended an event (say, a political rally)?
As an alternative to WiFi mentioned by Uri, you could place Bluetooth scanner(s) in 'strategic' locations of your venue. I've attended a presentation during MPA workshop about such development in Netherlands.
How to estimate how many people attended an event (say, a political rally)?
As an alternative to WiFi mentioned by Uri, you could place Bluetooth scanner(s) in 'strategic' locations of your venue. I've attended a presentation during MPA workshop about such development in Neth
How to estimate how many people attended an event (say, a political rally)? As an alternative to WiFi mentioned by Uri, you could place Bluetooth scanner(s) in 'strategic' locations of your venue. I've attended a presentation during MPA workshop about such development in Netherlands.
How to estimate how many people attended an event (say, a political rally)? As an alternative to WiFi mentioned by Uri, you could place Bluetooth scanner(s) in 'strategic' locations of your venue. I've attended a presentation during MPA workshop about such development in Neth
10,022
How to estimate how many people attended an event (say, a political rally)?
Here's an idea (but I am not sure this could work in practice): place a free wifi access point, and count the number of connections ( of iPhones, blackbery...).
How to estimate how many people attended an event (say, a political rally)?
Here's an idea (but I am not sure this could work in practice): place a free wifi access point, and count the number of connections ( of iPhones, blackbery...).
How to estimate how many people attended an event (say, a political rally)? Here's an idea (but I am not sure this could work in practice): place a free wifi access point, and count the number of connections ( of iPhones, blackbery...).
How to estimate how many people attended an event (say, a political rally)? Here's an idea (but I am not sure this could work in practice): place a free wifi access point, and count the number of connections ( of iPhones, blackbery...).
10,023
How to estimate how many people attended an event (say, a political rally)?
A police officer told me once that they had rules of thumb to guesstimate attendance at demonstrations (don't ask me for specifics), probably based on what Tim said.
How to estimate how many people attended an event (say, a political rally)?
A police officer told me once that they had rules of thumb to guesstimate attendance at demonstrations (don't ask me for specifics), probably based on what Tim said.
How to estimate how many people attended an event (say, a political rally)? A police officer told me once that they had rules of thumb to guesstimate attendance at demonstrations (don't ask me for specifics), probably based on what Tim said.
How to estimate how many people attended an event (say, a political rally)? A police officer told me once that they had rules of thumb to guesstimate attendance at demonstrations (don't ask me for specifics), probably based on what Tim said.
10,024
Any suggestions for making R code use multiple processors?
If it's on Linux, then the most straight-forward is multicore. Beyond that, I suggest having a look at MPI (especially with the snow package). More generally, have a look at: The High-Performance Computing view on CRAN. "State of the Art in Parallel Computing with R" Lastly, I recommend using the foreach package to abstract away the parallel backend in your code. That will make it more useful in the long run.
Any suggestions for making R code use multiple processors?
If it's on Linux, then the most straight-forward is multicore. Beyond that, I suggest having a look at MPI (especially with the snow package). More generally, have a look at: The High-Performance Co
Any suggestions for making R code use multiple processors? If it's on Linux, then the most straight-forward is multicore. Beyond that, I suggest having a look at MPI (especially with the snow package). More generally, have a look at: The High-Performance Computing view on CRAN. "State of the Art in Parallel Computing with R" Lastly, I recommend using the foreach package to abstract away the parallel backend in your code. That will make it more useful in the long run.
Any suggestions for making R code use multiple processors? If it's on Linux, then the most straight-forward is multicore. Beyond that, I suggest having a look at MPI (especially with the snow package). More generally, have a look at: The High-Performance Co
10,025
Any suggestions for making R code use multiple processors?
If you are using GNU/Linux previous answers by Shane and Dirk are great. If you need a solution for windows, there is one in this post: Parallel Multicore Processing with R (on Windows) Although the package is not yet on CRAN. it can be downloaded from that link.
Any suggestions for making R code use multiple processors?
If you are using GNU/Linux previous answers by Shane and Dirk are great. If you need a solution for windows, there is one in this post: Parallel Multicore Processing with R (on Windows) Although the p
Any suggestions for making R code use multiple processors? If you are using GNU/Linux previous answers by Shane and Dirk are great. If you need a solution for windows, there is one in this post: Parallel Multicore Processing with R (on Windows) Although the package is not yet on CRAN. it can be downloaded from that link.
Any suggestions for making R code use multiple processors? If you are using GNU/Linux previous answers by Shane and Dirk are great. If you need a solution for windows, there is one in this post: Parallel Multicore Processing with R (on Windows) Although the p
10,026
Any suggestions for making R code use multiple processors?
Shane is correct. Both multicore and Rmpi are winners. Slightly broader coverage of the topic is in the CRAN Task View on High-Performance Computing. This also links to a fairly recent survey article on Parallel Computing with R from JSS. Lastly, a few hands-on examples and tips are in the Intro to HPC with R tutorial I give once in a while -- see my presentations page for the most recent copy from last week at useR.
Any suggestions for making R code use multiple processors?
Shane is correct. Both multicore and Rmpi are winners. Slightly broader coverage of the topic is in the CRAN Task View on High-Performance Computing. This also links to a fairly recent survey article
Any suggestions for making R code use multiple processors? Shane is correct. Both multicore and Rmpi are winners. Slightly broader coverage of the topic is in the CRAN Task View on High-Performance Computing. This also links to a fairly recent survey article on Parallel Computing with R from JSS. Lastly, a few hands-on examples and tips are in the Intro to HPC with R tutorial I give once in a while -- see my presentations page for the most recent copy from last week at useR.
Any suggestions for making R code use multiple processors? Shane is correct. Both multicore and Rmpi are winners. Slightly broader coverage of the topic is in the CRAN Task View on High-Performance Computing. This also links to a fairly recent survey article
10,027
Any suggestions for making R code use multiple processors?
I noticed that the previous answers lack some general HPC considerations. First of all, neither of those packages will enable you to run one SVM in parallel. So what you can speed up is parameter optimization or cross-validation, still you must write your own functions for that. Or of course you may run the job for different datasets in parallel, if it is a case. The second issue is memory; if you want to spread calculation over a few physical computers, there is no free lunch and you must copy the data -- here you must consider if it makes sense to predistribute a copy of data across computers to save some communication. On the other hand if you wish to use multiple cores on one computer, than the multicore is especially appropriate because it enables all child processes to access the memory of the parent process, so you can save some time and a lot of memory space.
Any suggestions for making R code use multiple processors?
I noticed that the previous answers lack some general HPC considerations. First of all, neither of those packages will enable you to run one SVM in parallel. So what you can speed up is parameter opti
Any suggestions for making R code use multiple processors? I noticed that the previous answers lack some general HPC considerations. First of all, neither of those packages will enable you to run one SVM in parallel. So what you can speed up is parameter optimization or cross-validation, still you must write your own functions for that. Or of course you may run the job for different datasets in parallel, if it is a case. The second issue is memory; if you want to spread calculation over a few physical computers, there is no free lunch and you must copy the data -- here you must consider if it makes sense to predistribute a copy of data across computers to save some communication. On the other hand if you wish to use multiple cores on one computer, than the multicore is especially appropriate because it enables all child processes to access the memory of the parent process, so you can save some time and a lot of memory space.
Any suggestions for making R code use multiple processors? I noticed that the previous answers lack some general HPC considerations. First of all, neither of those packages will enable you to run one SVM in parallel. So what you can speed up is parameter opti
10,028
Any suggestions for making R code use multiple processors?
Both Shane and Dirk's responses are spot on. Nevertheless, you might wanna take a look at a commercial version of R, called Revolution R which is built to deal with big datasets and run on multiple cores. This software is free for academics (which might be your case, I dont know)
Any suggestions for making R code use multiple processors?
Both Shane and Dirk's responses are spot on. Nevertheless, you might wanna take a look at a commercial version of R, called Revolution R which is built to deal with big datasets and run on multiple
Any suggestions for making R code use multiple processors? Both Shane and Dirk's responses are spot on. Nevertheless, you might wanna take a look at a commercial version of R, called Revolution R which is built to deal with big datasets and run on multiple cores. This software is free for academics (which might be your case, I dont know)
Any suggestions for making R code use multiple processors? Both Shane and Dirk's responses are spot on. Nevertheless, you might wanna take a look at a commercial version of R, called Revolution R which is built to deal with big datasets and run on multiple
10,029
What's the intuition behind contrastive learning or approach?
Contrastive learning is very intuitive. If I ask you to find the matching animal in the photo below, you can do so quite easily. You understand the animal on left is a "cat" and you want to find another "cat" image on the right side. So, you can contrast between similar and dissimilar things. Contrastive learning is an approach to formulate this task of finding similar and dissimilar things for a machine. You can train a machine learning model to classify between similar and dissimilar images. There are various choices to make ranging from: Encoder Architecture: To convert the image into representations Similarity measure between two images: mean squared error, cosine similarity, content loss Generating the Training Pairs: manual annotation, self-supervised methods This blog post explains the intuition behind contrastive learning and how it is applied in recent papers like SimCLR in more detail.
What's the intuition behind contrastive learning or approach?
Contrastive learning is very intuitive. If I ask you to find the matching animal in the photo below, you can do so quite easily. You understand the animal on left is a "cat" and you want to find anoth
What's the intuition behind contrastive learning or approach? Contrastive learning is very intuitive. If I ask you to find the matching animal in the photo below, you can do so quite easily. You understand the animal on left is a "cat" and you want to find another "cat" image on the right side. So, you can contrast between similar and dissimilar things. Contrastive learning is an approach to formulate this task of finding similar and dissimilar things for a machine. You can train a machine learning model to classify between similar and dissimilar images. There are various choices to make ranging from: Encoder Architecture: To convert the image into representations Similarity measure between two images: mean squared error, cosine similarity, content loss Generating the Training Pairs: manual annotation, self-supervised methods This blog post explains the intuition behind contrastive learning and how it is applied in recent papers like SimCLR in more detail.
What's the intuition behind contrastive learning or approach? Contrastive learning is very intuitive. If I ask you to find the matching animal in the photo below, you can do so quite easily. You understand the animal on left is a "cat" and you want to find anoth
10,030
What's the intuition behind contrastive learning or approach?
Contrastive learning is a framework that learns similar/dissimilar representations from data that are organized into similar/dissimilar pairs. This can be formulated as a dictionary look-up problem. Both MoCo and SimCLR use varients of a contrastive loss function, like InfoNCE from the paper Representation Learning with Contrastive Predictive Coding \begin{eqnarray*} \mathcal{L}_{q,k^+,\{k^-\}}=-log\frac{exp(q\cdot k^+/\tau)}{exp(q\cdot k^+/\tau)+\sum\limits_{k^-}exp(q\cdot k^-/\tau)} \end{eqnarray*} Here q is a query representation, $k^+$ is a representation of the positive (similar) key sample, and ${k^−}$ are representations of the negative (dissimilar) key samples. $\tau$ is a temperature hyper-parameter. In the instance discrimination pretext task (used by MoCo and SimCLR), a query and a key form a positive pair if they are data-augmented versions of the same image, and otherwise form a negative pair. The contrastive loss can be minimized by various mechanisms that differ in how the keys are maintained. In an end-to-end mechanism (Fig. 1a), the negative keys are from the same batch and updated end-to-end by back-propagation. SimCLR, is based on this mechanism and requires a large batch to provide a large set of negatives. In the MoCo mechanism i.e. Momentum Contrast (Fig. 1b), the negative keys are maintained in a queue, and only the queries and positive keys are encoded in each training batch. Quoted from a recent research paper, Improved Baselines with Momentum Contrastive Learning @ https://arxiv.org/abs/2003.04297
What's the intuition behind contrastive learning or approach?
Contrastive learning is a framework that learns similar/dissimilar representations from data that are organized into similar/dissimilar pairs. This can be formulated as a dictionary look-up problem. B
What's the intuition behind contrastive learning or approach? Contrastive learning is a framework that learns similar/dissimilar representations from data that are organized into similar/dissimilar pairs. This can be formulated as a dictionary look-up problem. Both MoCo and SimCLR use varients of a contrastive loss function, like InfoNCE from the paper Representation Learning with Contrastive Predictive Coding \begin{eqnarray*} \mathcal{L}_{q,k^+,\{k^-\}}=-log\frac{exp(q\cdot k^+/\tau)}{exp(q\cdot k^+/\tau)+\sum\limits_{k^-}exp(q\cdot k^-/\tau)} \end{eqnarray*} Here q is a query representation, $k^+$ is a representation of the positive (similar) key sample, and ${k^−}$ are representations of the negative (dissimilar) key samples. $\tau$ is a temperature hyper-parameter. In the instance discrimination pretext task (used by MoCo and SimCLR), a query and a key form a positive pair if they are data-augmented versions of the same image, and otherwise form a negative pair. The contrastive loss can be minimized by various mechanisms that differ in how the keys are maintained. In an end-to-end mechanism (Fig. 1a), the negative keys are from the same batch and updated end-to-end by back-propagation. SimCLR, is based on this mechanism and requires a large batch to provide a large set of negatives. In the MoCo mechanism i.e. Momentum Contrast (Fig. 1b), the negative keys are maintained in a queue, and only the queries and positive keys are encoded in each training batch. Quoted from a recent research paper, Improved Baselines with Momentum Contrastive Learning @ https://arxiv.org/abs/2003.04297
What's the intuition behind contrastive learning or approach? Contrastive learning is a framework that learns similar/dissimilar representations from data that are organized into similar/dissimilar pairs. This can be formulated as a dictionary look-up problem. B
10,031
Adding weights to logistic regression for imbalanced data
Ching, You do not have to make your data set balanced in terms of 1’s and 0’s. All you need is sufficient number of 1’s for the maximum likelihood to converge. Looking at the distribution of 1’s (100,000) in your dataset, you should not have any problems. You can do a simple experiment here Sample 10 % of the 1’s and 10% of the 0’s and use a weight of 10 for both Sample 100% of the 1’s and 10% of the 0’s and use a weight of 10 for the 0’s In both cases, you will get identical estimates. Again the idea of weighting is related to sampling. If you are using the whole data set you should not weight it. If I were you I would just use 10% if 1's and 10% of 0's. In R, you would use glm. Here is a sample code: glm(y ~ x1 + x2, weights = wt, data =data, family = binomial("logit")) In your dataset there should be a variable wt for weights. If you use 10% of both 0's and 1's, your wt variable will have a value of 10. If you use 10% of the 0's and 100% of 1's: wt variable will have a value of 10 for observations with y=0 and 1 for observations with y=1
Adding weights to logistic regression for imbalanced data
Ching, You do not have to make your data set balanced in terms of 1’s and 0’s. All you need is sufficient number of 1’s for the maximum likelihood to converge. Looking at the distribution of 1’s (10
Adding weights to logistic regression for imbalanced data Ching, You do not have to make your data set balanced in terms of 1’s and 0’s. All you need is sufficient number of 1’s for the maximum likelihood to converge. Looking at the distribution of 1’s (100,000) in your dataset, you should not have any problems. You can do a simple experiment here Sample 10 % of the 1’s and 10% of the 0’s and use a weight of 10 for both Sample 100% of the 1’s and 10% of the 0’s and use a weight of 10 for the 0’s In both cases, you will get identical estimates. Again the idea of weighting is related to sampling. If you are using the whole data set you should not weight it. If I were you I would just use 10% if 1's and 10% of 0's. In R, you would use glm. Here is a sample code: glm(y ~ x1 + x2, weights = wt, data =data, family = binomial("logit")) In your dataset there should be a variable wt for weights. If you use 10% of both 0's and 1's, your wt variable will have a value of 10. If you use 10% of the 0's and 100% of 1's: wt variable will have a value of 10 for observations with y=0 and 1 for observations with y=1
Adding weights to logistic regression for imbalanced data Ching, You do not have to make your data set balanced in terms of 1’s and 0’s. All you need is sufficient number of 1’s for the maximum likelihood to converge. Looking at the distribution of 1’s (10
10,032
Adding weights to logistic regression for imbalanced data
Weighting is a procedure that weights the data to compensate for differences in sample and population (King 2001). For example, in rare events (such as fraud in credit risk, deaths in medical literature) we tend to sample all the 1’s (rare events) and a fraction of 0’s (non events). In such cases we have to weight the observations accordingly. Example: Let us say, In a population of 500,000 transactions there are 50 fraud transactions. In this case you would Sample all 50 frauds transaction (100% of the fraud) 10% of the good transactions (10% of 500,000 is 50,000 good transactions) In this case you would assign a weight of 1 for fraud transactions and a weight of 10 for good transactions. This is called the Weighted Maximum Likelihood method. The important takeaway is that the weighting is related to sampling proportions Refer: Logistic Regression in Rare Events Data (King 2001)
Adding weights to logistic regression for imbalanced data
Weighting is a procedure that weights the data to compensate for differences in sample and population (King 2001). For example, in rare events (such as fraud in credit risk, deaths in medical literatu
Adding weights to logistic regression for imbalanced data Weighting is a procedure that weights the data to compensate for differences in sample and population (King 2001). For example, in rare events (such as fraud in credit risk, deaths in medical literature) we tend to sample all the 1’s (rare events) and a fraction of 0’s (non events). In such cases we have to weight the observations accordingly. Example: Let us say, In a population of 500,000 transactions there are 50 fraud transactions. In this case you would Sample all 50 frauds transaction (100% of the fraud) 10% of the good transactions (10% of 500,000 is 50,000 good transactions) In this case you would assign a weight of 1 for fraud transactions and a weight of 10 for good transactions. This is called the Weighted Maximum Likelihood method. The important takeaway is that the weighting is related to sampling proportions Refer: Logistic Regression in Rare Events Data (King 2001)
Adding weights to logistic regression for imbalanced data Weighting is a procedure that weights the data to compensate for differences in sample and population (King 2001). For example, in rare events (such as fraud in credit risk, deaths in medical literatu
10,033
How to describe or visualize a multiple linear regression model
My favorite way of showing the results of a basic multiple linear regression is to first fit the model to normalized (continuous) variables. That is, z-transform the $X$s by subtracting the mean and dividing by the standard deviation, then fit the model and estimate the parameters. When the variables are transformed in this way, the estimated coefficients are 'standardized' to have unit $\Delta Y/\Delta sd(X)$. In this way, the distance the coefficients are from zero ranks their relative 'importance' and their CI gives the precision. I think it sums up the relationships rather well and offers a lot more information than the coefficients and p.values on their natural and often disparate numerical scales. An example is below: EDIT: Another possibility is to use an 'added variable plot' (i.e. plot the partial regressions). This gives another perspective in that it shows the bivariate relations between $Y$ and $X_i$ AFTER THE OTHER VARIABLES ARE ACCOUNTED FOR. For example, the partial regressions of $Y \sim X_1 + X_2 + X_3$ would give bivariate relations between $X_i$ against the residuals of $Y$ after regressing against the other two terms. You would go on to do this for each variable. Function avPlots() from library car gives these plots from a fitted lm object. An example is below:
How to describe or visualize a multiple linear regression model
My favorite way of showing the results of a basic multiple linear regression is to first fit the model to normalized (continuous) variables. That is, z-transform the $X$s by subtracting the mean and d
How to describe or visualize a multiple linear regression model My favorite way of showing the results of a basic multiple linear regression is to first fit the model to normalized (continuous) variables. That is, z-transform the $X$s by subtracting the mean and dividing by the standard deviation, then fit the model and estimate the parameters. When the variables are transformed in this way, the estimated coefficients are 'standardized' to have unit $\Delta Y/\Delta sd(X)$. In this way, the distance the coefficients are from zero ranks their relative 'importance' and their CI gives the precision. I think it sums up the relationships rather well and offers a lot more information than the coefficients and p.values on their natural and often disparate numerical scales. An example is below: EDIT: Another possibility is to use an 'added variable plot' (i.e. plot the partial regressions). This gives another perspective in that it shows the bivariate relations between $Y$ and $X_i$ AFTER THE OTHER VARIABLES ARE ACCOUNTED FOR. For example, the partial regressions of $Y \sim X_1 + X_2 + X_3$ would give bivariate relations between $X_i$ against the residuals of $Y$ after regressing against the other two terms. You would go on to do this for each variable. Function avPlots() from library car gives these plots from a fitted lm object. An example is below:
How to describe or visualize a multiple linear regression model My favorite way of showing the results of a basic multiple linear regression is to first fit the model to normalized (continuous) variables. That is, z-transform the $X$s by subtracting the mean and d
10,034
How to describe or visualize a multiple linear regression model
Since they all have to do with explaining the contributors for cirrhosis, have you tried doing a bubble/circle chart and use color to indicate the different regressors and circle radius to indicate relative impact upon cirrhosis? I'm referring here to a Google chart type that looks like this: And on an unrelated note, unless I'm reading your plots wrong, I think you have some redundant regressors in there. Wine is already a liquor so if those two are separate regressors it doesn't make sense to keep both of them, if your goal is to explain the incidence of cirrhosis.
How to describe or visualize a multiple linear regression model
Since they all have to do with explaining the contributors for cirrhosis, have you tried doing a bubble/circle chart and use color to indicate the different regressors and circle radius to indicate re
How to describe or visualize a multiple linear regression model Since they all have to do with explaining the contributors for cirrhosis, have you tried doing a bubble/circle chart and use color to indicate the different regressors and circle radius to indicate relative impact upon cirrhosis? I'm referring here to a Google chart type that looks like this: And on an unrelated note, unless I'm reading your plots wrong, I think you have some redundant regressors in there. Wine is already a liquor so if those two are separate regressors it doesn't make sense to keep both of them, if your goal is to explain the incidence of cirrhosis.
How to describe or visualize a multiple linear regression model Since they all have to do with explaining the contributors for cirrhosis, have you tried doing a bubble/circle chart and use color to indicate the different regressors and circle radius to indicate re
10,035
How to describe or visualize a multiple linear regression model
@gregory_britten 's answer was exactly what I was looking for. I figured I would share my implementation in python using pandas, matplotlib, and statsmodels. X_norm = X4.copy() # This is a pd.Dataframe of the independent variables X_norm = (X_norm - X_norm.mean()) / X_norm.std() res_norm = sm.OLS(y_log, sm.add_constant(X_norm)).fit() to_include = res_norm.params[res_norm.pvalues < 0.05][1:].sort_values() # get only those with significant pvalues fig, ax = plt.subplots(figsize=(5,6), dpi=100) ax.scatter(to_include, range(len(to_include)), color="#1a9988", zorder=2) ax.set_yticks(range(len(to_include)), to_include.index) # label the y axis with the ind. variable names ax.set_xlabel("Proportional Effect") ax.set_title("Strength of Relationships") # add the confidence interval error bars for idx, ci in enumerate(res_norm.conf_int().loc[to_include.index].iterrows()): ax.hlines(idx, ci[1][0], ci[1][1], color="#eb5600", zorder=1, linewidth=3) plt.axline((0,0), (0,1), color="#eb5600", linestyle="--") # add a dashed line at 0.0
How to describe or visualize a multiple linear regression model
@gregory_britten 's answer was exactly what I was looking for. I figured I would share my implementation in python using pandas, matplotlib, and statsmodels. X_norm = X4.copy() # This is a pd.Datafra
How to describe or visualize a multiple linear regression model @gregory_britten 's answer was exactly what I was looking for. I figured I would share my implementation in python using pandas, matplotlib, and statsmodels. X_norm = X4.copy() # This is a pd.Dataframe of the independent variables X_norm = (X_norm - X_norm.mean()) / X_norm.std() res_norm = sm.OLS(y_log, sm.add_constant(X_norm)).fit() to_include = res_norm.params[res_norm.pvalues < 0.05][1:].sort_values() # get only those with significant pvalues fig, ax = plt.subplots(figsize=(5,6), dpi=100) ax.scatter(to_include, range(len(to_include)), color="#1a9988", zorder=2) ax.set_yticks(range(len(to_include)), to_include.index) # label the y axis with the ind. variable names ax.set_xlabel("Proportional Effect") ax.set_title("Strength of Relationships") # add the confidence interval error bars for idx, ci in enumerate(res_norm.conf_int().loc[to_include.index].iterrows()): ax.hlines(idx, ci[1][0], ci[1][1], color="#eb5600", zorder=1, linewidth=3) plt.axline((0,0), (0,1), color="#eb5600", linestyle="--") # add a dashed line at 0.0
How to describe or visualize a multiple linear regression model @gregory_britten 's answer was exactly what I was looking for. I figured I would share my implementation in python using pandas, matplotlib, and statsmodels. X_norm = X4.copy() # This is a pd.Datafra
10,036
How to describe or visualize a multiple linear regression model
The visualization you show in 3 (scatter diagram of actual value against predicted value) is a good one. It can be used for any regressor. In this case, the example you show helps confirm the assumption of linearity, since the points are scattered above and below the line throughout the range. Another assumption you have made is a lack of interaction among the factors. If you want to test that, then a good visualization is a scatter diagram of x_i against x_j, where the points are coloured by the size of the error in the prediction. Pairwise interactions among the xs will be revealed by patterns in the colours.
How to describe or visualize a multiple linear regression model
The visualization you show in 3 (scatter diagram of actual value against predicted value) is a good one. It can be used for any regressor. In this case, the example you show helps confirm the assumpti
How to describe or visualize a multiple linear regression model The visualization you show in 3 (scatter diagram of actual value against predicted value) is a good one. It can be used for any regressor. In this case, the example you show helps confirm the assumption of linearity, since the points are scattered above and below the line throughout the range. Another assumption you have made is a lack of interaction among the factors. If you want to test that, then a good visualization is a scatter diagram of x_i against x_j, where the points are coloured by the size of the error in the prediction. Pairwise interactions among the xs will be revealed by patterns in the colours.
How to describe or visualize a multiple linear regression model The visualization you show in 3 (scatter diagram of actual value against predicted value) is a good one. It can be used for any regressor. In this case, the example you show helps confirm the assumpti
10,037
Geometric interpretation of penalized linear regression
Sorry for my painting skills, I will try to give you the following intuition. Let $f(\beta)$ be the objective function (for example, MSE in case of regression). Let's imagine the contour plot of this function in red (of course we paint it in the space of $\beta$, here for simplicity $\beta_1$ and $\beta_2$). There is a minimum of this function, in the middle of the red circles. And this minimum gives us the non-penalized solution. Now we add different objective $g(\beta)$ which contour plot is given in blue. Either LASSO regularizer or ridge regression regularizer. For LASSO $g(\beta) = \lambda (|\beta_1| + |\beta_2|)$, for ridge regression $g(\beta) = \lambda (\beta_1^2 + \beta_2^2)$ ($\lambda$ is a penalization parameter). Contour plots shows the area at which the function have the fixed values. So the larger $\lambda$ - the faster $g(x)$ growth, and the more "narrow" the contour plot is. Now we have to find the minimum of the sum of this two objectives: $f(\beta) + g(\beta)$. And this is achieved when two contour plots meet each other. The larger penalty, the "more narrow" blue contours we get, and then the plots meet each other in a point closer to zero. An vise-versa: the smaller the penalty, the contours expand, and the intersection of blue and red plots comes closer to the center of the red circle (non-penalized solution). And now follows an interesting thing that greatly explains to me the difference between ridge regression and LASSO: in case of LASSO two contour plots will probably meet where the corner of regularizer is ($\beta_1 = 0$ or $\beta_2 = 0$). In case of ridge regression that is almost never the case. That's why LASSO gives us sparse solution, making some of parameters exactly equal $0$. Hope that will explain some intuition about how penalized regression works in the space of parameters.
Geometric interpretation of penalized linear regression
Sorry for my painting skills, I will try to give you the following intuition. Let $f(\beta)$ be the objective function (for example, MSE in case of regression). Let's imagine the contour plot of this
Geometric interpretation of penalized linear regression Sorry for my painting skills, I will try to give you the following intuition. Let $f(\beta)$ be the objective function (for example, MSE in case of regression). Let's imagine the contour plot of this function in red (of course we paint it in the space of $\beta$, here for simplicity $\beta_1$ and $\beta_2$). There is a minimum of this function, in the middle of the red circles. And this minimum gives us the non-penalized solution. Now we add different objective $g(\beta)$ which contour plot is given in blue. Either LASSO regularizer or ridge regression regularizer. For LASSO $g(\beta) = \lambda (|\beta_1| + |\beta_2|)$, for ridge regression $g(\beta) = \lambda (\beta_1^2 + \beta_2^2)$ ($\lambda$ is a penalization parameter). Contour plots shows the area at which the function have the fixed values. So the larger $\lambda$ - the faster $g(x)$ growth, and the more "narrow" the contour plot is. Now we have to find the minimum of the sum of this two objectives: $f(\beta) + g(\beta)$. And this is achieved when two contour plots meet each other. The larger penalty, the "more narrow" blue contours we get, and then the plots meet each other in a point closer to zero. An vise-versa: the smaller the penalty, the contours expand, and the intersection of blue and red plots comes closer to the center of the red circle (non-penalized solution). And now follows an interesting thing that greatly explains to me the difference between ridge regression and LASSO: in case of LASSO two contour plots will probably meet where the corner of regularizer is ($\beta_1 = 0$ or $\beta_2 = 0$). In case of ridge regression that is almost never the case. That's why LASSO gives us sparse solution, making some of parameters exactly equal $0$. Hope that will explain some intuition about how penalized regression works in the space of parameters.
Geometric interpretation of penalized linear regression Sorry for my painting skills, I will try to give you the following intuition. Let $f(\beta)$ be the objective function (for example, MSE in case of regression). Let's imagine the contour plot of this
10,038
Geometric interpretation of penalized linear regression
The intuition I have is the following: In the least-squares case, the hat matrix is an orthogonal projection thus idempotent. In the penalized case, the hat matrix is no longer idempotent. Actually, applying it infinitely many times, will shrink the coefficients to the origin. On the other hand, the coefficients still have to lie in the span of the predictors, so it is still a projection, albeit not orthogonal. The magnitude of the penalizing factor and the type of norm control the distance and direction of shrinkage towards the origin.
Geometric interpretation of penalized linear regression
The intuition I have is the following: In the least-squares case, the hat matrix is an orthogonal projection thus idempotent. In the penalized case, the hat matrix is no longer idempotent. Actually, a
Geometric interpretation of penalized linear regression The intuition I have is the following: In the least-squares case, the hat matrix is an orthogonal projection thus idempotent. In the penalized case, the hat matrix is no longer idempotent. Actually, applying it infinitely many times, will shrink the coefficients to the origin. On the other hand, the coefficients still have to lie in the span of the predictors, so it is still a projection, albeit not orthogonal. The magnitude of the penalizing factor and the type of norm control the distance and direction of shrinkage towards the origin.
Geometric interpretation of penalized linear regression The intuition I have is the following: In the least-squares case, the hat matrix is an orthogonal projection thus idempotent. In the penalized case, the hat matrix is no longer idempotent. Actually, a
10,039
Geometric interpretation of penalized linear regression
Second image The geometric interpretation in the second figure will look as following: With OLS the observations are projected onto a surface spanned by the regressor variables and this finds the point in the plane that has the shortest distance to the observed vector $(y_1,y_2,y_3)$. With ridge regression we do not look for a closest point in the entire plane but for a closest point that is inside a circle on the plane (or sphere in higher dimensions and other shape for different types of regression). Image from the question Why does regularization wreck orthogonality of predictions and residuals in linear regression? First image Regularisation will reduce the size of the parameters. So, the fitted line will have a smaller intercept and a smaller slope. In general this will mean that the line will be more flat and closer to the x-axis.
Geometric interpretation of penalized linear regression
Second image The geometric interpretation in the second figure will look as following: With OLS the observations are projected onto a surface spanned by the regressor variables and this finds the poin
Geometric interpretation of penalized linear regression Second image The geometric interpretation in the second figure will look as following: With OLS the observations are projected onto a surface spanned by the regressor variables and this finds the point in the plane that has the shortest distance to the observed vector $(y_1,y_2,y_3)$. With ridge regression we do not look for a closest point in the entire plane but for a closest point that is inside a circle on the plane (or sphere in higher dimensions and other shape for different types of regression). Image from the question Why does regularization wreck orthogonality of predictions and residuals in linear regression? First image Regularisation will reduce the size of the parameters. So, the fitted line will have a smaller intercept and a smaller slope. In general this will mean that the line will be more flat and closer to the x-axis.
Geometric interpretation of penalized linear regression Second image The geometric interpretation in the second figure will look as following: With OLS the observations are projected onto a surface spanned by the regressor variables and this finds the poin
10,040
What is the difference between Kalman filter and moving average?
A random walk + noise model can be shown to be equivalent to a EWMA (exponentially weighted moving average). The kalman gain ends up being the same as the EWMA weighting. This is shown to some details in Time Series Analysis by State Space, if you Google Kalman Filter and EWMA you will find a number of resources that discuss the equivalence. In fact you can use the state space equivalence to build confidence intervals for EWMA estimates, etc.
What is the difference between Kalman filter and moving average?
A random walk + noise model can be shown to be equivalent to a EWMA (exponentially weighted moving average). The kalman gain ends up being the same as the EWMA weighting. This is shown to some details
What is the difference between Kalman filter and moving average? A random walk + noise model can be shown to be equivalent to a EWMA (exponentially weighted moving average). The kalman gain ends up being the same as the EWMA weighting. This is shown to some details in Time Series Analysis by State Space, if you Google Kalman Filter and EWMA you will find a number of resources that discuss the equivalence. In fact you can use the state space equivalence to build confidence intervals for EWMA estimates, etc.
What is the difference between Kalman filter and moving average? A random walk + noise model can be shown to be equivalent to a EWMA (exponentially weighted moving average). The kalman gain ends up being the same as the EWMA weighting. This is shown to some details
10,041
What is the difference between Kalman filter and moving average?
To Start: The equivalence of Kalman filter with EWMA is only for the case of a "random walk plus noise" and it is covered in the book, Forecast Structural Time Series Model and Kalman Filter by Andrew Harvey. The equivalence of EWMA with Kalman filter for random walk with noise is covered on page 175 of the text. There the author also mentions that the equivalence of the two was first shown in 1960 and gives the reference to it. Here is the link for that page of the text: https://books.google.com/books?id=Kc6tnRHBwLcC&pg=PA175&lpg=PA175&dq=ewma+and+kalman+for+random+walk+with+noise&source=bl&ots=I3VOQsYZOC&sig=RdUCwgFE1s7zrPFylF3e3HxIUNY&hl=en&sa=X&ved=0ahUKEwiK5t2J84HMAhWINSYKHcmyAXkQ6AEINDAD#v=onepage&q=ewma%20and%20kalman%20for%20random%20walk%20with%20noise&f=false Now here is reference which covers an ALETERNATIVE to the Kalman and Extended Kalman filters -- it yielded results that match the Kalman filter but the results are obtained much faster! It is "Double Exponential Smoothing: An Alternative to Kalman Filter-Based Predictive Tracking." In Abstract of the paper (see below) the authors state "...empirical results supporting the validity of our claims that these predictors are faster, easier to implement, and perform equivalently to the Kalman and extended Kalman filtering predictors..." http://cs.brown.edu/~jjl/pubs/kfvsexp_final_laviola.pdf This is their Abstract "We present novel algorithms for predictive tracking of user position and orientation based on double exponential smoothing. These algorithms, when compared against Kalman and extended Kalman filter-based predictors with derivative free measurement models, run approximately 135 times faster with equivalent prediction performance and simpler implementations. This paper describes these algorithms in detail along with the Kalman and extended Kalman Filter predictors tested against. In addition, we describe the details of a predictor experiment and present empirical results supporting the validity of our claims that these predictors are faster, easier to implement, and perform equivalently to the Kalman and extended Kalman filtering predictors."
What is the difference between Kalman filter and moving average?
To Start: The equivalence of Kalman filter with EWMA is only for the case of a "random walk plus noise" and it is covered in the book, Forecast Structural Time Series Model and Kalman Filter by Andrew
What is the difference between Kalman filter and moving average? To Start: The equivalence of Kalman filter with EWMA is only for the case of a "random walk plus noise" and it is covered in the book, Forecast Structural Time Series Model and Kalman Filter by Andrew Harvey. The equivalence of EWMA with Kalman filter for random walk with noise is covered on page 175 of the text. There the author also mentions that the equivalence of the two was first shown in 1960 and gives the reference to it. Here is the link for that page of the text: https://books.google.com/books?id=Kc6tnRHBwLcC&pg=PA175&lpg=PA175&dq=ewma+and+kalman+for+random+walk+with+noise&source=bl&ots=I3VOQsYZOC&sig=RdUCwgFE1s7zrPFylF3e3HxIUNY&hl=en&sa=X&ved=0ahUKEwiK5t2J84HMAhWINSYKHcmyAXkQ6AEINDAD#v=onepage&q=ewma%20and%20kalman%20for%20random%20walk%20with%20noise&f=false Now here is reference which covers an ALETERNATIVE to the Kalman and Extended Kalman filters -- it yielded results that match the Kalman filter but the results are obtained much faster! It is "Double Exponential Smoothing: An Alternative to Kalman Filter-Based Predictive Tracking." In Abstract of the paper (see below) the authors state "...empirical results supporting the validity of our claims that these predictors are faster, easier to implement, and perform equivalently to the Kalman and extended Kalman filtering predictors..." http://cs.brown.edu/~jjl/pubs/kfvsexp_final_laviola.pdf This is their Abstract "We present novel algorithms for predictive tracking of user position and orientation based on double exponential smoothing. These algorithms, when compared against Kalman and extended Kalman filter-based predictors with derivative free measurement models, run approximately 135 times faster with equivalent prediction performance and simpler implementations. This paper describes these algorithms in detail along with the Kalman and extended Kalman Filter predictors tested against. In addition, we describe the details of a predictor experiment and present empirical results supporting the validity of our claims that these predictors are faster, easier to implement, and perform equivalently to the Kalman and extended Kalman filtering predictors."
What is the difference between Kalman filter and moving average? To Start: The equivalence of Kalman filter with EWMA is only for the case of a "random walk plus noise" and it is covered in the book, Forecast Structural Time Series Model and Kalman Filter by Andrew
10,042
What's the Bayesian equivalent of a general goodness of fit test?
I would suggest the book Bayesian Data Analysis as a great source for answering this question (in particular chapter 6) and everything I am about to say. But one of the usual ways that Bayesians attack this problem is by using Posterior Predictive P-values (PPPs). Before I jump into how PPPs would solve this problem let me first define the following notation: Let $y$ be the observed data and $\theta$ be the vector of parameters. We define $y^{\text{rep}}$ as the replicated data that could have been observed, or, to think predictively, as the data we would see tomorrow if the experiment that produced $y$ today were replicated with the same model and the same value of $\theta$ that produced the observed data. Note, we will define the distribution of $y^{\text{rep}}$ given the current state of knowledge with the posterior predictive distribution $$p(y^{\text{rep}}|y)=\int_\Theta p(y^{\text{rep}}|\theta)p(\theta|y)d\theta$$ Now, we can measure the discrepancy between the model and the data by defining test quantities, the aspects of the data we wish to check. A test quantity, or discrepancy measure, $T(y,\theta)$, is a scalar summary of parameters and data that is used as a standard when comparing data to predictive simulations. Test quantities play the role in Bayesian model checking that test statistics play in classical testing. We define the notation $T(y)$ for a test statistic, which is a test quantity that depends only on data; in the Bayesian context, we can generalize test statistics to allow dependence on the model parameters under their posterior distribution. Classically, the p-value for the test statistic $T(y)$ is $$p_C=\text{Pr}(T(y^{\text{rep}})\geq T(y)|\theta)$$ where the probability is taken over the distribution of $y^{\text{rep}}$ with $\theta$ fixed. From a Bayesian perspective, lack of fit of the data with respect to the posterior predictive distribution can be measured by the tail-area probability, or p-value, of the test quantity, and computed using posterior simulations of $(\theta,y^{\text{rep}})$. In the Bayesian approach, test quantities can be functions of the unknown parameters as well as data because the test quantity is evaluated over draws from the posterior distribution of the unknown parameters. Now, we can define the Bayesian p-value (PPPs) as the probability that the replicated data could be more extreme than the observed data, as measured by the test quantity: $$p_B=\text{Pr}(T(y^{\text{rep}},\theta)\geq T(y,\theta)|y)$$ where the probability is taken over the posterior distribution of $\theta$ and the posterior predictive distribution of $y^{\text{rep}}$ (that is, the joint distribution, $p(\theta,y^{\text{rep}}|y)$): $$p_B=\iint_\Theta I_{T(y^{\text{rep}},\theta)\geq T(y|\theta)}p(y^{\text{rep}}|\theta)p(\theta|y)dy^{\text{rep}}d\theta,$$ where $I$ is the indicator function. In practice though we usually compute the posterior predictive distribution using simulations. If we already have, say, $L$ simulations from the posterior distribution of $\theta$, then we can just draw one $y^{\text{rep}}$ from the predictive distribution for each simulated $\theta$; we now have $L$ draws from the joint posterior distribution, $p(y^{\text{rep}},\theta|y)$. The posterior predictive check is the comparison between the realized test quantities $T(y,\theta^l)$ and the predictive test quantities $T(y^{\text{rep}l},\theta^l)$. The estimated p-value is just the proportion of these $L$ simulations for which the test quantity equals or exceeds its realized value; that is, for which $$T(y^{\text{rep}l},\theta^l)\geq T(y,\theta^l)$$ for $l=1,...,L$. In contrast to the classical approach, Bayesian model checking does not require special methods to handle "nuisance parameters." By using posterior simulations, we implicitly average over all the parameters in the model. An additional source, Andrew Gelman also has a very nice paper on PPP's here: http://www.stat.columbia.edu/~gelman/research/unpublished/ppc_understand2.pdf
What's the Bayesian equivalent of a general goodness of fit test?
I would suggest the book Bayesian Data Analysis as a great source for answering this question (in particular chapter 6) and everything I am about to say. But one of the usual ways that Bayesians attac
What's the Bayesian equivalent of a general goodness of fit test? I would suggest the book Bayesian Data Analysis as a great source for answering this question (in particular chapter 6) and everything I am about to say. But one of the usual ways that Bayesians attack this problem is by using Posterior Predictive P-values (PPPs). Before I jump into how PPPs would solve this problem let me first define the following notation: Let $y$ be the observed data and $\theta$ be the vector of parameters. We define $y^{\text{rep}}$ as the replicated data that could have been observed, or, to think predictively, as the data we would see tomorrow if the experiment that produced $y$ today were replicated with the same model and the same value of $\theta$ that produced the observed data. Note, we will define the distribution of $y^{\text{rep}}$ given the current state of knowledge with the posterior predictive distribution $$p(y^{\text{rep}}|y)=\int_\Theta p(y^{\text{rep}}|\theta)p(\theta|y)d\theta$$ Now, we can measure the discrepancy between the model and the data by defining test quantities, the aspects of the data we wish to check. A test quantity, or discrepancy measure, $T(y,\theta)$, is a scalar summary of parameters and data that is used as a standard when comparing data to predictive simulations. Test quantities play the role in Bayesian model checking that test statistics play in classical testing. We define the notation $T(y)$ for a test statistic, which is a test quantity that depends only on data; in the Bayesian context, we can generalize test statistics to allow dependence on the model parameters under their posterior distribution. Classically, the p-value for the test statistic $T(y)$ is $$p_C=\text{Pr}(T(y^{\text{rep}})\geq T(y)|\theta)$$ where the probability is taken over the distribution of $y^{\text{rep}}$ with $\theta$ fixed. From a Bayesian perspective, lack of fit of the data with respect to the posterior predictive distribution can be measured by the tail-area probability, or p-value, of the test quantity, and computed using posterior simulations of $(\theta,y^{\text{rep}})$. In the Bayesian approach, test quantities can be functions of the unknown parameters as well as data because the test quantity is evaluated over draws from the posterior distribution of the unknown parameters. Now, we can define the Bayesian p-value (PPPs) as the probability that the replicated data could be more extreme than the observed data, as measured by the test quantity: $$p_B=\text{Pr}(T(y^{\text{rep}},\theta)\geq T(y,\theta)|y)$$ where the probability is taken over the posterior distribution of $\theta$ and the posterior predictive distribution of $y^{\text{rep}}$ (that is, the joint distribution, $p(\theta,y^{\text{rep}}|y)$): $$p_B=\iint_\Theta I_{T(y^{\text{rep}},\theta)\geq T(y|\theta)}p(y^{\text{rep}}|\theta)p(\theta|y)dy^{\text{rep}}d\theta,$$ where $I$ is the indicator function. In practice though we usually compute the posterior predictive distribution using simulations. If we already have, say, $L$ simulations from the posterior distribution of $\theta$, then we can just draw one $y^{\text{rep}}$ from the predictive distribution for each simulated $\theta$; we now have $L$ draws from the joint posterior distribution, $p(y^{\text{rep}},\theta|y)$. The posterior predictive check is the comparison between the realized test quantities $T(y,\theta^l)$ and the predictive test quantities $T(y^{\text{rep}l},\theta^l)$. The estimated p-value is just the proportion of these $L$ simulations for which the test quantity equals or exceeds its realized value; that is, for which $$T(y^{\text{rep}l},\theta^l)\geq T(y,\theta^l)$$ for $l=1,...,L$. In contrast to the classical approach, Bayesian model checking does not require special methods to handle "nuisance parameters." By using posterior simulations, we implicitly average over all the parameters in the model. An additional source, Andrew Gelman also has a very nice paper on PPP's here: http://www.stat.columbia.edu/~gelman/research/unpublished/ppc_understand2.pdf
What's the Bayesian equivalent of a general goodness of fit test? I would suggest the book Bayesian Data Analysis as a great source for answering this question (in particular chapter 6) and everything I am about to say. But one of the usual ways that Bayesians attac
10,043
What's the Bayesian equivalent of a general goodness of fit test?
One relatively simple possibility: Smooth tests of goodness of fit e.g.[1] - which frame the alternative in terms of smooth deviations from the null, built by orthogonal polynomials (with respect to the null density as weight-function) would be relatively straightforward to carry over to a Bayesian framework, since the coefficients of the polynomials form a flexible-but-parametric extension of the null. [1]: Rayner, J.C.W. and D.J. Best (1990), "Smooth Tests of Goodness of Fit: An Overview," International Statistical Review, 58: 1 (Apr), pp. 9-17
What's the Bayesian equivalent of a general goodness of fit test?
One relatively simple possibility: Smooth tests of goodness of fit e.g.[1] - which frame the alternative in terms of smooth deviations from the null, built by orthogonal polynomials (with respect to t
What's the Bayesian equivalent of a general goodness of fit test? One relatively simple possibility: Smooth tests of goodness of fit e.g.[1] - which frame the alternative in terms of smooth deviations from the null, built by orthogonal polynomials (with respect to the null density as weight-function) would be relatively straightforward to carry over to a Bayesian framework, since the coefficients of the polynomials form a flexible-but-parametric extension of the null. [1]: Rayner, J.C.W. and D.J. Best (1990), "Smooth Tests of Goodness of Fit: An Overview," International Statistical Review, 58: 1 (Apr), pp. 9-17
What's the Bayesian equivalent of a general goodness of fit test? One relatively simple possibility: Smooth tests of goodness of fit e.g.[1] - which frame the alternative in terms of smooth deviations from the null, built by orthogonal polynomials (with respect to t
10,044
Generating visually appealing density heat maps in R
There are two things that will impact the smoothness of the plot, the bandwidth used for your kernel density estimate and the breaks you assign colors to in the plot. In my experience, for exploratory analysis I just adjust the bandwidth until I get a useful plot. Demonstration below. library(spatstat) set.seed(3) X <- rpoispp(10) par(mfrow = c(2,2)) plot(density(X, 1)) plot(density(X, 0.1)) plot(density(X, 0.05)) plot(density(X, 0.01)) Simply changing the default color scheme won't help any, nor will changing the resolution of the pixels (if anything the default resolution is too precise, and you should reduce the resolution and make the pixels larger). Although you may want to change the default color scheme for aesthetic purposes, it is intended to be highly discriminating. Things you can do to help the color are change the scale level to logarithms (will really only help if you have a very inhomogenous process), change the color palette to vary more at the lower end (bias in terms of the color ramp specification in R), or adjust the legend to have discrete bins instead of continuous. Examples of bias in the legend adapted from here, and I have another post on the GIS site explaining coloring the discrete bins in a pretty simple example here. These won't help though if the pattern is over or under smoothed though to begin with. Z <- density(X, 0.1) logZ <- eval.im(log(Z)) bias_palette <- colorRampPalette(c("blue", "magenta", "red", "yellow", "white"), bias=2, space="Lab") norm_palette <- colorRampPalette(c("white","red")) par(mfrow = c(2,2)) plot(Z) plot(logZ) plot(Z, col=bias_palette(256)) plot(Z, col=norm_palette(5)) To make the colors transparent in the last image (where the first color bin is white) one can just generate the color ramp and then replace the RGB specification with transparent colors. Example below using the same data as above. library(spatstat) set.seed(3) X <- rpoispp(10) Z <- density(X, 0.1) A <- rpoispp(100) #points other places than density norm_palette <- colorRampPalette(c("white","red")) pal_opaque <- norm_palette(5) pal_trans <- norm_palette(5) pal_trans[1] <- "#FFFFFF00" #was originally "#FFFFFF" par(mfrow = c(1,3)) plot(A, Main = "Opaque Density") plot(Z, add=T, col = pal_opaque) plot(A, Main = "Transparent Density") plot(Z, add=T, col = pal_trans) pal_trans2 <- paste(pal_opaque,"50",sep = "") plot(A, Main = "All slightly transparent") plot(Z, add=T, col = pal_trans2)
Generating visually appealing density heat maps in R
There are two things that will impact the smoothness of the plot, the bandwidth used for your kernel density estimate and the breaks you assign colors to in the plot. In my experience, for explorator
Generating visually appealing density heat maps in R There are two things that will impact the smoothness of the plot, the bandwidth used for your kernel density estimate and the breaks you assign colors to in the plot. In my experience, for exploratory analysis I just adjust the bandwidth until I get a useful plot. Demonstration below. library(spatstat) set.seed(3) X <- rpoispp(10) par(mfrow = c(2,2)) plot(density(X, 1)) plot(density(X, 0.1)) plot(density(X, 0.05)) plot(density(X, 0.01)) Simply changing the default color scheme won't help any, nor will changing the resolution of the pixels (if anything the default resolution is too precise, and you should reduce the resolution and make the pixels larger). Although you may want to change the default color scheme for aesthetic purposes, it is intended to be highly discriminating. Things you can do to help the color are change the scale level to logarithms (will really only help if you have a very inhomogenous process), change the color palette to vary more at the lower end (bias in terms of the color ramp specification in R), or adjust the legend to have discrete bins instead of continuous. Examples of bias in the legend adapted from here, and I have another post on the GIS site explaining coloring the discrete bins in a pretty simple example here. These won't help though if the pattern is over or under smoothed though to begin with. Z <- density(X, 0.1) logZ <- eval.im(log(Z)) bias_palette <- colorRampPalette(c("blue", "magenta", "red", "yellow", "white"), bias=2, space="Lab") norm_palette <- colorRampPalette(c("white","red")) par(mfrow = c(2,2)) plot(Z) plot(logZ) plot(Z, col=bias_palette(256)) plot(Z, col=norm_palette(5)) To make the colors transparent in the last image (where the first color bin is white) one can just generate the color ramp and then replace the RGB specification with transparent colors. Example below using the same data as above. library(spatstat) set.seed(3) X <- rpoispp(10) Z <- density(X, 0.1) A <- rpoispp(100) #points other places than density norm_palette <- colorRampPalette(c("white","red")) pal_opaque <- norm_palette(5) pal_trans <- norm_palette(5) pal_trans[1] <- "#FFFFFF00" #was originally "#FFFFFF" par(mfrow = c(1,3)) plot(A, Main = "Opaque Density") plot(Z, add=T, col = pal_opaque) plot(A, Main = "Transparent Density") plot(Z, add=T, col = pal_trans) pal_trans2 <- paste(pal_opaque,"50",sep = "") plot(A, Main = "All slightly transparent") plot(Z, add=T, col = pal_trans2)
Generating visually appealing density heat maps in R There are two things that will impact the smoothness of the plot, the bandwidth used for your kernel density estimate and the breaks you assign colors to in the plot. In my experience, for explorator
10,045
Generating visually appealing density heat maps in R
You may benefit from the interp function from the akima package. This will let you interpolate your matrix to another resolution if need be. To make something like your linked example, you would need to interpolate to a pretty fine grid (perhaps with the arguments xo and yo being ~ 1000 in length). This will give you a new matrix that you can plot with image(). If you want transparency, this will take some additional work. It's not easy to do that with a color palette, so you may end up having to plot each grid as a polygon with an assigned color.
Generating visually appealing density heat maps in R
You may benefit from the interp function from the akima package. This will let you interpolate your matrix to another resolution if need be. To make something like your linked example, you would need
Generating visually appealing density heat maps in R You may benefit from the interp function from the akima package. This will let you interpolate your matrix to another resolution if need be. To make something like your linked example, you would need to interpolate to a pretty fine grid (perhaps with the arguments xo and yo being ~ 1000 in length). This will give you a new matrix that you can plot with image(). If you want transparency, this will take some additional work. It's not easy to do that with a color palette, so you may end up having to plot each grid as a polygon with an assigned color.
Generating visually appealing density heat maps in R You may benefit from the interp function from the akima package. This will let you interpolate your matrix to another resolution if need be. To make something like your linked example, you would need
10,046
Generating visually appealing density heat maps in R
You may want to look into ggplot2. It seems like the package you've tried doesn't have a great color schemes or "flow" -- take a look at RColorBrewer. There is a blog where it implemented these package with a simple example. I'm not sure if you are trying to plot geographical data as shown in your linked example, but if you do I know that Google offers "Static Maps API V2 Developer Guide" and you can combine Google and R with a package called, RgoogleMaps. Good luck with your research.
Generating visually appealing density heat maps in R
You may want to look into ggplot2. It seems like the package you've tried doesn't have a great color schemes or "flow" -- take a look at RColorBrewer. There is a blog where it implemented these packag
Generating visually appealing density heat maps in R You may want to look into ggplot2. It seems like the package you've tried doesn't have a great color schemes or "flow" -- take a look at RColorBrewer. There is a blog where it implemented these package with a simple example. I'm not sure if you are trying to plot geographical data as shown in your linked example, but if you do I know that Google offers "Static Maps API V2 Developer Guide" and you can combine Google and R with a package called, RgoogleMaps. Good luck with your research.
Generating visually appealing density heat maps in R You may want to look into ggplot2. It seems like the package you've tried doesn't have a great color schemes or "flow" -- take a look at RColorBrewer. There is a blog where it implemented these packag
10,047
Generating visually appealing density heat maps in R
Have you tried cranking up the resolution in density? Try argument dimyx=c(512, 512) or higher.
Generating visually appealing density heat maps in R
Have you tried cranking up the resolution in density? Try argument dimyx=c(512, 512) or higher.
Generating visually appealing density heat maps in R Have you tried cranking up the resolution in density? Try argument dimyx=c(512, 512) or higher.
Generating visually appealing density heat maps in R Have you tried cranking up the resolution in density? Try argument dimyx=c(512, 512) or higher.
10,048
Basic Simpson's paradox
I think A and E aren't a good combination, because A says you should pick Mercy and E says you should pick Hope. A and D have the virtue of advocating the same choice. But, lets examine the line of reasoning in D in further detail, since that seems to be the confusion. The probability of success for the surgeries follows the same ordering at both hospitals, with the A type being most likely to be successful and the E type being the least likely. If we collapse over (i.e., ignore) the hospitals, we can see that the marginal probability of success for the surgeries is: Type A B C D E All Prob .81 .78 .56 .21 .08 .52 Because E is much less likely to be successful, it is reasonable to imagine that it is more difficult (although in the real world, other possibilities exist as well). We can extend that line of thinking to the other four types also. Now lets look at what proportion of each hospital's total surgeries are of each type: Type A B C D E Mercy .08 .39 .06 .44 .03 Hope .09 .54 .23 .09 .05 What we notice here is that Hope tends to do more of the easier surgeries A-C (and especially B & C), and fewer of the harder surgeries like D. E is pretty uncommon in both hospitals, but, for what it's worth, Hope actually does a higher percentage. Nonetheless, the Simpson's Paradox effect is going to mostly be driven by B-D here (not actually column E as answer choice D suggested). Simpson's Paradox occurs because the surgeries vary in difficulty (in general) and also because the N's differ. It is the differing base rates of the different types of surgeries that makes this counter-intuitive. What is happening would be easy to see if both hospitals did exactly the same number of each type of surgery. We can do that by simply calculating the success probabilities and multiplying by 100; this adjusts for the different frequencies: Type A B C D E All Mercy 81 79 60 21 09 250 Hope 80 76 51 14 04 225 Now, because both hospitals did 100 of each surgery (500 total), the answer is obvious: Mercy is the better hospital.
Basic Simpson's paradox
I think A and E aren't a good combination, because A says you should pick Mercy and E says you should pick Hope. A and D have the virtue of advocating the same choice. But, lets examine the line of
Basic Simpson's paradox I think A and E aren't a good combination, because A says you should pick Mercy and E says you should pick Hope. A and D have the virtue of advocating the same choice. But, lets examine the line of reasoning in D in further detail, since that seems to be the confusion. The probability of success for the surgeries follows the same ordering at both hospitals, with the A type being most likely to be successful and the E type being the least likely. If we collapse over (i.e., ignore) the hospitals, we can see that the marginal probability of success for the surgeries is: Type A B C D E All Prob .81 .78 .56 .21 .08 .52 Because E is much less likely to be successful, it is reasonable to imagine that it is more difficult (although in the real world, other possibilities exist as well). We can extend that line of thinking to the other four types also. Now lets look at what proportion of each hospital's total surgeries are of each type: Type A B C D E Mercy .08 .39 .06 .44 .03 Hope .09 .54 .23 .09 .05 What we notice here is that Hope tends to do more of the easier surgeries A-C (and especially B & C), and fewer of the harder surgeries like D. E is pretty uncommon in both hospitals, but, for what it's worth, Hope actually does a higher percentage. Nonetheless, the Simpson's Paradox effect is going to mostly be driven by B-D here (not actually column E as answer choice D suggested). Simpson's Paradox occurs because the surgeries vary in difficulty (in general) and also because the N's differ. It is the differing base rates of the different types of surgeries that makes this counter-intuitive. What is happening would be easy to see if both hospitals did exactly the same number of each type of surgery. We can do that by simply calculating the success probabilities and multiplying by 100; this adjusts for the different frequencies: Type A B C D E All Mercy 81 79 60 21 09 250 Hope 80 76 51 14 04 225 Now, because both hospitals did 100 of each surgery (500 total), the answer is obvious: Mercy is the better hospital.
Basic Simpson's paradox I think A and E aren't a good combination, because A says you should pick Mercy and E says you should pick Hope. A and D have the virtue of advocating the same choice. But, lets examine the line of
10,049
Basic Simpson's paradox
None of the answers are entirely baseless. But they ALL assume significant external knowledge and can't be taken to be correct strictly on the basis of the statistics. A, B, D, and E all require assumptions about the factors the cause patients to choose one hospital over another; the process by which doctors and patients are matched up, the extent to which success rates are attributable to specific classes of operations vs. shared factors like ICU, and on an on. In the real world we could legitimately consider many alternate factors such as the payment providers the hospital officially accepts, the socioeconomics and obesity rates of the neighborhood, whether this is a teaching hospital (in which case the success rate plummets when new interns arrive and we have to consider monthly mix), and on and on. Obviously we can and do make reasonable assumptions about these factors, but without specifically addressing or excluding them from the problem, it's impossible to say if an answer is "right" or not.
Basic Simpson's paradox
None of the answers are entirely baseless. But they ALL assume significant external knowledge and can't be taken to be correct strictly on the basis of the statistics. A, B, D, and E all require assu
Basic Simpson's paradox None of the answers are entirely baseless. But they ALL assume significant external knowledge and can't be taken to be correct strictly on the basis of the statistics. A, B, D, and E all require assumptions about the factors the cause patients to choose one hospital over another; the process by which doctors and patients are matched up, the extent to which success rates are attributable to specific classes of operations vs. shared factors like ICU, and on an on. In the real world we could legitimately consider many alternate factors such as the payment providers the hospital officially accepts, the socioeconomics and obesity rates of the neighborhood, whether this is a teaching hospital (in which case the success rate plummets when new interns arrive and we have to consider monthly mix), and on and on. Obviously we can and do make reasonable assumptions about these factors, but without specifically addressing or excluding them from the problem, it's impossible to say if an answer is "right" or not.
Basic Simpson's paradox None of the answers are entirely baseless. But they ALL assume significant external knowledge and can't be taken to be correct strictly on the basis of the statistics. A, B, D, and E all require assu
10,050
Basic Simpson's paradox
@gung gave a very thorough answer, but there is one more reason why D is a correct answer to the question: Better hospitals do more of the difficult operations because they are better. That is, if a person comes into Hope Hospital for operation E (the hardest) they may send him/her to Mercy because they at Hope don't know how to do it. This even happens in the real world, with the most difficult cases being sent to larger or more specialized hospitals.
Basic Simpson's paradox
@gung gave a very thorough answer, but there is one more reason why D is a correct answer to the question: Better hospitals do more of the difficult operations because they are better. That is, if a p
Basic Simpson's paradox @gung gave a very thorough answer, but there is one more reason why D is a correct answer to the question: Better hospitals do more of the difficult operations because they are better. That is, if a person comes into Hope Hospital for operation E (the hardest) they may send him/her to Mercy because they at Hope don't know how to do it. This even happens in the real world, with the most difficult cases being sent to larger or more specialized hospitals.
Basic Simpson's paradox @gung gave a very thorough answer, but there is one more reason why D is a correct answer to the question: Better hospitals do more of the difficult operations because they are better. That is, if a p
10,051
Regression vs. ANOVA discrepancy (aov vs lm in R)
The summary function calls different methods depending on the class of the object. The difference isn't in the aov vs lm, but in the information presented about the models. For example, if you used anova(mod1) and anova(mod2) instead, you should get the same results. As @Glen says, the key is whether the tests reported are based on Type 1 or Type 3 sums of squares. These will differ when the correlation between your explanatory variables is not exactly 0. When they are correlated, some SS are unique to one predictor and some to the other, but some SS could be attributed to either or both. (You can visualize this by imagining the MasterCard symbol--there's a small region of overlap in the center.) There is no unique answer in this situation, and unfortunately, this is the norm for non-experimental data. One approach is for the analyst to use their judgment and assign the overlapping SS to one of the variables. That variable goes into the model first. The other variable goes into the model second and gets the SS that looks like a cookie with a bite taken out of it. It's effect can be tested by what is sometimes called $R^2$ change or F change. This approach uses Type 1 SS. Alternatively, you could do this twice with each going in first, and report the F change test for both predictors. In this way, neither variable gets the SS due to the overlap. This approach uses Type 3 SS. (I should also tell you that the latter approach is held in low regard.) Following the suggestion of @BrettMagill in the comment below, I can try to make this a little clearer. (Note that, in my example, I'm using just 2 predictors and no interaction, but this idea can be scaled up to include whatever you like.) Type 1: SS(A) and SS(B|A) Type 3: SS(A|B) and SS(B|A)
Regression vs. ANOVA discrepancy (aov vs lm in R)
The summary function calls different methods depending on the class of the object. The difference isn't in the aov vs lm, but in the information presented about the models. For example, if you used
Regression vs. ANOVA discrepancy (aov vs lm in R) The summary function calls different methods depending on the class of the object. The difference isn't in the aov vs lm, but in the information presented about the models. For example, if you used anova(mod1) and anova(mod2) instead, you should get the same results. As @Glen says, the key is whether the tests reported are based on Type 1 or Type 3 sums of squares. These will differ when the correlation between your explanatory variables is not exactly 0. When they are correlated, some SS are unique to one predictor and some to the other, but some SS could be attributed to either or both. (You can visualize this by imagining the MasterCard symbol--there's a small region of overlap in the center.) There is no unique answer in this situation, and unfortunately, this is the norm for non-experimental data. One approach is for the analyst to use their judgment and assign the overlapping SS to one of the variables. That variable goes into the model first. The other variable goes into the model second and gets the SS that looks like a cookie with a bite taken out of it. It's effect can be tested by what is sometimes called $R^2$ change or F change. This approach uses Type 1 SS. Alternatively, you could do this twice with each going in first, and report the F change test for both predictors. In this way, neither variable gets the SS due to the overlap. This approach uses Type 3 SS. (I should also tell you that the latter approach is held in low regard.) Following the suggestion of @BrettMagill in the comment below, I can try to make this a little clearer. (Note that, in my example, I'm using just 2 predictors and no interaction, but this idea can be scaled up to include whatever you like.) Type 1: SS(A) and SS(B|A) Type 3: SS(A|B) and SS(B|A)
Regression vs. ANOVA discrepancy (aov vs lm in R) The summary function calls different methods depending on the class of the object. The difference isn't in the aov vs lm, but in the information presented about the models. For example, if you used
10,052
Regression vs. ANOVA discrepancy (aov vs lm in R)
The results from the aov output are giving you probabilities based on Type 1 sum of squares. This is why the interaction result is the same and the main effects differ. If you use probabilities based on Type 3 sum of squares then they will match the linear regression results. library(car) Anova(aov(score~group*moderator),type=3)
Regression vs. ANOVA discrepancy (aov vs lm in R)
The results from the aov output are giving you probabilities based on Type 1 sum of squares. This is why the interaction result is the same and the main effects differ. If you use probabilities based
Regression vs. ANOVA discrepancy (aov vs lm in R) The results from the aov output are giving you probabilities based on Type 1 sum of squares. This is why the interaction result is the same and the main effects differ. If you use probabilities based on Type 3 sum of squares then they will match the linear regression results. library(car) Anova(aov(score~group*moderator),type=3)
Regression vs. ANOVA discrepancy (aov vs lm in R) The results from the aov output are giving you probabilities based on Type 1 sum of squares. This is why the interaction result is the same and the main effects differ. If you use probabilities based
10,053
Regression vs. ANOVA discrepancy (aov vs lm in R)
The main difference between linear regression and ANOVA is, in ANOVA the predictor variables are discrete (that is they have different levels). Whereas in linear regression, the predictor variables are continuous.
Regression vs. ANOVA discrepancy (aov vs lm in R)
The main difference between linear regression and ANOVA is, in ANOVA the predictor variables are discrete (that is they have different levels). Whereas in linear regression, the predictor variables ar
Regression vs. ANOVA discrepancy (aov vs lm in R) The main difference between linear regression and ANOVA is, in ANOVA the predictor variables are discrete (that is they have different levels). Whereas in linear regression, the predictor variables are continuous.
Regression vs. ANOVA discrepancy (aov vs lm in R) The main difference between linear regression and ANOVA is, in ANOVA the predictor variables are discrete (that is they have different levels). Whereas in linear regression, the predictor variables ar
10,054
Average ROC for repeated 10-fold cross validation with probability estimates
From your description it seems to make perfect sense: not only you may calculate the mean ROC curve, but also the variance around it to build confidence intervals. It should give you the idea of how stable your model is. For example, like this: Here I put individual ROC curves as well as the mean curve and the confidence intervals. There are areas where curves agree, so we have less variance, and there are areas where they disagree. For repeated CV you can just repeat it multiple times and get the total average across all individual folds: It's quite similar to the previous picture, but gives more stable (i.e. reliable) estimates of the mean and variance. Here's the code to get the plot: import matplotlib.pyplot as plt import numpy as np from sklearn.datasets import make_classification from sklearn.cross_validation import KFold from sklearn.linear_model import LogisticRegression from sklearn.metrics import roc_curve X, y = make_classification(n_samples=500, random_state=100, flip_y=0.3) kf = KFold(n=len(y), n_folds=10) tprs = [] base_fpr = np.linspace(0, 1, 101) plt.figure(figsize=(5, 5)) plt.axes().set_aspect('equal', 'datalim') for i, (train, test) in enumerate(kf): model = LogisticRegression().fit(X[train], y[train]) y_score = model.predict_proba(X[test]) fpr, tpr, _ = roc_curve(y[test], y_score[:, 1]) plt.plot(fpr, tpr, 'b', alpha=0.15) tpr = np.interp(base_fpr, fpr, tpr) tpr[0] = 0.0 tprs.append(tpr) tprs = np.array(tprs) mean_tprs = tprs.mean(axis=0) std = tprs.std(axis=0) tprs_upper = np.minimum(mean_tprs + std, 1) tprs_lower = mean_tprs - std plt.plot(base_fpr, mean_tprs, 'b') plt.fill_between(base_fpr, tprs_lower, tprs_upper, color='grey', alpha=0.3) plt.plot([0, 1], [0, 1],'r--') plt.xlim([-0.01, 1.01]) plt.ylim([-0.01, 1.01]) plt.ylabel('True Positive Rate') plt.xlabel('False Positive Rate') plt.show() For repeated CV: idx = np.arange(0, len(y)) for j in np.random.randint(0, high=10000, size=10): np.random.shuffle(idx) kf = KFold(n=len(y), n_folds=10, random_state=j) for i, (train, test) in enumerate(kf): model = LogisticRegression().fit(X[idx][train], y[idx][train]) y_score = model.predict_proba(X[idx][test]) fpr, tpr, _ = roc_curve(y[idx][test], y_score[:, 1]) plt.plot(fpr, tpr, 'b', alpha=0.05) tpr = interp(base_fpr, fpr, tpr) tpr[0] = 0.0 tprs.append(tpr) Source of inspiration: http://scikit-learn.org/stable/auto_examples/model_selection/plot_roc_crossval.html
Average ROC for repeated 10-fold cross validation with probability estimates
From your description it seems to make perfect sense: not only you may calculate the mean ROC curve, but also the variance around it to build confidence intervals. It should give you the idea of how s
Average ROC for repeated 10-fold cross validation with probability estimates From your description it seems to make perfect sense: not only you may calculate the mean ROC curve, but also the variance around it to build confidence intervals. It should give you the idea of how stable your model is. For example, like this: Here I put individual ROC curves as well as the mean curve and the confidence intervals. There are areas where curves agree, so we have less variance, and there are areas where they disagree. For repeated CV you can just repeat it multiple times and get the total average across all individual folds: It's quite similar to the previous picture, but gives more stable (i.e. reliable) estimates of the mean and variance. Here's the code to get the plot: import matplotlib.pyplot as plt import numpy as np from sklearn.datasets import make_classification from sklearn.cross_validation import KFold from sklearn.linear_model import LogisticRegression from sklearn.metrics import roc_curve X, y = make_classification(n_samples=500, random_state=100, flip_y=0.3) kf = KFold(n=len(y), n_folds=10) tprs = [] base_fpr = np.linspace(0, 1, 101) plt.figure(figsize=(5, 5)) plt.axes().set_aspect('equal', 'datalim') for i, (train, test) in enumerate(kf): model = LogisticRegression().fit(X[train], y[train]) y_score = model.predict_proba(X[test]) fpr, tpr, _ = roc_curve(y[test], y_score[:, 1]) plt.plot(fpr, tpr, 'b', alpha=0.15) tpr = np.interp(base_fpr, fpr, tpr) tpr[0] = 0.0 tprs.append(tpr) tprs = np.array(tprs) mean_tprs = tprs.mean(axis=0) std = tprs.std(axis=0) tprs_upper = np.minimum(mean_tprs + std, 1) tprs_lower = mean_tprs - std plt.plot(base_fpr, mean_tprs, 'b') plt.fill_between(base_fpr, tprs_lower, tprs_upper, color='grey', alpha=0.3) plt.plot([0, 1], [0, 1],'r--') plt.xlim([-0.01, 1.01]) plt.ylim([-0.01, 1.01]) plt.ylabel('True Positive Rate') plt.xlabel('False Positive Rate') plt.show() For repeated CV: idx = np.arange(0, len(y)) for j in np.random.randint(0, high=10000, size=10): np.random.shuffle(idx) kf = KFold(n=len(y), n_folds=10, random_state=j) for i, (train, test) in enumerate(kf): model = LogisticRegression().fit(X[idx][train], y[idx][train]) y_score = model.predict_proba(X[idx][test]) fpr, tpr, _ = roc_curve(y[idx][test], y_score[:, 1]) plt.plot(fpr, tpr, 'b', alpha=0.05) tpr = interp(base_fpr, fpr, tpr) tpr[0] = 0.0 tprs.append(tpr) Source of inspiration: http://scikit-learn.org/stable/auto_examples/model_selection/plot_roc_crossval.html
Average ROC for repeated 10-fold cross validation with probability estimates From your description it seems to make perfect sense: not only you may calculate the mean ROC curve, but also the variance around it to build confidence intervals. It should give you the idea of how s
10,055
Average ROC for repeated 10-fold cross validation with probability estimates
It is not correct to average probabilities because that would not represent the predictions you are trying to validate and involves contamination across validation samples. Note that 100 repeats of 10-fold cross-validation may be required to achieve adequate precision. Or use the Efron-Gong optimism bootstrap which requires fewer iterations for the same precision (see e.g. R rms package validate functions). ROC curves are in no way insightful for this problem. Use a proper accuracy score and accompany it with the $c$-index (concordance probability; AUROC) which is much easier to deal with than the curve, since it is calculated easily and quickly using the Wilcoxon-Mann-Whitney statistic.
Average ROC for repeated 10-fold cross validation with probability estimates
It is not correct to average probabilities because that would not represent the predictions you are trying to validate and involves contamination across validation samples. Note that 100 repeats of 10
Average ROC for repeated 10-fold cross validation with probability estimates It is not correct to average probabilities because that would not represent the predictions you are trying to validate and involves contamination across validation samples. Note that 100 repeats of 10-fold cross-validation may be required to achieve adequate precision. Or use the Efron-Gong optimism bootstrap which requires fewer iterations for the same precision (see e.g. R rms package validate functions). ROC curves are in no way insightful for this problem. Use a proper accuracy score and accompany it with the $c$-index (concordance probability; AUROC) which is much easier to deal with than the curve, since it is calculated easily and quickly using the Wilcoxon-Mann-Whitney statistic.
Average ROC for repeated 10-fold cross validation with probability estimates It is not correct to average probabilities because that would not represent the predictions you are trying to validate and involves contamination across validation samples. Note that 100 repeats of 10
10,056
Central limit theorem and the law of large numbers
This figure shows the distributions of the means of $n=1$ (blue), $10$ (red), and $100$ (gold) independent and identically distributed (iid) normal distributions (of unit variance and mean $\mu$): As $n$ increases, the distribution of the mean becomes more "focused" on $\mu$. (The sense of "focusing" is easily quantified: given any fixed open interval $(a,b)$ surrounding $\mu$, the amount of the distribution within $[a,b]$ increases with $n$ and has a limiting value of $1$.) However, when we standardize these distributions, we rescale each of them to have a mean of $0$ and a unit variance: they are all the same then. This is how we see that although the PDFs of the means themselves are spiking upwards and focusing around $\mu$, nevertheless every one of these distributions is still has a Normal shape, even though they differ individually. The Central Limit Theorem says that when you start with any distribution--not just a normal distribution--that has a finite variance, and play the same game with means of $n$ iid values as $n$ increases, you see the same thing: the mean distributions focus around the original mean (the Weak Law of Large Numbers), but the standardized mean distributions converge to a standard Normal distribution (the Central Limit Theorem).
Central limit theorem and the law of large numbers
This figure shows the distributions of the means of $n=1$ (blue), $10$ (red), and $100$ (gold) independent and identically distributed (iid) normal distributions (of unit variance and mean $\mu$): As
Central limit theorem and the law of large numbers This figure shows the distributions of the means of $n=1$ (blue), $10$ (red), and $100$ (gold) independent and identically distributed (iid) normal distributions (of unit variance and mean $\mu$): As $n$ increases, the distribution of the mean becomes more "focused" on $\mu$. (The sense of "focusing" is easily quantified: given any fixed open interval $(a,b)$ surrounding $\mu$, the amount of the distribution within $[a,b]$ increases with $n$ and has a limiting value of $1$.) However, when we standardize these distributions, we rescale each of them to have a mean of $0$ and a unit variance: they are all the same then. This is how we see that although the PDFs of the means themselves are spiking upwards and focusing around $\mu$, nevertheless every one of these distributions is still has a Normal shape, even though they differ individually. The Central Limit Theorem says that when you start with any distribution--not just a normal distribution--that has a finite variance, and play the same game with means of $n$ iid values as $n$ increases, you see the same thing: the mean distributions focus around the original mean (the Weak Law of Large Numbers), but the standardized mean distributions converge to a standard Normal distribution (the Central Limit Theorem).
Central limit theorem and the law of large numbers This figure shows the distributions of the means of $n=1$ (blue), $10$ (red), and $100$ (gold) independent and identically distributed (iid) normal distributions (of unit variance and mean $\mu$): As
10,057
Difference between missing data and sparse data in machine learning algorithms
For the ease of understanding, I'll describe this using an example. Let's say that you are collecting data from a device which has 12 sensors. And you have collected data for 10 days. The data you have collected is as follows: This is called sparse data because most of the sensor outputs are zero. Which means those sensors are functioning properly but the actual reading is zero. Although this matrix has high dimensional data (12 axises) it can be said that it contains less information. Let's say 2 sensors of your device is malfunctioning. Then your data will be like: In this case, you can see that you cannot use data from Sensor1 and Sensor6. Either you have to fill data manually without affecting the results or you have to redo the experiment.
Difference between missing data and sparse data in machine learning algorithms
For the ease of understanding, I'll describe this using an example. Let's say that you are collecting data from a device which has 12 sensors. And you have collected data for 10 days. The data you hav
Difference between missing data and sparse data in machine learning algorithms For the ease of understanding, I'll describe this using an example. Let's say that you are collecting data from a device which has 12 sensors. And you have collected data for 10 days. The data you have collected is as follows: This is called sparse data because most of the sensor outputs are zero. Which means those sensors are functioning properly but the actual reading is zero. Although this matrix has high dimensional data (12 axises) it can be said that it contains less information. Let's say 2 sensors of your device is malfunctioning. Then your data will be like: In this case, you can see that you cannot use data from Sensor1 and Sensor6. Either you have to fill data manually without affecting the results or you have to redo the experiment.
Difference between missing data and sparse data in machine learning algorithms For the ease of understanding, I'll describe this using an example. Let's say that you are collecting data from a device which has 12 sensors. And you have collected data for 10 days. The data you hav
10,058
What are the multidimensional versions of median [duplicate]
The Geometric Median is a generalization of the median to higher dimensions. One of the properties of the median is that it is a point with minimal distance to all other points in the set, and GM generalizes this notion (using Euclidean/L2 distance). Regarding robustness, the Wikipedia article mentions that: "The geometric median has a breakdown point of 0.5. That is, up to half of the sample data may be arbitrarily corrupted, and the median of the samples will still provide a robust estimator for the location of the uncorrupted data." Next, note that in one dimension, minimizing L1 and L2 distances is the same, but in higher dimensions it is different. So, different norms will result in different generalizations. This paper, to the best of my understanding, suggests that the L1 distance generalization, which they simply call the "Minimum Sum of Distances" estimator, is also robust. So it seems that there are at least two useful generalizations: L1 (MSoD) and L2 (GM). For some additional perspective, note that one could also consider minimizing the square of the distances. This is in fact the arithmetic mean.
What are the multidimensional versions of median [duplicate]
The Geometric Median is a generalization of the median to higher dimensions. One of the properties of the median is that it is a point with minimal distance to all other points in the set, and GM gene
What are the multidimensional versions of median [duplicate] The Geometric Median is a generalization of the median to higher dimensions. One of the properties of the median is that it is a point with minimal distance to all other points in the set, and GM generalizes this notion (using Euclidean/L2 distance). Regarding robustness, the Wikipedia article mentions that: "The geometric median has a breakdown point of 0.5. That is, up to half of the sample data may be arbitrarily corrupted, and the median of the samples will still provide a robust estimator for the location of the uncorrupted data." Next, note that in one dimension, minimizing L1 and L2 distances is the same, but in higher dimensions it is different. So, different norms will result in different generalizations. This paper, to the best of my understanding, suggests that the L1 distance generalization, which they simply call the "Minimum Sum of Distances" estimator, is also robust. So it seems that there are at least two useful generalizations: L1 (MSoD) and L2 (GM). For some additional perspective, note that one could also consider minimizing the square of the distances. This is in fact the arithmetic mean.
What are the multidimensional versions of median [duplicate] The Geometric Median is a generalization of the median to higher dimensions. One of the properties of the median is that it is a point with minimal distance to all other points in the set, and GM gene
10,059
Statistics/Probability Videos for Beginners
I think a number of the suggestions put forward on the mathematical statistics video question probably fall in the stats 101 category: http://www.khanacademy.org/#Statistics: series of short videos on introductory statistics http://www.khanacademy.org/#Probability: series of short videos on introductory probability Math and probability for life sciences: A whole university course introducing statistics and probability. I also have a list of maths and statistics videos with a few others. The Stat 579 Videos on statistical computing in R are also quite good: http://connect.extension.iastate.edu/p31588910/ http://connect.extension.iastate.edu/p45341752/ http://connect.extension.iastate.edu/p39131597/ Factor & reshaping data Debugging & data aggregation Data aggregation & maps Data aggregation & maps (copy?) LaTeX and Sweave Random numbers, basic Simulations Permutations & data from the web Text & Patterns Databases
Statistics/Probability Videos for Beginners
I think a number of the suggestions put forward on the mathematical statistics video question probably fall in the stats 101 category: http://www.khanacademy.org/#Statistics: series of short videos o
Statistics/Probability Videos for Beginners I think a number of the suggestions put forward on the mathematical statistics video question probably fall in the stats 101 category: http://www.khanacademy.org/#Statistics: series of short videos on introductory statistics http://www.khanacademy.org/#Probability: series of short videos on introductory probability Math and probability for life sciences: A whole university course introducing statistics and probability. I also have a list of maths and statistics videos with a few others. The Stat 579 Videos on statistical computing in R are also quite good: http://connect.extension.iastate.edu/p31588910/ http://connect.extension.iastate.edu/p45341752/ http://connect.extension.iastate.edu/p39131597/ Factor & reshaping data Debugging & data aggregation Data aggregation & maps Data aggregation & maps (copy?) LaTeX and Sweave Random numbers, basic Simulations Permutations & data from the web Text & Patterns Databases
Statistics/Probability Videos for Beginners I think a number of the suggestions put forward on the mathematical statistics video question probably fall in the stats 101 category: http://www.khanacademy.org/#Statistics: series of short videos o
10,060
Statistics/Probability Videos for Beginners
I would suggest Statistics 401 (from Iowa State University). This is the link for Lesson 1. There are 64 lectures in total. (Here is the last one). Unfortunately, I haven't found the links gathered together in one page. I think also that lessons 21,26 and 39 are missing. However, I don't remember having any problem in following the course). You can also find the handouts for this class posted here. Some other introductory courses in Statistics are: Introductory Probability and Statistics for Business Basics of probability and statistics Lesson Videos for Statistics 2007 SLUO Lectures on Statistics
Statistics/Probability Videos for Beginners
I would suggest Statistics 401 (from Iowa State University). This is the link for Lesson 1. There are 64 lectures in total. (Here is the last one). Unfortunately, I haven't found the links gathered t
Statistics/Probability Videos for Beginners I would suggest Statistics 401 (from Iowa State University). This is the link for Lesson 1. There are 64 lectures in total. (Here is the last one). Unfortunately, I haven't found the links gathered together in one page. I think also that lessons 21,26 and 39 are missing. However, I don't remember having any problem in following the course). You can also find the handouts for this class posted here. Some other introductory courses in Statistics are: Introductory Probability and Statistics for Business Basics of probability and statistics Lesson Videos for Statistics 2007 SLUO Lectures on Statistics
Statistics/Probability Videos for Beginners I would suggest Statistics 401 (from Iowa State University). This is the link for Lesson 1. There are 64 lectures in total. (Here is the last one). Unfortunately, I haven't found the links gathered t
10,061
Statistics/Probability Videos for Beginners
GD047 linked to a UC Berkeley video on statistics, and I had another one. It's similar to MIT's Open Courseware (maybe a little lower quality). This one is for the Intro Statistics and Probability Class. It unfortunately only has 9 episodes, but it's free :). UC Berkeley STATS 20 Webcast
Statistics/Probability Videos for Beginners
GD047 linked to a UC Berkeley video on statistics, and I had another one. It's similar to MIT's Open Courseware (maybe a little lower quality). This one is for the Intro Statistics and Probability Cla
Statistics/Probability Videos for Beginners GD047 linked to a UC Berkeley video on statistics, and I had another one. It's similar to MIT's Open Courseware (maybe a little lower quality). This one is for the Intro Statistics and Probability Class. It unfortunately only has 9 episodes, but it's free :). UC Berkeley STATS 20 Webcast
Statistics/Probability Videos for Beginners GD047 linked to a UC Berkeley video on statistics, and I had another one. It's similar to MIT's Open Courseware (maybe a little lower quality). This one is for the Intro Statistics and Probability Cla
10,062
Statistics/Probability Videos for Beginners
Harvard's Stat 110 Probability taught by Joseph Blitzstein is available on iTunesU or Academic Earth.
Statistics/Probability Videos for Beginners
Harvard's Stat 110 Probability taught by Joseph Blitzstein is available on iTunesU or Academic Earth.
Statistics/Probability Videos for Beginners Harvard's Stat 110 Probability taught by Joseph Blitzstein is available on iTunesU or Academic Earth.
Statistics/Probability Videos for Beginners Harvard's Stat 110 Probability taught by Joseph Blitzstein is available on iTunesU or Academic Earth.
10,063
Statistics/Probability Videos for Beginners
You should definitely consider the Stats courses on Udacity. ST101: http://www.udacity.com/overview/Course/st101/CourseRev/1 There is also a ST095 course on Udacity, which I would have linked to but the link was blocked in this answer. Replace the 101 in the above link with 095. EdX, which is a consortium between Harvard, MIT and Berkeley also has a Stats course from Berkeley http://www.edx.org/courses/BerkeleyX/Stat2.1x/2013_Spring/about Hope this helps.
Statistics/Probability Videos for Beginners
You should definitely consider the Stats courses on Udacity. ST101: http://www.udacity.com/overview/Course/st101/CourseRev/1 There is also a ST095 course on Udacity, which I would have linked to but
Statistics/Probability Videos for Beginners You should definitely consider the Stats courses on Udacity. ST101: http://www.udacity.com/overview/Course/st101/CourseRev/1 There is also a ST095 course on Udacity, which I would have linked to but the link was blocked in this answer. Replace the 101 in the above link with 095. EdX, which is a consortium between Harvard, MIT and Berkeley also has a Stats course from Berkeley http://www.edx.org/courses/BerkeleyX/Stat2.1x/2013_Spring/about Hope this helps.
Statistics/Probability Videos for Beginners You should definitely consider the Stats courses on Udacity. ST101: http://www.udacity.com/overview/Course/st101/CourseRev/1 There is also a ST095 course on Udacity, which I would have linked to but
10,064
Statistics/Probability Videos for Beginners
I've studied from John E. Freund's Mathematical Statistics with Applications (7th Edition) at Freiburg University. It is indeed a good book, but you would also need a solutions manual to it because the excercises at the end of each chapter are not trivial.
Statistics/Probability Videos for Beginners
I've studied from John E. Freund's Mathematical Statistics with Applications (7th Edition) at Freiburg University. It is indeed a good book, but you would also need a solutions manual to it because th
Statistics/Probability Videos for Beginners I've studied from John E. Freund's Mathematical Statistics with Applications (7th Edition) at Freiburg University. It is indeed a good book, but you would also need a solutions manual to it because the excercises at the end of each chapter are not trivial.
Statistics/Probability Videos for Beginners I've studied from John E. Freund's Mathematical Statistics with Applications (7th Edition) at Freiburg University. It is indeed a good book, but you would also need a solutions manual to it because th
10,065
When are genetic algorithms a good choice for optimization?
Genetic algorithms (GA) are a family of heuristics which are empirically good at providing a decent answer in many cases, although they are rarely the best option for a given domain. You mention derivative-based algorithms, but even in the absence of derivatives there are plenty of derivative-free optimization algorithms that perform way better than GAs. See this and this answer for some ideas. What many standard optimization algorithms have in common (even derivative-free methods) is the assumption that the underlying space is a smooth manifold (perhaps with a few discrete dimensions), and the function to optimize is somewhat well-behaved. However, not all functions are defined on a smooth manifold. Sometimes you want to optimize over a graph or other discrete structures (combinatorial optimization) -- here there are dedicated algorithms, but GAs would also work. The more you go towards functions defined over complex, discrete structures, the more GAs can be useful, especially if you can find a representation in which the genetic operators work at their best (which requires a lot of hand-tuning and domain knowledge). Of course, the future might lead to forget GAs altogether and develop methods to map discrete spaces to continuous space, and use the optimization machinery we have on the continuous representation.
When are genetic algorithms a good choice for optimization?
Genetic algorithms (GA) are a family of heuristics which are empirically good at providing a decent answer in many cases, although they are rarely the best option for a given domain. You mention deriv
When are genetic algorithms a good choice for optimization? Genetic algorithms (GA) are a family of heuristics which are empirically good at providing a decent answer in many cases, although they are rarely the best option for a given domain. You mention derivative-based algorithms, but even in the absence of derivatives there are plenty of derivative-free optimization algorithms that perform way better than GAs. See this and this answer for some ideas. What many standard optimization algorithms have in common (even derivative-free methods) is the assumption that the underlying space is a smooth manifold (perhaps with a few discrete dimensions), and the function to optimize is somewhat well-behaved. However, not all functions are defined on a smooth manifold. Sometimes you want to optimize over a graph or other discrete structures (combinatorial optimization) -- here there are dedicated algorithms, but GAs would also work. The more you go towards functions defined over complex, discrete structures, the more GAs can be useful, especially if you can find a representation in which the genetic operators work at their best (which requires a lot of hand-tuning and domain knowledge). Of course, the future might lead to forget GAs altogether and develop methods to map discrete spaces to continuous space, and use the optimization machinery we have on the continuous representation.
When are genetic algorithms a good choice for optimization? Genetic algorithms (GA) are a family of heuristics which are empirically good at providing a decent answer in many cases, although they are rarely the best option for a given domain. You mention deriv
10,066
When are genetic algorithms a good choice for optimization?
Genetic methods are well suited for multicriteria optimization when gradient descent is dedicated to monocriteria optimization. Gradient descent allow to find minimum of functions when derivatives exists and there is only one optimum solution (if we except local minimas). A genetics algorithm can be used in multicriteria problems and lead to a continuum of solutions, each one beeing individuals of a population, having evolved from a initial population. The values to optimize are the phenotypes of the individuals and there can be several phenotypes. Generaly, none of the individual has simultaneously the better value of each phenotype, so there is not only one solution. The individuals in the final population, that are all solutions of the optimization, are part of the "Pareto front" and marked as being "Pareto rank one" individuals. This mean that compared to every others individuals having the same performance for each phenotype, they are at least better for one phenotype than the others.
When are genetic algorithms a good choice for optimization?
Genetic methods are well suited for multicriteria optimization when gradient descent is dedicated to monocriteria optimization. Gradient descent allow to find minimum of functions when derivatives exi
When are genetic algorithms a good choice for optimization? Genetic methods are well suited for multicriteria optimization when gradient descent is dedicated to monocriteria optimization. Gradient descent allow to find minimum of functions when derivatives exists and there is only one optimum solution (if we except local minimas). A genetics algorithm can be used in multicriteria problems and lead to a continuum of solutions, each one beeing individuals of a population, having evolved from a initial population. The values to optimize are the phenotypes of the individuals and there can be several phenotypes. Generaly, none of the individual has simultaneously the better value of each phenotype, so there is not only one solution. The individuals in the final population, that are all solutions of the optimization, are part of the "Pareto front" and marked as being "Pareto rank one" individuals. This mean that compared to every others individuals having the same performance for each phenotype, they are at least better for one phenotype than the others.
When are genetic algorithms a good choice for optimization? Genetic methods are well suited for multicriteria optimization when gradient descent is dedicated to monocriteria optimization. Gradient descent allow to find minimum of functions when derivatives exi
10,067
When are genetic algorithms a good choice for optimization?
Best in which sense ? In my experience, GAs are one of the most pragmatic optimizers. While many more precise algorithms require time and effort to formalize real problems in the mathematical world, GAs can handle any cost function with complex rules and constraints (GAs are related by an execution approach afterall and not by specific calculation). This process is straightforward and you can try many approaches for exploratory work. I appreciate also the possibility to reinject past solutions to the algorithm for future runs which is good for repeated task. Conceptually, a genetic algorithm can be represented by a hashmap of functions and suits so functionnal languages well like Clojure which is also a language where you can achieve big results very quickly. Genetic Algorithms can also be nested : the cost function of one GA can be a GA ! These algorithms take advantage of modern hardware and infrastructure which allow them to compute a very large population so that - even with simple mutation/selection operations - you can still achieve good results. Even for simple problems like finding the minimum of a wave function, GAs are not that bad and can achieve a decent precision in an acceptable time. So yeah, analytical solutions may have quicker execution time and precision, but the time required to produce them overweights often expected benefits ! So when ? Almost everytime to me, at least for meta-optimization.
When are genetic algorithms a good choice for optimization?
Best in which sense ? In my experience, GAs are one of the most pragmatic optimizers. While many more precise algorithms require time and effort to formalize real problems in the mathematical world,
When are genetic algorithms a good choice for optimization? Best in which sense ? In my experience, GAs are one of the most pragmatic optimizers. While many more precise algorithms require time and effort to formalize real problems in the mathematical world, GAs can handle any cost function with complex rules and constraints (GAs are related by an execution approach afterall and not by specific calculation). This process is straightforward and you can try many approaches for exploratory work. I appreciate also the possibility to reinject past solutions to the algorithm for future runs which is good for repeated task. Conceptually, a genetic algorithm can be represented by a hashmap of functions and suits so functionnal languages well like Clojure which is also a language where you can achieve big results very quickly. Genetic Algorithms can also be nested : the cost function of one GA can be a GA ! These algorithms take advantage of modern hardware and infrastructure which allow them to compute a very large population so that - even with simple mutation/selection operations - you can still achieve good results. Even for simple problems like finding the minimum of a wave function, GAs are not that bad and can achieve a decent precision in an acceptable time. So yeah, analytical solutions may have quicker execution time and precision, but the time required to produce them overweights often expected benefits ! So when ? Almost everytime to me, at least for meta-optimization.
When are genetic algorithms a good choice for optimization? Best in which sense ? In my experience, GAs are one of the most pragmatic optimizers. While many more precise algorithms require time and effort to formalize real problems in the mathematical world,
10,068
When are genetic algorithms a good choice for optimization?
Genetic algorithms are best when many processors can be used in parallel. and when the object function has a high modality (many local optima). Also, for multi-objective optimization, there are multi-objective genetic algorithms, MOGA. However, I think Genetic algorithms are overrated. A lot of the popularity probably comes from the fact that they are inspired by biology. They do tend to find global optima more often than other direct search methods, but at a high cost, which means that another direct search method (e.g. Nelder-Mead, Complex or SQP) can be run several times to find a global optimum, and yield a better performance (i.e., in terms of convergence, and probability of finding global optimum) overall. This is true not only if a single processor is used, but also even when multi processors are available. I think they stay popular because there are so many problems where very simple models are used, so performance is not an issue.
When are genetic algorithms a good choice for optimization?
Genetic algorithms are best when many processors can be used in parallel. and when the object function has a high modality (many local optima). Also, for multi-objective optimization, there are multi-
When are genetic algorithms a good choice for optimization? Genetic algorithms are best when many processors can be used in parallel. and when the object function has a high modality (many local optima). Also, for multi-objective optimization, there are multi-objective genetic algorithms, MOGA. However, I think Genetic algorithms are overrated. A lot of the popularity probably comes from the fact that they are inspired by biology. They do tend to find global optima more often than other direct search methods, but at a high cost, which means that another direct search method (e.g. Nelder-Mead, Complex or SQP) can be run several times to find a global optimum, and yield a better performance (i.e., in terms of convergence, and probability of finding global optimum) overall. This is true not only if a single processor is used, but also even when multi processors are available. I think they stay popular because there are so many problems where very simple models are used, so performance is not an issue.
When are genetic algorithms a good choice for optimization? Genetic algorithms are best when many processors can be used in parallel. and when the object function has a high modality (many local optima). Also, for multi-objective optimization, there are multi-
10,069
History of uninformative prior theory
What you seem to be missing is the early history. You can check the paper by Fienberg (2006) When Did Bayesian Inference Become "Bayesian"?. First, he notices that Thomas Bayes was the first one who suggested using a uniform prior: In current statistical language, Bayes' paper introduces a uniform prior distribution on the binomial parameter, $\theta$, reasoning by analogy with a "billiard table" and drawing on the form of the marginal distribution of the binomial random variable, and not on the principle of "insufficient reason," as many others have claimed. Pierre Simon Laplace was the next person to discuss it: Laplace also articulated, more clearly than Bayes, his argument for the choice of a uniform prior distribution, arguing that the posterior distribution of the parameter $\theta$ should be proportional to what we now call the likelihood of the data, i.e., $$ f(\theta\mid x_1,x_2,\dots,x_n) \propto f(x_1,x_2,\dots,x_n\mid\theta) $$ We now understand that this implies that the prior distribution for $\theta$ is uniform, although in general, of course, the prior may not exist. Moreover Carl Friedrich Gauss also referred to using an uninformative prior, as noted by David and Edwards (2001) in their book Annotated Readings in the History of Statistics: Gauss uses an ad hoc Bayesian-type argument to show that the posterior density of $h$ is proportional to the likelihood (in modern terminology): $$ f(h|x) \propto f(x|h) $$ where he has assumed $h$ to be uniformly distributed over $[0, \infty)$. Gauss mentions neither Bayes nor Laplace, although the latter had popularized this approach since Laplace (1774). and as Fienberg (2006) notices, "inverse probability" (and what follows, using uniform priors) was popular at the turn of the 19th century [...] Thus, in retrospect, it shouldn't be surprising to see inverse probability as the method of choice of the great English statisticians of the turn of the century, such as Edgeworth and Pearson. For example, Edgeworth (49) gave one of the earliest derivations of what we now know as Student's $t$-distribution, the posterior distribution of the mean $\mu$ of a normal distribution given uniform prior distributions on $\mu$ and $h =\sigma^{-1}$ [...] The early history of the Bayesian approach is also reviewed by Stigler (1986) in his book The history of statistics: The measurement of uncertainty before 1900. In your short review you also do not seem to mention Ronald Aylmer Fisher (again quoted after Fienberg, 2006): Fisher moved away from the inverse methods and towards his own approach to inference he called the "likelihood," a concept he claimed was distinct from probability. But Fisher's progression in this regard was slow. Stigler (164) has pointed out that, in an unpublished manuscript dating from 1916, Fisher didn't distinguish between likelihood and inverse probability with a flat prior, even though when he later made the distinction he claimed to have understood it at this time. Jaynes (1986) provided his own short review paper Bayesian Methods: General Background. An Introductory Tutorial that you could check, but it does not focus on uninformative priors. Moreover, as noted by AdamO, you should definitely read The Epic Story of Maximum Likelihood by Stigler (2007). It is also worth mentioning that there is no such thing as an "uninformative prior", so many authors prefer talking about "vague priors", or "weekly informative priors". A theoretical review is provided by Kass and Wasserman (1996) in The selection of prior distributions by formal rules, who go into greater detail about choosing priors, with extended discussion of usage of uninformative priors.
History of uninformative prior theory
What you seem to be missing is the early history. You can check the paper by Fienberg (2006) When Did Bayesian Inference Become "Bayesian"?. First, he notices that Thomas Bayes was the first one who s
History of uninformative prior theory What you seem to be missing is the early history. You can check the paper by Fienberg (2006) When Did Bayesian Inference Become "Bayesian"?. First, he notices that Thomas Bayes was the first one who suggested using a uniform prior: In current statistical language, Bayes' paper introduces a uniform prior distribution on the binomial parameter, $\theta$, reasoning by analogy with a "billiard table" and drawing on the form of the marginal distribution of the binomial random variable, and not on the principle of "insufficient reason," as many others have claimed. Pierre Simon Laplace was the next person to discuss it: Laplace also articulated, more clearly than Bayes, his argument for the choice of a uniform prior distribution, arguing that the posterior distribution of the parameter $\theta$ should be proportional to what we now call the likelihood of the data, i.e., $$ f(\theta\mid x_1,x_2,\dots,x_n) \propto f(x_1,x_2,\dots,x_n\mid\theta) $$ We now understand that this implies that the prior distribution for $\theta$ is uniform, although in general, of course, the prior may not exist. Moreover Carl Friedrich Gauss also referred to using an uninformative prior, as noted by David and Edwards (2001) in their book Annotated Readings in the History of Statistics: Gauss uses an ad hoc Bayesian-type argument to show that the posterior density of $h$ is proportional to the likelihood (in modern terminology): $$ f(h|x) \propto f(x|h) $$ where he has assumed $h$ to be uniformly distributed over $[0, \infty)$. Gauss mentions neither Bayes nor Laplace, although the latter had popularized this approach since Laplace (1774). and as Fienberg (2006) notices, "inverse probability" (and what follows, using uniform priors) was popular at the turn of the 19th century [...] Thus, in retrospect, it shouldn't be surprising to see inverse probability as the method of choice of the great English statisticians of the turn of the century, such as Edgeworth and Pearson. For example, Edgeworth (49) gave one of the earliest derivations of what we now know as Student's $t$-distribution, the posterior distribution of the mean $\mu$ of a normal distribution given uniform prior distributions on $\mu$ and $h =\sigma^{-1}$ [...] The early history of the Bayesian approach is also reviewed by Stigler (1986) in his book The history of statistics: The measurement of uncertainty before 1900. In your short review you also do not seem to mention Ronald Aylmer Fisher (again quoted after Fienberg, 2006): Fisher moved away from the inverse methods and towards his own approach to inference he called the "likelihood," a concept he claimed was distinct from probability. But Fisher's progression in this regard was slow. Stigler (164) has pointed out that, in an unpublished manuscript dating from 1916, Fisher didn't distinguish between likelihood and inverse probability with a flat prior, even though when he later made the distinction he claimed to have understood it at this time. Jaynes (1986) provided his own short review paper Bayesian Methods: General Background. An Introductory Tutorial that you could check, but it does not focus on uninformative priors. Moreover, as noted by AdamO, you should definitely read The Epic Story of Maximum Likelihood by Stigler (2007). It is also worth mentioning that there is no such thing as an "uninformative prior", so many authors prefer talking about "vague priors", or "weekly informative priors". A theoretical review is provided by Kass and Wasserman (1996) in The selection of prior distributions by formal rules, who go into greater detail about choosing priors, with extended discussion of usage of uninformative priors.
History of uninformative prior theory What you seem to be missing is the early history. You can check the paper by Fienberg (2006) When Did Bayesian Inference Become "Bayesian"?. First, he notices that Thomas Bayes was the first one who s
10,070
History of uninformative prior theory
A few comments about flaws of noninformative priors (uninformative priors) are probably a good idea since the investigation of such flaws helped development of the concept of noninformative prior in history. You may want to add some comments about the drawbacks/flaws of adopting noninformative priors. Among many criticisms I point out two. (1) Generally the adoption of noninformative priors has consistency problems especially when the model distribution has multi-modal behavior. This problem is not unique to noninformative priors but is shared by many other Bayesian procedures as pointed out in the following paper along with its discussions. Diaconis, Persi, and David Freedman. "On the consistency of Bayes estimates." The Annals of Statistics (1986): 1-26. Nowadays the noninformative prior is no longer a research focus. It seems that there is more interest in more flexible choices of prior in nonparametric settings. Examples are the Gaussian process prior in nonparametric Bayes procedure or a flexible model like a mixture of Dirichlet priors, as in Antoniak, Charles E. "Mixtures of Dirichlet processes with applications to Bayesian nonparametric problems." The annals of statistics (1974): 1152-1174. But again such a prior has its own consistency problems. (2) Most so-called "noninformative priors" are not well-defined. This is probably the most evident problem associated with noninformative priors during their development. One example is that the limit definition of noninformative prior as a limit of a sequence of proper priors will lead to a marginalization paradox. As you mentioned, Bernardo's reference prior also has the problem that Berger never proved that its formal definition is independent from its construction/partition. See the discussion in Berger, James O., José M. Bernardo, and Dongchu Sun. "The formal definition of reference priors." The Annals of Statistics (2009): 905-938. One best definition about Jeffreys' prior that is well-defined is that it is chosen to be a prior such that it is invariant under certain parallel translation over the Riemannian manifold equipped with Fisher information metric, but even that does not solve the first problem. Also you may want to read my explanation about marginalization paradox.
History of uninformative prior theory
A few comments about flaws of noninformative priors (uninformative priors) are probably a good idea since the investigation of such flaws helped development of the concept of noninformative prior in h
History of uninformative prior theory A few comments about flaws of noninformative priors (uninformative priors) are probably a good idea since the investigation of such flaws helped development of the concept of noninformative prior in history. You may want to add some comments about the drawbacks/flaws of adopting noninformative priors. Among many criticisms I point out two. (1) Generally the adoption of noninformative priors has consistency problems especially when the model distribution has multi-modal behavior. This problem is not unique to noninformative priors but is shared by many other Bayesian procedures as pointed out in the following paper along with its discussions. Diaconis, Persi, and David Freedman. "On the consistency of Bayes estimates." The Annals of Statistics (1986): 1-26. Nowadays the noninformative prior is no longer a research focus. It seems that there is more interest in more flexible choices of prior in nonparametric settings. Examples are the Gaussian process prior in nonparametric Bayes procedure or a flexible model like a mixture of Dirichlet priors, as in Antoniak, Charles E. "Mixtures of Dirichlet processes with applications to Bayesian nonparametric problems." The annals of statistics (1974): 1152-1174. But again such a prior has its own consistency problems. (2) Most so-called "noninformative priors" are not well-defined. This is probably the most evident problem associated with noninformative priors during their development. One example is that the limit definition of noninformative prior as a limit of a sequence of proper priors will lead to a marginalization paradox. As you mentioned, Bernardo's reference prior also has the problem that Berger never proved that its formal definition is independent from its construction/partition. See the discussion in Berger, James O., José M. Bernardo, and Dongchu Sun. "The formal definition of reference priors." The Annals of Statistics (2009): 905-938. One best definition about Jeffreys' prior that is well-defined is that it is chosen to be a prior such that it is invariant under certain parallel translation over the Riemannian manifold equipped with Fisher information metric, but even that does not solve the first problem. Also you may want to read my explanation about marginalization paradox.
History of uninformative prior theory A few comments about flaws of noninformative priors (uninformative priors) are probably a good idea since the investigation of such flaws helped development of the concept of noninformative prior in h
10,071
History of uninformative prior theory
I would have posted in the comments, but I guess I do not have the reputation yet. The only missing thing, not in the comments already marked, is a special case of noninformative priors whose origins that I have tried to hunt down and have not found. It may precede Jeffreys paper. For the normal distribution, I have seen the Cauchy distribution used as a noninformative prior for data with a normal likelihood. The reason is that the precision of the Cauchy distribution is zero, where precision is one divided by the variance. It creates a rather peculiar set of contradictory concepts. The formula for the Cauchy is $$\frac{1}{\pi}\frac{\Gamma}{\Gamma^2+(x-\mu)^2}.$$ Depending on how you define the integral there is either no defined variance or it goes to infinity about the median, which implies the precision goes to zero. In conjugate updating, which wouldn't apply here, you add the weighted precisions. I think this is why this idea of a proper prior with a perfectly imprecise density formed. It is also equivalent to Student's t with one degree of freedom, which could also be the source. This is a strange idea in the sense that the Cauchy distribution has a well defined center of location and inter-quartile range, which is $2\Gamma$. The two earliest references to the Cauchy distribution are as likelihood functions. The first in a letter from Poisson to Laplace as an exception to the Central Limit Theorem. The second was in 1851 journal articles in a battle between Bienayme' and Cauchy over the validity of ordinary least squares. I have found references to its use as a noninformative prior back into the 1980's but I cannot find a first article or book. I also have not found a proof that it is noninformative. I did find a citation to Jeffreys' 1961 book on probability theory, but I have never requested the book via interlibrary loan. It may be simply weakly informative. The 99.99% highest density region is 1272 semi-interquartile ranges wide. I hope it helps. It is a weird special case, but you see it come up in a number of regression papers. It satisfies the requirements for a Bayes action by being a proper prior, while minimally influencing location and scale.
History of uninformative prior theory
I would have posted in the comments, but I guess I do not have the reputation yet. The only missing thing, not in the comments already marked, is a special case of noninformative priors whose origins
History of uninformative prior theory I would have posted in the comments, but I guess I do not have the reputation yet. The only missing thing, not in the comments already marked, is a special case of noninformative priors whose origins that I have tried to hunt down and have not found. It may precede Jeffreys paper. For the normal distribution, I have seen the Cauchy distribution used as a noninformative prior for data with a normal likelihood. The reason is that the precision of the Cauchy distribution is zero, where precision is one divided by the variance. It creates a rather peculiar set of contradictory concepts. The formula for the Cauchy is $$\frac{1}{\pi}\frac{\Gamma}{\Gamma^2+(x-\mu)^2}.$$ Depending on how you define the integral there is either no defined variance or it goes to infinity about the median, which implies the precision goes to zero. In conjugate updating, which wouldn't apply here, you add the weighted precisions. I think this is why this idea of a proper prior with a perfectly imprecise density formed. It is also equivalent to Student's t with one degree of freedom, which could also be the source. This is a strange idea in the sense that the Cauchy distribution has a well defined center of location and inter-quartile range, which is $2\Gamma$. The two earliest references to the Cauchy distribution are as likelihood functions. The first in a letter from Poisson to Laplace as an exception to the Central Limit Theorem. The second was in 1851 journal articles in a battle between Bienayme' and Cauchy over the validity of ordinary least squares. I have found references to its use as a noninformative prior back into the 1980's but I cannot find a first article or book. I also have not found a proof that it is noninformative. I did find a citation to Jeffreys' 1961 book on probability theory, but I have never requested the book via interlibrary loan. It may be simply weakly informative. The 99.99% highest density region is 1272 semi-interquartile ranges wide. I hope it helps. It is a weird special case, but you see it come up in a number of regression papers. It satisfies the requirements for a Bayes action by being a proper prior, while minimally influencing location and scale.
History of uninformative prior theory I would have posted in the comments, but I guess I do not have the reputation yet. The only missing thing, not in the comments already marked, is a special case of noninformative priors whose origins
10,072
Support vector machines and regression
Basically they generalize in the same way. The kernel based approach to regression is to transform the feature, call it $\mathbf{x}$ to some vector space, then perform a linear regression in that vector space. To avoid the 'curse of dimensionality', the linear regression in the transformed space is somewhat different than ordinary least squares. The upshot is that the regression in the transformed space can be expressed as $\ell(\mathbf{x}) = \sum_i w_i \phi(\mathbf{x_i}) \cdot \phi(\mathbf{x})$, where $\mathbf{x_i}$ are observations from the training set, $\phi(\cdot)$ is the transform applied to data, and the dot is the dot product. Thus the linear regression is 'supported' by a few (preferrably a very small number of) training vectors. All the mathematical details are hidden in the weird regression done in the transformed space ('epsilon-insensitive tube' or whatever) and the choice of transform, $\phi$. For a practitioner, there are also questions of a few free parameters (usually in the definition of $\phi$ and the regression), as well as featurization, which is where domain knowledge is usually helpful.
Support vector machines and regression
Basically they generalize in the same way. The kernel based approach to regression is to transform the feature, call it $\mathbf{x}$ to some vector space, then perform a linear regression in that vect
Support vector machines and regression Basically they generalize in the same way. The kernel based approach to regression is to transform the feature, call it $\mathbf{x}$ to some vector space, then perform a linear regression in that vector space. To avoid the 'curse of dimensionality', the linear regression in the transformed space is somewhat different than ordinary least squares. The upshot is that the regression in the transformed space can be expressed as $\ell(\mathbf{x}) = \sum_i w_i \phi(\mathbf{x_i}) \cdot \phi(\mathbf{x})$, where $\mathbf{x_i}$ are observations from the training set, $\phi(\cdot)$ is the transform applied to data, and the dot is the dot product. Thus the linear regression is 'supported' by a few (preferrably a very small number of) training vectors. All the mathematical details are hidden in the weird regression done in the transformed space ('epsilon-insensitive tube' or whatever) and the choice of transform, $\phi$. For a practitioner, there are also questions of a few free parameters (usually in the definition of $\phi$ and the regression), as well as featurization, which is where domain knowledge is usually helpful.
Support vector machines and regression Basically they generalize in the same way. The kernel based approach to regression is to transform the feature, call it $\mathbf{x}$ to some vector space, then perform a linear regression in that vect
10,073
Support vector machines and regression
For an overview of SVM: How does a Support Vector Machine (SVM) work? Regarding support vector regression (SVR), I find these slides from http://cs.adelaide.edu.au/~chhshen/teaching/ML_SVR.pdf (mirror) very clear: The Matlab documentation also has a decent explanation and additionally goes over the optimization solving algorithm: https://www.mathworks.com/help/stats/understanding-support-vector-machine-regression.html (mirror). So far this answer has presented the so-called epsilon-insensitive SVM (ε-SVM) regression. There exists a more recent variant of SVM for either classification of regression: Least squares support vector machine. Additionally, SVR may be extended for multi-output a.k.a. multi-target, e.g. see {1}. References: {1} Borchani, Hanen, Gherardo Varando, Concha Bielza, and Pedro Larrañaga. "A survey on multi‐output regression." Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery 5, no. 5 (2015): 216-233. https://scholar.google.com/scholar?cluster=10208375872303977988&hl=en&as_sdt=0,14; https://web.archive.org/web/20170628222235/http://oa.upm.es/40804/1/INVE_MEM_2015_204213.pdf
Support vector machines and regression
For an overview of SVM: How does a Support Vector Machine (SVM) work? Regarding support vector regression (SVR), I find these slides from http://cs.adelaide.edu.au/~chhshen/teaching/ML_SVR.pdf (mirro
Support vector machines and regression For an overview of SVM: How does a Support Vector Machine (SVM) work? Regarding support vector regression (SVR), I find these slides from http://cs.adelaide.edu.au/~chhshen/teaching/ML_SVR.pdf (mirror) very clear: The Matlab documentation also has a decent explanation and additionally goes over the optimization solving algorithm: https://www.mathworks.com/help/stats/understanding-support-vector-machine-regression.html (mirror). So far this answer has presented the so-called epsilon-insensitive SVM (ε-SVM) regression. There exists a more recent variant of SVM for either classification of regression: Least squares support vector machine. Additionally, SVR may be extended for multi-output a.k.a. multi-target, e.g. see {1}. References: {1} Borchani, Hanen, Gherardo Varando, Concha Bielza, and Pedro Larrañaga. "A survey on multi‐output regression." Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery 5, no. 5 (2015): 216-233. https://scholar.google.com/scholar?cluster=10208375872303977988&hl=en&as_sdt=0,14; https://web.archive.org/web/20170628222235/http://oa.upm.es/40804/1/INVE_MEM_2015_204213.pdf
Support vector machines and regression For an overview of SVM: How does a Support Vector Machine (SVM) work? Regarding support vector regression (SVR), I find these slides from http://cs.adelaide.edu.au/~chhshen/teaching/ML_SVR.pdf (mirro
10,074
What's the difference between binomial regression and logistic regression?
Logistic regression is a binomial regression with the "logistic" link function: $$g(p)=\log\left(\frac{p}{1-p}\right)=X\beta$$ Although I also think logistic regression is usually applied to binomial proportions rather than binomial counts.
What's the difference between binomial regression and logistic regression?
Logistic regression is a binomial regression with the "logistic" link function: $$g(p)=\log\left(\frac{p}{1-p}\right)=X\beta$$ Although I also think logistic regression is usually applied to binomial
What's the difference between binomial regression and logistic regression? Logistic regression is a binomial regression with the "logistic" link function: $$g(p)=\log\left(\frac{p}{1-p}\right)=X\beta$$ Although I also think logistic regression is usually applied to binomial proportions rather than binomial counts.
What's the difference between binomial regression and logistic regression? Logistic regression is a binomial regression with the "logistic" link function: $$g(p)=\log\left(\frac{p}{1-p}\right)=X\beta$$ Although I also think logistic regression is usually applied to binomial
10,075
What's the difference between binomial regression and logistic regression?
Binomial regression is any type of GLM using a binomial mean-variance relationship where the variance is given by $\mbox{var}(Y) = \hat{Y}(1-\hat{Y})$. In logistic regression the $\hat{Y} = \mbox{logit}^{-1}(\mathbf{X}\hat{\beta})=1/(1-\exp{(\mathbf{X}\hat{\beta})})$ with the logit function said to be a "link" function. However a general class of binomial regression models can be defined with any type of link function, even functions outputting a range outside of $[0,1]$. For instance, probit regression takes a link of the inverse normal CDF, relative risk regression takes as a link the log function, and additive risk models take the identity link model.
What's the difference between binomial regression and logistic regression?
Binomial regression is any type of GLM using a binomial mean-variance relationship where the variance is given by $\mbox{var}(Y) = \hat{Y}(1-\hat{Y})$. In logistic regression the $\hat{Y} = \mbox{logi
What's the difference between binomial regression and logistic regression? Binomial regression is any type of GLM using a binomial mean-variance relationship where the variance is given by $\mbox{var}(Y) = \hat{Y}(1-\hat{Y})$. In logistic regression the $\hat{Y} = \mbox{logit}^{-1}(\mathbf{X}\hat{\beta})=1/(1-\exp{(\mathbf{X}\hat{\beta})})$ with the logit function said to be a "link" function. However a general class of binomial regression models can be defined with any type of link function, even functions outputting a range outside of $[0,1]$. For instance, probit regression takes a link of the inverse normal CDF, relative risk regression takes as a link the log function, and additive risk models take the identity link model.
What's the difference between binomial regression and logistic regression? Binomial regression is any type of GLM using a binomial mean-variance relationship where the variance is given by $\mbox{var}(Y) = \hat{Y}(1-\hat{Y})$. In logistic regression the $\hat{Y} = \mbox{logi
10,076
Differences between heavy tail and fat tail distributions
I would say that the usual definition in applied probability theory is that a right heavy tailed distribution is one with infinite moment generating function on $(0, \infty)$, that is, $X$ has right heavy tail if $$E(e^{tX}) = \infty, \quad t > 0.$$ This is in agreement with Wikipedia, which does mention other used definitions such as the one you have (some moment is infinite). There are also important subclasses such as the long-tailed distributions and the subexponential distributions. The standard example of a heavy-tailed distribution, according to the definition above, with all moments finite is the log-normal distribution. It may very well be that some authors use fat tailed and heavy tailed interchangeably, and others distinguish between fat tailed and heavy tailed. I would say that fat tailed can be used more vaguely to indicate fatter than normal tails and is sometimes used in the sense of leptokurtic (positive kurtosis) as you indicate. One example of such a distribution, which is not heavy tailed according to the definition above, is the logistic distribution. However, this is not in agreement with e.g. Wikipedia, which is much more restrictive and requires that the (right) tail has a power law decay. The Wikipedia article also suggests that fat tail and heavy tail are equivalent concepts, even though power law decay is much stronger than the definition of heavy tails given above. To avoid confusions, I would recommend to use the definition of a (right) heavy tail above and forget about fat tails whatever that is. The primary reason behind the definition above is that in the analysis of rare events there is a qualitative difference between distributions with finite moment generating function on a positive interval and those with infinite moment generating function on $(0, \infty)$.
Differences between heavy tail and fat tail distributions
I would say that the usual definition in applied probability theory is that a right heavy tailed distribution is one with infinite moment generating function on $(0, \infty)$, that is, $X$ has right h
Differences between heavy tail and fat tail distributions I would say that the usual definition in applied probability theory is that a right heavy tailed distribution is one with infinite moment generating function on $(0, \infty)$, that is, $X$ has right heavy tail if $$E(e^{tX}) = \infty, \quad t > 0.$$ This is in agreement with Wikipedia, which does mention other used definitions such as the one you have (some moment is infinite). There are also important subclasses such as the long-tailed distributions and the subexponential distributions. The standard example of a heavy-tailed distribution, according to the definition above, with all moments finite is the log-normal distribution. It may very well be that some authors use fat tailed and heavy tailed interchangeably, and others distinguish between fat tailed and heavy tailed. I would say that fat tailed can be used more vaguely to indicate fatter than normal tails and is sometimes used in the sense of leptokurtic (positive kurtosis) as you indicate. One example of such a distribution, which is not heavy tailed according to the definition above, is the logistic distribution. However, this is not in agreement with e.g. Wikipedia, which is much more restrictive and requires that the (right) tail has a power law decay. The Wikipedia article also suggests that fat tail and heavy tail are equivalent concepts, even though power law decay is much stronger than the definition of heavy tails given above. To avoid confusions, I would recommend to use the definition of a (right) heavy tail above and forget about fat tails whatever that is. The primary reason behind the definition above is that in the analysis of rare events there is a qualitative difference between distributions with finite moment generating function on a positive interval and those with infinite moment generating function on $(0, \infty)$.
Differences between heavy tail and fat tail distributions I would say that the usual definition in applied probability theory is that a right heavy tailed distribution is one with infinite moment generating function on $(0, \infty)$, that is, $X$ has right h
10,077
Differences between heavy tail and fat tail distributions
NN Taleb, P Cirillo (2019) address this directly in Branching epistemic uncertainty and thickness of tails where they state: From the point of view of extreme value statistics, both the Gamma and the Lognormal are heavy-tailed distributions, meaning that their right tail goes to zero slower than an exponential function, but not "true" fat-tailed, i.e. their tail decreases faster than a power law [31]. From the point of view of extreme value theory, both distributions are in the maximum domain of attraction of the Gumbel case of the Generalized Extreme Value distribution [9], [14], and not of the Fréchet one, i.e. the proper fat-tailed case. As a consequence, the moments of these distributions will always be finite.
Differences between heavy tail and fat tail distributions
NN Taleb, P Cirillo (2019) address this directly in Branching epistemic uncertainty and thickness of tails where they state: From the point of view of extreme value statistics, both the Gamma and the
Differences between heavy tail and fat tail distributions NN Taleb, P Cirillo (2019) address this directly in Branching epistemic uncertainty and thickness of tails where they state: From the point of view of extreme value statistics, both the Gamma and the Lognormal are heavy-tailed distributions, meaning that their right tail goes to zero slower than an exponential function, but not "true" fat-tailed, i.e. their tail decreases faster than a power law [31]. From the point of view of extreme value theory, both distributions are in the maximum domain of attraction of the Gumbel case of the Generalized Extreme Value distribution [9], [14], and not of the Fréchet one, i.e. the proper fat-tailed case. As a consequence, the moments of these distributions will always be finite.
Differences between heavy tail and fat tail distributions NN Taleb, P Cirillo (2019) address this directly in Branching epistemic uncertainty and thickness of tails where they state: From the point of view of extreme value statistics, both the Gamma and the
10,078
Differences between heavy tail and fat tail distributions
First there can be left tails and right tails, then long tails and short tails. A short-tailed distribution can be thought of a having a finite range, called its support. And a long tail has semi-infinite support in that direction. For right-tail heaviness one does a comparison of either survival functions (RVs) or complimentary cumulative density functions (1-CDF), typically by examining the logarithm of ratio of two different distributions. In general, heavy tailed means heavier than the exponential distribution, and light tailed means lighter than that. A subset of heavier-tailed distributions are called "fat-tailed." From a historical perspective it is most likely that the concept of a fat tail relates to the type I Pareto distribution, i.e., \begin{equation}\label{eq:PD} \text{PD}(t; \alpha, \beta)= \dfrac{\alpha}{t} \left(\dfrac{\beta}{t}\right) ^{\alpha } \theta(t-\beta)\;, \end{equation} where $\alpha$ is the shape parameter, $\beta$ is a scale parameter and $\theta(\cdot)$ is the unit step function such that $\theta(t-\beta)$ is the unit step function time-delayed by $\beta$, and is used to make a product that is non-zero only when $t> \beta$. From Juran, "The Pareto Principle (Sic, 80-20 rule) gets its name from the Italian-born economist Vilfredo Pareto (1848-1923), who observed that a relative few people held the majority of the wealth (20%) – back in 1895. Pareto developed logarithmic mathematical models to describe this non-uniform distribution of wealth and the mathematician M.O. Lorenz developed graphs to illustrate it." Next, let us consider the attitude toward wealth at that time. Renzaho quotes Grivetti saying "At the turn of the 20th century in North America obesity was admired; wealthy consumers exhibited their wealth around their waist. Fat cheeks and ample stomachs were visual cues that individuals were healthy, not infected with the dreaded slim tuberculosis. Photographs of American executives taken during the late 19th and early 20th centuries reveal that dietary intakes of wealthy gentlemen regularly exceeded calories expended." The history of those times lends considerable weight to those words. From the US 1910 census, tuberculosis, A.K.A, "consumption," which literally eats the body from the inside out, had been endemic for decades and was responsible for approximately 15 deaths per 1,000 inhabitants per year, or, if you wish, approximately 30 times the annual death rate from SARS-CoV-2. Thus, the more modern concept of slimness being healthy was not plausibly in vogue. Next, the term "fat cats" came to describe wealthy political donors in approximately 1920 or earlier and Pareto's work was first translated into English in 1916. Wesolowski et al. summarize the prevailing attitudes of those times in a footnote, "Ironically, the fat-tailed distribution of wealth inspired Karl Marx’s [49], as well as Benito Mussolini’s economic policies as diametrically opposite and extreme reactions to the same statistics [50]." and attribute the meaning of fat tails as follows, "The statistical form for a power law is the Pareto distribution (PD), which like the Cauchy distribution, has tails so heavy they confer unusual statistical properties and have been given the name fat-tailed distributions. Power laws are scale independent and intrinsically fractal." In that paper, [49] refers to Of Fat Cats and Fat Tails: From the Financial Crisis to the ‘New’ Probabilistic Marxism and [50] refers to Pareto and Fascism Reconsidered by Zanden. That Vilfredo Pareto had Benito Mussolini as his most well known student should be lost on no one.
Differences between heavy tail and fat tail distributions
First there can be left tails and right tails, then long tails and short tails. A short-tailed distribution can be thought of a having a finite range, called its support. And a long tail has semi-infi
Differences between heavy tail and fat tail distributions First there can be left tails and right tails, then long tails and short tails. A short-tailed distribution can be thought of a having a finite range, called its support. And a long tail has semi-infinite support in that direction. For right-tail heaviness one does a comparison of either survival functions (RVs) or complimentary cumulative density functions (1-CDF), typically by examining the logarithm of ratio of two different distributions. In general, heavy tailed means heavier than the exponential distribution, and light tailed means lighter than that. A subset of heavier-tailed distributions are called "fat-tailed." From a historical perspective it is most likely that the concept of a fat tail relates to the type I Pareto distribution, i.e., \begin{equation}\label{eq:PD} \text{PD}(t; \alpha, \beta)= \dfrac{\alpha}{t} \left(\dfrac{\beta}{t}\right) ^{\alpha } \theta(t-\beta)\;, \end{equation} where $\alpha$ is the shape parameter, $\beta$ is a scale parameter and $\theta(\cdot)$ is the unit step function such that $\theta(t-\beta)$ is the unit step function time-delayed by $\beta$, and is used to make a product that is non-zero only when $t> \beta$. From Juran, "The Pareto Principle (Sic, 80-20 rule) gets its name from the Italian-born economist Vilfredo Pareto (1848-1923), who observed that a relative few people held the majority of the wealth (20%) – back in 1895. Pareto developed logarithmic mathematical models to describe this non-uniform distribution of wealth and the mathematician M.O. Lorenz developed graphs to illustrate it." Next, let us consider the attitude toward wealth at that time. Renzaho quotes Grivetti saying "At the turn of the 20th century in North America obesity was admired; wealthy consumers exhibited their wealth around their waist. Fat cheeks and ample stomachs were visual cues that individuals were healthy, not infected with the dreaded slim tuberculosis. Photographs of American executives taken during the late 19th and early 20th centuries reveal that dietary intakes of wealthy gentlemen regularly exceeded calories expended." The history of those times lends considerable weight to those words. From the US 1910 census, tuberculosis, A.K.A, "consumption," which literally eats the body from the inside out, had been endemic for decades and was responsible for approximately 15 deaths per 1,000 inhabitants per year, or, if you wish, approximately 30 times the annual death rate from SARS-CoV-2. Thus, the more modern concept of slimness being healthy was not plausibly in vogue. Next, the term "fat cats" came to describe wealthy political donors in approximately 1920 or earlier and Pareto's work was first translated into English in 1916. Wesolowski et al. summarize the prevailing attitudes of those times in a footnote, "Ironically, the fat-tailed distribution of wealth inspired Karl Marx’s [49], as well as Benito Mussolini’s economic policies as diametrically opposite and extreme reactions to the same statistics [50]." and attribute the meaning of fat tails as follows, "The statistical form for a power law is the Pareto distribution (PD), which like the Cauchy distribution, has tails so heavy they confer unusual statistical properties and have been given the name fat-tailed distributions. Power laws are scale independent and intrinsically fractal." In that paper, [49] refers to Of Fat Cats and Fat Tails: From the Financial Crisis to the ‘New’ Probabilistic Marxism and [50] refers to Pareto and Fascism Reconsidered by Zanden. That Vilfredo Pareto had Benito Mussolini as his most well known student should be lost on no one.
Differences between heavy tail and fat tail distributions First there can be left tails and right tails, then long tails and short tails. A short-tailed distribution can be thought of a having a finite range, called its support. And a long tail has semi-infi
10,079
STL trend of time series using R
I wouldn't bother with stl() for this - the bandwidth for the lowess smoother used to extract the trend is far, far, to small resulting in the small scale fluctuations you see. I would use an additive model. Here is an example using data and model code from Simon Wood's book on GAMs: require(mgcv) require(gamair) data(cairo) cairo2 <- within(cairo, Date <- as.Date(paste(year, month, day.of.month, sep = "-"))) plot(temp ~ Date, data = cairo2, type = "l") Fit a model with trend and seasonal components --- warning this is slow: mod <- gamm(temp ~ s(day.of.year, bs = "cc") + s(time, bs = "cr"), data = cairo2, method = "REML", correlation = corAR1(form = ~ 1 | year), knots = list(day.of.year = c(0, 366))) The fitted model looks like this: > summary(mod$gam) Family: gaussian Link function: identity Formula: temp ~ s(day.of.year, bs = "cc") + s(time, bs = "cr") Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 71.6603 0.1523 470.7 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Approximate significance of smooth terms: edf Ref.df F p-value s(day.of.year) 7.092 7.092 555.407 < 2e-16 *** s(time) 1.383 1.383 7.035 0.00345 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 R-sq.(adj) = 0.848 Scale est. = 16.572 n = 3780 and we can visualise the trend and seasonal terms via plot(mod$gam, pages = 1) and if we want to plot the trend on the observed data we can do that with prediction via: pred <- predict(mod$gam, newdata = cairo2, type = "terms") ptemp <- attr(pred, "constant") + pred[,2] plot(temp ~ Date, data = cairo2, type = "l", xlab = "year", ylab = expression(Temperature ~ (degree*F))) lines(ptemp ~ Date, data = cairo2, col = "red", lwd = 2) Or the same for the actual model: pred2 <- predict(mod$gam, newdata = cairo2) plot(temp ~ Date, data = cairo2, type = "l", xlab = "year", ylab = expression(Temperature ~ (degree*F))) lines(pred2 ~ Date, data = cairo2, col = "red", lwd = 2) This is just an example, and a more in-depth analysis might have to deal with the fact that there are a few missing data, but the above should be a good starting point. As to your point about how to quantify the trend - well that is a problem, because the trend is not linear, neither in your stl() version nor the GAM version I show. If it were, you could give the rate of change (slope). If you want to know by how much has the estimated trend changed over the period of sampling, then we can use the data contained in pred and compute the difference between the start and the end of the series in the trend component only: > tail(pred[,2], 1) - head(pred[,2], 1) 3794 1.756163 so temperatures are, on average, 1.76 degrees warmer than at the start of the record.
STL trend of time series using R
I wouldn't bother with stl() for this - the bandwidth for the lowess smoother used to extract the trend is far, far, to small resulting in the small scale fluctuations you see. I would use an additive
STL trend of time series using R I wouldn't bother with stl() for this - the bandwidth for the lowess smoother used to extract the trend is far, far, to small resulting in the small scale fluctuations you see. I would use an additive model. Here is an example using data and model code from Simon Wood's book on GAMs: require(mgcv) require(gamair) data(cairo) cairo2 <- within(cairo, Date <- as.Date(paste(year, month, day.of.month, sep = "-"))) plot(temp ~ Date, data = cairo2, type = "l") Fit a model with trend and seasonal components --- warning this is slow: mod <- gamm(temp ~ s(day.of.year, bs = "cc") + s(time, bs = "cr"), data = cairo2, method = "REML", correlation = corAR1(form = ~ 1 | year), knots = list(day.of.year = c(0, 366))) The fitted model looks like this: > summary(mod$gam) Family: gaussian Link function: identity Formula: temp ~ s(day.of.year, bs = "cc") + s(time, bs = "cr") Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 71.6603 0.1523 470.7 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Approximate significance of smooth terms: edf Ref.df F p-value s(day.of.year) 7.092 7.092 555.407 < 2e-16 *** s(time) 1.383 1.383 7.035 0.00345 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 R-sq.(adj) = 0.848 Scale est. = 16.572 n = 3780 and we can visualise the trend and seasonal terms via plot(mod$gam, pages = 1) and if we want to plot the trend on the observed data we can do that with prediction via: pred <- predict(mod$gam, newdata = cairo2, type = "terms") ptemp <- attr(pred, "constant") + pred[,2] plot(temp ~ Date, data = cairo2, type = "l", xlab = "year", ylab = expression(Temperature ~ (degree*F))) lines(ptemp ~ Date, data = cairo2, col = "red", lwd = 2) Or the same for the actual model: pred2 <- predict(mod$gam, newdata = cairo2) plot(temp ~ Date, data = cairo2, type = "l", xlab = "year", ylab = expression(Temperature ~ (degree*F))) lines(pred2 ~ Date, data = cairo2, col = "red", lwd = 2) This is just an example, and a more in-depth analysis might have to deal with the fact that there are a few missing data, but the above should be a good starting point. As to your point about how to quantify the trend - well that is a problem, because the trend is not linear, neither in your stl() version nor the GAM version I show. If it were, you could give the rate of change (slope). If you want to know by how much has the estimated trend changed over the period of sampling, then we can use the data contained in pred and compute the difference between the start and the end of the series in the trend component only: > tail(pred[,2], 1) - head(pred[,2], 1) 3794 1.756163 so temperatures are, on average, 1.76 degrees warmer than at the start of the record.
STL trend of time series using R I wouldn't bother with stl() for this - the bandwidth for the lowess smoother used to extract the trend is far, far, to small resulting in the small scale fluctuations you see. I would use an additive
10,080
STL trend of time series using R
Gavin provided a very thorough answer, but for a simpler and faster solution, I recommend setting the stl function t.window parameter to a value that is a multiple of the frequency of the ts data. I would use the inferred periodicity of interest (e.g., a value of 3660 for decadal trends with diurnal resolution data). You may also be interested in the stl2 package described in the author's dissertation. I have applied Gavin's method to my own data and it is very effective too.
STL trend of time series using R
Gavin provided a very thorough answer, but for a simpler and faster solution, I recommend setting the stl function t.window parameter to a value that is a multiple of the frequency of the ts data. I w
STL trend of time series using R Gavin provided a very thorough answer, but for a simpler and faster solution, I recommend setting the stl function t.window parameter to a value that is a multiple of the frequency of the ts data. I would use the inferred periodicity of interest (e.g., a value of 3660 for decadal trends with diurnal resolution data). You may also be interested in the stl2 package described in the author's dissertation. I have applied Gavin's method to my own data and it is very effective too.
STL trend of time series using R Gavin provided a very thorough answer, but for a simpler and faster solution, I recommend setting the stl function t.window parameter to a value that is a multiple of the frequency of the ts data. I w
10,081
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)?
Set $\mathbf w = \phi(\mathbf x)\cdot \mathbf u$ so that $\mathbf w^t \phi(\mathbf x)=\mathbf u^t \cdot \mathbf K$ and $\mathbf w^t\mathbf w = \mathbf u^t\mathbf K\mathbf u$, with $\mathbf K = \phi(\mathbf x)^t\phi(\mathbf x)$, where $\phi(x)$ is a mapping of the original input matrix, $\mathbf x$. This allows one to solve the SVM through the primal formulation. Using your notation for the loss: $$J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{(i)} (\mathbf{u}^t \cdot \mathbf{K}^{(i)} + b)\right)} + \dfrac{1}{2} \mathbf{u}^t \cdot \mathbf{K} \cdot \mathbf{u}$$ $ \mathbf{K}$ is a $m \times m$ matrix, and $\mathbf{u}$ is a $m \times 1$ matrix. Neither is infinite. Indeed, the dual is usually faster to solve, but the primal has it's advantages as well, such as approximate solutions (which are not guaranteed in the dual formulation). Now, why is the dual so much more prominent isn't obvious at all: [1] The historical reasons for which most of the research in the last decade has been about dual optimization are unclear. We believe that it is because SVMs were first introduced in their hard margin formulation [Boser et al., 1992], for which a dual optimization (because of the constraints) seems more natural. In general, however, soft margin SVMs should be preferred, even if the training data are separable: the decision boundary is more robust because more training points are taken into account [Chapelle et al., 2000] Chapelle (2007) argues the time complexity of both primal and dual optimization is $\mathcal{O}\left(nn_{sv} + n_{sv}^3\right)$, worst case being $\mathcal{O}\left(n^3\right)$, but they analyzed quadratic and approximate hinge losses, so not a proper hinge loss, as it's not differentiable to be used with Newton's method. [1] Chapelle, O. (2007). Training a support vector machine in the primal. Neural computation, 19(5), 1155-1178.
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)?
Set $\mathbf w = \phi(\mathbf x)\cdot \mathbf u$ so that $\mathbf w^t \phi(\mathbf x)=\mathbf u^t \cdot \mathbf K$ and $\mathbf w^t\mathbf w = \mathbf u^t\mathbf K\mathbf u$, with $\mathbf K = \phi(\m
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)? Set $\mathbf w = \phi(\mathbf x)\cdot \mathbf u$ so that $\mathbf w^t \phi(\mathbf x)=\mathbf u^t \cdot \mathbf K$ and $\mathbf w^t\mathbf w = \mathbf u^t\mathbf K\mathbf u$, with $\mathbf K = \phi(\mathbf x)^t\phi(\mathbf x)$, where $\phi(x)$ is a mapping of the original input matrix, $\mathbf x$. This allows one to solve the SVM through the primal formulation. Using your notation for the loss: $$J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{(i)} (\mathbf{u}^t \cdot \mathbf{K}^{(i)} + b)\right)} + \dfrac{1}{2} \mathbf{u}^t \cdot \mathbf{K} \cdot \mathbf{u}$$ $ \mathbf{K}$ is a $m \times m$ matrix, and $\mathbf{u}$ is a $m \times 1$ matrix. Neither is infinite. Indeed, the dual is usually faster to solve, but the primal has it's advantages as well, such as approximate solutions (which are not guaranteed in the dual formulation). Now, why is the dual so much more prominent isn't obvious at all: [1] The historical reasons for which most of the research in the last decade has been about dual optimization are unclear. We believe that it is because SVMs were first introduced in their hard margin formulation [Boser et al., 1992], for which a dual optimization (because of the constraints) seems more natural. In general, however, soft margin SVMs should be preferred, even if the training data are separable: the decision boundary is more robust because more training points are taken into account [Chapelle et al., 2000] Chapelle (2007) argues the time complexity of both primal and dual optimization is $\mathcal{O}\left(nn_{sv} + n_{sv}^3\right)$, worst case being $\mathcal{O}\left(n^3\right)$, but they analyzed quadratic and approximate hinge losses, so not a proper hinge loss, as it's not differentiable to be used with Newton's method. [1] Chapelle, O. (2007). Training a support vector machine in the primal. Neural computation, 19(5), 1155-1178.
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)? Set $\mathbf w = \phi(\mathbf x)\cdot \mathbf u$ so that $\mathbf w^t \phi(\mathbf x)=\mathbf u^t \cdot \mathbf K$ and $\mathbf w^t\mathbf w = \mathbf u^t\mathbf K\mathbf u$, with $\mathbf K = \phi(\m
10,082
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)?
If we apply a transformation $\phi$ to all input weight vectors ($\mathbf{x}^{(i)}$), we get the following cost function: $J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{(i)} (\mathbf{w}^t \cdot \phi(\mathbf{x}^{(i)}) + b)\right)} \quad + \quad \dfrac{1}{2} \mathbf{w}^t \cdot \mathbf{w}$ The kernel trick replaces $\phi(\mathbf{u})^t \cdot \phi(\mathbf{v})$ by $K(\mathbf{u}, \mathbf{v})$. Since the weight vector $\mathbf{w}$ is not transformed, the kernel trick cannot be applied to the cost function above. The cost function above corresponds to the primal form of the SVM objective: $\underset{\mathbf{w}, b, \mathbf{\zeta}}\min{C \sum\limits_{i=1}^m{\zeta^{(i)}} + \dfrac{1}{2}\mathbf{w}^t \cdot \mathbf{w}}$ subject to $y^{(i)}(\mathbf{w}^t \cdot \phi(\mathbf{x}^{(i)}) + b) \ge 1 - \zeta^{(i)})$ and $\zeta^{(i)} \ge 0$ for $i=1, \cdots, m$ The dual form is: $\underset{\mathbf{\alpha}}\min{\dfrac{1}{2}\mathbf{\alpha}^t \cdot \mathbf{Q} \cdot \mathbf{\alpha} - \mathbf{1}^t \cdot \mathbf{\alpha}}$ subject to $\mathbf{y}^t \cdot \mathbf{\alpha} = 0$ and $0 \le \alpha_i \le C$ for $i = 1, 2, \cdots, m$ where $\mathbf{1}$ is a vector full of 1s and $\mathbf{Q}$ is an $m \times m$ matrix with elements $Q_{ij} = y^{(i)} y^{(j)} \phi(\mathbf{x}^{(i)})^t \cdot \phi(\mathbf{x}^{(j)})$. Now we can use the kernel trick by computing $Q_{ij}$ like so: $Q_{ij} = y^{(i)} y^{(j)} K(\mathbf{x}^{(i)}, \mathbf{x}^{(j)})$ So the kernel trick can only be used on the dual form of the SVM problem (plus some other algorithms such as logistic regression). Now you can use off-the-shelf Quadratic Programming libraries to solve this problem, or use Lagrangian multipliers to get an unconstrained function (the dual cost function), then search for a minimum using Gradient Descent or any other optimization technique. One of the most efficient approach seems to be the SMO algorithm implemented by the libsvm library (for kernelized SVM).
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)?
If we apply a transformation $\phi$ to all input weight vectors ($\mathbf{x}^{(i)}$), we get the following cost function: $J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)? If we apply a transformation $\phi$ to all input weight vectors ($\mathbf{x}^{(i)}$), we get the following cost function: $J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{(i)} (\mathbf{w}^t \cdot \phi(\mathbf{x}^{(i)}) + b)\right)} \quad + \quad \dfrac{1}{2} \mathbf{w}^t \cdot \mathbf{w}$ The kernel trick replaces $\phi(\mathbf{u})^t \cdot \phi(\mathbf{v})$ by $K(\mathbf{u}, \mathbf{v})$. Since the weight vector $\mathbf{w}$ is not transformed, the kernel trick cannot be applied to the cost function above. The cost function above corresponds to the primal form of the SVM objective: $\underset{\mathbf{w}, b, \mathbf{\zeta}}\min{C \sum\limits_{i=1}^m{\zeta^{(i)}} + \dfrac{1}{2}\mathbf{w}^t \cdot \mathbf{w}}$ subject to $y^{(i)}(\mathbf{w}^t \cdot \phi(\mathbf{x}^{(i)}) + b) \ge 1 - \zeta^{(i)})$ and $\zeta^{(i)} \ge 0$ for $i=1, \cdots, m$ The dual form is: $\underset{\mathbf{\alpha}}\min{\dfrac{1}{2}\mathbf{\alpha}^t \cdot \mathbf{Q} \cdot \mathbf{\alpha} - \mathbf{1}^t \cdot \mathbf{\alpha}}$ subject to $\mathbf{y}^t \cdot \mathbf{\alpha} = 0$ and $0 \le \alpha_i \le C$ for $i = 1, 2, \cdots, m$ where $\mathbf{1}$ is a vector full of 1s and $\mathbf{Q}$ is an $m \times m$ matrix with elements $Q_{ij} = y^{(i)} y^{(j)} \phi(\mathbf{x}^{(i)})^t \cdot \phi(\mathbf{x}^{(j)})$. Now we can use the kernel trick by computing $Q_{ij}$ like so: $Q_{ij} = y^{(i)} y^{(j)} K(\mathbf{x}^{(i)}, \mathbf{x}^{(j)})$ So the kernel trick can only be used on the dual form of the SVM problem (plus some other algorithms such as logistic regression). Now you can use off-the-shelf Quadratic Programming libraries to solve this problem, or use Lagrangian multipliers to get an unconstrained function (the dual cost function), then search for a minimum using Gradient Descent or any other optimization technique. One of the most efficient approach seems to be the SMO algorithm implemented by the libsvm library (for kernelized SVM).
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)? If we apply a transformation $\phi$ to all input weight vectors ($\mathbf{x}^{(i)}$), we get the following cost function: $J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{
10,083
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)?
I might be wrong, but I don't see how we can replace the dot products with kernels without turning it into the dual problem. The kernels map the input implicitly to some feature space where $x$ becomes $\phi(x)$, the loss function then becomes $J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{(i)} (\mathbf{w}^t \cdot \phi(\mathbf{x}^{(i)}) + b)\right)} \quad + \quad \dfrac{1}{2} \mathbf{w}^t \cdot \mathbf{w}$ If Gaussian kernel is applied, $\phi(\mathbf{x}^{(i)})$ will have ifinite dimensions, so will $\mathbf{w}$. It seems difficult to optimize a vector of infinite dimensions using gradient descent directly. Update Firebug's answer gives a way of replacing the dot products with kernels in the primal formulation.
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)?
I might be wrong, but I don't see how we can replace the dot products with kernels without turning it into the dual problem. The kernels map the input implicitly to some feature space where $x$ become
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)? I might be wrong, but I don't see how we can replace the dot products with kernels without turning it into the dual problem. The kernels map the input implicitly to some feature space where $x$ becomes $\phi(x)$, the loss function then becomes $J(\mathbf{w}, b) = C {\displaystyle \sum\limits_{i=1}^{m} max\left(0, 1 - y^{(i)} (\mathbf{w}^t \cdot \phi(\mathbf{x}^{(i)}) + b)\right)} \quad + \quad \dfrac{1}{2} \mathbf{w}^t \cdot \mathbf{w}$ If Gaussian kernel is applied, $\phi(\mathbf{x}^{(i)})$ will have ifinite dimensions, so will $\mathbf{w}$. It seems difficult to optimize a vector of infinite dimensions using gradient descent directly. Update Firebug's answer gives a way of replacing the dot products with kernels in the primal formulation.
Is Gradient Descent possible for kernelized SVMs (if so, why do people use Quadratic Programming)? I might be wrong, but I don't see how we can replace the dot products with kernels without turning it into the dual problem. The kernels map the input implicitly to some feature space where $x$ become
10,084
What is the upside of treating a factor as random in a mixed model?
1. A famous example in psychology and linguistics is described by Herb Clark (1973; following Coleman, 1964): "The language-as-fixed-effect fallacy: A critique of language statistics in psychological research." Clark is a psycholinguist discussing psychological experiments in which a sample of research subjects make responses to a set of stimulus materials, commonly various words drawn from some corpus. He points out that the standard statistical procedure used in these cases, based on repeated-measures ANOVA, and referred to by Clark as $F_1$, treats participants as a random factor but (perhaps implicitly) treats the stimulus materials (or "language") as fixed. This leads to problems in interpreting the results of hypothesis tests on the experimental condition factor: naturally we want to assume that a positive result tells us something about both the population from which we drew our participant sample as well as the theoretical population from which we drew the language materials. But $F_1$, by treating participants as random and stimuli as fixed, only tells us the about the effect of the condition factor across other similar participants responding to the exact same stimuli. Conducting the $F_1$ analysis when both participants and stimuli are more appropriately viewed as random can lead to Type 1 error rates that substantially exceed the nominal $\alpha$ level--usually .05--with the extent depending on factors such as the number and variability of stimuli and the design of the experiment. In these cases, the more appropriate analysis, at least under the classical ANOVA framework, is to use what are called quasi-$F$ statistics based on ratios of linear combinations of mean squares. Clark's paper made a splash in psycholinguistics at the time, but failed to make a big dent in the wider psychological literature. (And even within psycholinguistics the advice of Clark became somewhat distorted over the years, as documented by Raaijmakers, Schrijnemakers, & Gremmen, 1999.) But in more recent years the issue has seen something of a revival, due in large part to statistical advances in mixed-effects models, of which the classical mixed model ANOVA can be seen as a special case. Some of these recent papers include Baayen, Davidson, & Bates (2008), Murayama, Sakaki, Yan, & Smith (2014), and (ahem) Judd, Westfall, & Kenny (2012). I'm sure there are some I'm forgetting. 2. Not exactly. There are methods of getting at whether a factor is better included as a random effect or not in the model at all (see e.g., Pinheiro & Bates, 2000, pp. 83-87; however see Barr, Levy, Scheepers, & Tily, 2013). And of course there are classical model comparison techniques for determining if a factor is better included as a fixed effect or not at all (i.e., $F$-tests). But I think that determining whether a factor is better considered as fixed or random is generally best left as a conceptual question, to be answered by considering the design of the study and the nature of the conclusions to be drawn from it. One of my graduate statistics instructors, Gary McClelland, liked to say that perhaps the fundamental question of statistical inference is: "Compared to what?" Following Gary, I think we can frame the conceptual question that I mentioned above as: What is the reference class of hypothetical experimental results that I want to compare my actual observed results to? Staying in the psycholinguistics context, and considering an experimental design in which we have a sample of Subjects responding to a sample of Words that are classified in one of two Conditions (the particular design discussed at length by Clark, 1973), I will focus on two possibilities: The set of experiments in which, for each experiment, we draw a new sample of Subjects, a new sample of Words, and a new sample of errors from the generative model. Under this model, Subjects and Words are both random effects. The set of experiments in which, for each experiment, we draw a new sample of Subjects, and a new sample of errors, but we always use the same set of Words. Under this model, Subjects are random effects but Words are fixed effects. To make this totally concrete, below are some plots from (above) 4 sets of hypothetical results from 4 simulated experiments under Model 1; (below) 4 sets of hypothetical results from 4 simulated experiments under Model 2. Each experiment views the results in two ways: (left panels) grouped by Subjects, with the Subject-by-Condition means plotted and tied together for each Subject; (right panels) grouped by Words, with box plots summarizing the distribution of responses for each Word. All experiments involve 10 Subjects responding to 10 Words, and in all experiments the "null hypothesis" of no Condition difference is true in the relevant population. Subjects and Words both random: 4 simulated experiments Notice here that in each experiment, the response profiles for the Subjects and Words are totally different. For the Subjects, we sometimes get low overall responders, sometimes high responders, sometimes Subjects that tend to show large Condition differences, and sometimes Subjects that tend to show small Condition difference. Likewise, for the Words, we sometimes get Words that tend to elicit low responses, and sometimes get Words that tend to elicit high responses. Subjects random, Words fixed: 4 simulated experiments Notice here that across the 4 simulated experiments, the Subjects look different every time, but the responses profiles for the Words look basically the same, consistent with the assumption that we are reusing the same set of Words for every experiment under this model. Our choice of whether we think Model 1 (Subjects and Words both random) or Model 2 (Subjects random, Words fixed) provides the appropriate reference class for the experimental results we actually observed can make a big difference to our assessment of whether the Condition manipulation "worked." We expect more chance variation in the data under Model 1 than under Model 2, because there are more "moving parts." So if the conclusions that we wish to draw are more consistent with the assumptions of Model 1, where chance variability is relatively higher, but we analyze our data under the assumptions of Model 2, where chance variability is relatively lower, then our Type 1 error rate for testing the Condition difference is going to be inflated to some (possibly quite large) extent. For more information, see the References below. References Baayen, R. H., Davidson, D. J., & Bates, D. M. (2008). Mixed-effects modeling with crossed random effects for subjects and items. Journal of memory and language, 59(4), 390-412. PDF Barr, D. J., Levy, R., Scheepers, C., & Tily, H. J. (2013). Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of Memory and Language, 68(3), 255-278. PDF Clark, H. H. (1973). The language-as-fixed-effect fallacy: A critique of language statistics in psychological research. Journal of verbal learning and verbal behavior, 12(4), 335-359. PDF Coleman, E. B. (1964). Generalizing to a language population. Psychological Reports, 14(1), 219-226. Judd, C. M., Westfall, J., & Kenny, D. A. (2012). Treating stimuli as a random factor in social psychology: a new and comprehensive solution to a pervasive but largely ignored problem. Journal of personality and social psychology, 103(1), 54. PDF Murayama, K., Sakaki, M., Yan, V. X., & Smith, G. M. (2014). Type I Error Inflation in the Traditional By-Participant Analysis to Metamemory Accuracy: A Generalized Mixed-Effects Model Perspective. Journal of Experimental Psychology: Learning, Memory, and Cognition. PDF Pinheiro, J. C., & Bates, D. M. (2000). Mixed-effects models in S and S-PLUS. Springer. Raaijmakers, J. G., Schrijnemakers, J., & Gremmen, F. (1999). How to deal with “the language-as-fixed-effect fallacy”: Common misconceptions and alternative solutions. Journal of Memory and Language, 41(3), 416-426. PDF
What is the upside of treating a factor as random in a mixed model?
1. A famous example in psychology and linguistics is described by Herb Clark (1973; following Coleman, 1964): "The language-as-fixed-effect fallacy: A critique of language statistics in psychological
What is the upside of treating a factor as random in a mixed model? 1. A famous example in psychology and linguistics is described by Herb Clark (1973; following Coleman, 1964): "The language-as-fixed-effect fallacy: A critique of language statistics in psychological research." Clark is a psycholinguist discussing psychological experiments in which a sample of research subjects make responses to a set of stimulus materials, commonly various words drawn from some corpus. He points out that the standard statistical procedure used in these cases, based on repeated-measures ANOVA, and referred to by Clark as $F_1$, treats participants as a random factor but (perhaps implicitly) treats the stimulus materials (or "language") as fixed. This leads to problems in interpreting the results of hypothesis tests on the experimental condition factor: naturally we want to assume that a positive result tells us something about both the population from which we drew our participant sample as well as the theoretical population from which we drew the language materials. But $F_1$, by treating participants as random and stimuli as fixed, only tells us the about the effect of the condition factor across other similar participants responding to the exact same stimuli. Conducting the $F_1$ analysis when both participants and stimuli are more appropriately viewed as random can lead to Type 1 error rates that substantially exceed the nominal $\alpha$ level--usually .05--with the extent depending on factors such as the number and variability of stimuli and the design of the experiment. In these cases, the more appropriate analysis, at least under the classical ANOVA framework, is to use what are called quasi-$F$ statistics based on ratios of linear combinations of mean squares. Clark's paper made a splash in psycholinguistics at the time, but failed to make a big dent in the wider psychological literature. (And even within psycholinguistics the advice of Clark became somewhat distorted over the years, as documented by Raaijmakers, Schrijnemakers, & Gremmen, 1999.) But in more recent years the issue has seen something of a revival, due in large part to statistical advances in mixed-effects models, of which the classical mixed model ANOVA can be seen as a special case. Some of these recent papers include Baayen, Davidson, & Bates (2008), Murayama, Sakaki, Yan, & Smith (2014), and (ahem) Judd, Westfall, & Kenny (2012). I'm sure there are some I'm forgetting. 2. Not exactly. There are methods of getting at whether a factor is better included as a random effect or not in the model at all (see e.g., Pinheiro & Bates, 2000, pp. 83-87; however see Barr, Levy, Scheepers, & Tily, 2013). And of course there are classical model comparison techniques for determining if a factor is better included as a fixed effect or not at all (i.e., $F$-tests). But I think that determining whether a factor is better considered as fixed or random is generally best left as a conceptual question, to be answered by considering the design of the study and the nature of the conclusions to be drawn from it. One of my graduate statistics instructors, Gary McClelland, liked to say that perhaps the fundamental question of statistical inference is: "Compared to what?" Following Gary, I think we can frame the conceptual question that I mentioned above as: What is the reference class of hypothetical experimental results that I want to compare my actual observed results to? Staying in the psycholinguistics context, and considering an experimental design in which we have a sample of Subjects responding to a sample of Words that are classified in one of two Conditions (the particular design discussed at length by Clark, 1973), I will focus on two possibilities: The set of experiments in which, for each experiment, we draw a new sample of Subjects, a new sample of Words, and a new sample of errors from the generative model. Under this model, Subjects and Words are both random effects. The set of experiments in which, for each experiment, we draw a new sample of Subjects, and a new sample of errors, but we always use the same set of Words. Under this model, Subjects are random effects but Words are fixed effects. To make this totally concrete, below are some plots from (above) 4 sets of hypothetical results from 4 simulated experiments under Model 1; (below) 4 sets of hypothetical results from 4 simulated experiments under Model 2. Each experiment views the results in two ways: (left panels) grouped by Subjects, with the Subject-by-Condition means plotted and tied together for each Subject; (right panels) grouped by Words, with box plots summarizing the distribution of responses for each Word. All experiments involve 10 Subjects responding to 10 Words, and in all experiments the "null hypothesis" of no Condition difference is true in the relevant population. Subjects and Words both random: 4 simulated experiments Notice here that in each experiment, the response profiles for the Subjects and Words are totally different. For the Subjects, we sometimes get low overall responders, sometimes high responders, sometimes Subjects that tend to show large Condition differences, and sometimes Subjects that tend to show small Condition difference. Likewise, for the Words, we sometimes get Words that tend to elicit low responses, and sometimes get Words that tend to elicit high responses. Subjects random, Words fixed: 4 simulated experiments Notice here that across the 4 simulated experiments, the Subjects look different every time, but the responses profiles for the Words look basically the same, consistent with the assumption that we are reusing the same set of Words for every experiment under this model. Our choice of whether we think Model 1 (Subjects and Words both random) or Model 2 (Subjects random, Words fixed) provides the appropriate reference class for the experimental results we actually observed can make a big difference to our assessment of whether the Condition manipulation "worked." We expect more chance variation in the data under Model 1 than under Model 2, because there are more "moving parts." So if the conclusions that we wish to draw are more consistent with the assumptions of Model 1, where chance variability is relatively higher, but we analyze our data under the assumptions of Model 2, where chance variability is relatively lower, then our Type 1 error rate for testing the Condition difference is going to be inflated to some (possibly quite large) extent. For more information, see the References below. References Baayen, R. H., Davidson, D. J., & Bates, D. M. (2008). Mixed-effects modeling with crossed random effects for subjects and items. Journal of memory and language, 59(4), 390-412. PDF Barr, D. J., Levy, R., Scheepers, C., & Tily, H. J. (2013). Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of Memory and Language, 68(3), 255-278. PDF Clark, H. H. (1973). The language-as-fixed-effect fallacy: A critique of language statistics in psychological research. Journal of verbal learning and verbal behavior, 12(4), 335-359. PDF Coleman, E. B. (1964). Generalizing to a language population. Psychological Reports, 14(1), 219-226. Judd, C. M., Westfall, J., & Kenny, D. A. (2012). Treating stimuli as a random factor in social psychology: a new and comprehensive solution to a pervasive but largely ignored problem. Journal of personality and social psychology, 103(1), 54. PDF Murayama, K., Sakaki, M., Yan, V. X., & Smith, G. M. (2014). Type I Error Inflation in the Traditional By-Participant Analysis to Metamemory Accuracy: A Generalized Mixed-Effects Model Perspective. Journal of Experimental Psychology: Learning, Memory, and Cognition. PDF Pinheiro, J. C., & Bates, D. M. (2000). Mixed-effects models in S and S-PLUS. Springer. Raaijmakers, J. G., Schrijnemakers, J., & Gremmen, F. (1999). How to deal with “the language-as-fixed-effect fallacy”: Common misconceptions and alternative solutions. Journal of Memory and Language, 41(3), 416-426. PDF
What is the upside of treating a factor as random in a mixed model? 1. A famous example in psychology and linguistics is described by Herb Clark (1973; following Coleman, 1964): "The language-as-fixed-effect fallacy: A critique of language statistics in psychological
10,085
What is the upside of treating a factor as random in a mixed model?
Suppose I have a manufacturing process that involves making material on several different machines. They're the only machines I have so "machine" is a fixed effect. But I make many lots of material on each machine and I am interested in predicting things about future lots. I'll make "Lot number" a random factor because I'm interested in the results that I'll get for future lots.
What is the upside of treating a factor as random in a mixed model?
Suppose I have a manufacturing process that involves making material on several different machines. They're the only machines I have so "machine" is a fixed effect. But I make many lots of material
What is the upside of treating a factor as random in a mixed model? Suppose I have a manufacturing process that involves making material on several different machines. They're the only machines I have so "machine" is a fixed effect. But I make many lots of material on each machine and I am interested in predicting things about future lots. I'll make "Lot number" a random factor because I'm interested in the results that I'll get for future lots.
What is the upside of treating a factor as random in a mixed model? Suppose I have a manufacturing process that involves making material on several different machines. They're the only machines I have so "machine" is a fixed effect. But I make many lots of material
10,086
What is the upside of treating a factor as random in a mixed model?
So you treat them as random so that there is an averaging effect between the overall average and the average for that particular factor based on the sample size of the factor and the overall number of observations. This allows you to say that your results apply to the population at large, since you have a type of weighted average and an estimate of the variation due to that factor, if not, you really can only say that your results apply to the factor levels you used since the regression will treat them as discrete factors and not random ones that get the weighted averaging. They are also useful when you have repeated measures on the same subject, since you can use them to account for the correlation between measures on the same subject.
What is the upside of treating a factor as random in a mixed model?
So you treat them as random so that there is an averaging effect between the overall average and the average for that particular factor based on the sample size of the factor and the overall number of
What is the upside of treating a factor as random in a mixed model? So you treat them as random so that there is an averaging effect between the overall average and the average for that particular factor based on the sample size of the factor and the overall number of observations. This allows you to say that your results apply to the population at large, since you have a type of weighted average and an estimate of the variation due to that factor, if not, you really can only say that your results apply to the factor levels you used since the regression will treat them as discrete factors and not random ones that get the weighted averaging. They are also useful when you have repeated measures on the same subject, since you can use them to account for the correlation between measures on the same subject.
What is the upside of treating a factor as random in a mixed model? So you treat them as random so that there is an averaging effect between the overall average and the average for that particular factor based on the sample size of the factor and the overall number of
10,087
What is the upside of treating a factor as random in a mixed model?
When we have a grouping structure to our data $ Y_{ij} = \beta_1 X_{ij} + \beta_2 Z_{i} + e_{i} + \mu_{ij}$ where $X_{ij}$ are the observables of our individual observations and $Z_{i}$ are observations invariant among them and only observed at the grouping level, we cannot use fixed effects if we want to estimate $\beta_2$, since if we use the within estimator, $Z_{i}$ drops out, and if we use dummy variables for each $i$, $Z_{i}$ is collinear with them. So if we use a fixed effects estimator in this situation, we are ignoring potentially important information. Even in the case $ Y_{ij} = \beta_1 X_{ij} + e_{i} + \mu_{ij}$ where we do not have any $Z_{i}$, we may still want to use random effects for a few reasons, despite the problems that may come with them, some of which are listed in your question. In these kind of settings, random variation has two (or more if there are multiple grouping levels) sources of variation - variation "within" a group and variation "between" groups. The fixed effects (or "within") estimator completely removes variation between groups in estimating $\beta_1$. The random/mixed effects estimator allows "between" variation to contribute to the estimate of $\beta_1$, theoretically resulting in smaller standard errors. (Original Answer) One place where you are essentially required to use random effects is when you want to include parameters that are invariant at the grouping level of the fixed effect. For example, say you want to investigate the impact of doctor characteristics (eg/ education) on patient outcomes. The dataset is patient-level with observed patient outcomes and patient /doctor characteristics. Since patients treated under a single doctor are likely correlated, you want to control for this. You could insert a doctor fixed effect here but in doing so, you preclude including any of the doctor characteristics in the model. Which is problematic if the interest is in doctor-level characteristics.
What is the upside of treating a factor as random in a mixed model?
When we have a grouping structure to our data $ Y_{ij} = \beta_1 X_{ij} + \beta_2 Z_{i} + e_{i} + \mu_{ij}$ where $X_{ij}$ are the observables of our individual observations and $Z_{i}$ are observatio
What is the upside of treating a factor as random in a mixed model? When we have a grouping structure to our data $ Y_{ij} = \beta_1 X_{ij} + \beta_2 Z_{i} + e_{i} + \mu_{ij}$ where $X_{ij}$ are the observables of our individual observations and $Z_{i}$ are observations invariant among them and only observed at the grouping level, we cannot use fixed effects if we want to estimate $\beta_2$, since if we use the within estimator, $Z_{i}$ drops out, and if we use dummy variables for each $i$, $Z_{i}$ is collinear with them. So if we use a fixed effects estimator in this situation, we are ignoring potentially important information. Even in the case $ Y_{ij} = \beta_1 X_{ij} + e_{i} + \mu_{ij}$ where we do not have any $Z_{i}$, we may still want to use random effects for a few reasons, despite the problems that may come with them, some of which are listed in your question. In these kind of settings, random variation has two (or more if there are multiple grouping levels) sources of variation - variation "within" a group and variation "between" groups. The fixed effects (or "within") estimator completely removes variation between groups in estimating $\beta_1$. The random/mixed effects estimator allows "between" variation to contribute to the estimate of $\beta_1$, theoretically resulting in smaller standard errors. (Original Answer) One place where you are essentially required to use random effects is when you want to include parameters that are invariant at the grouping level of the fixed effect. For example, say you want to investigate the impact of doctor characteristics (eg/ education) on patient outcomes. The dataset is patient-level with observed patient outcomes and patient /doctor characteristics. Since patients treated under a single doctor are likely correlated, you want to control for this. You could insert a doctor fixed effect here but in doing so, you preclude including any of the doctor characteristics in the model. Which is problematic if the interest is in doctor-level characteristics.
What is the upside of treating a factor as random in a mixed model? When we have a grouping structure to our data $ Y_{ij} = \beta_1 X_{ij} + \beta_2 Z_{i} + e_{i} + \mu_{ij}$ where $X_{ij}$ are the observables of our individual observations and $Z_{i}$ are observatio
10,088
What is the upside of treating a factor as random in a mixed model?
I think it's related to consistency of the estimates. Let's say $x_{ij} = a_i+b_j+e$ where $a_i$ stands for fixed effect(some experimental condition) and $b_j$ stands for random effect(may person). Neyman and Scott(1948) points out the problem of consistency of Maximum Likelihood Estimates of $a_i$ and $b_j$. If we take $a_i$ and $b_j$ as both fixed effect, the estimates are no longer consistent. At least, that's how I understood...
What is the upside of treating a factor as random in a mixed model?
I think it's related to consistency of the estimates. Let's say $x_{ij} = a_i+b_j+e$ where $a_i$ stands for fixed effect(some experimental condition) and $b_j$ stands for random effect(may person). Ne
What is the upside of treating a factor as random in a mixed model? I think it's related to consistency of the estimates. Let's say $x_{ij} = a_i+b_j+e$ where $a_i$ stands for fixed effect(some experimental condition) and $b_j$ stands for random effect(may person). Neyman and Scott(1948) points out the problem of consistency of Maximum Likelihood Estimates of $a_i$ and $b_j$. If we take $a_i$ and $b_j$ as both fixed effect, the estimates are no longer consistent. At least, that's how I understood...
What is the upside of treating a factor as random in a mixed model? I think it's related to consistency of the estimates. Let's say $x_{ij} = a_i+b_j+e$ where $a_i$ stands for fixed effect(some experimental condition) and $b_j$ stands for random effect(may person). Ne
10,089
Post hoc test after ANOVA with repeated measures using R
What you could do is specify the model with lme and then use glht from the multcomp package to do what you want. However, lme gives slightly different F-values than a standard ANOVA (see also my recent questions here). lme_velocity = lme(Velocity ~ Material, data=scrd, random = ~1|Subject) anova(lme_velocity) require(multcomp) summary(glht(lme_velocity, linfct=mcp(Material = "Tukey")), test = adjusted(type = "bonferroni")) For other contrasts then bonferroni, see e.g., the book on multcomp from the authors of the package. You may also want to see this post on the R-mailing list, and this blog post for specifying a repeated measures ANOVA in R. However, as shown in this question from me I am not sure if this approachs is identical to an ANOVA. Furthermore, glht only reports z-values instead of the usual t or F values. This seems to be uncommon, too. So far, I haven't encountered another way of doing this.
Post hoc test after ANOVA with repeated measures using R
What you could do is specify the model with lme and then use glht from the multcomp package to do what you want. However, lme gives slightly different F-values than a standard ANOVA (see also my recen
Post hoc test after ANOVA with repeated measures using R What you could do is specify the model with lme and then use glht from the multcomp package to do what you want. However, lme gives slightly different F-values than a standard ANOVA (see also my recent questions here). lme_velocity = lme(Velocity ~ Material, data=scrd, random = ~1|Subject) anova(lme_velocity) require(multcomp) summary(glht(lme_velocity, linfct=mcp(Material = "Tukey")), test = adjusted(type = "bonferroni")) For other contrasts then bonferroni, see e.g., the book on multcomp from the authors of the package. You may also want to see this post on the R-mailing list, and this blog post for specifying a repeated measures ANOVA in R. However, as shown in this question from me I am not sure if this approachs is identical to an ANOVA. Furthermore, glht only reports z-values instead of the usual t or F values. This seems to be uncommon, too. So far, I haven't encountered another way of doing this.
Post hoc test after ANOVA with repeated measures using R What you could do is specify the model with lme and then use glht from the multcomp package to do what you want. However, lme gives slightly different F-values than a standard ANOVA (see also my recen
10,090
Post hoc test after ANOVA with repeated measures using R
If you want to stick with the aov() function you can use the emmeans package which can handle aovlist (and many other) objects. library("emmeans") # set orthogonal contrasts options(contrasts = c("contr.sum", "contr.poly")) aov_velocity <- aov(Velocity ~ Material + Error(Subject / Material), data = scrd) After creating an emmGrid object as follows emm <- emmeans(aov_velocity, ~ Material) it is very easy to get all (post hoc) pairwise comparisons using the pairs() function or any desired contrast using the contrast() function of the emmeans package. Multiple-testing adjustments can be achieved via the adjust argument of these functions: pairs(emm) # adjust argument not specified -> default p-value adjustment in this case is "tukey" For more information on this I found the detailed emmeans vignettes and the documentation to be very helpful. Also, you can find a complete (reproducible) example including a description on how to get the correct contrast weights in my answer here. Note, however, that using a univariate model for the post hoc tests can result in anti-conservative p-values if sphericity is violated.
Post hoc test after ANOVA with repeated measures using R
If you want to stick with the aov() function you can use the emmeans package which can handle aovlist (and many other) objects. library("emmeans") # set orthogonal contrasts options(contrasts = c("c
Post hoc test after ANOVA with repeated measures using R If you want to stick with the aov() function you can use the emmeans package which can handle aovlist (and many other) objects. library("emmeans") # set orthogonal contrasts options(contrasts = c("contr.sum", "contr.poly")) aov_velocity <- aov(Velocity ~ Material + Error(Subject / Material), data = scrd) After creating an emmGrid object as follows emm <- emmeans(aov_velocity, ~ Material) it is very easy to get all (post hoc) pairwise comparisons using the pairs() function or any desired contrast using the contrast() function of the emmeans package. Multiple-testing adjustments can be achieved via the adjust argument of these functions: pairs(emm) # adjust argument not specified -> default p-value adjustment in this case is "tukey" For more information on this I found the detailed emmeans vignettes and the documentation to be very helpful. Also, you can find a complete (reproducible) example including a description on how to get the correct contrast weights in my answer here. Note, however, that using a univariate model for the post hoc tests can result in anti-conservative p-values if sphericity is violated.
Post hoc test after ANOVA with repeated measures using R If you want to stick with the aov() function you can use the emmeans package which can handle aovlist (and many other) objects. library("emmeans") # set orthogonal contrasts options(contrasts = c("c
10,091
Post hoc test after ANOVA with repeated measures using R
If sphericity is met then you can run a two-way ANOVA: aov_velocity = aov(Velocity~Material+Subject, data=scrd) posthoc = TukeyHSD(aov_velocity, 'Material', conf.level=0.95).
Post hoc test after ANOVA with repeated measures using R
If sphericity is met then you can run a two-way ANOVA: aov_velocity = aov(Velocity~Material+Subject, data=scrd) posthoc = TukeyHSD(aov_velocity, 'Material', conf.level=0.95).
Post hoc test after ANOVA with repeated measures using R If sphericity is met then you can run a two-way ANOVA: aov_velocity = aov(Velocity~Material+Subject, data=scrd) posthoc = TukeyHSD(aov_velocity, 'Material', conf.level=0.95).
Post hoc test after ANOVA with repeated measures using R If sphericity is met then you can run a two-way ANOVA: aov_velocity = aov(Velocity~Material+Subject, data=scrd) posthoc = TukeyHSD(aov_velocity, 'Material', conf.level=0.95).
10,092
interpreting y axis of a partial dependence plots
Each point on the partial dependence plot is the average vote percentage in favor of the "Yes trees" class across all observations, given a fixed level of TRI. It's not a probability of correct classification. It has absolutely nothing to do with accuracy, true negatives, and true positives. When you see the phrase Values greater than TRI 30 begin to have a positive influence for classification in your model is an puffed-up way of saying Values greater than TRI 30 begin to predict "Yes trees" more strongly than values lower than TRI 30
interpreting y axis of a partial dependence plots
Each point on the partial dependence plot is the average vote percentage in favor of the "Yes trees" class across all observations, given a fixed level of TRI. It's not a probability of correct classi
interpreting y axis of a partial dependence plots Each point on the partial dependence plot is the average vote percentage in favor of the "Yes trees" class across all observations, given a fixed level of TRI. It's not a probability of correct classification. It has absolutely nothing to do with accuracy, true negatives, and true positives. When you see the phrase Values greater than TRI 30 begin to have a positive influence for classification in your model is an puffed-up way of saying Values greater than TRI 30 begin to predict "Yes trees" more strongly than values lower than TRI 30
interpreting y axis of a partial dependence plots Each point on the partial dependence plot is the average vote percentage in favor of the "Yes trees" class across all observations, given a fixed level of TRI. It's not a probability of correct classi
10,093
interpreting y axis of a partial dependence plots
The partial dependence function basically gives you the "average" trend of that variable (integrating out all others in the model). It's the shape of that trend that is "important". You may interpret the relative range of these plots from different predictor variables, but not the absolute range. Hope that helps.
interpreting y axis of a partial dependence plots
The partial dependence function basically gives you the "average" trend of that variable (integrating out all others in the model). It's the shape of that trend that is "important". You may interp
interpreting y axis of a partial dependence plots The partial dependence function basically gives you the "average" trend of that variable (integrating out all others in the model). It's the shape of that trend that is "important". You may interpret the relative range of these plots from different predictor variables, but not the absolute range. Hope that helps.
interpreting y axis of a partial dependence plots The partial dependence function basically gives you the "average" trend of that variable (integrating out all others in the model). It's the shape of that trend that is "important". You may interp
10,094
interpreting y axis of a partial dependence plots
A way to look at y axis values is that they are relative to each other in the other plots. When that number is higher than in the other plots in absolute values, it means it is more important cause the impact of that variable on the output is larger. If you are interested in the math behind partial dependence plots and how that number is estimates, you can find it here: http://statweb.stanford.edu/~jhf/ftp/RuleFit.pdf section 8.1
interpreting y axis of a partial dependence plots
A way to look at y axis values is that they are relative to each other in the other plots. When that number is higher than in the other plots in absolute values, it means it is more important cause th
interpreting y axis of a partial dependence plots A way to look at y axis values is that they are relative to each other in the other plots. When that number is higher than in the other plots in absolute values, it means it is more important cause the impact of that variable on the output is larger. If you are interested in the math behind partial dependence plots and how that number is estimates, you can find it here: http://statweb.stanford.edu/~jhf/ftp/RuleFit.pdf section 8.1
interpreting y axis of a partial dependence plots A way to look at y axis values is that they are relative to each other in the other plots. When that number is higher than in the other plots in absolute values, it means it is more important cause th
10,095
Full information maximum likelihood for missing data in R
Credit of this answer goes to @Joshua who gave an awesome answer when I posted this question to the R and Statistics community on Google+. I am simply pasting his answer below. For running regression (without latent variable modeling), please read my notes typed after the quoted text. Handling missing data with Maximum Likelihood on all available data (so-called FIML) is a very useful technique. However, there are a number of complications that make it challenging to implement in a general way. Consider a simple linear regression model, predicting some continuous outcome from say age, sex, and occupation type. In OLS, you do not worry about the distribution of age, sex, and occupation, only the outcome. Typically for categorical predictors, they are dummy coded (0/1). To use ML, distributional assumptions are required for all variables with missingness. By far the easiest approach is multivariate normal (MVN). This is what for example Mplus will do by default if you do not go out for your way to declare the type of variable (e.g., categorical). In the simple example I gave, you would probably want to assume, normal for age, Bernoulli for sex, and multinomal for job type. The latter is tricky because what you actually have are several binary variables, but you do not want to treat them as Bernoulli. This means you do not want to work with the dummy coded variables, you need to work with the actual categorical variable so the ML estimators can properly use a multinomial, but this in turn means that the dummy coding process needs to be built into the model, not the data. Again complicating life. Further, the joint distribution of continuous and categorical variables is nontrivial to compute (when I run into problems like this in Mplus, it pretty quickly starts to break down and struggle). Finally, you really ideally specify the missing data mechanism. In SEM style, FIML, all variables are essentially conditioned on all others, but this is not necessarily correct. For example, perhaps age is missing as a function not of gender and occupation type, but their interaction. The interaction may not be important for the focal outcome, but if it is important for missingness on age, then it must also be in the model, not necessarily the substantive model of interest but the missing data model. lavaan will use ML for MVN, but presently I believe the categorical data options are limited (again coming from the SEM field, this is standard). Multiple imputation seems less elegant at first because it makes explicit many hidden assumptions behind FIML (like distributional assumptions for every variable and the predictive model assumed for missingness on every variable). However, it gives you a lot of control and explicitly thinking about the distribution of each variable, and the optimal missing data mechanism for each is valuable. I am becoming more and more convinced that Bayesian models are the way to handle missing data. The reason is that they are very flexible at including distributions for each variable, allowing many different types of distributions, and can easily incorporate the variability introduced by missing data on predictors, into the overall model estimates (which is the trick with multiple imputation where you then have to somehow combine results). Of course, these methods are not the easiest and can take a lot of training and time to use. So that doesn't really answer your question, but explains a bit of why completely general frameworks for dealing with missingness are tricky. In my semutils package for the covariance matrices, I use lavaan underneath to use ML. I do that because I assume for a variance covariance matrix that you are using continuous variables anyway so that I assume my users are already assuming MVN for their data. This means that if all variables with missingness are continuous, lavaan, a structural equation modelling (SEM) package is a nice one to use for FIML in R. Now going back to my initial question. My intention was to have a magic fix for missingness when running linear regression. All my variables with missing were nice and continuous. So I proceeded to run my analyses in two styles: The usual way with multiple imputation In SEM style with lavaan using FIML. I was missing a lot of things by doing regression in SEM style. Both styles gave similar coefficients and R squares, but in SEM style I didn't get the significance testing of the regression (the typical F values with df), instead I got fit indices that were not helpful as I had used up all my degrees of freedom. Also when one model had a larger R2 than another, I couldn’t find a way to compare whether the difference was significant. Additionally, doing regression the usual way gives access to a bunch of testing for regression assumptions that are invaluable. For a more detailed answer on this issue see my other question that was nicely answered by @StasK. So the conclusion seems to be that lavaan is a decent package for FIML in R, yet the use of FIML depends on statistical assumptions and the type of analysis one is conducting. As far as regression (without latent variable modeling) goes, keeping it out of SEM programs and using multiple imputation is probably a wise move.
Full information maximum likelihood for missing data in R
Credit of this answer goes to @Joshua who gave an awesome answer when I posted this question to the R and Statistics community on Google+. I am simply pasting his answer below. For running regressi
Full information maximum likelihood for missing data in R Credit of this answer goes to @Joshua who gave an awesome answer when I posted this question to the R and Statistics community on Google+. I am simply pasting his answer below. For running regression (without latent variable modeling), please read my notes typed after the quoted text. Handling missing data with Maximum Likelihood on all available data (so-called FIML) is a very useful technique. However, there are a number of complications that make it challenging to implement in a general way. Consider a simple linear regression model, predicting some continuous outcome from say age, sex, and occupation type. In OLS, you do not worry about the distribution of age, sex, and occupation, only the outcome. Typically for categorical predictors, they are dummy coded (0/1). To use ML, distributional assumptions are required for all variables with missingness. By far the easiest approach is multivariate normal (MVN). This is what for example Mplus will do by default if you do not go out for your way to declare the type of variable (e.g., categorical). In the simple example I gave, you would probably want to assume, normal for age, Bernoulli for sex, and multinomal for job type. The latter is tricky because what you actually have are several binary variables, but you do not want to treat them as Bernoulli. This means you do not want to work with the dummy coded variables, you need to work with the actual categorical variable so the ML estimators can properly use a multinomial, but this in turn means that the dummy coding process needs to be built into the model, not the data. Again complicating life. Further, the joint distribution of continuous and categorical variables is nontrivial to compute (when I run into problems like this in Mplus, it pretty quickly starts to break down and struggle). Finally, you really ideally specify the missing data mechanism. In SEM style, FIML, all variables are essentially conditioned on all others, but this is not necessarily correct. For example, perhaps age is missing as a function not of gender and occupation type, but their interaction. The interaction may not be important for the focal outcome, but if it is important for missingness on age, then it must also be in the model, not necessarily the substantive model of interest but the missing data model. lavaan will use ML for MVN, but presently I believe the categorical data options are limited (again coming from the SEM field, this is standard). Multiple imputation seems less elegant at first because it makes explicit many hidden assumptions behind FIML (like distributional assumptions for every variable and the predictive model assumed for missingness on every variable). However, it gives you a lot of control and explicitly thinking about the distribution of each variable, and the optimal missing data mechanism for each is valuable. I am becoming more and more convinced that Bayesian models are the way to handle missing data. The reason is that they are very flexible at including distributions for each variable, allowing many different types of distributions, and can easily incorporate the variability introduced by missing data on predictors, into the overall model estimates (which is the trick with multiple imputation where you then have to somehow combine results). Of course, these methods are not the easiest and can take a lot of training and time to use. So that doesn't really answer your question, but explains a bit of why completely general frameworks for dealing with missingness are tricky. In my semutils package for the covariance matrices, I use lavaan underneath to use ML. I do that because I assume for a variance covariance matrix that you are using continuous variables anyway so that I assume my users are already assuming MVN for their data. This means that if all variables with missingness are continuous, lavaan, a structural equation modelling (SEM) package is a nice one to use for FIML in R. Now going back to my initial question. My intention was to have a magic fix for missingness when running linear regression. All my variables with missing were nice and continuous. So I proceeded to run my analyses in two styles: The usual way with multiple imputation In SEM style with lavaan using FIML. I was missing a lot of things by doing regression in SEM style. Both styles gave similar coefficients and R squares, but in SEM style I didn't get the significance testing of the regression (the typical F values with df), instead I got fit indices that were not helpful as I had used up all my degrees of freedom. Also when one model had a larger R2 than another, I couldn’t find a way to compare whether the difference was significant. Additionally, doing regression the usual way gives access to a bunch of testing for regression assumptions that are invaluable. For a more detailed answer on this issue see my other question that was nicely answered by @StasK. So the conclusion seems to be that lavaan is a decent package for FIML in R, yet the use of FIML depends on statistical assumptions and the type of analysis one is conducting. As far as regression (without latent variable modeling) goes, keeping it out of SEM programs and using multiple imputation is probably a wise move.
Full information maximum likelihood for missing data in R Credit of this answer goes to @Joshua who gave an awesome answer when I posted this question to the R and Statistics community on Google+. I am simply pasting his answer below. For running regressi
10,096
Full information maximum likelihood for missing data in R
there is 2 main ways of handling missing data/records. U either delete the entire row of observation that has a missing value, or you find a way to generate this missing value. If u take the first approach, then you might end up losing a lot of data. In the second approach, you have to find a "clever" way to generate this missing data, in such a way that the parameters estimates of the the new data set, is not much different from the paramaters estimates of the observed data set. This second approach is called Data imputation, and there are several R packages that do that. One of them is called mclust, and the function you need is called imputeData. This function using the EM (expectation maximization) algorithm to estimate the parameters of the unobserved part of the data set, given the observed part. Once the parameters are found, the new data point are generated. The distribution assumption of the missing data, the observed data, and the entire data set is assumed to be Gaussian. Hope this explanation helps u achieve what you are trying to do
Full information maximum likelihood for missing data in R
there is 2 main ways of handling missing data/records. U either delete the entire row of observation that has a missing value, or you find a way to generate this missing value. If u take the first app
Full information maximum likelihood for missing data in R there is 2 main ways of handling missing data/records. U either delete the entire row of observation that has a missing value, or you find a way to generate this missing value. If u take the first approach, then you might end up losing a lot of data. In the second approach, you have to find a "clever" way to generate this missing data, in such a way that the parameters estimates of the the new data set, is not much different from the paramaters estimates of the observed data set. This second approach is called Data imputation, and there are several R packages that do that. One of them is called mclust, and the function you need is called imputeData. This function using the EM (expectation maximization) algorithm to estimate the parameters of the unobserved part of the data set, given the observed part. Once the parameters are found, the new data point are generated. The distribution assumption of the missing data, the observed data, and the entire data set is assumed to be Gaussian. Hope this explanation helps u achieve what you are trying to do
Full information maximum likelihood for missing data in R there is 2 main ways of handling missing data/records. U either delete the entire row of observation that has a missing value, or you find a way to generate this missing value. If u take the first app
10,097
Why there are two different logistic loss formulation / notations?
The short version Yes Yes The long version The nice thing about mathematical modeling is that it's flexible. These are indeed equivalent loss functions, but they derive from very different underlying models of the data. Formula 1 The first notation derives from a Bernoulli probability model for $y$, which is conventionally defined on $\{0, 1\}$. In this model, the outcome/label/class/prediction is represented by a random variable $Y$ that follows a $\mathrm{Bernoulli}(p)$ distribution. Therefore its likelihood is: $$ P(Y = y\ |\ p) = \mathcal L(p; y) = p^y\ (1-p)^{1-y} = \begin{cases}1-p &y=0 \\ p &y=1 \end{cases} $$ for $p\in[0, 1]$. Using 0 and 1 as the indicator values lets us reduce the piecewise function on the far right to a concise expression. As you've pointed out, you can then link $Y$ to a matrix of input data $x$ by letting $\operatorname{logit} p = \beta^T x$. From here, straightforward algebraic manipulation reveals that $\log \mathcal L(p;y)$ is the same as the first $L(y, \beta^Tx)$ in your question (hint: $(y - 1) = - (1 - y)$). So minimizing log-loss over $\{0, 1\}$ is equivalent to maximum likelihood estimation of a Bernoulli model. This formulation is also a special case of the generalized linear model, which is formulated as $Y \sim D(\theta),\ g(Y) = \beta^T x$ for an invertible, differentiable function $g$ and a distribution $D$ in the exponential family. Formula 2 Actually.. I'm not familiar with Formula 2. However, defining $y$ on $\{-1, 1\}$ is standard in the formulation of a support vector machine. Fitting an SVM corresponds to maximizing $$ \max \left(\{0, 1 - y \beta^T x \}\right) + \lambda \|\beta\|^2. $$ This is the Lagrangian form of a constrained optimization problem. It is also an example of a regularized optimization problem with objective function $$ \ell(y, \beta) + \lambda \|\beta\|^2 $$ For some loss function $\ell$ and a scalar hyperparameter $\lambda$ that controls the amount of regularization (also called "shrinkage") applied to $\beta$. Hinge loss is just one of several drop-in possibilities for $\ell$, which also include the second $L(y, \beta^Tx)$ in your question.
Why there are two different logistic loss formulation / notations?
The short version Yes Yes The long version The nice thing about mathematical modeling is that it's flexible. These are indeed equivalent loss functions, but they derive from very different underlyin
Why there are two different logistic loss formulation / notations? The short version Yes Yes The long version The nice thing about mathematical modeling is that it's flexible. These are indeed equivalent loss functions, but they derive from very different underlying models of the data. Formula 1 The first notation derives from a Bernoulli probability model for $y$, which is conventionally defined on $\{0, 1\}$. In this model, the outcome/label/class/prediction is represented by a random variable $Y$ that follows a $\mathrm{Bernoulli}(p)$ distribution. Therefore its likelihood is: $$ P(Y = y\ |\ p) = \mathcal L(p; y) = p^y\ (1-p)^{1-y} = \begin{cases}1-p &y=0 \\ p &y=1 \end{cases} $$ for $p\in[0, 1]$. Using 0 and 1 as the indicator values lets us reduce the piecewise function on the far right to a concise expression. As you've pointed out, you can then link $Y$ to a matrix of input data $x$ by letting $\operatorname{logit} p = \beta^T x$. From here, straightforward algebraic manipulation reveals that $\log \mathcal L(p;y)$ is the same as the first $L(y, \beta^Tx)$ in your question (hint: $(y - 1) = - (1 - y)$). So minimizing log-loss over $\{0, 1\}$ is equivalent to maximum likelihood estimation of a Bernoulli model. This formulation is also a special case of the generalized linear model, which is formulated as $Y \sim D(\theta),\ g(Y) = \beta^T x$ for an invertible, differentiable function $g$ and a distribution $D$ in the exponential family. Formula 2 Actually.. I'm not familiar with Formula 2. However, defining $y$ on $\{-1, 1\}$ is standard in the formulation of a support vector machine. Fitting an SVM corresponds to maximizing $$ \max \left(\{0, 1 - y \beta^T x \}\right) + \lambda \|\beta\|^2. $$ This is the Lagrangian form of a constrained optimization problem. It is also an example of a regularized optimization problem with objective function $$ \ell(y, \beta) + \lambda \|\beta\|^2 $$ For some loss function $\ell$ and a scalar hyperparameter $\lambda$ that controls the amount of regularization (also called "shrinkage") applied to $\beta$. Hinge loss is just one of several drop-in possibilities for $\ell$, which also include the second $L(y, \beta^Tx)$ in your question.
Why there are two different logistic loss formulation / notations? The short version Yes Yes The long version The nice thing about mathematical modeling is that it's flexible. These are indeed equivalent loss functions, but they derive from very different underlyin
10,098
Why there are two different logistic loss formulation / notations?
I think @ssdecontrol had a very good answer. I just want to add some comments for the formula 2 for my own question. $$ L(y,\hat y)=\log(1+\exp{(-y\cdot \hat y})) $$ The reason people like this formulation is that it is very concise, and it removes the "probability interpretation details". The tricky notation is the $\hat y$, note, $y$ is a binary variable, but $\hat y$ here is a real number. Comparing to formulation 1, we need two additional steps to make it to discrete label, step 1. sigmod function step 2. apply 0.5 threshold. But without these details are good in terms of we can easily compare it with other classification loss, such as 01 loss or hinge loss. $$ L_{01}(y,\hat y)=I[y \cdot \hat y >0]\\ L_{\text{hinge}}(y,\hat y)=(1-y \cdot \hat y)_+\\ L_{\text{logistic}}(y,\hat y)=\log(1+\exp(-y \cdot \hat y)) $$ Here we plot three loss functions, x axis is $y \cdot \hat y$ and y axis is the loss value. Note, in all above formulas $\hat y$ is a real number, and this number can come from linear form $\beta^Tx$ or other forms. Such notation hides probability details.
Why there are two different logistic loss formulation / notations?
I think @ssdecontrol had a very good answer. I just want to add some comments for the formula 2 for my own question. $$ L(y,\hat y)=\log(1+\exp{(-y\cdot \hat y})) $$ The reason people like this formul
Why there are two different logistic loss formulation / notations? I think @ssdecontrol had a very good answer. I just want to add some comments for the formula 2 for my own question. $$ L(y,\hat y)=\log(1+\exp{(-y\cdot \hat y})) $$ The reason people like this formulation is that it is very concise, and it removes the "probability interpretation details". The tricky notation is the $\hat y$, note, $y$ is a binary variable, but $\hat y$ here is a real number. Comparing to formulation 1, we need two additional steps to make it to discrete label, step 1. sigmod function step 2. apply 0.5 threshold. But without these details are good in terms of we can easily compare it with other classification loss, such as 01 loss or hinge loss. $$ L_{01}(y,\hat y)=I[y \cdot \hat y >0]\\ L_{\text{hinge}}(y,\hat y)=(1-y \cdot \hat y)_+\\ L_{\text{logistic}}(y,\hat y)=\log(1+\exp(-y \cdot \hat y)) $$ Here we plot three loss functions, x axis is $y \cdot \hat y$ and y axis is the loss value. Note, in all above formulas $\hat y$ is a real number, and this number can come from linear form $\beta^Tx$ or other forms. Such notation hides probability details.
Why there are two different logistic loss formulation / notations? I think @ssdecontrol had a very good answer. I just want to add some comments for the formula 2 for my own question. $$ L(y,\hat y)=\log(1+\exp{(-y\cdot \hat y})) $$ The reason people like this formul
10,099
How to interpret Matthews correlation coefficient (MCC)?
This question was so simple and unfortunately no one could answer this question. According to this paper: http://www.bioinfopublication.org/files/articles/2_1_1_JMLT.pdf, MCC is a contingency matrix method of calculating the Pearson product-moment correlation coefficient. Therefore, it has the same interpretation.
How to interpret Matthews correlation coefficient (MCC)?
This question was so simple and unfortunately no one could answer this question. According to this paper: http://www.bioinfopublication.org/files/articles/2_1_1_JMLT.pdf, MCC is a contingency matrix m
How to interpret Matthews correlation coefficient (MCC)? This question was so simple and unfortunately no one could answer this question. According to this paper: http://www.bioinfopublication.org/files/articles/2_1_1_JMLT.pdf, MCC is a contingency matrix method of calculating the Pearson product-moment correlation coefficient. Therefore, it has the same interpretation.
How to interpret Matthews correlation coefficient (MCC)? This question was so simple and unfortunately no one could answer this question. According to this paper: http://www.bioinfopublication.org/files/articles/2_1_1_JMLT.pdf, MCC is a contingency matrix m
10,100
How to interpret Matthews correlation coefficient (MCC)?
Matthews Correlation Coefficient is a special case of Pearson Correlation Coefficient. Therefore, the interpretations for both of them are the same. Check the derivations and other details in my blog post on github.
How to interpret Matthews correlation coefficient (MCC)?
Matthews Correlation Coefficient is a special case of Pearson Correlation Coefficient. Therefore, the interpretations for both of them are the same. Check the derivations and other details in my blog
How to interpret Matthews correlation coefficient (MCC)? Matthews Correlation Coefficient is a special case of Pearson Correlation Coefficient. Therefore, the interpretations for both of them are the same. Check the derivations and other details in my blog post on github.
How to interpret Matthews correlation coefficient (MCC)? Matthews Correlation Coefficient is a special case of Pearson Correlation Coefficient. Therefore, the interpretations for both of them are the same. Check the derivations and other details in my blog