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 |
|---|---|---|---|---|---|---|
37,501 | How does LDA (Latent Dirichlet Allocation) assign a topic-distribution to a new document? | What you should actually do is run inference (training) on the new set of documents (the old ones and the new ones together). A short-cut that estimates this well is applying Gibbs sampling only to the new documents while using the data obtained during training unchanged, as described by @SheldonCooper in Topic prediction using latent Dirichlet allocation. | How does LDA (Latent Dirichlet Allocation) assign a topic-distribution to a new document? | What you should actually do is run inference (training) on the new set of documents (the old ones and the new ones together). A short-cut that estimates this well is applying Gibbs sampling only to th | How does LDA (Latent Dirichlet Allocation) assign a topic-distribution to a new document?
What you should actually do is run inference (training) on the new set of documents (the old ones and the new ones together). A short-cut that estimates this well is applying Gibbs sampling only to the new documents while using the data obtained during training unchanged, as described by @SheldonCooper in Topic prediction using latent Dirichlet allocation. | How does LDA (Latent Dirichlet Allocation) assign a topic-distribution to a new document?
What you should actually do is run inference (training) on the new set of documents (the old ones and the new ones together). A short-cut that estimates this well is applying Gibbs sampling only to th |
37,502 | What is a mixture of finite mixtures? | Here is my understanding,
we draw the index or indicator as follows to indicate which $\theta_j$ to use
$$
Z_i \sim \text{Categorical}(\pi_1, ..., \pi_k), i=1,...,n
$$
then we draw the parameters of each component of a mixture model as,
$$
\theta_j \sim H, j = 1,...,K
$$
then we draw the sample according to the selected parameter $\theta_{Z_i}$ | What is a mixture of finite mixtures? | Here is my understanding,
we draw the index or indicator as follows to indicate which $\theta_j$ to use
$$
Z_i \sim \text{Categorical}(\pi_1, ..., \pi_k), i=1,...,n
$$
then we draw the parameters of e | What is a mixture of finite mixtures?
Here is my understanding,
we draw the index or indicator as follows to indicate which $\theta_j$ to use
$$
Z_i \sim \text{Categorical}(\pi_1, ..., \pi_k), i=1,...,n
$$
then we draw the parameters of each component of a mixture model as,
$$
\theta_j \sim H, j = 1,...,K
$$
then we draw the sample according to the selected parameter $\theta_{Z_i}$ | What is a mixture of finite mixtures?
Here is my understanding,
we draw the index or indicator as follows to indicate which $\theta_j$ to use
$$
Z_i \sim \text{Categorical}(\pi_1, ..., \pi_k), i=1,...,n
$$
then we draw the parameters of e |
37,503 | What is a mixture of finite mixtures? | I started working on Mixtures of Finite Mixture this week, and my understanding is the following, (it might be wrong but seems to make sense). I started with the paper Generalized Mixtures of Finite Mixtures and
Telescoping Sampling.
A simple Finite Mixture model is a model defined as
$$p_{K}(y) = \sum_{i=1}^{K}\eta_{k}f(y|\theta_{k}) \ \ (1)$$
equivalently an observation $y$ comes from the mixture component $f(y|\theta_{k})$ with probability $\eta_{k}.$ So, (1) is a mixture of densities with different mixture components $\theta_{k}$
Now since we call a Mixture of Finite Mixtures, we want a mixture of such things that we defined as (1). The (1) is conditional on the number of mixture components $K$, so a natural way to create a Mixture of Finite Mixtures, is if you let the mixing happen on $K$, and you can do that by letting $K$ being random and unknown. So, you can have something like
$$p(y) = \sum_{K=1}^{\infty}p(K)p_{K}(y)$$
So, equivalently you can say an observation $y$ comes from the Finite Mixture $p_{K}(y)$ with mixture probability $p(K)$ (can be regarded as the prior distribution over $K$). So, you can see that you have some nested mixture models, so I guess that comes from where the names Mixture of Finite Mixtures come. | What is a mixture of finite mixtures? | I started working on Mixtures of Finite Mixture this week, and my understanding is the following, (it might be wrong but seems to make sense). I started with the paper Generalized Mixtures of Finite M | What is a mixture of finite mixtures?
I started working on Mixtures of Finite Mixture this week, and my understanding is the following, (it might be wrong but seems to make sense). I started with the paper Generalized Mixtures of Finite Mixtures and
Telescoping Sampling.
A simple Finite Mixture model is a model defined as
$$p_{K}(y) = \sum_{i=1}^{K}\eta_{k}f(y|\theta_{k}) \ \ (1)$$
equivalently an observation $y$ comes from the mixture component $f(y|\theta_{k})$ with probability $\eta_{k}.$ So, (1) is a mixture of densities with different mixture components $\theta_{k}$
Now since we call a Mixture of Finite Mixtures, we want a mixture of such things that we defined as (1). The (1) is conditional on the number of mixture components $K$, so a natural way to create a Mixture of Finite Mixtures, is if you let the mixing happen on $K$, and you can do that by letting $K$ being random and unknown. So, you can have something like
$$p(y) = \sum_{K=1}^{\infty}p(K)p_{K}(y)$$
So, equivalently you can say an observation $y$ comes from the Finite Mixture $p_{K}(y)$ with mixture probability $p(K)$ (can be regarded as the prior distribution over $K$). So, you can see that you have some nested mixture models, so I guess that comes from where the names Mixture of Finite Mixtures come. | What is a mixture of finite mixtures?
I started working on Mixtures of Finite Mixture this week, and my understanding is the following, (it might be wrong but seems to make sense). I started with the paper Generalized Mixtures of Finite M |
37,504 | Showing $Z_i$'s are independent if $Z_1=\sum_{i=1}^{n+1}X_i$ and $Z_i=\frac{X_i}{\sum_{j=1}^iX_j}, i\ge2$ when $X_i\sim\text{G}(\alpha,p_i)$ | I'll prove the equivalent statement.
Let $n\ge 1$, $X_k\sim \Gamma(\alpha,p_k)$, $k=1,\dots,n+1$, are independent. Denote $S_k = X_1+\dots+X_k$, $k=1,\dots,n+1$; $R_k = \frac{S_k}{S_{k+1}}$, $k=1,\dots,n$. Then $R_1$, $R_2$, $\dots$, $R_{n}$, and $S_{n+1}$ are independent and $S_{n+1}\sim \Gamma(\alpha,p_1+\dots + p_{n+1})$.
Remark In OP notation, $Z_1=S_{n+1}$, $Z_k = 1 - R_{k-1}$, $k=2,\dots,n+1$.
Proof. $n=1$ is easy (and well known).
$n-1\Rightarrow n$.
By induction hypothesis and independence, the vectors $\mathbf{R} = (R_1,\dots,R_{n-1})$ and $(S_{n},X_{n+1})$ are independent. Therefore, the vectors $\mathbf{R}$ and $\big(\frac{S_{n}}{S_{n}+X_{n+1}},S_{n}+X_{n+1}\big) = (R_n,S_{n+1})$ are independent. Both vectors have independent components: $\mathbf R$ by induction hypotheses, $(R_n,S_{n+1})$ by induction base. Therefore, their components are independent random variables.
It is no problem to include the distribution of $R_n$ to the statement, the proof won't change. The distribution of $S_n$ is already there: I need it for saying that the independence of $R_n$ and $S_{n+1}$ follows from the induction base. | Showing $Z_i$'s are independent if $Z_1=\sum_{i=1}^{n+1}X_i$ and $Z_i=\frac{X_i}{\sum_{j=1}^iX_j}, i | I'll prove the equivalent statement.
Let $n\ge 1$, $X_k\sim \Gamma(\alpha,p_k)$, $k=1,\dots,n+1$, are independent. Denote $S_k = X_1+\dots+X_k$, $k=1,\dots,n+1$; $R_k = \frac{S_k}{S_{k+1}}$, $k=1,\do | Showing $Z_i$'s are independent if $Z_1=\sum_{i=1}^{n+1}X_i$ and $Z_i=\frac{X_i}{\sum_{j=1}^iX_j}, i\ge2$ when $X_i\sim\text{G}(\alpha,p_i)$
I'll prove the equivalent statement.
Let $n\ge 1$, $X_k\sim \Gamma(\alpha,p_k)$, $k=1,\dots,n+1$, are independent. Denote $S_k = X_1+\dots+X_k$, $k=1,\dots,n+1$; $R_k = \frac{S_k}{S_{k+1}}$, $k=1,\dots,n$. Then $R_1$, $R_2$, $\dots$, $R_{n}$, and $S_{n+1}$ are independent and $S_{n+1}\sim \Gamma(\alpha,p_1+\dots + p_{n+1})$.
Remark In OP notation, $Z_1=S_{n+1}$, $Z_k = 1 - R_{k-1}$, $k=2,\dots,n+1$.
Proof. $n=1$ is easy (and well known).
$n-1\Rightarrow n$.
By induction hypothesis and independence, the vectors $\mathbf{R} = (R_1,\dots,R_{n-1})$ and $(S_{n},X_{n+1})$ are independent. Therefore, the vectors $\mathbf{R}$ and $\big(\frac{S_{n}}{S_{n}+X_{n+1}},S_{n}+X_{n+1}\big) = (R_n,S_{n+1})$ are independent. Both vectors have independent components: $\mathbf R$ by induction hypotheses, $(R_n,S_{n+1})$ by induction base. Therefore, their components are independent random variables.
It is no problem to include the distribution of $R_n$ to the statement, the proof won't change. The distribution of $S_n$ is already there: I need it for saying that the independence of $R_n$ and $S_{n+1}$ follows from the induction base. | Showing $Z_i$'s are independent if $Z_1=\sum_{i=1}^{n+1}X_i$ and $Z_i=\frac{X_i}{\sum_{j=1}^iX_j}, i
I'll prove the equivalent statement.
Let $n\ge 1$, $X_k\sim \Gamma(\alpha,p_k)$, $k=1,\dots,n+1$, are independent. Denote $S_k = X_1+\dots+X_k$, $k=1,\dots,n+1$; $R_k = \frac{S_k}{S_{k+1}}$, $k=1,\do |
37,505 | Why decision boundary differs between multinomial (softmax) and One-vs-Rest Logistic Regression for multiclass classification | Most likely it is because in One-versus-rest you are training independent binary classifiers using the sigmoid function.
In multinomial logistic regression you use another different function, i.e., the softmax function which forces the outputs to sum to $1$.
Being the functions different, also the boundaries will be different. | Why decision boundary differs between multinomial (softmax) and One-vs-Rest Logistic Regression for | Most likely it is because in One-versus-rest you are training independent binary classifiers using the sigmoid function.
In multinomial logistic regression you use another different function, i.e., t | Why decision boundary differs between multinomial (softmax) and One-vs-Rest Logistic Regression for multiclass classification
Most likely it is because in One-versus-rest you are training independent binary classifiers using the sigmoid function.
In multinomial logistic regression you use another different function, i.e., the softmax function which forces the outputs to sum to $1$.
Being the functions different, also the boundaries will be different. | Why decision boundary differs between multinomial (softmax) and One-vs-Rest Logistic Regression for
Most likely it is because in One-versus-rest you are training independent binary classifiers using the sigmoid function.
In multinomial logistic regression you use another different function, i.e., t |
37,506 | How are estimators like the Horvitz-Thompson Estimator derived? | the estimator seemed to appear out of nowhere with no motivation
If you think the idea behind stratified sampling is intuitive, then I believe Horvitz-Thompson should come as a natural extension, it's not something out of the blue.
To illustrate how a simple stratified sample could help you come up with the formula, consider a case with two strata, $S_1$ and $S_2$ of known sizes $N_1$ and $N_2$ and suppose you get samples $n_1$ and $n_2$ respectively. Now imagine you compute the average for each sample $\bar{y}_1$ and $\bar{y}_2$.
How would you use this information to estimate the total $Y$? The natural way is to take the estimated average of each stratum and multiply by the total (population) number of elements of the stratum:
$$
\hat{Y} = N_1 \bar{y}_1 + N_2 \bar{y}_2
$$
But take this simple expression and rewrite it as:
$$
\begin{align}
\hat{Y} &= N_1 \sum_{i \in S_1}\frac{y_i}{n_1} + N_2 \sum_{i \in S_2}\frac{y_i}{n_2}\\
&= \sum_{i \in S_1}\frac{y_i}{n_1/N_1} + \sum_{i \in S_2}\frac{y_i}{n_2/N_2}\\
&= \sum_{i} \frac{y_i}{\pi_i}
\end{align}
$$
Where $\pi_i = n_1/N_1$ if $i\in S_1$ and $\pi_i = n_2/N_2$ if $i\in S_2$. That is, a simple stratified sampling already gives you the insight that, in essence, what we are doing is summing each sampled $y_i$ upweighted by its probability of selection. Then the idea of a general inverse probability weighting, where each $\pi_i$ could be different, should come naturally. | How are estimators like the Horvitz-Thompson Estimator derived? | the estimator seemed to appear out of nowhere with no motivation
If you think the idea behind stratified sampling is intuitive, then I believe Horvitz-Thompson should come as a natural extension, it' | How are estimators like the Horvitz-Thompson Estimator derived?
the estimator seemed to appear out of nowhere with no motivation
If you think the idea behind stratified sampling is intuitive, then I believe Horvitz-Thompson should come as a natural extension, it's not something out of the blue.
To illustrate how a simple stratified sample could help you come up with the formula, consider a case with two strata, $S_1$ and $S_2$ of known sizes $N_1$ and $N_2$ and suppose you get samples $n_1$ and $n_2$ respectively. Now imagine you compute the average for each sample $\bar{y}_1$ and $\bar{y}_2$.
How would you use this information to estimate the total $Y$? The natural way is to take the estimated average of each stratum and multiply by the total (population) number of elements of the stratum:
$$
\hat{Y} = N_1 \bar{y}_1 + N_2 \bar{y}_2
$$
But take this simple expression and rewrite it as:
$$
\begin{align}
\hat{Y} &= N_1 \sum_{i \in S_1}\frac{y_i}{n_1} + N_2 \sum_{i \in S_2}\frac{y_i}{n_2}\\
&= \sum_{i \in S_1}\frac{y_i}{n_1/N_1} + \sum_{i \in S_2}\frac{y_i}{n_2/N_2}\\
&= \sum_{i} \frac{y_i}{\pi_i}
\end{align}
$$
Where $\pi_i = n_1/N_1$ if $i\in S_1$ and $\pi_i = n_2/N_2$ if $i\in S_2$. That is, a simple stratified sampling already gives you the insight that, in essence, what we are doing is summing each sampled $y_i$ upweighted by its probability of selection. Then the idea of a general inverse probability weighting, where each $\pi_i$ could be different, should come naturally. | How are estimators like the Horvitz-Thompson Estimator derived?
the estimator seemed to appear out of nowhere with no motivation
If you think the idea behind stratified sampling is intuitive, then I believe Horvitz-Thompson should come as a natural extension, it' |
37,507 | How are estimators like the Horvitz-Thompson Estimator derived? | I'd like to take a different approach to the accepted answer. The accepted answer justifies the intuition behind the inverse probability weighting, but I'd like to justify why the Horvitz-Thompson Estimator makes sense to arrive at rather than some other estimator. It can stem from two properties:
The estimator is a linear combination of survey responses. This property is an advantage because it allows us to calculate expectations (and variances) without considering all possible samples, and instead only deal with individual units' (joint) probabilities of selection.
The estimator is unbiased (as you already note). This is a nice property because it makes the eventual estimate easier to interpret/explain to someone else.
The Horvitz-Thompson Estimator is the unique estimator with these two properties. In my opinion, the most intuitive way to approach it is to:
Justify the two properties above,
Use property 1 to define the structure of the estimator ($\sum w_i y_i$),
Use property 2 to show that $w_i=\pi_i^{-1}$, and then,
Show that this is unique (e.g. consider particular $y_i$ values) | How are estimators like the Horvitz-Thompson Estimator derived? | I'd like to take a different approach to the accepted answer. The accepted answer justifies the intuition behind the inverse probability weighting, but I'd like to justify why the Horvitz-Thompson Est | How are estimators like the Horvitz-Thompson Estimator derived?
I'd like to take a different approach to the accepted answer. The accepted answer justifies the intuition behind the inverse probability weighting, but I'd like to justify why the Horvitz-Thompson Estimator makes sense to arrive at rather than some other estimator. It can stem from two properties:
The estimator is a linear combination of survey responses. This property is an advantage because it allows us to calculate expectations (and variances) without considering all possible samples, and instead only deal with individual units' (joint) probabilities of selection.
The estimator is unbiased (as you already note). This is a nice property because it makes the eventual estimate easier to interpret/explain to someone else.
The Horvitz-Thompson Estimator is the unique estimator with these two properties. In my opinion, the most intuitive way to approach it is to:
Justify the two properties above,
Use property 1 to define the structure of the estimator ($\sum w_i y_i$),
Use property 2 to show that $w_i=\pi_i^{-1}$, and then,
Show that this is unique (e.g. consider particular $y_i$ values) | How are estimators like the Horvitz-Thompson Estimator derived?
I'd like to take a different approach to the accepted answer. The accepted answer justifies the intuition behind the inverse probability weighting, but I'd like to justify why the Horvitz-Thompson Est |
37,508 | How are estimators like the Horvitz-Thompson Estimator derived? | First, note that the Horvitz-Thompson (H-T) estimator is used for both $\textit{with or without replacement}$ random sampling designs.
$\pi$ is the inclusion probability. The H-T estimator provides us with an estimate of the population total.
As a simple illustration, a Horvitz-Thompson "like" estimator can be derived as follows:
If we let $\pi = \frac{n}{N}$, where $n$ is the sample size and $N$ is the population size, and substitute into the H-T estimator, then, after simplification, we get that $\hat{Y} = N\frac{Y}{n} = N\bar{y}$.
Showing that such an estimator is unbiased is now a straightforward task. | How are estimators like the Horvitz-Thompson Estimator derived? | First, note that the Horvitz-Thompson (H-T) estimator is used for both $\textit{with or without replacement}$ random sampling designs.
$\pi$ is the inclusion probability. The H-T estimator provides us | How are estimators like the Horvitz-Thompson Estimator derived?
First, note that the Horvitz-Thompson (H-T) estimator is used for both $\textit{with or without replacement}$ random sampling designs.
$\pi$ is the inclusion probability. The H-T estimator provides us with an estimate of the population total.
As a simple illustration, a Horvitz-Thompson "like" estimator can be derived as follows:
If we let $\pi = \frac{n}{N}$, where $n$ is the sample size and $N$ is the population size, and substitute into the H-T estimator, then, after simplification, we get that $\hat{Y} = N\frac{Y}{n} = N\bar{y}$.
Showing that such an estimator is unbiased is now a straightforward task. | How are estimators like the Horvitz-Thompson Estimator derived?
First, note that the Horvitz-Thompson (H-T) estimator is used for both $\textit{with or without replacement}$ random sampling designs.
$\pi$ is the inclusion probability. The H-T estimator provides us |
37,509 | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approach (Aris Spanos) | There are quite some similarities between Aris Spanos' framework and David Hendry's econometric methodology; no wonder as Spanos was a student of Hendry. Here is my brief summary of what Hendry had to say when confronted by Edward Leamer and Dale Poirier on the problem of pretesting and post-selection inference (Hendry et al., 1990).
Summary
Hendry does not see a problem with pretesting and post-selection inference in his methodology. He views it as the model discovery stage which is "outside the confines of classical hypothesis testing theory" (p. 213). The conventional theory of estimation and inference is suited for a given model with unknown parameters, not for an unknown model (p. 201). There is no theory for design of models (p. 224). Hendry intentionally and willingly conditions inference on the model (p. 222) (!!!).
It is not important how one arrives at a model as this has nothing to say about the model's validity. The route to the final model does affects the model's compellingness, however. Extensive specification search makes the model less compelling, but not less (or more) valid.
Quotes
Here are some quotes from the paper. P. 207-210:
Poirier: David, you stated something before which I think suggests behavior very much in tune with the Likelihood Principle. As Pagan [38, p. 7] also points out, your attitude seems to be how the final model is derived is largely irrelevant in concluding what evidence there is in the data about the unknown parameters. That is something that a likelihood proponent would adhere to. The path getting there, however, is something that becomes very important for the frequentist...
Hendry: The path is obviously irrelevant for the validity of the model (see, for example, my comments above about the principle of buoyancy).
Poirier: Well, for purposes of drawing inferences about the parameters...
Hendry: No, I haven't said that. We must be clear about what the route independence proposition applies to. The validity of the model as an intrinsic description of the world is independent of the discovery path. The inferences you draw from the model might still be route dependent. This is the issue that Ed called "compellingness." If I thought of the model in my bath, you might not think that's very compelling. You might not accept any inferences from that model. But whether or not that model characterizes reality to the degree that is claimed is independent of how the model was found. That is the statement I'm making.
Poirier: There is a mixing here of when to condition on the data and when not. I think you are saying that it is okay to condition on it for evaluating the model, but not for drawing inferences concerning the parameters.
<...>
Leamer: My understanding is that you refuse to submit to the discipline of either one of those approaches. You're clearly not asking what is the prior distribution that underlies the procedure that you are recommending. Nor do I see you laying out the sampling properties of these very complex processes that you are working with. This makes it very difficult for me to know whether what you're recommending is appropriate or not, because I don't see that there is a framework by which we can evaluate it.
More on p. 213-214:
Hendry: In the context of evaluation the role of testing is clear cut. Someone produces a model. I make a prediction on the basis of their claims about the model, and construct a test that would be accepted as valid, at an agreed significance level. Then I check if the outcome falls within the critical region. That is critical evaluation of the model. In the context of discovery, we are outside the confines of classical hypothesis testing theory. We do not know what the properties of our procedures are. But the intrinsic validity of the model is independent of the route, so validity cannot depend on the order of testing, how many tests were done, etc. The ability to find good models or the credence that others might place on the model may depend on the procedure, but the latter doesn't worry me greatly. If you come up with good models, those models will be robust over time and will serve the functions you claim they serve, and the fact that you thought of them in your bath or did fifty tests or five hundred regressions or discovered them in the very first trial, seems to me irrelevant. But in the context of evaluation or justification it is very important to reveal whether or not the four hundredth test on the model yielded the first rejection.
(Emphasis is mine.)
P. 220-221 (this is quite on the point):
Hendry: My treatment of the pretesting issue per se is that in the context of discovery the tests are not tests, they are selection criteria or indices of adequacy of design. They show if the bridge you are building will withstand a particular gust of wind or a certain volume of traffic, whether the steel in it was properly made, etc. These are ways of self-evaluation, so you can decide for yourself whether you have matched the criteria that are relevant for congruency. So you are always going to look at some index of white noise or innovation, some index of exogeneity, some index of invariance and constancy, some index of theory con-sistency, and some index of encompassing. PCGIVE (see Hendry [19]), for example, provides many of those that I think are necessary, although they are not sufficient. When one has designed the model to characterize the data, I call it congruent.
The pretesting issue would be if one wanted at that stage to make inferences which were not simply that "the model is well designed." That is all that can be claimed when you quote these criteria: "Here is my design criteria and I meet them. This bridge is designed to take a ten-ton truck. Here's a ten-ton truck going over it and it stood up." That's the sense in which the indices of model adequacy are being offered.
Outside of that context, including diagnostic testing in a new data set or against new rival models or using new tests, then you must be careful of the pretesting issue. Not for the parameter standard errors, but for the fact that if under the null of a valid model, you conducted 100 tests at the 5% level, then there's a fair probability you'll get some rejections. If you want to interpret them correctly, the overall test size in the evaluation domain is an important factor to think about. It is fairly easily controlled. You can let it get smaller as the sample size gets larger, and smaller for each individual test as the number of tests gets larger. It is rare that you find a situation in which the model does well in many ways, but badly in a rather obvious dimension, but it could happen.
P. 222-224 (this is quite on the point):
Poirier: One frequentist result on pretest estimators is that in usual situations they're inadmissable. Now, as a good frequentist, why doesn't that bother you?
Hendry: Because at the end of the day I want to condition on the model. Given route independence, if the model congruently characterizes reality, then the statistics I quote with it are the correct basis for forecast variances, etc.
<...>
It is not usually worth spending a lot of time worrying about the particular properties of estimators when you are in the context of discovery, because the revision process takes us outside the formal domain of statistics.
<...>
But I see the model selection problem as being the crucial one, which cannot be formulated as "we already know that $y=X\beta+u$, and just need the best estimate of $\beta$". That latter is a different statistical problem, and it is one to which pretesting is relevant. But it is not directly relevant when we're analyzing data.
Poirier: So, do you think classical statistics has misled people by emphasizing admissability criteria and sampling distributions of procedures? Is it asking the wrong questions?
Hendry: It's asking different questions. It's asking questions concerning if you know $y=X\beta+u$, and you are going to get different samples of data from this process, how should you estimate j? That is a mathematical/statistical question that falls into my second category where we can study the properties of procedures, whether they are Bayes procedures, classical procedures, or likelihood procedures. We can study them, but they cannot solve what is wrong in econometrics. They are necessary tools, but do not answer the practical question of how do you find a model that characterizes the data which is a question in my third category.
<...>
We do not yet have any theory, either Bayesian or sampling for design of models. It's not in your work and I haven't seen it anywhere else.
(Emphasis is mine.)
References:
Hendry, D. F., Leamer, E. E., & Poirier, D. J. (1990). The ET dialogue: a conversation on econometric methodology. Econometric Theory, 6(2), 171-261. | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approa | There are quite some similarities between Aris Spanos' framework and David Hendry's econometric methodology; no wonder as Spanos was a student of Hendry. Here is my brief summary of what Hendry had to | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approach (Aris Spanos)
There are quite some similarities between Aris Spanos' framework and David Hendry's econometric methodology; no wonder as Spanos was a student of Hendry. Here is my brief summary of what Hendry had to say when confronted by Edward Leamer and Dale Poirier on the problem of pretesting and post-selection inference (Hendry et al., 1990).
Summary
Hendry does not see a problem with pretesting and post-selection inference in his methodology. He views it as the model discovery stage which is "outside the confines of classical hypothesis testing theory" (p. 213). The conventional theory of estimation and inference is suited for a given model with unknown parameters, not for an unknown model (p. 201). There is no theory for design of models (p. 224). Hendry intentionally and willingly conditions inference on the model (p. 222) (!!!).
It is not important how one arrives at a model as this has nothing to say about the model's validity. The route to the final model does affects the model's compellingness, however. Extensive specification search makes the model less compelling, but not less (or more) valid.
Quotes
Here are some quotes from the paper. P. 207-210:
Poirier: David, you stated something before which I think suggests behavior very much in tune with the Likelihood Principle. As Pagan [38, p. 7] also points out, your attitude seems to be how the final model is derived is largely irrelevant in concluding what evidence there is in the data about the unknown parameters. That is something that a likelihood proponent would adhere to. The path getting there, however, is something that becomes very important for the frequentist...
Hendry: The path is obviously irrelevant for the validity of the model (see, for example, my comments above about the principle of buoyancy).
Poirier: Well, for purposes of drawing inferences about the parameters...
Hendry: No, I haven't said that. We must be clear about what the route independence proposition applies to. The validity of the model as an intrinsic description of the world is independent of the discovery path. The inferences you draw from the model might still be route dependent. This is the issue that Ed called "compellingness." If I thought of the model in my bath, you might not think that's very compelling. You might not accept any inferences from that model. But whether or not that model characterizes reality to the degree that is claimed is independent of how the model was found. That is the statement I'm making.
Poirier: There is a mixing here of when to condition on the data and when not. I think you are saying that it is okay to condition on it for evaluating the model, but not for drawing inferences concerning the parameters.
<...>
Leamer: My understanding is that you refuse to submit to the discipline of either one of those approaches. You're clearly not asking what is the prior distribution that underlies the procedure that you are recommending. Nor do I see you laying out the sampling properties of these very complex processes that you are working with. This makes it very difficult for me to know whether what you're recommending is appropriate or not, because I don't see that there is a framework by which we can evaluate it.
More on p. 213-214:
Hendry: In the context of evaluation the role of testing is clear cut. Someone produces a model. I make a prediction on the basis of their claims about the model, and construct a test that would be accepted as valid, at an agreed significance level. Then I check if the outcome falls within the critical region. That is critical evaluation of the model. In the context of discovery, we are outside the confines of classical hypothesis testing theory. We do not know what the properties of our procedures are. But the intrinsic validity of the model is independent of the route, so validity cannot depend on the order of testing, how many tests were done, etc. The ability to find good models or the credence that others might place on the model may depend on the procedure, but the latter doesn't worry me greatly. If you come up with good models, those models will be robust over time and will serve the functions you claim they serve, and the fact that you thought of them in your bath or did fifty tests or five hundred regressions or discovered them in the very first trial, seems to me irrelevant. But in the context of evaluation or justification it is very important to reveal whether or not the four hundredth test on the model yielded the first rejection.
(Emphasis is mine.)
P. 220-221 (this is quite on the point):
Hendry: My treatment of the pretesting issue per se is that in the context of discovery the tests are not tests, they are selection criteria or indices of adequacy of design. They show if the bridge you are building will withstand a particular gust of wind or a certain volume of traffic, whether the steel in it was properly made, etc. These are ways of self-evaluation, so you can decide for yourself whether you have matched the criteria that are relevant for congruency. So you are always going to look at some index of white noise or innovation, some index of exogeneity, some index of invariance and constancy, some index of theory con-sistency, and some index of encompassing. PCGIVE (see Hendry [19]), for example, provides many of those that I think are necessary, although they are not sufficient. When one has designed the model to characterize the data, I call it congruent.
The pretesting issue would be if one wanted at that stage to make inferences which were not simply that "the model is well designed." That is all that can be claimed when you quote these criteria: "Here is my design criteria and I meet them. This bridge is designed to take a ten-ton truck. Here's a ten-ton truck going over it and it stood up." That's the sense in which the indices of model adequacy are being offered.
Outside of that context, including diagnostic testing in a new data set or against new rival models or using new tests, then you must be careful of the pretesting issue. Not for the parameter standard errors, but for the fact that if under the null of a valid model, you conducted 100 tests at the 5% level, then there's a fair probability you'll get some rejections. If you want to interpret them correctly, the overall test size in the evaluation domain is an important factor to think about. It is fairly easily controlled. You can let it get smaller as the sample size gets larger, and smaller for each individual test as the number of tests gets larger. It is rare that you find a situation in which the model does well in many ways, but badly in a rather obvious dimension, but it could happen.
P. 222-224 (this is quite on the point):
Poirier: One frequentist result on pretest estimators is that in usual situations they're inadmissable. Now, as a good frequentist, why doesn't that bother you?
Hendry: Because at the end of the day I want to condition on the model. Given route independence, if the model congruently characterizes reality, then the statistics I quote with it are the correct basis for forecast variances, etc.
<...>
It is not usually worth spending a lot of time worrying about the particular properties of estimators when you are in the context of discovery, because the revision process takes us outside the formal domain of statistics.
<...>
But I see the model selection problem as being the crucial one, which cannot be formulated as "we already know that $y=X\beta+u$, and just need the best estimate of $\beta$". That latter is a different statistical problem, and it is one to which pretesting is relevant. But it is not directly relevant when we're analyzing data.
Poirier: So, do you think classical statistics has misled people by emphasizing admissability criteria and sampling distributions of procedures? Is it asking the wrong questions?
Hendry: It's asking different questions. It's asking questions concerning if you know $y=X\beta+u$, and you are going to get different samples of data from this process, how should you estimate j? That is a mathematical/statistical question that falls into my second category where we can study the properties of procedures, whether they are Bayes procedures, classical procedures, or likelihood procedures. We can study them, but they cannot solve what is wrong in econometrics. They are necessary tools, but do not answer the practical question of how do you find a model that characterizes the data which is a question in my third category.
<...>
We do not yet have any theory, either Bayesian or sampling for design of models. It's not in your work and I haven't seen it anywhere else.
(Emphasis is mine.)
References:
Hendry, D. F., Leamer, E. E., & Poirier, D. J. (1990). The ET dialogue: a conversation on econometric methodology. Econometric Theory, 6(2), 171-261. | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approa
There are quite some similarities between Aris Spanos' framework and David Hendry's econometric methodology; no wonder as Spanos was a student of Hendry. Here is my brief summary of what Hendry had to |
37,510 | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approach (Aris Spanos) | There is some research on the effect of pre-testing on subsequent inference. This has a long tradition starting from Bancroft's work in 1944. The baseline is that it can hurt, but it doesn't always. No black or white there. We did a survey paper on this with some new results.
M. I. Shamsudheen & C. Hennig: Should we test the model assumptions before running a model-based test? https://arxiv.org/abs/1908.02218
Spanos is not exactly keen on this, see here (I respond in the comments): https://errorstatistics.com/2021/02/25/aris-spanos-modeling-vs-inference-in-frequentist-statistics-guest-post/ | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approa | There is some research on the effect of pre-testing on subsequent inference. This has a long tradition starting from Bancroft's work in 1944. The baseline is that it can hurt, but it doesn't always. N | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approach (Aris Spanos)
There is some research on the effect of pre-testing on subsequent inference. This has a long tradition starting from Bancroft's work in 1944. The baseline is that it can hurt, but it doesn't always. No black or white there. We did a survey paper on this with some new results.
M. I. Shamsudheen & C. Hennig: Should we test the model assumptions before running a model-based test? https://arxiv.org/abs/1908.02218
Spanos is not exactly keen on this, see here (I respond in the comments): https://errorstatistics.com/2021/02/25/aris-spanos-modeling-vs-inference-in-frequentist-statistics-guest-post/ | Effects of model selection and misspecification testing on inference: Probabilistic Reduction approa
There is some research on the effect of pre-testing on subsequent inference. This has a long tradition starting from Bancroft's work in 1944. The baseline is that it can hurt, but it doesn't always. N |
37,511 | Signatures of underfitting and overfitting in logistic regression calibration curves | it isn't intuitively obvious to me how that noise would necessarily lead to overestimates of risk in high risk and underestimates of risk in low risk patients.
It does not "necessarily", but it "tends" to:
Overfitted models tend to [...]
Why can't an overfitted model capture noise in a way that it underestimates the risk in high risk patients?
It can, and occasionally it does. But it doesn't do it and cannot do it systematically. If it did, it wouldn't be overfitted, but underfitted. It would systematically give lower estimates (i.e. higher uncertainty, as @gung said it his/her comment) than the optimal model.
Fitting a function to the data means minimising some error measure. The more free parameters (coefficients) the function has, the better it can approximate the empirical data and, consequently, reduce the error.
Now, for low risk patients, we'll $-$ on average! $-$ have more non-events, and an overfitted model will better approach the non-event level (e.g. zero), as it attempts to minimise the error. Occasionally, we will encounter an event even for low-risk patients, and our overfitted model will likely pick that noise too, but, due to its flexibility (being overfitted) will rapidly return to zero as we move away from that observation. The mirror-image happens for high-risk patients: There are more events than non-events there and the overfitted model will try to approximate these.
To give you some intuition, observe the following artificial dataset and the fitted probabilities:
(two normally distributed classes, fitted by simple logistic regression (green), logistic regression with poly(x, 3) predictors (orange) and with poly(x, 5) predictors (red))
As you can see, the severely overfitted red curve is, for $x < 0$ almost constantly below the green (optimal) one, except for one single peak around $x = -0.5$, where it picked up the noise on the "event" side. For "high risk patients" it's the opposite: The red curve is almost always above the green one, except again for some noise around $x = +0.5$. | Signatures of underfitting and overfitting in logistic regression calibration curves | it isn't intuitively obvious to me how that noise would necessarily lead to overestimates of risk in high risk and underestimates of risk in low risk patients.
It does not "necessarily", but it "tend | Signatures of underfitting and overfitting in logistic regression calibration curves
it isn't intuitively obvious to me how that noise would necessarily lead to overestimates of risk in high risk and underestimates of risk in low risk patients.
It does not "necessarily", but it "tends" to:
Overfitted models tend to [...]
Why can't an overfitted model capture noise in a way that it underestimates the risk in high risk patients?
It can, and occasionally it does. But it doesn't do it and cannot do it systematically. If it did, it wouldn't be overfitted, but underfitted. It would systematically give lower estimates (i.e. higher uncertainty, as @gung said it his/her comment) than the optimal model.
Fitting a function to the data means minimising some error measure. The more free parameters (coefficients) the function has, the better it can approximate the empirical data and, consequently, reduce the error.
Now, for low risk patients, we'll $-$ on average! $-$ have more non-events, and an overfitted model will better approach the non-event level (e.g. zero), as it attempts to minimise the error. Occasionally, we will encounter an event even for low-risk patients, and our overfitted model will likely pick that noise too, but, due to its flexibility (being overfitted) will rapidly return to zero as we move away from that observation. The mirror-image happens for high-risk patients: There are more events than non-events there and the overfitted model will try to approximate these.
To give you some intuition, observe the following artificial dataset and the fitted probabilities:
(two normally distributed classes, fitted by simple logistic regression (green), logistic regression with poly(x, 3) predictors (orange) and with poly(x, 5) predictors (red))
As you can see, the severely overfitted red curve is, for $x < 0$ almost constantly below the green (optimal) one, except for one single peak around $x = -0.5$, where it picked up the noise on the "event" side. For "high risk patients" it's the opposite: The red curve is almost always above the green one, except again for some noise around $x = +0.5$. | Signatures of underfitting and overfitting in logistic regression calibration curves
it isn't intuitively obvious to me how that noise would necessarily lead to overestimates of risk in high risk and underestimates of risk in low risk patients.
It does not "necessarily", but it "tend |
37,512 | When is oversampling poor practice? | If you have the entire population, there there is nothing to do. You know exactly what happened. If a subject had a certain combination of predictors (features) and experienced an outcome, then that was the outcome. If multiple subjects had the same combination of predictors and experienced different outcomes, you know the proportion in which they experienced the various outcomes.
You have the entire population. There is no need to do any modeling. Do not run logistic regressions. Do not run random forests. Do not run SVMs. You have the absolute, inarguable truth. It's like predicting yesterday's closing stock price. You don't predict it; you look up what it was, and that's what it was.
(In my opinion, even when we think we have the entire population, usually we are really interested in a data-generating process. If you find my response unsatisfactory, think hard about if you are interested in something beyond the subjects you observed.) | When is oversampling poor practice? | If you have the entire population, there there is nothing to do. You know exactly what happened. If a subject had a certain combination of predictors (features) and experienced an outcome, then that w | When is oversampling poor practice?
If you have the entire population, there there is nothing to do. You know exactly what happened. If a subject had a certain combination of predictors (features) and experienced an outcome, then that was the outcome. If multiple subjects had the same combination of predictors and experienced different outcomes, you know the proportion in which they experienced the various outcomes.
You have the entire population. There is no need to do any modeling. Do not run logistic regressions. Do not run random forests. Do not run SVMs. You have the absolute, inarguable truth. It's like predicting yesterday's closing stock price. You don't predict it; you look up what it was, and that's what it was.
(In my opinion, even when we think we have the entire population, usually we are really interested in a data-generating process. If you find my response unsatisfactory, think hard about if you are interested in something beyond the subjects you observed.) | When is oversampling poor practice?
If you have the entire population, there there is nothing to do. You know exactly what happened. If a subject had a certain combination of predictors (features) and experienced an outcome, then that w |
37,513 | Time series anomaly detection | A few years ago my team implemented a impulse detection algorithm in Holt-Winters (HW) context, this time with strong seasonality and no trend.
The main idea was to look for an unusual difference between prediction at time $t$ and real value: an outlier that goes several times beyond the std. deviation of the noise (the std. deviation being estimated from the past errors).
This article was our starting point: http://www.jmlr.org/papers/volume9/li08a/li08a.pdf. It is worth reading. But soon we realized their precise idea did not and could not work (page 2222 point 3) even if the global outlier idea was OK.
There were many difficult points. One of them is once the impulse has started but not reached the threshold of "it's an impulse", HW is already influenced. We used sort of geometric sequences to balance the fact that is has already been influenced. This worked but was not easy and required a bit of work.
We also needed to work on repeated impulses and implement a rewind because sometimes it's not possible to process things online and you have to recompute things from the past, after eliminating the past impulses.
And this was just for impulses. Ramp is something else.
I don't believe ARIMA would be very helpful for this specific problem. It is more sophisticated but most often not better than HW. One problem: less robust, which is a problem especially with anomalies.
I would recommend to get your hands dirty and try something step by step until it works in most cases, fixing problems one by one. At least, I don't known any mature method to solve this generally. | Time series anomaly detection | A few years ago my team implemented a impulse detection algorithm in Holt-Winters (HW) context, this time with strong seasonality and no trend.
The main idea was to look for an unusual difference betw | Time series anomaly detection
A few years ago my team implemented a impulse detection algorithm in Holt-Winters (HW) context, this time with strong seasonality and no trend.
The main idea was to look for an unusual difference between prediction at time $t$ and real value: an outlier that goes several times beyond the std. deviation of the noise (the std. deviation being estimated from the past errors).
This article was our starting point: http://www.jmlr.org/papers/volume9/li08a/li08a.pdf. It is worth reading. But soon we realized their precise idea did not and could not work (page 2222 point 3) even if the global outlier idea was OK.
There were many difficult points. One of them is once the impulse has started but not reached the threshold of "it's an impulse", HW is already influenced. We used sort of geometric sequences to balance the fact that is has already been influenced. This worked but was not easy and required a bit of work.
We also needed to work on repeated impulses and implement a rewind because sometimes it's not possible to process things online and you have to recompute things from the past, after eliminating the past impulses.
And this was just for impulses. Ramp is something else.
I don't believe ARIMA would be very helpful for this specific problem. It is more sophisticated but most often not better than HW. One problem: less robust, which is a problem especially with anomalies.
I would recommend to get your hands dirty and try something step by step until it works in most cases, fixing problems one by one. At least, I don't known any mature method to solve this generally. | Time series anomaly detection
A few years ago my team implemented a impulse detection algorithm in Holt-Winters (HW) context, this time with strong seasonality and no trend.
The main idea was to look for an unusual difference betw |
37,514 | Time series anomaly detection | An approach I can recommend is to use Tukeys methods from his EDA book. Use his smooth algorithms to split the time series into a smooth and a rough. The smooth acts acts as a reference level and the rough is how far the data is away from the reference level. Then apply Tukey outlier detection methods from box plots on the rough data to identify when the data is too far away from the smooth. I use various different versions of smooth and then combine these to give a result. You do not have to use the multiples Tukey recommends for outliers or far out values, you can use multiples that make sense for your data. | Time series anomaly detection | An approach I can recommend is to use Tukeys methods from his EDA book. Use his smooth algorithms to split the time series into a smooth and a rough. The smooth acts acts as a reference level and the | Time series anomaly detection
An approach I can recommend is to use Tukeys methods from his EDA book. Use his smooth algorithms to split the time series into a smooth and a rough. The smooth acts acts as a reference level and the rough is how far the data is away from the reference level. Then apply Tukey outlier detection methods from box plots on the rough data to identify when the data is too far away from the smooth. I use various different versions of smooth and then combine these to give a result. You do not have to use the multiples Tukey recommends for outliers or far out values, you can use multiples that make sense for your data. | Time series anomaly detection
An approach I can recommend is to use Tukeys methods from his EDA book. Use his smooth algorithms to split the time series into a smooth and a rough. The smooth acts acts as a reference level and the |
37,515 | Does there exist zero-inflated linear regression? | I have found 2 references so far using zero-inflated normal regression, one in medical research and the other in animal conservation:
Semiparametric zero-inflated modeling in multi-ethnic study of atherosclerosis (mesa): note that they use $\log(y+1)$-transform: $f(y) = \log(y+1)$ , so it could be problematic (e.g., here and here).
A drop in immigration results in the extinction of a local woodchat shrike population: it looks like Bayesian models.
Both the response variables, Agatston scores of CAC and the number of fledglings of brood, are probably non-negative, however. | Does there exist zero-inflated linear regression? | I have found 2 references so far using zero-inflated normal regression, one in medical research and the other in animal conservation:
Semiparametric zero-inflated modeling in multi-ethnic study of at | Does there exist zero-inflated linear regression?
I have found 2 references so far using zero-inflated normal regression, one in medical research and the other in animal conservation:
Semiparametric zero-inflated modeling in multi-ethnic study of atherosclerosis (mesa): note that they use $\log(y+1)$-transform: $f(y) = \log(y+1)$ , so it could be problematic (e.g., here and here).
A drop in immigration results in the extinction of a local woodchat shrike population: it looks like Bayesian models.
Both the response variables, Agatston scores of CAC and the number of fledglings of brood, are probably non-negative, however. | Does there exist zero-inflated linear regression?
I have found 2 references so far using zero-inflated normal regression, one in medical research and the other in animal conservation:
Semiparametric zero-inflated modeling in multi-ethnic study of at |
37,516 | Calculating the polynomial features after or before centering the data? | If the polynomial fit contains intercept, it will take account the centering job. If not, it is good to center data before passing it to the model.
Here is a demo in R, where red line is the model without intercept.
set.seed(3)
x=runif(10)+3
y=runif(10)
fit1=lm(y~poly(x,2))
plot(x,y,ylim=c(0,1))
lines(seq(-5,5,0.01),predict(fit1,data.frame(x=seq(-5,5,0.01))))
fit2=lm(y~poly(x,2)-1)
lines(seq(-5,5,0.01),predict(fit2,data.frame(x=seq(-5,5,0.01))),col=2)
In addition if you use orthogonal polynomials not only it centers for you, but also numerically stable.
Here is the demo
> set.seed(0)
> x=runif(100)
> colMeans(poly(x,2,raw=F))
1 2
3.971433e-18 -4.330303e-18
> colMeans(poly(x,2,raw=T))
1 2
0.5207647 0.3434324 | Calculating the polynomial features after or before centering the data? | If the polynomial fit contains intercept, it will take account the centering job. If not, it is good to center data before passing it to the model.
Here is a demo in R, where red line is the model wit | Calculating the polynomial features after or before centering the data?
If the polynomial fit contains intercept, it will take account the centering job. If not, it is good to center data before passing it to the model.
Here is a demo in R, where red line is the model without intercept.
set.seed(3)
x=runif(10)+3
y=runif(10)
fit1=lm(y~poly(x,2))
plot(x,y,ylim=c(0,1))
lines(seq(-5,5,0.01),predict(fit1,data.frame(x=seq(-5,5,0.01))))
fit2=lm(y~poly(x,2)-1)
lines(seq(-5,5,0.01),predict(fit2,data.frame(x=seq(-5,5,0.01))),col=2)
In addition if you use orthogonal polynomials not only it centers for you, but also numerically stable.
Here is the demo
> set.seed(0)
> x=runif(100)
> colMeans(poly(x,2,raw=F))
1 2
3.971433e-18 -4.330303e-18
> colMeans(poly(x,2,raw=T))
1 2
0.5207647 0.3434324 | Calculating the polynomial features after or before centering the data?
If the polynomial fit contains intercept, it will take account the centering job. If not, it is good to center data before passing it to the model.
Here is a demo in R, where red line is the model wit |
37,517 | What's the intuition behind Velicer's minimum average partial (MAP) test? | I think the intuition behind MAP can be grasped by looking at the formula of partial correlation, included in Velicer (1976) paper (equation 11), which I also write here for convenience:
$$r_{ij.y} = \frac{r_{ij}-r_{iy}r_{jy}}{((1-r_{iy}^2)(1-r_{jy}^2))^{1/2}}$$
At the numerator you have the partial covariance between each pair of variables $i$ and $j$; this number will go down as you partial out more components, since you are removing systematic variance. You divide this number to get a normalization, pretty much like you divide covariance by the product of the standard deviations in order to have a correlation coefficient that has value between -1 and +1. This denominator contains the two correlation terms between each of the two variables and the component $y$ that you are removing. These correlation terms will go up as you keep removing components, since components will contain more and more individual variability/noise. This makes the denominator as a whole to go down.
So, both the numerator and the denominator go down as you remove more components, the former because partial covariance goes down since you are removing common/systematic variability, the latter because components catch more and more individual variability.
Now, it comes a point at which the denominator starts decreasing faster than the numerator, because you are removing more individual variability than systematic variability in the data. This makes the partial correlation go up. The MAP criterion computes the average of the partial correlations, and tells you to stop when the average partial correlation stops going down and starts going up, i.e. when you are starting the remove more individual variability than common variability in the data. | What's the intuition behind Velicer's minimum average partial (MAP) test? | I think the intuition behind MAP can be grasped by looking at the formula of partial correlation, included in Velicer (1976) paper (equation 11), which I also write here for convenience:
$$r_{ij.y} = | What's the intuition behind Velicer's minimum average partial (MAP) test?
I think the intuition behind MAP can be grasped by looking at the formula of partial correlation, included in Velicer (1976) paper (equation 11), which I also write here for convenience:
$$r_{ij.y} = \frac{r_{ij}-r_{iy}r_{jy}}{((1-r_{iy}^2)(1-r_{jy}^2))^{1/2}}$$
At the numerator you have the partial covariance between each pair of variables $i$ and $j$; this number will go down as you partial out more components, since you are removing systematic variance. You divide this number to get a normalization, pretty much like you divide covariance by the product of the standard deviations in order to have a correlation coefficient that has value between -1 and +1. This denominator contains the two correlation terms between each of the two variables and the component $y$ that you are removing. These correlation terms will go up as you keep removing components, since components will contain more and more individual variability/noise. This makes the denominator as a whole to go down.
So, both the numerator and the denominator go down as you remove more components, the former because partial covariance goes down since you are removing common/systematic variability, the latter because components catch more and more individual variability.
Now, it comes a point at which the denominator starts decreasing faster than the numerator, because you are removing more individual variability than systematic variability in the data. This makes the partial correlation go up. The MAP criterion computes the average of the partial correlations, and tells you to stop when the average partial correlation stops going down and starts going up, i.e. when you are starting the remove more individual variability than common variability in the data. | What's the intuition behind Velicer's minimum average partial (MAP) test?
I think the intuition behind MAP can be grasped by looking at the formula of partial correlation, included in Velicer (1976) paper (equation 11), which I also write here for convenience:
$$r_{ij.y} = |
37,518 | Generalized Linear Models - What's special about the exponential family? | Jaynes makes the argument that when you leave the exponential family, your estimators cease to be sufficient statistics. If a statistic is sufficient for a parameter then $\Pr(t|\theta)=\Pr(X|\theta)$. Implying that the information in $t$ is the same as in the sample $X$. Bayesian methods always use all the information in $X$. Non-Bayesian methods use a statistic. If that statistic contains the same information then the estimator will be no worse.
If the statistic is not sufficient, then it will be noisier than the Bayesian estimate. Bayesian estimators are always admissible statistics. If the distribution is not in the exponential family, then the Bayesian estimator will stochastically dominate it, hence the estimator will be inadmissible.
So if you do not make such an assumption, then you would be better off using a Bayesian model in all circumstances. If that were the case, why would you use an alternative? | Generalized Linear Models - What's special about the exponential family? | Jaynes makes the argument that when you leave the exponential family, your estimators cease to be sufficient statistics. If a statistic is sufficient for a parameter then $\Pr(t|\theta)=\Pr(X|\theta) | Generalized Linear Models - What's special about the exponential family?
Jaynes makes the argument that when you leave the exponential family, your estimators cease to be sufficient statistics. If a statistic is sufficient for a parameter then $\Pr(t|\theta)=\Pr(X|\theta)$. Implying that the information in $t$ is the same as in the sample $X$. Bayesian methods always use all the information in $X$. Non-Bayesian methods use a statistic. If that statistic contains the same information then the estimator will be no worse.
If the statistic is not sufficient, then it will be noisier than the Bayesian estimate. Bayesian estimators are always admissible statistics. If the distribution is not in the exponential family, then the Bayesian estimator will stochastically dominate it, hence the estimator will be inadmissible.
So if you do not make such an assumption, then you would be better off using a Bayesian model in all circumstances. If that were the case, why would you use an alternative? | Generalized Linear Models - What's special about the exponential family?
Jaynes makes the argument that when you leave the exponential family, your estimators cease to be sufficient statistics. If a statistic is sufficient for a parameter then $\Pr(t|\theta)=\Pr(X|\theta) |
37,519 | Doubts on the derivation of Gaussian Process Regression equations in a paper | If we fix $\mathbf{f}$, then all uncertainty in $\mathbf{y}$ comes from noise. So for equation (5) in the article we have that given $\mathbf{f}$ we have at each point independent noise with variance $\sigma_{noise}^2$ and mean zero $0$. We add initial mean and get the answer.
One way to prove the suggested equality
$$
p(\mathbf{y} | \mathbf{f}, \mathbf{f}^*) = p(\mathbf{y} | \mathbf{f})
$$
is to find the distribution at the left hand side and at the right hand side of the quality. Both of them are Gaussian, for the left side we already know the answer. For the right hand side we proceed in a similar way. Let us find the conditional distribution for $(\mathbf{y}, \mathbf{y}^*)$. From the result from the first part we know:
$$
p(\mathbf{y}, \mathbf{y}^* | \mathbf{f}, \mathbf{f}^*) = \mathcal{N}((\mathbf{f}, \mathbf{f}^*), \sigma^2_{noise} I).
$$
Using probability rules it is easy to integrate out $\mathbf{y}^*$ from $(\mathbf{y}, \mathbf{y}^*)$, as the covariance matrix is diagonal, and vectors $\mathbf{y}$ and $\mathbf{y}^*$ are independent. By doing this we get:
$$
p(\mathbf{y} | \mathbf{f}, \mathbf{f}^*) = \mathcal{N}(\mathbf{f}, \sigma^2_{noise} I) = p(\mathbf{y} | \mathbf{f}).
$$ | Doubts on the derivation of Gaussian Process Regression equations in a paper | If we fix $\mathbf{f}$, then all uncertainty in $\mathbf{y}$ comes from noise. So for equation (5) in the article we have that given $\mathbf{f}$ we have at each point independent noise with variance | Doubts on the derivation of Gaussian Process Regression equations in a paper
If we fix $\mathbf{f}$, then all uncertainty in $\mathbf{y}$ comes from noise. So for equation (5) in the article we have that given $\mathbf{f}$ we have at each point independent noise with variance $\sigma_{noise}^2$ and mean zero $0$. We add initial mean and get the answer.
One way to prove the suggested equality
$$
p(\mathbf{y} | \mathbf{f}, \mathbf{f}^*) = p(\mathbf{y} | \mathbf{f})
$$
is to find the distribution at the left hand side and at the right hand side of the quality. Both of them are Gaussian, for the left side we already know the answer. For the right hand side we proceed in a similar way. Let us find the conditional distribution for $(\mathbf{y}, \mathbf{y}^*)$. From the result from the first part we know:
$$
p(\mathbf{y}, \mathbf{y}^* | \mathbf{f}, \mathbf{f}^*) = \mathcal{N}((\mathbf{f}, \mathbf{f}^*), \sigma^2_{noise} I).
$$
Using probability rules it is easy to integrate out $\mathbf{y}^*$ from $(\mathbf{y}, \mathbf{y}^*)$, as the covariance matrix is diagonal, and vectors $\mathbf{y}$ and $\mathbf{y}^*$ are independent. By doing this we get:
$$
p(\mathbf{y} | \mathbf{f}, \mathbf{f}^*) = \mathcal{N}(\mathbf{f}, \sigma^2_{noise} I) = p(\mathbf{y} | \mathbf{f}).
$$ | Doubts on the derivation of Gaussian Process Regression equations in a paper
If we fix $\mathbf{f}$, then all uncertainty in $\mathbf{y}$ comes from noise. So for equation (5) in the article we have that given $\mathbf{f}$ we have at each point independent noise with variance |
37,520 | Bootstrap to test differences between correlation coefficients | I think in your case it is best to use a permutation test in which you compute a permuted correlation for each condition and then take their difference. For instance, you can concatenate row-wise your two variables under condition A and those under condition B, so you end up with a matrix (20*2 $\times$ 2). Then you permute across this 40 rows and get the p-value, as explained by the following R code:
# fix the # permutations
nperm <- 5000 # needs to be large enough but depends on the samp. size
# set a void vector for the dif of correl.
cor.dif <- rep(NA, nperm)
# simulate some fake data
n1 <- n2 <- 10
x1a <- runif(n1)
x2a <- rnorm(n2)
x1b <- rnorm(n1)
x2b <- runif(n2)
X1 <- cbind(x1a, x2a) # the two measurements in cond. A
X2 <- cbind(x1b, x2b) # the two measurements in cond. B
# concatenate row-wise X1 and X2
X <- rbind(X1, X2) # this is the matrix of 20*2 x 2
# now start permuting
for(i in 1:nperm){
# sample an index
idx <- sample(na+nb,na, replace = FALSE)
# calculate the permuted correlation in the first condition
cor.1 <- cor(X[idx,1],X[idx,2])
# calculate the permuted correlation in the second condition
cor.2 <- cor(X[-ida,1],X[-idx,2])
# store the dif. of correlations
cor.dif[i] <- cor.1-cor.2
}
# compute the empirical/actual difference of correlations
emp.cor.dif <- cor(x1a, x2a)-cor(x1a, x2a)
# see at the plot
hist(cor.dif)
abline(v = emp.cor.dif)
# compute the Monte Carlo approximation of the permutation p-value
2*min(mean(cor.dif>emp.cor.dif), mean(cor.dif<emp.cor.dif)) | Bootstrap to test differences between correlation coefficients | I think in your case it is best to use a permutation test in which you compute a permuted correlation for each condition and then take their difference. For instance, you can concatenate row-wise your | Bootstrap to test differences between correlation coefficients
I think in your case it is best to use a permutation test in which you compute a permuted correlation for each condition and then take their difference. For instance, you can concatenate row-wise your two variables under condition A and those under condition B, so you end up with a matrix (20*2 $\times$ 2). Then you permute across this 40 rows and get the p-value, as explained by the following R code:
# fix the # permutations
nperm <- 5000 # needs to be large enough but depends on the samp. size
# set a void vector for the dif of correl.
cor.dif <- rep(NA, nperm)
# simulate some fake data
n1 <- n2 <- 10
x1a <- runif(n1)
x2a <- rnorm(n2)
x1b <- rnorm(n1)
x2b <- runif(n2)
X1 <- cbind(x1a, x2a) # the two measurements in cond. A
X2 <- cbind(x1b, x2b) # the two measurements in cond. B
# concatenate row-wise X1 and X2
X <- rbind(X1, X2) # this is the matrix of 20*2 x 2
# now start permuting
for(i in 1:nperm){
# sample an index
idx <- sample(na+nb,na, replace = FALSE)
# calculate the permuted correlation in the first condition
cor.1 <- cor(X[idx,1],X[idx,2])
# calculate the permuted correlation in the second condition
cor.2 <- cor(X[-ida,1],X[-idx,2])
# store the dif. of correlations
cor.dif[i] <- cor.1-cor.2
}
# compute the empirical/actual difference of correlations
emp.cor.dif <- cor(x1a, x2a)-cor(x1a, x2a)
# see at the plot
hist(cor.dif)
abline(v = emp.cor.dif)
# compute the Monte Carlo approximation of the permutation p-value
2*min(mean(cor.dif>emp.cor.dif), mean(cor.dif<emp.cor.dif)) | Bootstrap to test differences between correlation coefficients
I think in your case it is best to use a permutation test in which you compute a permuted correlation for each condition and then take their difference. For instance, you can concatenate row-wise your |
37,521 | Bootstrap to test differences between correlation coefficients | If you are testing the effect of behavioral parameter on neuro-physiological parameter on two different condition. you can test whether interaction of two different condition and behavioral on neuro-physiological. If the addition of interaction term is significant, you can say that neuro-physiological values are associated with two different condition. | Bootstrap to test differences between correlation coefficients | If you are testing the effect of behavioral parameter on neuro-physiological parameter on two different condition. you can test whether interaction of two different condition and behavioral on neuro-p | Bootstrap to test differences between correlation coefficients
If you are testing the effect of behavioral parameter on neuro-physiological parameter on two different condition. you can test whether interaction of two different condition and behavioral on neuro-physiological. If the addition of interaction term is significant, you can say that neuro-physiological values are associated with two different condition. | Bootstrap to test differences between correlation coefficients
If you are testing the effect of behavioral parameter on neuro-physiological parameter on two different condition. you can test whether interaction of two different condition and behavioral on neuro-p |
37,522 | Simulating the posterior of a Gaussian process | When given a test set, $e$, the expected values will be calculated considering a conditional distribution of the value of the function for these new data points, given the data points in the training set, $a$. The idea exposed in the video is that we would have a joint distribution of $a$ and $e$ (in the lecture denoted by an asterisk, $*$) of the form:
$${\bf\begin{bmatrix} a\\ \bf e\end{bmatrix}}\sim \mathscr N\left( \begin{bmatrix}\bf \mu_a\\\mu_e \end{bmatrix}\,,\begin{bmatrix}\bf \Sigma_{aa}&\bf \Sigma_{ae} \\ {\bf \Sigma_{ae}}^T & \bf \Sigma_{ee}\end{bmatrix}\right)$$.
The conditional of a multivariate Gaussian distribution has a mean $E({\bf x}_1 | {\bf x}_2)= {\boldsymbol \mu}_1 + \Sigma_{12} \Sigma^{-1}_{22} ({\bf x}_2- {\boldsymbol \mu}_2)$. Now, considering that the first row of the block matrix of covariances above is $[50 \times 50]$ for $\bf \Sigma_{aa}$, but only $[50 \times 5]$ for $\bf \Sigma_{ae}$, a transposed will be necessary to make the matrices congruous in:
$$E ({\bf e\vert a}) = {\bf \mu_e} + {\bf \Sigma_{ae}}^T {\bf \Sigma_{aa}}^{-1}\,\left ({\bf y}-{\bf \mu_{a}}\right)$$
Because the model is planned with ${\bf \mu_{a}} = {\bf \mu_{e}}=0$, the formula simplifies nicely into:
$$E ({\bf e\vert a}) = {\bf \Sigma_{ae}}^T {\bf \Sigma_{aa}}^{-1}\,{\bf y_{tr}}$$
Enter the Cholesky decomposition (which again I will code in orange as in OP):
\begin{align*}
E ({\bf e\vert a}) &= {\bf \Sigma_{ae}}^T\,\, \,\underset{\color{gray}{<--\alpha-->}}{{\bf \Sigma_{aa}}^{-1}\,{\bf y_{tr}}}\\
&={\bf \Sigma_{ae}}^T {\bf \color{orange}{(L_{aa}L_{aa}^T)}}^{-1}\,{\bf y_{tr}}\\
&= {\bf \Sigma_{ae}}^T {\bf \color{orange}{L_{aa}^{-T}L_{aa}^{-1}}}\,{\bf y_{tr}}\\
&= {\bf \Sigma_{ae}}^T {\bf \color{orange}{L_{aa}^{-T}}\,\,\,\,\,\, \underset {\color{gray}{ <-m->}}{\color{orange}{L_{aa}^{-1}}{\bf y_{tr}}}} \tag {*}
\end{align*}
If $\bf m =\color{orange}{{\bf L_{aa}}^{-1}}\,{\bf y_{tr}}$, then $\color{orange}{\bf L_{aa}} \bf m= {\bf y_{tr}}$, and we end up with a linear system that we can solve, obtaining $\bf m$. Here is the key slide in the original presentation:
Since $\bf B^T A^T = (A\,B)^T$, Eq. (*) is equivalent to Eq.(1) equation in the OP:
\begin{align}
{\bf \hat \mu}&={\bf \left [ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right ]^T \, \underset{\color{blue}{[5 \times 5]}}{\color{orange}{L_{aa}}^{-1}} \, \underset{\color{blue}{[5 \times 1]}}{y_{tr}}}\\
&=\bf \left( \Sigma_{ae}^T \color{orange}{ L_{aa}^{-T}} \right) \left(\color{orange}{ L_{aa}^{-1}}\, y_{tr} \right)\\
&\text{dimensions} = \color{red}{\left[50 \times 1\right]}
\end{align}
given that
$$\bf \left [ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right ]^T =
\underset{\color{blue}{[50 \times 5]}}{\Sigma_{ae}}^T
\underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1T}}\, \, \, $$
Similar reasoning would be applied to the variance, starting with the formula for the conditional variance in a multivariate Gaussian:
$${\rm var}({\bf x}_1|{\bf x}_2)= \Sigma_{11} -\Sigma_{12}\Sigma^{-1}_{22}\Sigma_{21}$$
which in our case would be:
\begin{align*}
\bf \text{var}_{\hat\mu_{\bf e}} &= \bf \Sigma_{ee} - \Sigma_{ae}^T\Sigma_{aa}^{-1}\Sigma_{ae}\\
&= \bf \Sigma_{ee} - \Sigma_{ae}^T \left[ L_{aa}L_{aa}^T\right]^{-1}\Sigma_{ae}\\
&= \bf \Sigma_{ee} - \Sigma_{ae}^T \left[ L_{aa}^{-1}\right]^TL_{aa}^{-1}\Sigma_{ae}\\
&= \bf \Sigma_{ee} - \left[ L_{aa}^{-1} \Sigma_{ae}\right]^T L_{aa}^{-1}\Sigma_{ae}
\end{align*}
and arriving at Eq.(2):
\begin{align}
\text{var}_{\hat\mu_{\bf e}}&=\text{d}\left[ \bf K_{ee} - \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right]^T \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right] \right]\\
&\text{dimensions}=\color{red}{\left[50 \times 1\right]}
\end{align}
We can see that Eq.(3) in the OP is a way of generating posterior random curves conditional on the data (training set), and utilizing a Cholesky form to generate three multivariate normal random draws:
\begin{align}
f_{\text{post}} &= {\bf \hat \mu} + \left[ \text{var}_{\hat\mu_{\bf e}}\right][\text{rnorm}\sim (0,1)]\\
&=\bf \hat \mu + \left[ \underset{\color{blue}{[50 \times 50]}} {\color{orange}{L_{ee}}}\, \, \, - \left[ \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right]^T \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right] \right] \right] \left[\underset{\color{green}{[50 \times 3]}}{\text{rand.norm's}}\right]\\ &\text{dimensions}= \color{red}{\left[50 \times 3\right]}
\end{align} | Simulating the posterior of a Gaussian process | When given a test set, $e$, the expected values will be calculated considering a conditional distribution of the value of the function for these new data points, given the data points in the training | Simulating the posterior of a Gaussian process
When given a test set, $e$, the expected values will be calculated considering a conditional distribution of the value of the function for these new data points, given the data points in the training set, $a$. The idea exposed in the video is that we would have a joint distribution of $a$ and $e$ (in the lecture denoted by an asterisk, $*$) of the form:
$${\bf\begin{bmatrix} a\\ \bf e\end{bmatrix}}\sim \mathscr N\left( \begin{bmatrix}\bf \mu_a\\\mu_e \end{bmatrix}\,,\begin{bmatrix}\bf \Sigma_{aa}&\bf \Sigma_{ae} \\ {\bf \Sigma_{ae}}^T & \bf \Sigma_{ee}\end{bmatrix}\right)$$.
The conditional of a multivariate Gaussian distribution has a mean $E({\bf x}_1 | {\bf x}_2)= {\boldsymbol \mu}_1 + \Sigma_{12} \Sigma^{-1}_{22} ({\bf x}_2- {\boldsymbol \mu}_2)$. Now, considering that the first row of the block matrix of covariances above is $[50 \times 50]$ for $\bf \Sigma_{aa}$, but only $[50 \times 5]$ for $\bf \Sigma_{ae}$, a transposed will be necessary to make the matrices congruous in:
$$E ({\bf e\vert a}) = {\bf \mu_e} + {\bf \Sigma_{ae}}^T {\bf \Sigma_{aa}}^{-1}\,\left ({\bf y}-{\bf \mu_{a}}\right)$$
Because the model is planned with ${\bf \mu_{a}} = {\bf \mu_{e}}=0$, the formula simplifies nicely into:
$$E ({\bf e\vert a}) = {\bf \Sigma_{ae}}^T {\bf \Sigma_{aa}}^{-1}\,{\bf y_{tr}}$$
Enter the Cholesky decomposition (which again I will code in orange as in OP):
\begin{align*}
E ({\bf e\vert a}) &= {\bf \Sigma_{ae}}^T\,\, \,\underset{\color{gray}{<--\alpha-->}}{{\bf \Sigma_{aa}}^{-1}\,{\bf y_{tr}}}\\
&={\bf \Sigma_{ae}}^T {\bf \color{orange}{(L_{aa}L_{aa}^T)}}^{-1}\,{\bf y_{tr}}\\
&= {\bf \Sigma_{ae}}^T {\bf \color{orange}{L_{aa}^{-T}L_{aa}^{-1}}}\,{\bf y_{tr}}\\
&= {\bf \Sigma_{ae}}^T {\bf \color{orange}{L_{aa}^{-T}}\,\,\,\,\,\, \underset {\color{gray}{ <-m->}}{\color{orange}{L_{aa}^{-1}}{\bf y_{tr}}}} \tag {*}
\end{align*}
If $\bf m =\color{orange}{{\bf L_{aa}}^{-1}}\,{\bf y_{tr}}$, then $\color{orange}{\bf L_{aa}} \bf m= {\bf y_{tr}}$, and we end up with a linear system that we can solve, obtaining $\bf m$. Here is the key slide in the original presentation:
Since $\bf B^T A^T = (A\,B)^T$, Eq. (*) is equivalent to Eq.(1) equation in the OP:
\begin{align}
{\bf \hat \mu}&={\bf \left [ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right ]^T \, \underset{\color{blue}{[5 \times 5]}}{\color{orange}{L_{aa}}^{-1}} \, \underset{\color{blue}{[5 \times 1]}}{y_{tr}}}\\
&=\bf \left( \Sigma_{ae}^T \color{orange}{ L_{aa}^{-T}} \right) \left(\color{orange}{ L_{aa}^{-1}}\, y_{tr} \right)\\
&\text{dimensions} = \color{red}{\left[50 \times 1\right]}
\end{align}
given that
$$\bf \left [ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right ]^T =
\underset{\color{blue}{[50 \times 5]}}{\Sigma_{ae}}^T
\underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1T}}\, \, \, $$
Similar reasoning would be applied to the variance, starting with the formula for the conditional variance in a multivariate Gaussian:
$${\rm var}({\bf x}_1|{\bf x}_2)= \Sigma_{11} -\Sigma_{12}\Sigma^{-1}_{22}\Sigma_{21}$$
which in our case would be:
\begin{align*}
\bf \text{var}_{\hat\mu_{\bf e}} &= \bf \Sigma_{ee} - \Sigma_{ae}^T\Sigma_{aa}^{-1}\Sigma_{ae}\\
&= \bf \Sigma_{ee} - \Sigma_{ae}^T \left[ L_{aa}L_{aa}^T\right]^{-1}\Sigma_{ae}\\
&= \bf \Sigma_{ee} - \Sigma_{ae}^T \left[ L_{aa}^{-1}\right]^TL_{aa}^{-1}\Sigma_{ae}\\
&= \bf \Sigma_{ee} - \left[ L_{aa}^{-1} \Sigma_{ae}\right]^T L_{aa}^{-1}\Sigma_{ae}
\end{align*}
and arriving at Eq.(2):
\begin{align}
\text{var}_{\hat\mu_{\bf e}}&=\text{d}\left[ \bf K_{ee} - \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right]^T \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right] \right]\\
&\text{dimensions}=\color{red}{\left[50 \times 1\right]}
\end{align}
We can see that Eq.(3) in the OP is a way of generating posterior random curves conditional on the data (training set), and utilizing a Cholesky form to generate three multivariate normal random draws:
\begin{align}
f_{\text{post}} &= {\bf \hat \mu} + \left[ \text{var}_{\hat\mu_{\bf e}}\right][\text{rnorm}\sim (0,1)]\\
&=\bf \hat \mu + \left[ \underset{\color{blue}{[50 \times 50]}} {\color{orange}{L_{ee}}}\, \, \, - \left[ \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right]^T \left[ \underset{\color{blue}{[5 \times 5]}} {\color{orange}{L_{aa}}^{-1}}\, \, \, \underset{\color{blue}{[5 \times 50]}}{\Sigma_{ae}} \right] \right] \right] \left[\underset{\color{green}{[50 \times 3]}}{\text{rand.norm's}}\right]\\ &\text{dimensions}= \color{red}{\left[50 \times 3\right]}
\end{align} | Simulating the posterior of a Gaussian process
When given a test set, $e$, the expected values will be calculated considering a conditional distribution of the value of the function for these new data points, given the data points in the training |
37,523 | Noninferiority Using Logistic Regression | No. The exponentiation of the coefficients of logistic regression yields odds ratios. So you have to compare the confidence interval (CI) for the odds ratio to 1. If the outcome in the regression is adverse events count, then the upper side of the CI has to be less than 1.05 to imply noninferiority.
However, the common practice seems to impose noninferiority bounds not on the odds ratio, but on the difference of two proportions. For instance, if we wish that the two proportions' difference does not exceed 15%, then the noninfriority bound on the odds ratio will be 0.55 (or 1/0.55). See
Tunes da Silva G, Logan BR, Klein JP. Methods for equivalence and noninferiority testing. Biol Blood Marrow Transplant. 2009;15(1 Suppl):120‐127. doi:10.1016/j.bbmt.2008.10.004
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2701110/
Analogously, for the Cox regression, noninferiority bound 10% for difference of survival probabilities yields the upper bound 1.31 for exponentiated coefficients of the regression. See the mentioned paper.
Althunian et al. write:
"There are several applications of the margin in the analysis of
noninferiority trials, but the recommended approach by regulators,
such as the US Food and Drug Administration (FDA), is to compare the
estimated 95% confidence interval (CI) of the new drug vs. the active
comparator from the noninferiority trial to a predefined margin. If
the CI lies entirely below the margin (e.g. for effect measures where
the larger the effect the worse the outcome), noninferiority of the
new drug to the active comparator can be concluded."
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5510081/
Some authors suggest using 90% CI instead of 95% CI. E.g., see the mentioned paper by Tunes da Silva et al. or
https://www.ncss.com/wp-content/themes/ncss/pdf/Procedures/NCSS/Two-Sample_Non-Inferiority_Tests_for_Survival_Data_using_Cox_Regression.pdf
That corresponds to one-sided test with $\alpha=5\%$. But many methodologists support using $\alpha=2.5\%$ for one-sided tests. | Noninferiority Using Logistic Regression | No. The exponentiation of the coefficients of logistic regression yields odds ratios. So you have to compare the confidence interval (CI) for the odds ratio to 1. If the outcome in the regression is a | Noninferiority Using Logistic Regression
No. The exponentiation of the coefficients of logistic regression yields odds ratios. So you have to compare the confidence interval (CI) for the odds ratio to 1. If the outcome in the regression is adverse events count, then the upper side of the CI has to be less than 1.05 to imply noninferiority.
However, the common practice seems to impose noninferiority bounds not on the odds ratio, but on the difference of two proportions. For instance, if we wish that the two proportions' difference does not exceed 15%, then the noninfriority bound on the odds ratio will be 0.55 (or 1/0.55). See
Tunes da Silva G, Logan BR, Klein JP. Methods for equivalence and noninferiority testing. Biol Blood Marrow Transplant. 2009;15(1 Suppl):120‐127. doi:10.1016/j.bbmt.2008.10.004
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2701110/
Analogously, for the Cox regression, noninferiority bound 10% for difference of survival probabilities yields the upper bound 1.31 for exponentiated coefficients of the regression. See the mentioned paper.
Althunian et al. write:
"There are several applications of the margin in the analysis of
noninferiority trials, but the recommended approach by regulators,
such as the US Food and Drug Administration (FDA), is to compare the
estimated 95% confidence interval (CI) of the new drug vs. the active
comparator from the noninferiority trial to a predefined margin. If
the CI lies entirely below the margin (e.g. for effect measures where
the larger the effect the worse the outcome), noninferiority of the
new drug to the active comparator can be concluded."
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5510081/
Some authors suggest using 90% CI instead of 95% CI. E.g., see the mentioned paper by Tunes da Silva et al. or
https://www.ncss.com/wp-content/themes/ncss/pdf/Procedures/NCSS/Two-Sample_Non-Inferiority_Tests_for_Survival_Data_using_Cox_Regression.pdf
That corresponds to one-sided test with $\alpha=5\%$. But many methodologists support using $\alpha=2.5\%$ for one-sided tests. | Noninferiority Using Logistic Regression
No. The exponentiation of the coefficients of logistic regression yields odds ratios. So you have to compare the confidence interval (CI) for the odds ratio to 1. If the outcome in the regression is a |
37,524 | Alternative to chi-square where independence assumption is broken | I would try to model this using multivariate logistic regression. This can probably be fit in R with lme4::glmer, some information is at Fitting multivariate linear mixed model in R, follow the links and references therein!
This would need a random intercept for each respondent, shared among the 12 logistic regression, so would really be a multivariate model. | Alternative to chi-square where independence assumption is broken | I would try to model this using multivariate logistic regression. This can probably be fit in R with lme4::glmer, some information is at Fitting multivariate linear mixed model in R, follow the links | Alternative to chi-square where independence assumption is broken
I would try to model this using multivariate logistic regression. This can probably be fit in R with lme4::glmer, some information is at Fitting multivariate linear mixed model in R, follow the links and references therein!
This would need a random intercept for each respondent, shared among the 12 logistic regression, so would really be a multivariate model. | Alternative to chi-square where independence assumption is broken
I would try to model this using multivariate logistic regression. This can probably be fit in R with lme4::glmer, some information is at Fitting multivariate linear mixed model in R, follow the links |
37,525 | Why does scipy.stats.anderson_ksamp give a p-value of over a million for these data? [closed] | February 27, 2022 update for someone who may encounter the same issue and find this post:
Note: This answer is intended to point to a scipy bug when the question was originally asked on Jul 25, 2016. This bug led to p-values greater than 1 and was fixed in this commit and looks like scipy versions scipy>=1.2.0 are not impacted by this. Code examples and outputs are available here for reproducibility. Following are tested on Python 3.9.9 and scipy==1.8.0
The first code chunk:
from scipy.stats import anderson_ksamp
a = [-1.8, -2.4, -2.4, -0.0, -1.5, -2.7, -1.8, -3.0, -1.8, -1.2, -3.0,
-3.0, -2.8, -3.0, -2.1, -0.0, 0.6, -2.5, -2.4, -0.0, -2.7, -0.0,
-2.5, -2.1, -0.9, -3.0, -0.6, -0.6, -1.5, -2.2, -1.2, -2.4, -2.4,
-3.0, 1.5, -1.8, 1.5, -2.7, -3.0, -2.5, -2.5, -1.5, -1.5, -2.1,
-2.1, -3.0, -0.6, -2.7, -3.0, -1.5, -0.6, -0.0, -2.1, 0.6, -2.0,
-3.0, -3.0, -2.4, -3.0, -1.8, -0.0, -0.0, -3.0, -1.5, -3.0, -3.0,
-1.5, -2.5, -3.0, -2.8, -3.0, -2.2, -0.6, -0.0, -1.5, -2.7, -2.1,
-2.1, -2.2, -2.1, -0.6, -0.0, -2.5, -2.1, -1.5, -3.0, -2.2, -1.8,
-2.7, -2.4, -1.5, -2.1, -2.9, -2.4, -0.9, -0.0, -0.0, -2.4, -2.7,
-0.6, -2.2, -3.0, -1.5, -0.9, -3.0, -3.0, -0.0, -2.7, -2.7, -1.5,
-2.2, -3.0, -0.0, 1.5, -3.0, -2.7, -2.2, -2.9, -2.2, -3.0, -1.8,
-0.0, -3.0, -1.5, -2.7, -3.0, -3.0, -2.9, -3.0, -3.0, -3.0, -3.0,
-2.5, -0.0, 0.9, -3.0, -0.0, -3.0, 3.0, -3.0, -3.0, -1.2, -2.1,
1.5, -0.0, -0.9, -3.0, -2.7, -1.5, -2.4, -2.1, -3.0, -0.9, -3.0,
-0.8, -1.5, -2.1, -2.7, -0.0, -0.0, -2.2, -1.8, -2.1, -2.2, -3.0,
0.6, -2.4, -2.2, -2.4, -2.5, -1.5, -0.0, -2.7, -3.0, -3.0, -2.1,
-0.0, -2.4, -2.4, -0.0, -2.0, -0.9, -2.4, -3.0, -1.4, -2.7, -2.7,
-3.0, -3.0, -2.7, -1.2, -2.1, -3.0, -0.0, -3.0, -2.7, -2.7, -3.0,
-3.0, -2.5, -3.0, -1.8, -1.5, -2.7, -2.4, -1.8, -3.0, -2.7, 2.1,
-3.0, -2.2, -2.2, 0.6, -0.9, 6.0, -3.0, -2.1, -3.0, -2.1, -2.5,
-3.0, -1.5, -2.5, 3.0, -2.1, -3.0, -3.0, -1.5, -2.1, -2.7, -2.5,
1.5, -2.1, -0.0, -0.0, -3.0, -0.6, 1.5, -2.7, -2.4, -2.1, -3.0,
-2.7, -3.0, 9.0, -3.0, -1.7, -3.0, -0.0, -3.0, -2.2, -0.0, -0.6,
-2.7, -2.7, -3.0, -3.0, -1.7, -2.1, -2.0, -3.0, -2.1, -3.0, -1.1,
-3.0, -3.0, -2.4, -1.5, -3.0, -2.2, -3.0, -1.5, -2.7, -3.0, -3.0,
-3.0, -2.2, -3.0, -2.1, -2.1, -2.4, -3.0, -3.0, -0.0, -3.0, -3.0,
-2.1, -2.0, 1.5, -3.0, -3.0, -2.1, -2.9, -2.4, -3.0, -3.0, -1.5,
-2.2, -0.9, -1.8, -2.1, -1.8, -1.5, -3.0, -1.5, -3.0, -1.5, -3.0,
-2.4, 1.5, -2.7, -3.0, -1.8, -1.8, -1.5, -2.1, -2.7, -2.7, -2.7,
-3.0, -1.5, -2.7, -3.0, -2.7, -3.0, -1.5, -1.5, -3.0, 0.6, -0.6,
-3.0, -2.1, -2.4, -2.1, -3.0, -2.2, -3.0, -1.8, -1.2, -3.0, -0.8,
-2.4, -2.5, -3.0, -1.5, -1.2, -0.0, -2.7, -2.4, -3.0, -3.0, -2.1,
-2.1, -2.1, -3.0, -2.7, -2.4, -2.1, -1.5, -2.1, -0.6, -3.0, -3.0,
-3.0, -3.0]
b = [-1.2, 6.0, -3.0, 1.5, 12.0, 1.5, 3.0, -0.0, -1.5, -0.0, 6.0,
-0.0, 1.8, -1.5, -3.0, -3.0, 1.5, -0.0, 1.5, -3.0, -3.0, -0.0,
-1.2, -3.0, 22.5, -0.0, -3.0, -3.0, -2.1, 3.0, 2.4, 1.5, -2.1,
4.5, -3.0, -3.0, 12.0, 6.0, -3.0, 3.0, -3.0, 12.0, -2.8, 0.6,
4.5, 3.0, -0.0, -3.0, -1.0, -3.0, -0.0, 3.0, 2.1, -0.6, -3.0,
-3.0, 1.5, 1.5, -0.6, -0.0, 1.5, 6.0, -2.2, -2.1, -0.0, -0.8,
6.0, -3.0, -3.0, 9.0, -3.0, -0.9, 15.0, 1.5, -2.9, 19.5, 4.5,
-3.0, 1.5, -1.8, 1.5, 0.9, -3.0, -3.0, 9.0, -0.3, 9.0, -2.1,
-2.2, -3.0, 12.0, -2.1, -1.2, -3.0, 4.5, -1.2, -0.0, 12.0, -0.9,
-3.0, -0.6, -3.0, -1.5, -0.0, 27.0, 4.5, -2.4, -2.7, -0.0, 3.0,
1.5, 3.0, -3.0, 16.5, -2.1, -0.6, -3.0, -1.5, -1.2, -3.0, 4.4,
-2.5, -2.1, 3.0, -1.2, -3.0, 12.0, -1.8, -0.9, -3.0, -3.0, -0.0,
-3.0, -1.2, -3.0, -3.0, -0.0, 1.5, -3.0, 7.5, -3.0, -2.1, 3.0,
1.5, 3.0, -3.0, 1.5, -3.0, 19.5, -3.0, -2.2, 27.0, 3.0, -1.5,
-3.0, -3.0, 4.5, -1.2, 12.0, 3.0, 3.0, -2.1, 6.0, -2.2, -3.0,
-2.4, 6.0, -3.0, -1.9, -0.6, -0.0, 3.6, 15.0, -3.0, -3.0, 7.5,
-0.0, 4.5, -2.4, -3.0, -3.0, -3.0, -2.0, -3.0, -3.0, -3.0, -2.6,
3.0, -0.0, -3.0, 4.5, -1.2, -3.0, -3.0, 3.0, -3.0, 1.6, 1.5,
-3.0, -3.0, -3.0, -3.0, 3.0, -3.0, -1.5, -3.0, -1.5, 12.0, -1.5,
3.0, 9.6, -0.0, -1.8, -3.0, -2.1, -0.6, 9.0, -3.0, 19.5, -2.4,
-1.8, 15.0, -3.0, -3.0, 27.0, 7.5, 12.0, -3.0, -2.0, -3.0, 12.0,
-3.0, -3.0, 0.9, -3.0, -2.5, 12.6, -1.5, -0.6, -3.0, -3.0, -0.0,
-0.8, -3.0, 3.0, -0.0, 4.5, -3.0, -0.0, 0.6, 0.3, -2.7, -0.0,
4.5, -3.0, 3.0, -1.5, 9.0, -3.0, 1.5, -3.0, 6.0, -2.2, -0.0,
-3.0, -3.0, 3.0, -3.0, -2.7, -0.0, -3.0, 0.6, 4.5, 1.5, 1.5, 1.5,
-2.1, 7.5, -3.0, -3.0, -3.0, -2.1, -3.0, 6.0, -1.5, -2.0, -3.0,
-0.6, 6.0, -1.5, -3.0, 6.0, -3.0, 3.0, 3.0, -3.0, 7.5, -3.0,
-0.0, -3.0, -0.0, -3.0, -3.0, 0.6, -3.0, -3.0, -3.0, -3.0, -2.4,
-0.0, 1.5, 3.0, 2.1, -3.0, 3.0, 4.5, -3.0, -2.4, -3.0, -2.2, 7.5,
2.1, -3.0, -0.0, -2.0, -3.0, -3.0, -1.8, -3.0, 4.5, -1.5, -3.0,
4.5, 3.0, 15.0, 4.5, -2.1, 12.0, 6.0, 4.5, 27.0, -3.0, 3.0, 0.6,
-3.0, 0.6, -2.4, 4.5, -1.5, -2.2, 12.0, -2.0, 1.5, 9.0, -1.5,
-1.2, -2.0, 1.5, -1.2, -1.8, -3.0, -0.0, -0.0, -3.0, -0.9]
print(anderson_ksamp([a, b]))
Outputs:
Anderson_ksampResult(
statistic=53.56069633812226,
critical_values=array([0.325, 1.226, 1.961, 2.718, 3.752, 4.592, 6.546]),
significance_level=0.001
)
And generates a warning:
UserWarning: p-value floored: true value smaller than 0.001
The second code chunk:
from scipy.stats import ks_2samp
from statsmodels.distributions.empirical_distribution import ECDF
import matplotlib.pyplot as plt
import numpy as np
a = [-1.8, -2.4, -2.4, -0.0, -1.5, -2.7, -1.8, -3.0, -1.8, -1.2, -3.0,
-3.0, -2.8, -3.0, -2.1, -0.0, 0.6, -2.5, -2.4, -0.0, -2.7, -0.0,
-2.5, -2.1, -0.9, -3.0, -0.6, -0.6, -1.5, -2.2, -1.2, -2.4, -2.4,
-3.0, 1.5, -1.8, 1.5, -2.7, -3.0, -2.5, -2.5, -1.5, -1.5, -2.1,
-2.1, -3.0, -0.6, -2.7, -3.0, -1.5, -0.6, -0.0, -2.1, 0.6, -2.0,
-3.0, -3.0, -2.4, -3.0, -1.8, -0.0, -0.0, -3.0, -1.5, -3.0, -3.0,
-1.5, -2.5, -3.0, -2.8, -3.0, -2.2, -0.6, -0.0, -1.5, -2.7, -2.1,
-2.1, -2.2, -2.1, -0.6, -0.0, -2.5, -2.1, -1.5, -3.0, -2.2, -1.8,
-2.7, -2.4, -1.5, -2.1, -2.9, -2.4, -0.9, -0.0, -0.0, -2.4, -2.7,
-0.6, -2.2, -3.0, -1.5, -0.9, -3.0, -3.0, -0.0, -2.7, -2.7, -1.5,
-2.2, -3.0, -0.0, 1.5, -3.0, -2.7, -2.2, -2.9, -2.2, -3.0, -1.8,
-0.0, -3.0, -1.5, -2.7, -3.0, -3.0, -2.9, -3.0, -3.0, -3.0, -3.0,
-2.5, -0.0, 0.9, -3.0, -0.0, -3.0, 3.0, -3.0, -3.0, -1.2, -2.1,
1.5, -0.0, -0.9, -3.0, -2.7, -1.5, -2.4, -2.1, -3.0, -0.9, -3.0,
-0.8, -1.5, -2.1, -2.7, -0.0, -0.0, -2.2, -1.8, -2.1, -2.2, -3.0,
0.6, -2.4, -2.2, -2.4, -2.5, -1.5, -0.0, -2.7, -3.0, -3.0, -2.1,
-0.0, -2.4, -2.4, -0.0, -2.0, -0.9, -2.4, -3.0, -1.4, -2.7, -2.7,
-3.0, -3.0, -2.7, -1.2, -2.1, -3.0, -0.0, -3.0, -2.7, -2.7, -3.0,
-3.0, -2.5, -3.0, -1.8, -1.5, -2.7, -2.4, -1.8, -3.0, -2.7, 2.1,
-3.0, -2.2, -2.2, 0.6, -0.9, 6.0, -3.0, -2.1, -3.0, -2.1, -2.5,
-3.0, -1.5, -2.5, 3.0, -2.1, -3.0, -3.0, -1.5, -2.1, -2.7, -2.5,
1.5, -2.1, -0.0, -0.0, -3.0, -0.6, 1.5, -2.7, -2.4, -2.1, -3.0,
-2.7, -3.0, 9.0, -3.0, -1.7, -3.0, -0.0, -3.0, -2.2, -0.0, -0.6,
-2.7, -2.7, -3.0, -3.0, -1.7, -2.1, -2.0, -3.0, -2.1, -3.0, -1.1,
-3.0, -3.0, -2.4, -1.5, -3.0, -2.2, -3.0, -1.5, -2.7, -3.0, -3.0,
-3.0, -2.2, -3.0, -2.1, -2.1, -2.4, -3.0, -3.0, -0.0, -3.0, -3.0,
-2.1, -2.0, 1.5, -3.0, -3.0, -2.1, -2.9, -2.4, -3.0, -3.0, -1.5,
-2.2, -0.9, -1.8, -2.1, -1.8, -1.5, -3.0, -1.5, -3.0, -1.5, -3.0,
-2.4, 1.5, -2.7, -3.0, -1.8, -1.8, -1.5, -2.1, -2.7, -2.7, -2.7,
-3.0, -1.5, -2.7, -3.0, -2.7, -3.0, -1.5, -1.5, -3.0, 0.6, -0.6,
-3.0, -2.1, -2.4, -2.1, -3.0, -2.2, -3.0, -1.8, -1.2, -3.0, -0.8,
-2.4, -2.5, -3.0, -1.5, -1.2, -0.0, -2.7, -2.4, -3.0, -3.0, -2.1,
-2.1, -2.1, -3.0, -2.7, -2.4, -2.1, -1.5, -2.1, -0.6, -3.0, -3.0,
-3.0, -3.0]
b = [-1.2, 6.0, -3.0, 1.5, 12.0, 1.5, 3.0, -0.0, -1.5, -0.0, 6.0,
-0.0, 1.8, -1.5, -3.0, -3.0, 1.5, -0.0, 1.5, -3.0, -3.0, -0.0,
-1.2, -3.0, 22.5, -0.0, -3.0, -3.0, -2.1, 3.0, 2.4, 1.5, -2.1,
4.5, -3.0, -3.0, 12.0, 6.0, -3.0, 3.0, -3.0, 12.0, -2.8, 0.6,
4.5, 3.0, -0.0, -3.0, -1.0, -3.0, -0.0, 3.0, 2.1, -0.6, -3.0,
-3.0, 1.5, 1.5, -0.6, -0.0, 1.5, 6.0, -2.2, -2.1, -0.0, -0.8,
6.0, -3.0, -3.0, 9.0, -3.0, -0.9, 15.0, 1.5, -2.9, 19.5, 4.5,
-3.0, 1.5, -1.8, 1.5, 0.9, -3.0, -3.0, 9.0, -0.3, 9.0, -2.1,
-2.2, -3.0, 12.0, -2.1, -1.2, -3.0, 4.5, -1.2, -0.0, 12.0, -0.9,
-3.0, -0.6, -3.0, -1.5, -0.0, 27.0, 4.5, -2.4, -2.7, -0.0, 3.0,
1.5, 3.0, -3.0, 16.5, -2.1, -0.6, -3.0, -1.5, -1.2, -3.0, 4.4,
-2.5, -2.1, 3.0, -1.2, -3.0, 12.0, -1.8, -0.9, -3.0, -3.0, -0.0,
-3.0, -1.2, -3.0, -3.0, -0.0, 1.5, -3.0, 7.5, -3.0, -2.1, 3.0,
1.5, 3.0, -3.0, 1.5, -3.0, 19.5, -3.0, -2.2, 27.0, 3.0, -1.5,
-3.0, -3.0, 4.5, -1.2, 12.0, 3.0, 3.0, -2.1, 6.0, -2.2, -3.0,
-2.4, 6.0, -3.0, -1.9, -0.6, -0.0, 3.6, 15.0, -3.0, -3.0, 7.5,
-0.0, 4.5, -2.4, -3.0, -3.0, -3.0, -2.0, -3.0, -3.0, -3.0, -2.6,
3.0, -0.0, -3.0, 4.5, -1.2, -3.0, -3.0, 3.0, -3.0, 1.6, 1.5,
-3.0, -3.0, -3.0, -3.0, 3.0, -3.0, -1.5, -3.0, -1.5, 12.0, -1.5,
3.0, 9.6, -0.0, -1.8, -3.0, -2.1, -0.6, 9.0, -3.0, 19.5, -2.4,
-1.8, 15.0, -3.0, -3.0, 27.0, 7.5, 12.0, -3.0, -2.0, -3.0, 12.0,
-3.0, -3.0, 0.9, -3.0, -2.5, 12.6, -1.5, -0.6, -3.0, -3.0, -0.0,
-0.8, -3.0, 3.0, -0.0, 4.5, -3.0, -0.0, 0.6, 0.3, -2.7, -0.0,
4.5, -3.0, 3.0, -1.5, 9.0, -3.0, 1.5, -3.0, 6.0, -2.2, -0.0,
-3.0, -3.0, 3.0, -3.0, -2.7, -0.0, -3.0, 0.6, 4.5, 1.5, 1.5, 1.5,
-2.1, 7.5, -3.0, -3.0, -3.0, -2.1, -3.0, 6.0, -1.5, -2.0, -3.0,
-0.6, 6.0, -1.5, -3.0, 6.0, -3.0, 3.0, 3.0, -3.0, 7.5, -3.0,
-0.0, -3.0, -0.0, -3.0, -3.0, 0.6, -3.0, -3.0, -3.0, -3.0, -2.4,
-0.0, 1.5, 3.0, 2.1, -3.0, 3.0, 4.5, -3.0, -2.4, -3.0, -2.2, 7.5,
2.1, -3.0, -0.0, -2.0, -3.0, -3.0, -1.8, -3.0, 4.5, -1.5, -3.0,
4.5, 3.0, 15.0, 4.5, -2.1, 12.0, 6.0, 4.5, 27.0, -3.0, 3.0, 0.6,
-3.0, 0.6, -2.4, 4.5, -1.5, -2.2, 12.0, -2.0, 1.5, 9.0, -1.5,
-1.2, -2.0, 1.5, -1.2, -1.8, -3.0, -0.0, -0.0, -3.0, -0.9]
ecdf1, ecdf2 = ECDF(a), ECDF(b)
xs = np.linspace(min(a + b), max(a + b), num=10000)
plt.figure(figsize=(12, 8))
plt.plot(xs, ecdf1(xs), xs, ecdf2(xs))
plt.show()
print(ks_2samp(a, b))
Outputs:
KstestResult(statistic=0.3232876712328767, pvalue=2.8586245432606456e-17) | Why does scipy.stats.anderson_ksamp give a p-value of over a million for these data? [closed] | February 27, 2022 update for someone who may encounter the same issue and find this post:
Note: This answer is intended to point to a scipy bug when the question was originally asked on Jul 25, 2016. | Why does scipy.stats.anderson_ksamp give a p-value of over a million for these data? [closed]
February 27, 2022 update for someone who may encounter the same issue and find this post:
Note: This answer is intended to point to a scipy bug when the question was originally asked on Jul 25, 2016. This bug led to p-values greater than 1 and was fixed in this commit and looks like scipy versions scipy>=1.2.0 are not impacted by this. Code examples and outputs are available here for reproducibility. Following are tested on Python 3.9.9 and scipy==1.8.0
The first code chunk:
from scipy.stats import anderson_ksamp
a = [-1.8, -2.4, -2.4, -0.0, -1.5, -2.7, -1.8, -3.0, -1.8, -1.2, -3.0,
-3.0, -2.8, -3.0, -2.1, -0.0, 0.6, -2.5, -2.4, -0.0, -2.7, -0.0,
-2.5, -2.1, -0.9, -3.0, -0.6, -0.6, -1.5, -2.2, -1.2, -2.4, -2.4,
-3.0, 1.5, -1.8, 1.5, -2.7, -3.0, -2.5, -2.5, -1.5, -1.5, -2.1,
-2.1, -3.0, -0.6, -2.7, -3.0, -1.5, -0.6, -0.0, -2.1, 0.6, -2.0,
-3.0, -3.0, -2.4, -3.0, -1.8, -0.0, -0.0, -3.0, -1.5, -3.0, -3.0,
-1.5, -2.5, -3.0, -2.8, -3.0, -2.2, -0.6, -0.0, -1.5, -2.7, -2.1,
-2.1, -2.2, -2.1, -0.6, -0.0, -2.5, -2.1, -1.5, -3.0, -2.2, -1.8,
-2.7, -2.4, -1.5, -2.1, -2.9, -2.4, -0.9, -0.0, -0.0, -2.4, -2.7,
-0.6, -2.2, -3.0, -1.5, -0.9, -3.0, -3.0, -0.0, -2.7, -2.7, -1.5,
-2.2, -3.0, -0.0, 1.5, -3.0, -2.7, -2.2, -2.9, -2.2, -3.0, -1.8,
-0.0, -3.0, -1.5, -2.7, -3.0, -3.0, -2.9, -3.0, -3.0, -3.0, -3.0,
-2.5, -0.0, 0.9, -3.0, -0.0, -3.0, 3.0, -3.0, -3.0, -1.2, -2.1,
1.5, -0.0, -0.9, -3.0, -2.7, -1.5, -2.4, -2.1, -3.0, -0.9, -3.0,
-0.8, -1.5, -2.1, -2.7, -0.0, -0.0, -2.2, -1.8, -2.1, -2.2, -3.0,
0.6, -2.4, -2.2, -2.4, -2.5, -1.5, -0.0, -2.7, -3.0, -3.0, -2.1,
-0.0, -2.4, -2.4, -0.0, -2.0, -0.9, -2.4, -3.0, -1.4, -2.7, -2.7,
-3.0, -3.0, -2.7, -1.2, -2.1, -3.0, -0.0, -3.0, -2.7, -2.7, -3.0,
-3.0, -2.5, -3.0, -1.8, -1.5, -2.7, -2.4, -1.8, -3.0, -2.7, 2.1,
-3.0, -2.2, -2.2, 0.6, -0.9, 6.0, -3.0, -2.1, -3.0, -2.1, -2.5,
-3.0, -1.5, -2.5, 3.0, -2.1, -3.0, -3.0, -1.5, -2.1, -2.7, -2.5,
1.5, -2.1, -0.0, -0.0, -3.0, -0.6, 1.5, -2.7, -2.4, -2.1, -3.0,
-2.7, -3.0, 9.0, -3.0, -1.7, -3.0, -0.0, -3.0, -2.2, -0.0, -0.6,
-2.7, -2.7, -3.0, -3.0, -1.7, -2.1, -2.0, -3.0, -2.1, -3.0, -1.1,
-3.0, -3.0, -2.4, -1.5, -3.0, -2.2, -3.0, -1.5, -2.7, -3.0, -3.0,
-3.0, -2.2, -3.0, -2.1, -2.1, -2.4, -3.0, -3.0, -0.0, -3.0, -3.0,
-2.1, -2.0, 1.5, -3.0, -3.0, -2.1, -2.9, -2.4, -3.0, -3.0, -1.5,
-2.2, -0.9, -1.8, -2.1, -1.8, -1.5, -3.0, -1.5, -3.0, -1.5, -3.0,
-2.4, 1.5, -2.7, -3.0, -1.8, -1.8, -1.5, -2.1, -2.7, -2.7, -2.7,
-3.0, -1.5, -2.7, -3.0, -2.7, -3.0, -1.5, -1.5, -3.0, 0.6, -0.6,
-3.0, -2.1, -2.4, -2.1, -3.0, -2.2, -3.0, -1.8, -1.2, -3.0, -0.8,
-2.4, -2.5, -3.0, -1.5, -1.2, -0.0, -2.7, -2.4, -3.0, -3.0, -2.1,
-2.1, -2.1, -3.0, -2.7, -2.4, -2.1, -1.5, -2.1, -0.6, -3.0, -3.0,
-3.0, -3.0]
b = [-1.2, 6.0, -3.0, 1.5, 12.0, 1.5, 3.0, -0.0, -1.5, -0.0, 6.0,
-0.0, 1.8, -1.5, -3.0, -3.0, 1.5, -0.0, 1.5, -3.0, -3.0, -0.0,
-1.2, -3.0, 22.5, -0.0, -3.0, -3.0, -2.1, 3.0, 2.4, 1.5, -2.1,
4.5, -3.0, -3.0, 12.0, 6.0, -3.0, 3.0, -3.0, 12.0, -2.8, 0.6,
4.5, 3.0, -0.0, -3.0, -1.0, -3.0, -0.0, 3.0, 2.1, -0.6, -3.0,
-3.0, 1.5, 1.5, -0.6, -0.0, 1.5, 6.0, -2.2, -2.1, -0.0, -0.8,
6.0, -3.0, -3.0, 9.0, -3.0, -0.9, 15.0, 1.5, -2.9, 19.5, 4.5,
-3.0, 1.5, -1.8, 1.5, 0.9, -3.0, -3.0, 9.0, -0.3, 9.0, -2.1,
-2.2, -3.0, 12.0, -2.1, -1.2, -3.0, 4.5, -1.2, -0.0, 12.0, -0.9,
-3.0, -0.6, -3.0, -1.5, -0.0, 27.0, 4.5, -2.4, -2.7, -0.0, 3.0,
1.5, 3.0, -3.0, 16.5, -2.1, -0.6, -3.0, -1.5, -1.2, -3.0, 4.4,
-2.5, -2.1, 3.0, -1.2, -3.0, 12.0, -1.8, -0.9, -3.0, -3.0, -0.0,
-3.0, -1.2, -3.0, -3.0, -0.0, 1.5, -3.0, 7.5, -3.0, -2.1, 3.0,
1.5, 3.0, -3.0, 1.5, -3.0, 19.5, -3.0, -2.2, 27.0, 3.0, -1.5,
-3.0, -3.0, 4.5, -1.2, 12.0, 3.0, 3.0, -2.1, 6.0, -2.2, -3.0,
-2.4, 6.0, -3.0, -1.9, -0.6, -0.0, 3.6, 15.0, -3.0, -3.0, 7.5,
-0.0, 4.5, -2.4, -3.0, -3.0, -3.0, -2.0, -3.0, -3.0, -3.0, -2.6,
3.0, -0.0, -3.0, 4.5, -1.2, -3.0, -3.0, 3.0, -3.0, 1.6, 1.5,
-3.0, -3.0, -3.0, -3.0, 3.0, -3.0, -1.5, -3.0, -1.5, 12.0, -1.5,
3.0, 9.6, -0.0, -1.8, -3.0, -2.1, -0.6, 9.0, -3.0, 19.5, -2.4,
-1.8, 15.0, -3.0, -3.0, 27.0, 7.5, 12.0, -3.0, -2.0, -3.0, 12.0,
-3.0, -3.0, 0.9, -3.0, -2.5, 12.6, -1.5, -0.6, -3.0, -3.0, -0.0,
-0.8, -3.0, 3.0, -0.0, 4.5, -3.0, -0.0, 0.6, 0.3, -2.7, -0.0,
4.5, -3.0, 3.0, -1.5, 9.0, -3.0, 1.5, -3.0, 6.0, -2.2, -0.0,
-3.0, -3.0, 3.0, -3.0, -2.7, -0.0, -3.0, 0.6, 4.5, 1.5, 1.5, 1.5,
-2.1, 7.5, -3.0, -3.0, -3.0, -2.1, -3.0, 6.0, -1.5, -2.0, -3.0,
-0.6, 6.0, -1.5, -3.0, 6.0, -3.0, 3.0, 3.0, -3.0, 7.5, -3.0,
-0.0, -3.0, -0.0, -3.0, -3.0, 0.6, -3.0, -3.0, -3.0, -3.0, -2.4,
-0.0, 1.5, 3.0, 2.1, -3.0, 3.0, 4.5, -3.0, -2.4, -3.0, -2.2, 7.5,
2.1, -3.0, -0.0, -2.0, -3.0, -3.0, -1.8, -3.0, 4.5, -1.5, -3.0,
4.5, 3.0, 15.0, 4.5, -2.1, 12.0, 6.0, 4.5, 27.0, -3.0, 3.0, 0.6,
-3.0, 0.6, -2.4, 4.5, -1.5, -2.2, 12.0, -2.0, 1.5, 9.0, -1.5,
-1.2, -2.0, 1.5, -1.2, -1.8, -3.0, -0.0, -0.0, -3.0, -0.9]
print(anderson_ksamp([a, b]))
Outputs:
Anderson_ksampResult(
statistic=53.56069633812226,
critical_values=array([0.325, 1.226, 1.961, 2.718, 3.752, 4.592, 6.546]),
significance_level=0.001
)
And generates a warning:
UserWarning: p-value floored: true value smaller than 0.001
The second code chunk:
from scipy.stats import ks_2samp
from statsmodels.distributions.empirical_distribution import ECDF
import matplotlib.pyplot as plt
import numpy as np
a = [-1.8, -2.4, -2.4, -0.0, -1.5, -2.7, -1.8, -3.0, -1.8, -1.2, -3.0,
-3.0, -2.8, -3.0, -2.1, -0.0, 0.6, -2.5, -2.4, -0.0, -2.7, -0.0,
-2.5, -2.1, -0.9, -3.0, -0.6, -0.6, -1.5, -2.2, -1.2, -2.4, -2.4,
-3.0, 1.5, -1.8, 1.5, -2.7, -3.0, -2.5, -2.5, -1.5, -1.5, -2.1,
-2.1, -3.0, -0.6, -2.7, -3.0, -1.5, -0.6, -0.0, -2.1, 0.6, -2.0,
-3.0, -3.0, -2.4, -3.0, -1.8, -0.0, -0.0, -3.0, -1.5, -3.0, -3.0,
-1.5, -2.5, -3.0, -2.8, -3.0, -2.2, -0.6, -0.0, -1.5, -2.7, -2.1,
-2.1, -2.2, -2.1, -0.6, -0.0, -2.5, -2.1, -1.5, -3.0, -2.2, -1.8,
-2.7, -2.4, -1.5, -2.1, -2.9, -2.4, -0.9, -0.0, -0.0, -2.4, -2.7,
-0.6, -2.2, -3.0, -1.5, -0.9, -3.0, -3.0, -0.0, -2.7, -2.7, -1.5,
-2.2, -3.0, -0.0, 1.5, -3.0, -2.7, -2.2, -2.9, -2.2, -3.0, -1.8,
-0.0, -3.0, -1.5, -2.7, -3.0, -3.0, -2.9, -3.0, -3.0, -3.0, -3.0,
-2.5, -0.0, 0.9, -3.0, -0.0, -3.0, 3.0, -3.0, -3.0, -1.2, -2.1,
1.5, -0.0, -0.9, -3.0, -2.7, -1.5, -2.4, -2.1, -3.0, -0.9, -3.0,
-0.8, -1.5, -2.1, -2.7, -0.0, -0.0, -2.2, -1.8, -2.1, -2.2, -3.0,
0.6, -2.4, -2.2, -2.4, -2.5, -1.5, -0.0, -2.7, -3.0, -3.0, -2.1,
-0.0, -2.4, -2.4, -0.0, -2.0, -0.9, -2.4, -3.0, -1.4, -2.7, -2.7,
-3.0, -3.0, -2.7, -1.2, -2.1, -3.0, -0.0, -3.0, -2.7, -2.7, -3.0,
-3.0, -2.5, -3.0, -1.8, -1.5, -2.7, -2.4, -1.8, -3.0, -2.7, 2.1,
-3.0, -2.2, -2.2, 0.6, -0.9, 6.0, -3.0, -2.1, -3.0, -2.1, -2.5,
-3.0, -1.5, -2.5, 3.0, -2.1, -3.0, -3.0, -1.5, -2.1, -2.7, -2.5,
1.5, -2.1, -0.0, -0.0, -3.0, -0.6, 1.5, -2.7, -2.4, -2.1, -3.0,
-2.7, -3.0, 9.0, -3.0, -1.7, -3.0, -0.0, -3.0, -2.2, -0.0, -0.6,
-2.7, -2.7, -3.0, -3.0, -1.7, -2.1, -2.0, -3.0, -2.1, -3.0, -1.1,
-3.0, -3.0, -2.4, -1.5, -3.0, -2.2, -3.0, -1.5, -2.7, -3.0, -3.0,
-3.0, -2.2, -3.0, -2.1, -2.1, -2.4, -3.0, -3.0, -0.0, -3.0, -3.0,
-2.1, -2.0, 1.5, -3.0, -3.0, -2.1, -2.9, -2.4, -3.0, -3.0, -1.5,
-2.2, -0.9, -1.8, -2.1, -1.8, -1.5, -3.0, -1.5, -3.0, -1.5, -3.0,
-2.4, 1.5, -2.7, -3.0, -1.8, -1.8, -1.5, -2.1, -2.7, -2.7, -2.7,
-3.0, -1.5, -2.7, -3.0, -2.7, -3.0, -1.5, -1.5, -3.0, 0.6, -0.6,
-3.0, -2.1, -2.4, -2.1, -3.0, -2.2, -3.0, -1.8, -1.2, -3.0, -0.8,
-2.4, -2.5, -3.0, -1.5, -1.2, -0.0, -2.7, -2.4, -3.0, -3.0, -2.1,
-2.1, -2.1, -3.0, -2.7, -2.4, -2.1, -1.5, -2.1, -0.6, -3.0, -3.0,
-3.0, -3.0]
b = [-1.2, 6.0, -3.0, 1.5, 12.0, 1.5, 3.0, -0.0, -1.5, -0.0, 6.0,
-0.0, 1.8, -1.5, -3.0, -3.0, 1.5, -0.0, 1.5, -3.0, -3.0, -0.0,
-1.2, -3.0, 22.5, -0.0, -3.0, -3.0, -2.1, 3.0, 2.4, 1.5, -2.1,
4.5, -3.0, -3.0, 12.0, 6.0, -3.0, 3.0, -3.0, 12.0, -2.8, 0.6,
4.5, 3.0, -0.0, -3.0, -1.0, -3.0, -0.0, 3.0, 2.1, -0.6, -3.0,
-3.0, 1.5, 1.5, -0.6, -0.0, 1.5, 6.0, -2.2, -2.1, -0.0, -0.8,
6.0, -3.0, -3.0, 9.0, -3.0, -0.9, 15.0, 1.5, -2.9, 19.5, 4.5,
-3.0, 1.5, -1.8, 1.5, 0.9, -3.0, -3.0, 9.0, -0.3, 9.0, -2.1,
-2.2, -3.0, 12.0, -2.1, -1.2, -3.0, 4.5, -1.2, -0.0, 12.0, -0.9,
-3.0, -0.6, -3.0, -1.5, -0.0, 27.0, 4.5, -2.4, -2.7, -0.0, 3.0,
1.5, 3.0, -3.0, 16.5, -2.1, -0.6, -3.0, -1.5, -1.2, -3.0, 4.4,
-2.5, -2.1, 3.0, -1.2, -3.0, 12.0, -1.8, -0.9, -3.0, -3.0, -0.0,
-3.0, -1.2, -3.0, -3.0, -0.0, 1.5, -3.0, 7.5, -3.0, -2.1, 3.0,
1.5, 3.0, -3.0, 1.5, -3.0, 19.5, -3.0, -2.2, 27.0, 3.0, -1.5,
-3.0, -3.0, 4.5, -1.2, 12.0, 3.0, 3.0, -2.1, 6.0, -2.2, -3.0,
-2.4, 6.0, -3.0, -1.9, -0.6, -0.0, 3.6, 15.0, -3.0, -3.0, 7.5,
-0.0, 4.5, -2.4, -3.0, -3.0, -3.0, -2.0, -3.0, -3.0, -3.0, -2.6,
3.0, -0.0, -3.0, 4.5, -1.2, -3.0, -3.0, 3.0, -3.0, 1.6, 1.5,
-3.0, -3.0, -3.0, -3.0, 3.0, -3.0, -1.5, -3.0, -1.5, 12.0, -1.5,
3.0, 9.6, -0.0, -1.8, -3.0, -2.1, -0.6, 9.0, -3.0, 19.5, -2.4,
-1.8, 15.0, -3.0, -3.0, 27.0, 7.5, 12.0, -3.0, -2.0, -3.0, 12.0,
-3.0, -3.0, 0.9, -3.0, -2.5, 12.6, -1.5, -0.6, -3.0, -3.0, -0.0,
-0.8, -3.0, 3.0, -0.0, 4.5, -3.0, -0.0, 0.6, 0.3, -2.7, -0.0,
4.5, -3.0, 3.0, -1.5, 9.0, -3.0, 1.5, -3.0, 6.0, -2.2, -0.0,
-3.0, -3.0, 3.0, -3.0, -2.7, -0.0, -3.0, 0.6, 4.5, 1.5, 1.5, 1.5,
-2.1, 7.5, -3.0, -3.0, -3.0, -2.1, -3.0, 6.0, -1.5, -2.0, -3.0,
-0.6, 6.0, -1.5, -3.0, 6.0, -3.0, 3.0, 3.0, -3.0, 7.5, -3.0,
-0.0, -3.0, -0.0, -3.0, -3.0, 0.6, -3.0, -3.0, -3.0, -3.0, -2.4,
-0.0, 1.5, 3.0, 2.1, -3.0, 3.0, 4.5, -3.0, -2.4, -3.0, -2.2, 7.5,
2.1, -3.0, -0.0, -2.0, -3.0, -3.0, -1.8, -3.0, 4.5, -1.5, -3.0,
4.5, 3.0, 15.0, 4.5, -2.1, 12.0, 6.0, 4.5, 27.0, -3.0, 3.0, 0.6,
-3.0, 0.6, -2.4, 4.5, -1.5, -2.2, 12.0, -2.0, 1.5, 9.0, -1.5,
-1.2, -2.0, 1.5, -1.2, -1.8, -3.0, -0.0, -0.0, -3.0, -0.9]
ecdf1, ecdf2 = ECDF(a), ECDF(b)
xs = np.linspace(min(a + b), max(a + b), num=10000)
plt.figure(figsize=(12, 8))
plt.plot(xs, ecdf1(xs), xs, ecdf2(xs))
plt.show()
print(ks_2samp(a, b))
Outputs:
KstestResult(statistic=0.3232876712328767, pvalue=2.8586245432606456e-17) | Why does scipy.stats.anderson_ksamp give a p-value of over a million for these data? [closed]
February 27, 2022 update for someone who may encounter the same issue and find this post:
Note: This answer is intended to point to a scipy bug when the question was originally asked on Jul 25, 2016. |
37,526 | Intuition on t-SNE visualization technique | The a similar phenomenon can be seen if you search for images of "spring graph layout", which show you many examples of such arcs, such as this one from wikipedia. Near the top on the right edge of the image, we see one such arc. Admittedly this isn't the best example. The top right corner of this image from this paper shows the effect a bit
Most of these graph visualizations are generated by simulating a spring force between each pair of connected nodes, and allowing the nodes to move according to this force.
In t-SNE, a similar interpretation of the algorithm is possible -- points in 2D space have a spring, whose resting length depends on the distance of the points in the original high-dimensional space. So points that are closer in 2D space than they are in high-dimensional space are pushed farther apart, and points that are farther in 2D space than in high-dimensional space are pulled together.
So it's likely that the arcs form because they are trying to maintain a constant distance to another group of points in the data.
Unlike in the spring graph layout above, every pair of points in t-SNE has a spring/force attached to it, so it's a valid question to ask why the arcs don't clump together into blobs, as shown in the graph visualization from wikipedia, where some groups of nodes on the edges have formed roundish clusters rather than arcs.
I suspect the reason for this is that each point in t-SNE has a variance attached to it. Points in a sparser region of the high-dimensional space have a higher variance compared to points in a lower dimensional space. The force on the springs of high-variance points is reduced, so if points in an arc were located in a sparse region of the original space, there would only be a weak force trying to pull them into a cluster, which might not overcome other opposing forces.
Furthermore, the method that the authors used to reduce crowding was to use a heavy-tailed distribution in the 2D space, which means points aren't penalized too heavily for being farther away from each other than they should. This also reduces the forces which would try to pull an arc into a cluster. | Intuition on t-SNE visualization technique | The a similar phenomenon can be seen if you search for images of "spring graph layout", which show you many examples of such arcs, such as this one from wikipedia. Near the top on the right edge of th | Intuition on t-SNE visualization technique
The a similar phenomenon can be seen if you search for images of "spring graph layout", which show you many examples of such arcs, such as this one from wikipedia. Near the top on the right edge of the image, we see one such arc. Admittedly this isn't the best example. The top right corner of this image from this paper shows the effect a bit
Most of these graph visualizations are generated by simulating a spring force between each pair of connected nodes, and allowing the nodes to move according to this force.
In t-SNE, a similar interpretation of the algorithm is possible -- points in 2D space have a spring, whose resting length depends on the distance of the points in the original high-dimensional space. So points that are closer in 2D space than they are in high-dimensional space are pushed farther apart, and points that are farther in 2D space than in high-dimensional space are pulled together.
So it's likely that the arcs form because they are trying to maintain a constant distance to another group of points in the data.
Unlike in the spring graph layout above, every pair of points in t-SNE has a spring/force attached to it, so it's a valid question to ask why the arcs don't clump together into blobs, as shown in the graph visualization from wikipedia, where some groups of nodes on the edges have formed roundish clusters rather than arcs.
I suspect the reason for this is that each point in t-SNE has a variance attached to it. Points in a sparser region of the high-dimensional space have a higher variance compared to points in a lower dimensional space. The force on the springs of high-variance points is reduced, so if points in an arc were located in a sparse region of the original space, there would only be a weak force trying to pull them into a cluster, which might not overcome other opposing forces.
Furthermore, the method that the authors used to reduce crowding was to use a heavy-tailed distribution in the 2D space, which means points aren't penalized too heavily for being farther away from each other than they should. This also reduces the forces which would try to pull an arc into a cluster. | Intuition on t-SNE visualization technique
The a similar phenomenon can be seen if you search for images of "spring graph layout", which show you many examples of such arcs, such as this one from wikipedia. Near the top on the right edge of th |
37,527 | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting) | This is more of an extended comment, so take it as such.
Define:
$$
f(x) \equiv \frac{1}{n} \sum_{i = 1}^n \mathcal{N}\left(x | x_i, \sigma_i^2 \right)
$$
(I am using the standard notation for Gaussian distributions).
You want to prove that:
$$
\frac{1}{n} \sum_{i = 1}^n \log f(x_i) - \int f(x) \log f(x) dx \ge 0
$$
which is
$$
\left\{\frac{1}{n} \sum_{i = 1}^n \log f(x_i)\right\} + \mathcal{H}[f] \ge 0.
$$
Due to Jensen's inequality (see for example Huber et al., On Entropy Approximation for Gaussian Mixture Random Vectors, 2008),
$$
\mathcal{H}[f] \ge -\frac{1}{n} \sum_{i = 1}^n \log \int f(x) \mathcal{N}(x | x_i, \sigma_i^2) dx
= -\frac{1}{n} \sum_{i = 1}^n \log g_i(x_i)
$$
with $g_i(x) \equiv \frac{1}{n} \sum_{j = 1}^n \mathcal{N}\left(x | x_j, \sigma_i^2 + \sigma_j^2 \right)$, which comes from the convolution of two Gaussian densities. So we get:
$$
\left\{\frac{1}{n} \sum_{i = 1}^n \log f(x_i) \right\} + \mathcal{H}[f] \ge
\frac{1}{n} \sum_{i = 1}^n \log \frac{f(x_i)}{g_i(x_i)}.
$$
Interestingly, the $g_i$ are still mixtures of Gaussians with component means equal to the ones in $f$, but each component of $g_i$ has a strictly larger variance than its corresponding component in $f$.
Can you do anything with this? | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting) | This is more of an extended comment, so take it as such.
Define:
$$
f(x) \equiv \frac{1}{n} \sum_{i = 1}^n \mathcal{N}\left(x | x_i, \sigma_i^2 \right)
$$
(I am using the standard notation for Gaussia | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting)
This is more of an extended comment, so take it as such.
Define:
$$
f(x) \equiv \frac{1}{n} \sum_{i = 1}^n \mathcal{N}\left(x | x_i, \sigma_i^2 \right)
$$
(I am using the standard notation for Gaussian distributions).
You want to prove that:
$$
\frac{1}{n} \sum_{i = 1}^n \log f(x_i) - \int f(x) \log f(x) dx \ge 0
$$
which is
$$
\left\{\frac{1}{n} \sum_{i = 1}^n \log f(x_i)\right\} + \mathcal{H}[f] \ge 0.
$$
Due to Jensen's inequality (see for example Huber et al., On Entropy Approximation for Gaussian Mixture Random Vectors, 2008),
$$
\mathcal{H}[f] \ge -\frac{1}{n} \sum_{i = 1}^n \log \int f(x) \mathcal{N}(x | x_i, \sigma_i^2) dx
= -\frac{1}{n} \sum_{i = 1}^n \log g_i(x_i)
$$
with $g_i(x) \equiv \frac{1}{n} \sum_{j = 1}^n \mathcal{N}\left(x | x_j, \sigma_i^2 + \sigma_j^2 \right)$, which comes from the convolution of two Gaussian densities. So we get:
$$
\left\{\frac{1}{n} \sum_{i = 1}^n \log f(x_i) \right\} + \mathcal{H}[f] \ge
\frac{1}{n} \sum_{i = 1}^n \log \frac{f(x_i)}{g_i(x_i)}.
$$
Interestingly, the $g_i$ are still mixtures of Gaussians with component means equal to the ones in $f$, but each component of $g_i$ has a strictly larger variance than its corresponding component in $f$.
Can you do anything with this? | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting)
This is more of an extended comment, so take it as such.
Define:
$$
f(x) \equiv \frac{1}{n} \sum_{i = 1}^n \mathcal{N}\left(x | x_i, \sigma_i^2 \right)
$$
(I am using the standard notation for Gaussia |
37,528 | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting) | I think I got it. It only takes elementary steps, although you need to combine them right.
Let's denote by $f_i$ the density of $i$-th Gaussian, that is $\frac{1}{\sqrt{2\pi \sigma_i^2}}e^{\frac{(x-\mu_i)^2}{2\sigma_i^2}}$
We start off with Jensen's Inequality.
The function $g(x) = x log(x) $ is convex, hence we have:
$f(x) \log(f(x)) \leq \frac{1}{n}\sum_{i=1}^n f_i(x) \log(f_i(x))$. After integrating we get:
$$
\int f(x)\log(f(x)) dx \leq \frac{1}{n} \sum_{i=1}^n \int f_i(x) \log(f_i(x)) dx
$$
Edit: The inequality below is wrong and so is the solution itself
Now the RHS. For all $i$ we have $f \geq f_i$, so:
$$log(f(\mu_i)) \geq log(f_i(\mu_i))$$
Hence:
$$
\frac{1}{n} \sum_{i=1}^n log(f(\mu_i)) \geq \frac{1}{n}\sum_{i=1}^n log(f_i(\mu_i))
$$
We are left to prove:
$$
\frac{1}{n}\sum_{i=1}^n log(f_i(\mu_i)) \geq \frac{1}{n}\sum_{i=1}^n f_i(x) \log(f_i(x))
$$
But we have:
$$
log(f_i(\mu_i)) = \int f_i(x) log(f_i(\mu_i)) dx \geq \int f_i(x) log(f_i(x)) dx
$$
Summing over $i$ and dividing by $n$ we get what we needed | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting) | I think I got it. It only takes elementary steps, although you need to combine them right.
Let's denote by $f_i$ the density of $i$-th Gaussian, that is $\frac{1}{\sqrt{2\pi \sigma_i^2}}e^{\frac{(x-\m | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting)
I think I got it. It only takes elementary steps, although you need to combine them right.
Let's denote by $f_i$ the density of $i$-th Gaussian, that is $\frac{1}{\sqrt{2\pi \sigma_i^2}}e^{\frac{(x-\mu_i)^2}{2\sigma_i^2}}$
We start off with Jensen's Inequality.
The function $g(x) = x log(x) $ is convex, hence we have:
$f(x) \log(f(x)) \leq \frac{1}{n}\sum_{i=1}^n f_i(x) \log(f_i(x))$. After integrating we get:
$$
\int f(x)\log(f(x)) dx \leq \frac{1}{n} \sum_{i=1}^n \int f_i(x) \log(f_i(x)) dx
$$
Edit: The inequality below is wrong and so is the solution itself
Now the RHS. For all $i$ we have $f \geq f_i$, so:
$$log(f(\mu_i)) \geq log(f_i(\mu_i))$$
Hence:
$$
\frac{1}{n} \sum_{i=1}^n log(f(\mu_i)) \geq \frac{1}{n}\sum_{i=1}^n log(f_i(\mu_i))
$$
We are left to prove:
$$
\frac{1}{n}\sum_{i=1}^n log(f_i(\mu_i)) \geq \frac{1}{n}\sum_{i=1}^n f_i(x) \log(f_i(x))
$$
But we have:
$$
log(f_i(\mu_i)) = \int f_i(x) log(f_i(\mu_i)) dx \geq \int f_i(x) log(f_i(x)) dx
$$
Summing over $i$ and dividing by $n$ we get what we needed | How to prove this Gaussian Mixture inequality? (Fitting/Overfitting)
I think I got it. It only takes elementary steps, although you need to combine them right.
Let's denote by $f_i$ the density of $i$-th Gaussian, that is $\frac{1}{\sqrt{2\pi \sigma_i^2}}e^{\frac{(x-\m |
37,529 | How to Choose Activation Functions in a Regression Neural Network? | Well, I'm still interested in a guideline or rule of thumb regarding: Given $n$ samples $\left(x, y\right)$, how to choose the hidden layers of a regression neural network? Proposals, comments and answers are highly welcome!
Nevertheless, in my question, I stated a particular situation. Despite of its exemplary nature, I think that the choice of the hidden layers should be approached from the following point of view: The non-linearity in the relation $x \to y$ can be captured through the combination of two concepts:
univariate Polynomials (e.g. $w_m x^m + \dots + w_0 x^0$)
"and"-junction of features (like $x_i x_k$)
Let me drop two side notes:
Yes, the combination of these two concepts is called multivariate polynomials, but for simplicity, I didn't want to deal with them here.
I think, it's a legitimate question: How do we actually know that these two concepts are involved in the unknown mechanism, which generates $y$ from $x$? Well, we don't know that. But we can guess. Maybe kernel-PCA will tell us.
In conclusion, I implemented "and"-layers and polynomial layers. I was using the Lasagne framework, along with scikit-neuralnetwork.
implementation
The polynomial layer maps each input feature, that is a neuron from the previous layer, to $m+1$ of its own neurons. These neurons are $w_m x^m + \dots + w_0 x^0$.
class PolynomialLayer(lasagne.layers.Layer):
def __init__(self, incoming, deg, **kwargs):
super(PolynomialLayer, self).__init__(incoming, **kwargs)
self.deg = deg
def get_output_for(self, input, **kwargs):
monomials = [input ** i for i in range(self.deg + 1)]
return T.concatenate(monomials, axis=1)
def get_output_shape_for(self, input_shape):
return (input_shape[0], input_shape[1] * (self.deg + 1))
The "and"-layer links all distinct, unordered pairs of features from the previous layer into neurons, plus it repeats each feature from that layer.
class AndLayer(lasagne.layers.Layer):
def __init__(self, incoming, **kwargs):
super(AndLayer, self).__init__(incoming, **kwargs)
def get_output_for(self, input, **kwargs):
results = [input]
for i in range(self.input_shape[1]):
for k in range(i + 1, self.input_shape[1]):
results.append((input[:, i] * input[:, k]).dimshuffle((0, 'x')))
return T.concatenate(results, axis=1)
def get_output_shape_for(self, input_shape):
return (input_shape[0], ((input_shape[1] ** 2) + input_shape[1]) / 2)
evaluation
Another question arises: In which order should be put the two hidden layers?
first network
This is the network layout:
input layer | polyn. layer | "and" layer
-------------|--------------|-------------
4 neurons | 12 neurons | 78 neurons
And here is the overwhelming result:
The learning algorithm in use was stochastic gradient descent (SGD) with a learning rate of $2 \cdot 10^{-3}$. The SGD algorithm is the frameworks' default.
second network
The alternative network layout, where we swapped the hidden layers, looks as follows:
input layer | "and" layer | polyn. layer
-------------|-------------|--------------
4 neurons | 14 neurons | 42 neurons
With the same learning rate as before, the training failed for this layout and resulted in a root mean square (RMS) error of about $8.3 \cdot 10^9$. After reducing the learning rate to $1 \cdot 10^{-3}$, at least the SGD algorithm converged properly:
Though, the RMS error is much higher, than it was with the first layout. This suggests that, despite its lower complexity in terms of neurons counts, the second layout is somehow more sensitive to the learning rate parameter. I'm still wondering, where this comes from: Explanations are highly welcome! Might it be related to the nature of back propagation? | How to Choose Activation Functions in a Regression Neural Network? | Well, I'm still interested in a guideline or rule of thumb regarding: Given $n$ samples $\left(x, y\right)$, how to choose the hidden layers of a regression neural network? Proposals, comments and ans | How to Choose Activation Functions in a Regression Neural Network?
Well, I'm still interested in a guideline or rule of thumb regarding: Given $n$ samples $\left(x, y\right)$, how to choose the hidden layers of a regression neural network? Proposals, comments and answers are highly welcome!
Nevertheless, in my question, I stated a particular situation. Despite of its exemplary nature, I think that the choice of the hidden layers should be approached from the following point of view: The non-linearity in the relation $x \to y$ can be captured through the combination of two concepts:
univariate Polynomials (e.g. $w_m x^m + \dots + w_0 x^0$)
"and"-junction of features (like $x_i x_k$)
Let me drop two side notes:
Yes, the combination of these two concepts is called multivariate polynomials, but for simplicity, I didn't want to deal with them here.
I think, it's a legitimate question: How do we actually know that these two concepts are involved in the unknown mechanism, which generates $y$ from $x$? Well, we don't know that. But we can guess. Maybe kernel-PCA will tell us.
In conclusion, I implemented "and"-layers and polynomial layers. I was using the Lasagne framework, along with scikit-neuralnetwork.
implementation
The polynomial layer maps each input feature, that is a neuron from the previous layer, to $m+1$ of its own neurons. These neurons are $w_m x^m + \dots + w_0 x^0$.
class PolynomialLayer(lasagne.layers.Layer):
def __init__(self, incoming, deg, **kwargs):
super(PolynomialLayer, self).__init__(incoming, **kwargs)
self.deg = deg
def get_output_for(self, input, **kwargs):
monomials = [input ** i for i in range(self.deg + 1)]
return T.concatenate(monomials, axis=1)
def get_output_shape_for(self, input_shape):
return (input_shape[0], input_shape[1] * (self.deg + 1))
The "and"-layer links all distinct, unordered pairs of features from the previous layer into neurons, plus it repeats each feature from that layer.
class AndLayer(lasagne.layers.Layer):
def __init__(self, incoming, **kwargs):
super(AndLayer, self).__init__(incoming, **kwargs)
def get_output_for(self, input, **kwargs):
results = [input]
for i in range(self.input_shape[1]):
for k in range(i + 1, self.input_shape[1]):
results.append((input[:, i] * input[:, k]).dimshuffle((0, 'x')))
return T.concatenate(results, axis=1)
def get_output_shape_for(self, input_shape):
return (input_shape[0], ((input_shape[1] ** 2) + input_shape[1]) / 2)
evaluation
Another question arises: In which order should be put the two hidden layers?
first network
This is the network layout:
input layer | polyn. layer | "and" layer
-------------|--------------|-------------
4 neurons | 12 neurons | 78 neurons
And here is the overwhelming result:
The learning algorithm in use was stochastic gradient descent (SGD) with a learning rate of $2 \cdot 10^{-3}$. The SGD algorithm is the frameworks' default.
second network
The alternative network layout, where we swapped the hidden layers, looks as follows:
input layer | "and" layer | polyn. layer
-------------|-------------|--------------
4 neurons | 14 neurons | 42 neurons
With the same learning rate as before, the training failed for this layout and resulted in a root mean square (RMS) error of about $8.3 \cdot 10^9$. After reducing the learning rate to $1 \cdot 10^{-3}$, at least the SGD algorithm converged properly:
Though, the RMS error is much higher, than it was with the first layout. This suggests that, despite its lower complexity in terms of neurons counts, the second layout is somehow more sensitive to the learning rate parameter. I'm still wondering, where this comes from: Explanations are highly welcome! Might it be related to the nature of back propagation? | How to Choose Activation Functions in a Regression Neural Network?
Well, I'm still interested in a guideline or rule of thumb regarding: Given $n$ samples $\left(x, y\right)$, how to choose the hidden layers of a regression neural network? Proposals, comments and ans |
37,530 | Bagging of xgboost | The bag in bagging is about aggregation. If you have k CART models then for an input you get k candidate answers. How do you reduce that to a single value. The aggregation does that. It is often a measure of central tendency like the mean or mode.
In order to aggregate, you would need multiple outputs. The gradient boosted machine (gbm) as in XGboost, is a series ensemble, not parallel one. This means that it lines them all up in a bucket brigade, and all the learners (but front and back) take the output of one, and give it to the next one). The final output is the same structure as a CART model - a single output. There is no bootstrapping to be done on a single element. | Bagging of xgboost | The bag in bagging is about aggregation. If you have k CART models then for an input you get k candidate answers. How do you reduce that to a single value. The aggregation does that. It is often a | Bagging of xgboost
The bag in bagging is about aggregation. If you have k CART models then for an input you get k candidate answers. How do you reduce that to a single value. The aggregation does that. It is often a measure of central tendency like the mean or mode.
In order to aggregate, you would need multiple outputs. The gradient boosted machine (gbm) as in XGboost, is a series ensemble, not parallel one. This means that it lines them all up in a bucket brigade, and all the learners (but front and back) take the output of one, and give it to the next one). The final output is the same structure as a CART model - a single output. There is no bootstrapping to be done on a single element. | Bagging of xgboost
The bag in bagging is about aggregation. If you have k CART models then for an input you get k candidate answers. How do you reduce that to a single value. The aggregation does that. It is often a |
37,531 | Robust Bootstrap Covariance Estimator | I think you can just use robust estimator of covariance for each bootstrap estimation and it will work. This is not specific to your application.
There are a lot of different ways to have a robust covariance estimator. You can't avoid "artificially reduce variances" as you say because the "wild" estimates are consequence of a too large variance that you want to trim but you have to choose an estimator that trim the variance of outliers but do not trim the variance of inliers.
Among robust covariance estimators, one can use Minimum Covariance Determinant but this estimator suppose an elliptical density model on the data. Instead, I prefer to use M-estimators. For instance, in R, you can find such estimators rrcov or in robust package or you can code it yourself. And then, there is always a parameter that you have to tune (for instance, you say that you ignore the 5% of the data that are the "wilder" or something like that).
If you want a more precise answer, maybe you could give an example of a simulation or real dataset where what you speak of occurs. | Robust Bootstrap Covariance Estimator | I think you can just use robust estimator of covariance for each bootstrap estimation and it will work. This is not specific to your application.
There are a lot of different ways to have a robust cov | Robust Bootstrap Covariance Estimator
I think you can just use robust estimator of covariance for each bootstrap estimation and it will work. This is not specific to your application.
There are a lot of different ways to have a robust covariance estimator. You can't avoid "artificially reduce variances" as you say because the "wild" estimates are consequence of a too large variance that you want to trim but you have to choose an estimator that trim the variance of outliers but do not trim the variance of inliers.
Among robust covariance estimators, one can use Minimum Covariance Determinant but this estimator suppose an elliptical density model on the data. Instead, I prefer to use M-estimators. For instance, in R, you can find such estimators rrcov or in robust package or you can code it yourself. And then, there is always a parameter that you have to tune (for instance, you say that you ignore the 5% of the data that are the "wilder" or something like that).
If you want a more precise answer, maybe you could give an example of a simulation or real dataset where what you speak of occurs. | Robust Bootstrap Covariance Estimator
I think you can just use robust estimator of covariance for each bootstrap estimation and it will work. This is not specific to your application.
There are a lot of different ways to have a robust cov |
37,532 | Is Monte Carlo uncertainty estimation equivalent to analytical error propagation? | I think the question is to which order you calculate, the analytic method.
The usual, Gaussian error propagation does a first-order approximation of the function around a certain point and varies with the deviation. If the function has a lot of higher-order components (in that region) or you are dealing with comparable large uncertainties, you will end up with bad estimates.
MC on the other side will give you usually the "best" prediction but use up way more resources. Although you can account for higher order approximations in your error propagation, you basically do not know where to "stop" in order to get enough orders.
For the limit, AFAIK, they yield the same result (in the limit of infinite order and infinite MC runs). A simple reasoning: the errors are intrinsically given (even dough we don't know them). Both methods try to approximate those as good as possible and in the limit yielding the correct errors. | Is Monte Carlo uncertainty estimation equivalent to analytical error propagation? | I think the question is to which order you calculate, the analytic method.
The usual, Gaussian error propagation does a first-order approximation of the function around a certain point and varies with | Is Monte Carlo uncertainty estimation equivalent to analytical error propagation?
I think the question is to which order you calculate, the analytic method.
The usual, Gaussian error propagation does a first-order approximation of the function around a certain point and varies with the deviation. If the function has a lot of higher-order components (in that region) or you are dealing with comparable large uncertainties, you will end up with bad estimates.
MC on the other side will give you usually the "best" prediction but use up way more resources. Although you can account for higher order approximations in your error propagation, you basically do not know where to "stop" in order to get enough orders.
For the limit, AFAIK, they yield the same result (in the limit of infinite order and infinite MC runs). A simple reasoning: the errors are intrinsically given (even dough we don't know them). Both methods try to approximate those as good as possible and in the limit yielding the correct errors. | Is Monte Carlo uncertainty estimation equivalent to analytical error propagation?
I think the question is to which order you calculate, the analytic method.
The usual, Gaussian error propagation does a first-order approximation of the function around a certain point and varies with |
37,533 | How to pool results from post hoc lsmeans analysis across multiple imputations with MICE | package emmeans supports pooling of model-estimated means:
cimputed_mice=mice(data=cmiss[,-1], method="rf", maxit = 10, seed=123)
## perform a linear regression analysis on each imputed dataset
# and store the results
multi_lm = with(cimputed_mice, lm(cesd~MOSS+Income+decrease_inc+age+prescriptions+Chemo))
## pool the modeling results across imputations
pooled_fit=pool(multi_lm)
## pooled summary
summary(pooled_fit)
##pooled R squared
pool.r.squared(multi_lm)
## model-estimated means
emmeans(multi_lm,"decrease_inc")
plot(emmeans(multi_lm,"decrease_inc")) | How to pool results from post hoc lsmeans analysis across multiple imputations with MICE | package emmeans supports pooling of model-estimated means:
cimputed_mice=mice(data=cmiss[,-1], method="rf", maxit = 10, seed=123)
## perform a linear regression analysis on each imputed dataset
# an | How to pool results from post hoc lsmeans analysis across multiple imputations with MICE
package emmeans supports pooling of model-estimated means:
cimputed_mice=mice(data=cmiss[,-1], method="rf", maxit = 10, seed=123)
## perform a linear regression analysis on each imputed dataset
# and store the results
multi_lm = with(cimputed_mice, lm(cesd~MOSS+Income+decrease_inc+age+prescriptions+Chemo))
## pool the modeling results across imputations
pooled_fit=pool(multi_lm)
## pooled summary
summary(pooled_fit)
##pooled R squared
pool.r.squared(multi_lm)
## model-estimated means
emmeans(multi_lm,"decrease_inc")
plot(emmeans(multi_lm,"decrease_inc")) | How to pool results from post hoc lsmeans analysis across multiple imputations with MICE
package emmeans supports pooling of model-estimated means:
cimputed_mice=mice(data=cmiss[,-1], method="rf", maxit = 10, seed=123)
## perform a linear regression analysis on each imputed dataset
# an |
37,534 | What happens when we feed a 2D matrix to a LSTM layer | 1) X are your inputs, if you have 99 timesteps, then you have 99 vectors of size 13 each. Hence your input to each timestep is a vector that is of size 13. You will need a starting hidden state, unless you have a reason to do otherwise your beginning hidden state can be all 0's. The size of that vector is a hyperparameter you choose.
2) Keep in mind that there are not 99 LSTM cells, there is only 1 LSTM cell that is re-used 99 times for each timestep. The LSTM cell maintains a hidden state and a cell state within it that it passes forward to the next time step. But there is only 1 set of parameters being learned. Those parameters need to be able to handle all timesteps, conditional on the current input, hidden state, and cell state.
3) The cell state is not an output, however it is passed forward as an input to the next timestep. The hidden state h_t will be passed to the output as well as to the next timestep.
4) I'm not quite sure, I need a reference to the term output_dim.
This is an excellent tutorial on LSTMs: http://colah.github.io/posts/2015-08-Understanding-LSTMs/ | What happens when we feed a 2D matrix to a LSTM layer | 1) X are your inputs, if you have 99 timesteps, then you have 99 vectors of size 13 each. Hence your input to each timestep is a vector that is of size 13. You will need a starting hidden state, unles | What happens when we feed a 2D matrix to a LSTM layer
1) X are your inputs, if you have 99 timesteps, then you have 99 vectors of size 13 each. Hence your input to each timestep is a vector that is of size 13. You will need a starting hidden state, unless you have a reason to do otherwise your beginning hidden state can be all 0's. The size of that vector is a hyperparameter you choose.
2) Keep in mind that there are not 99 LSTM cells, there is only 1 LSTM cell that is re-used 99 times for each timestep. The LSTM cell maintains a hidden state and a cell state within it that it passes forward to the next time step. But there is only 1 set of parameters being learned. Those parameters need to be able to handle all timesteps, conditional on the current input, hidden state, and cell state.
3) The cell state is not an output, however it is passed forward as an input to the next timestep. The hidden state h_t will be passed to the output as well as to the next timestep.
4) I'm not quite sure, I need a reference to the term output_dim.
This is an excellent tutorial on LSTMs: http://colah.github.io/posts/2015-08-Understanding-LSTMs/ | What happens when we feed a 2D matrix to a LSTM layer
1) X are your inputs, if you have 99 timesteps, then you have 99 vectors of size 13 each. Hence your input to each timestep is a vector that is of size 13. You will need a starting hidden state, unles |
37,535 | What happens when we feed a 2D matrix to a LSTM layer | What is meant by output_dim (output dimension) of a given layer? Does it always have to be the number of nodes in the next layer?
output_dim = dimension of the LSTM hidden states. | What happens when we feed a 2D matrix to a LSTM layer | What is meant by output_dim (output dimension) of a given layer? Does it always have to be the number of nodes in the next layer?
output_dim = dimension of the LSTM hidden states. | What happens when we feed a 2D matrix to a LSTM layer
What is meant by output_dim (output dimension) of a given layer? Does it always have to be the number of nodes in the next layer?
output_dim = dimension of the LSTM hidden states. | What happens when we feed a 2D matrix to a LSTM layer
What is meant by output_dim (output dimension) of a given layer? Does it always have to be the number of nodes in the next layer?
output_dim = dimension of the LSTM hidden states. |
37,536 | Selection bias in trees | Based on your comment I'd go with a conditional inference framework. The code is readily available in R using the ctree function in the party package. It has unbiased variable selection, and while the algorithm underlying when and how to make splits is different compared to CART, the logic is essentially the same. Another benefit outlined by the authors (see the paper here) is that you don't have to worry so much about pruning the tree to avoid overfitting. The algorithm actually takes care of that by using permutation tests to determine whether a split is "statistically significant" or not. | Selection bias in trees | Based on your comment I'd go with a conditional inference framework. The code is readily available in R using the ctree function in the party package. It has unbiased variable selection, and while the | Selection bias in trees
Based on your comment I'd go with a conditional inference framework. The code is readily available in R using the ctree function in the party package. It has unbiased variable selection, and while the algorithm underlying when and how to make splits is different compared to CART, the logic is essentially the same. Another benefit outlined by the authors (see the paper here) is that you don't have to worry so much about pruning the tree to avoid overfitting. The algorithm actually takes care of that by using permutation tests to determine whether a split is "statistically significant" or not. | Selection bias in trees
Based on your comment I'd go with a conditional inference framework. The code is readily available in R using the ctree function in the party package. It has unbiased variable selection, and while the |
37,537 | Remove measured distribution from another distribution | Instead of going down a rocky road with the deconvolution, a possible approach is to plug the assumed Gaussian distribution for $X_\beta$ into a convolution with the PDF of $D_x\delta$, the above $f_{D_x\delta}$. The resulting curve can then be made to fit the measured profile with an iterative algorithm varying $\sigma_{x_\beta}$, the sought standard deviation of the assumed Gaussian distribution.
I got reasonable results with this method. Nonetheless, I'm open for your suggestions and other, possibly better approaches... :-) Thank you. | Remove measured distribution from another distribution | Instead of going down a rocky road with the deconvolution, a possible approach is to plug the assumed Gaussian distribution for $X_\beta$ into a convolution with the PDF of $D_x\delta$, the above $f_{ | Remove measured distribution from another distribution
Instead of going down a rocky road with the deconvolution, a possible approach is to plug the assumed Gaussian distribution for $X_\beta$ into a convolution with the PDF of $D_x\delta$, the above $f_{D_x\delta}$. The resulting curve can then be made to fit the measured profile with an iterative algorithm varying $\sigma_{x_\beta}$, the sought standard deviation of the assumed Gaussian distribution.
I got reasonable results with this method. Nonetheless, I'm open for your suggestions and other, possibly better approaches... :-) Thank you. | Remove measured distribution from another distribution
Instead of going down a rocky road with the deconvolution, a possible approach is to plug the assumed Gaussian distribution for $X_\beta$ into a convolution with the PDF of $D_x\delta$, the above $f_{ |
37,538 | Constructing a problem-specific loss function | You can use hinge loss which is an upper bound on the classification loss; that is, it penalizes the model if the label of the highest scoring category is different from the label of the ground-truth class.
For more details on the relation between classification loss and hinge loss you can read Section 2 of this awesome paper from C.N. J. Yu and T. Joachims.
In summary, there is a task loss, usually denoted by $\Delta \left( y_i, \hat{y}(x_i) \right)$, which measures the penalty for predicting output $\hat{y}(x_i)$ for input $x_i$ when the expected (ground-truth) output is $y_i$. The task loss for multi-class classification is usually defined as $\Delta \left( y_i, \hat{y}(x_i) \right) = \mathbf{1}\{ y_i \neq \hat{y}(x_i) \}$. However, as long as $\Delta$ only depends on the two labels $y$ and $\hat{y}$, you can define it however you want. In particular, one can view $\Delta$ as an arbitrary $K \times K$ matrix where $K$ is the number of categories and $\Delta(a, b)$ indicates the penalty of classifying an input of category $a$ as belonging to category $b$.
For example:
$\\\text{input data}: \\
\{(x_1, y_1), (x_2, y_2), (x_3, y_3)\}, \quad x_i \in \mathbb{R}^d, \quad y_i \in \mathcal{Y}=\{c_1, c_2, c_3, c_4\} \\
\text{network predictions}:\\
\hat{y}(x_1)=c_2, \quad \hat{y}(x_2)=c_1, \quad \hat{y}(x_3)=c_3 \\
\text{task loss matrix}:\\
\begin{bmatrix}
\Delta(y_{1}, y_{1}) & \Delta(y_{1}, y_{2}) & \Delta(y_{1}, y_{3}) & \Delta(y_{1}, y_{4}) \\
\Delta(y_{2}, y_{1}) & \Delta(y_{2}, y_{2}) & \Delta(y_{2}, y_{3}) & \Delta(y_{2}, y_{4}) \\
\Delta(y_{3}, y_{1}) & \Delta(y_{3}, y_{2}) & \Delta(y_{3}, y_{3}) & \Delta(y_{3}, y_{4}) \\
\Delta(y_{4}, y_{1}) & \Delta(y_{4}, y_{2}) & \Delta(y_{4}, y_{3}) & \Delta(y_{4}, y_{4})
\end{bmatrix}
=
\begin{bmatrix}
0 & 1 & 2 & 3 \\
1 & 0 & 1 & 2 \\
2 & 1 & 0 & 1 \\
3 & 2 & 1 & 0
\end{bmatrix}
\\
\text{classification loss assuming $\quad y_1=c_4, \quad y_2=c_1, \quad y_3=c_4$:} \\
\Delta(y_1, \hat{y}(x_1)) = \Delta(c_4, c_2) = 2 \\
\Delta(y_2, \hat{y}(x_2)) = \Delta(c_1, c_1) = 0 \\
\Delta(y_3, \hat{y}(x_3)) = \Delta(c_4, c_3) = 1 \\
$ | Constructing a problem-specific loss function | You can use hinge loss which is an upper bound on the classification loss; that is, it penalizes the model if the label of the highest scoring category is different from the label of the ground-truth | Constructing a problem-specific loss function
You can use hinge loss which is an upper bound on the classification loss; that is, it penalizes the model if the label of the highest scoring category is different from the label of the ground-truth class.
For more details on the relation between classification loss and hinge loss you can read Section 2 of this awesome paper from C.N. J. Yu and T. Joachims.
In summary, there is a task loss, usually denoted by $\Delta \left( y_i, \hat{y}(x_i) \right)$, which measures the penalty for predicting output $\hat{y}(x_i)$ for input $x_i$ when the expected (ground-truth) output is $y_i$. The task loss for multi-class classification is usually defined as $\Delta \left( y_i, \hat{y}(x_i) \right) = \mathbf{1}\{ y_i \neq \hat{y}(x_i) \}$. However, as long as $\Delta$ only depends on the two labels $y$ and $\hat{y}$, you can define it however you want. In particular, one can view $\Delta$ as an arbitrary $K \times K$ matrix where $K$ is the number of categories and $\Delta(a, b)$ indicates the penalty of classifying an input of category $a$ as belonging to category $b$.
For example:
$\\\text{input data}: \\
\{(x_1, y_1), (x_2, y_2), (x_3, y_3)\}, \quad x_i \in \mathbb{R}^d, \quad y_i \in \mathcal{Y}=\{c_1, c_2, c_3, c_4\} \\
\text{network predictions}:\\
\hat{y}(x_1)=c_2, \quad \hat{y}(x_2)=c_1, \quad \hat{y}(x_3)=c_3 \\
\text{task loss matrix}:\\
\begin{bmatrix}
\Delta(y_{1}, y_{1}) & \Delta(y_{1}, y_{2}) & \Delta(y_{1}, y_{3}) & \Delta(y_{1}, y_{4}) \\
\Delta(y_{2}, y_{1}) & \Delta(y_{2}, y_{2}) & \Delta(y_{2}, y_{3}) & \Delta(y_{2}, y_{4}) \\
\Delta(y_{3}, y_{1}) & \Delta(y_{3}, y_{2}) & \Delta(y_{3}, y_{3}) & \Delta(y_{3}, y_{4}) \\
\Delta(y_{4}, y_{1}) & \Delta(y_{4}, y_{2}) & \Delta(y_{4}, y_{3}) & \Delta(y_{4}, y_{4})
\end{bmatrix}
=
\begin{bmatrix}
0 & 1 & 2 & 3 \\
1 & 0 & 1 & 2 \\
2 & 1 & 0 & 1 \\
3 & 2 & 1 & 0
\end{bmatrix}
\\
\text{classification loss assuming $\quad y_1=c_4, \quad y_2=c_1, \quad y_3=c_4$:} \\
\Delta(y_1, \hat{y}(x_1)) = \Delta(c_4, c_2) = 2 \\
\Delta(y_2, \hat{y}(x_2)) = \Delta(c_1, c_1) = 0 \\
\Delta(y_3, \hat{y}(x_3)) = \Delta(c_4, c_3) = 1 \\
$ | Constructing a problem-specific loss function
You can use hinge loss which is an upper bound on the classification loss; that is, it penalizes the model if the label of the highest scoring category is different from the label of the ground-truth |
37,539 | Why do we use the eigenvectors of the Laplacian and not the Affinity matrix in spectral clustering? | Why the Laplacian?
The main idea in Spectral clustering is:
Find a graph representation of the data
Find a partition of the graph into $k$ highly inter-connected and lowly intra-connected 'clusters'
Step 2. can be reformulated as finding the minimum 'cut' of edges required to separate the graph into $k$ components.
It turns out* that minimising the value of the cut is equivalent to minimising a function of the Laplacian $L = D - W$:
$$\min_{A_1,...,A_k} \textrm{Tr}(H'LH) \textrm{ subject to } H'H = I$$
Where the columns of $H \in \mathbb{R}^{n \times k}$ are the indicator vectors of the $k$ vertex sets $A_1,...,A_k$ partitioning the graph.
Note: the solution of this is in general NP-hard given the definition of $H$, but a relaxed version where its entries can take any real value is solved by choosing $H$ as the matrix which contains the first $k$ eigenvectors of $L$ as columns.
These eigenvectors span the same space spanned by the partition indicator vectors, a space containing a lower dimensional embedding of our graph within which (due to the nature of the minimisation problem) our clusters are now more easily separable.
Properties of the Laplacian
Intuition for this may be motivated by recognising the Laplacian has several useful properties absent in the adjacency matrix:
The smallest eigenvalue of $L$ is $\lambda_0 = 0$ and its multiplicity equals the number of connected components in the graph.
The eigenspace of $\lambda_0$ is spanned by the indicator vectors of those components.
$L$ is singular
$L = UU^T$ where $U$ is the incidence matrix of the (arbitrarily directed) graph (and hence $L$ is positive-semidefinite)
Further reading
* See Chapter 5 of the following document for a full derivation:
... the main trick is to change the representation of the abstract data points $x_i [∈ \mathbb{R}^n]$ to points $y_i ∈ \mathbb{R}^k$. It is due to the properties of the graph Laplacians that this change of representation is useful. We will see in the next sections that this change of representation enhances the cluster-properties in the data, so that they can be trivially detected in the new representation. In particular, the simple k-means clustering algorithm has no difficulties to detect the clusters in this new representation.
- A Tutorial on Spectral Clustering (2006)
For further reading, see the original papers proposing he method:
Spectral clustering goes back to Donath and Hoffman (1973), who first suggested to construct graph partitions based on eigenvectors of the adjacency matrix. In the same year, Fiedler (1973) discovered that bi-partitions of a graph are closely connected with the second eigenvector of the graph Laplacian, and he suggested to use this eigenvector to partition a graph.
Note Fiedler himself states prior to this the Adjacency matrix (and incidence matrix) were indeed previously used to characterize graphs:
We recall that many authors, e.g. A. J. HOFFMAN, M. DOOB, D. K. RAY-CHAUDHURi, J. J. SEIDEL have characterized graphs by means of the spectra of the $(0, 1)$ and $(0, 1, —1)$ adjacency matrices. | Why do we use the eigenvectors of the Laplacian and not the Affinity matrix in spectral clustering? | Why the Laplacian?
The main idea in Spectral clustering is:
Find a graph representation of the data
Find a partition of the graph into $k$ highly inter-connected and lowly intra-connected 'clusters'
| Why do we use the eigenvectors of the Laplacian and not the Affinity matrix in spectral clustering?
Why the Laplacian?
The main idea in Spectral clustering is:
Find a graph representation of the data
Find a partition of the graph into $k$ highly inter-connected and lowly intra-connected 'clusters'
Step 2. can be reformulated as finding the minimum 'cut' of edges required to separate the graph into $k$ components.
It turns out* that minimising the value of the cut is equivalent to minimising a function of the Laplacian $L = D - W$:
$$\min_{A_1,...,A_k} \textrm{Tr}(H'LH) \textrm{ subject to } H'H = I$$
Where the columns of $H \in \mathbb{R}^{n \times k}$ are the indicator vectors of the $k$ vertex sets $A_1,...,A_k$ partitioning the graph.
Note: the solution of this is in general NP-hard given the definition of $H$, but a relaxed version where its entries can take any real value is solved by choosing $H$ as the matrix which contains the first $k$ eigenvectors of $L$ as columns.
These eigenvectors span the same space spanned by the partition indicator vectors, a space containing a lower dimensional embedding of our graph within which (due to the nature of the minimisation problem) our clusters are now more easily separable.
Properties of the Laplacian
Intuition for this may be motivated by recognising the Laplacian has several useful properties absent in the adjacency matrix:
The smallest eigenvalue of $L$ is $\lambda_0 = 0$ and its multiplicity equals the number of connected components in the graph.
The eigenspace of $\lambda_0$ is spanned by the indicator vectors of those components.
$L$ is singular
$L = UU^T$ where $U$ is the incidence matrix of the (arbitrarily directed) graph (and hence $L$ is positive-semidefinite)
Further reading
* See Chapter 5 of the following document for a full derivation:
... the main trick is to change the representation of the abstract data points $x_i [∈ \mathbb{R}^n]$ to points $y_i ∈ \mathbb{R}^k$. It is due to the properties of the graph Laplacians that this change of representation is useful. We will see in the next sections that this change of representation enhances the cluster-properties in the data, so that they can be trivially detected in the new representation. In particular, the simple k-means clustering algorithm has no difficulties to detect the clusters in this new representation.
- A Tutorial on Spectral Clustering (2006)
For further reading, see the original papers proposing he method:
Spectral clustering goes back to Donath and Hoffman (1973), who first suggested to construct graph partitions based on eigenvectors of the adjacency matrix. In the same year, Fiedler (1973) discovered that bi-partitions of a graph are closely connected with the second eigenvector of the graph Laplacian, and he suggested to use this eigenvector to partition a graph.
Note Fiedler himself states prior to this the Adjacency matrix (and incidence matrix) were indeed previously used to characterize graphs:
We recall that many authors, e.g. A. J. HOFFMAN, M. DOOB, D. K. RAY-CHAUDHURi, J. J. SEIDEL have characterized graphs by means of the spectra of the $(0, 1)$ and $(0, 1, —1)$ adjacency matrices. | Why do we use the eigenvectors of the Laplacian and not the Affinity matrix in spectral clustering?
Why the Laplacian?
The main idea in Spectral clustering is:
Find a graph representation of the data
Find a partition of the graph into $k$ highly inter-connected and lowly intra-connected 'clusters'
|
37,540 | Bayesian vs. Frequentist calculation steps | Brendon Brewer (the author) wrote a follow-up post on his blog that details the nitty-gritty for both the posterior probability and p-value calculations.
The p-value calculations are pretty standard, assuming a binomial likelihood. The Bayesian model he uses is defined as
\begin{align*}
p & \sim \text{dirac-uniform-mixture} \\
x \, | \, p & \sim \text{binomial(100, p)}
\end{align*}
where the Dirac/uniform mixture is defined for $p \in [0, 1]$ by
\begin{equation*}
\pi(p) = \frac{1}{2}\delta(p - 0.7) + \frac{1}{2}.
\end{equation*}
So given a model, you can calculate posterior probabilities in the standard way. Brendon (sensibly) uses a discrete approximation in his technical details, but it can be illustrative to grind things out analytically. I'll demonstrate how one can get to the 0.89 posterior probability of the new drug being better than the old; the other calculations proceed similarly.
The posterior is defined by
\begin{equation*}
\pi(p \, | \, x) = \frac{\pi(x \, | \, p) \pi(p)}{\pi(x)}
\end{equation*}
where $\pi(x \, | \, p)$ is the binomial mass function, and the normalizing function $\pi(x)$ for general $n$ is
\begin{align*}
\pi(x)
& = \int_{0}^{1} \pi(x \, | \, p)\pi(p) dp \\
& = \frac{1}{2}{n \choose x}\left(\int_{0}^{1}\delta(p - 0.7)p^x (1 - p)^{n - x}dp + \int_{0}^{1}p^x (1 - p)^{n - x} dp \right) \\
& = \frac{1}{2}{n \choose x}\left(0.7^x 0.3^{n - x} + B(x + 1, n - x + 1)\right).
\end{align*}
Here I've used the fact that $\int \delta(t-x)f(t)dt = f(x)$ (for sufficiently nice $f$) and that $\int_{0}^{1}p^{\alpha - 1}(1 - p)^{\beta - 1}dp = B(\alpha, \beta)$ for $B$ the beta function (see here).
Given the posterior, one just needs to work through some integration to find $P(p > 0.7 \, | \, x = 83)$:
\begin{align*}
\int_{0.7}^{1} \pi(p \, | \, x = 83) dp
& = \frac{1}{\pi(x = 83)} \int_{0.7}^{1} \left(\frac{1}{2}\delta(p - 0.7) + \frac{1}{2}\right)\pi(x = 83 \, | \, p) dp \\
& = \frac{1}{\pi(x = 83)} \int_{0.7}^{1} \frac{1}{2} {100 \choose 83} p^{83} (1 - p)^{17} dp \\
& = \frac{\int_{0.7}^{1} p^{83} (1 - p)^{17} dp}{0.7^{83} 0.3^{17} + B(84, 18)} \\
& = 0.8907679.
\end{align*} | Bayesian vs. Frequentist calculation steps | Brendon Brewer (the author) wrote a follow-up post on his blog that details the nitty-gritty for both the posterior probability and p-value calculations.
The p-value calculations are pretty standard, | Bayesian vs. Frequentist calculation steps
Brendon Brewer (the author) wrote a follow-up post on his blog that details the nitty-gritty for both the posterior probability and p-value calculations.
The p-value calculations are pretty standard, assuming a binomial likelihood. The Bayesian model he uses is defined as
\begin{align*}
p & \sim \text{dirac-uniform-mixture} \\
x \, | \, p & \sim \text{binomial(100, p)}
\end{align*}
where the Dirac/uniform mixture is defined for $p \in [0, 1]$ by
\begin{equation*}
\pi(p) = \frac{1}{2}\delta(p - 0.7) + \frac{1}{2}.
\end{equation*}
So given a model, you can calculate posterior probabilities in the standard way. Brendon (sensibly) uses a discrete approximation in his technical details, but it can be illustrative to grind things out analytically. I'll demonstrate how one can get to the 0.89 posterior probability of the new drug being better than the old; the other calculations proceed similarly.
The posterior is defined by
\begin{equation*}
\pi(p \, | \, x) = \frac{\pi(x \, | \, p) \pi(p)}{\pi(x)}
\end{equation*}
where $\pi(x \, | \, p)$ is the binomial mass function, and the normalizing function $\pi(x)$ for general $n$ is
\begin{align*}
\pi(x)
& = \int_{0}^{1} \pi(x \, | \, p)\pi(p) dp \\
& = \frac{1}{2}{n \choose x}\left(\int_{0}^{1}\delta(p - 0.7)p^x (1 - p)^{n - x}dp + \int_{0}^{1}p^x (1 - p)^{n - x} dp \right) \\
& = \frac{1}{2}{n \choose x}\left(0.7^x 0.3^{n - x} + B(x + 1, n - x + 1)\right).
\end{align*}
Here I've used the fact that $\int \delta(t-x)f(t)dt = f(x)$ (for sufficiently nice $f$) and that $\int_{0}^{1}p^{\alpha - 1}(1 - p)^{\beta - 1}dp = B(\alpha, \beta)$ for $B$ the beta function (see here).
Given the posterior, one just needs to work through some integration to find $P(p > 0.7 \, | \, x = 83)$:
\begin{align*}
\int_{0.7}^{1} \pi(p \, | \, x = 83) dp
& = \frac{1}{\pi(x = 83)} \int_{0.7}^{1} \left(\frac{1}{2}\delta(p - 0.7) + \frac{1}{2}\right)\pi(x = 83 \, | \, p) dp \\
& = \frac{1}{\pi(x = 83)} \int_{0.7}^{1} \frac{1}{2} {100 \choose 83} p^{83} (1 - p)^{17} dp \\
& = \frac{\int_{0.7}^{1} p^{83} (1 - p)^{17} dp}{0.7^{83} 0.3^{17} + B(84, 18)} \\
& = 0.8907679.
\end{align*} | Bayesian vs. Frequentist calculation steps
Brendon Brewer (the author) wrote a follow-up post on his blog that details the nitty-gritty for both the posterior probability and p-value calculations.
The p-value calculations are pretty standard, |
37,541 | Bayesian regression with singular $(X'X)$ - Is the posterior well-defined? | The major problem with your question is that taking limits does not straightforwardly extend to measures and probability distributions. There are many different types of convergence associated with measures.
Hence, considering the conjugate
$$\beta|h \sim \mathcal{N}(0,cI), h\sim \mathcal{G}(s^{-2},\nu)$$
and letting $\nu$ and $c$ go to $0$ and $\infty$, respectively, does not have a proper or unique mathematical meaning.
Now, if you consider the improper prior
$$\pi(\beta,h)\propto\frac{1}{h}$$
there is no posterior distribution associated with the likelihood
$$L(\beta,h|X,y)=\exp\{-h(y-X\beta)^\text{T}(y-X\beta)/2\}h^{T/2}$$
because the potential posterior does not integrate in $\beta$ conditional on $h$. There is no $$\hat{\Sigma}=(X^\text{T}X)^{-1}$$ either because the inverse does not exist and no well-defined distribution on $A\beta$. | Bayesian regression with singular $(X'X)$ - Is the posterior well-defined? | The major problem with your question is that taking limits does not straightforwardly extend to measures and probability distributions. There are many different types of convergence associated with me | Bayesian regression with singular $(X'X)$ - Is the posterior well-defined?
The major problem with your question is that taking limits does not straightforwardly extend to measures and probability distributions. There are many different types of convergence associated with measures.
Hence, considering the conjugate
$$\beta|h \sim \mathcal{N}(0,cI), h\sim \mathcal{G}(s^{-2},\nu)$$
and letting $\nu$ and $c$ go to $0$ and $\infty$, respectively, does not have a proper or unique mathematical meaning.
Now, if you consider the improper prior
$$\pi(\beta,h)\propto\frac{1}{h}$$
there is no posterior distribution associated with the likelihood
$$L(\beta,h|X,y)=\exp\{-h(y-X\beta)^\text{T}(y-X\beta)/2\}h^{T/2}$$
because the potential posterior does not integrate in $\beta$ conditional on $h$. There is no $$\hat{\Sigma}=(X^\text{T}X)^{-1}$$ either because the inverse does not exist and no well-defined distribution on $A\beta$. | Bayesian regression with singular $(X'X)$ - Is the posterior well-defined?
The major problem with your question is that taking limits does not straightforwardly extend to measures and probability distributions. There are many different types of convergence associated with me |
37,542 | Pagerank vs Eigenvector centrality | Eigenvector centrality is undirected, and PageRank applies for directed network. However, PageRank uses the indegree as the main measure to estimate the influence level, thus it turns to be a very specific case or variant of Eigenvector centrality. | Pagerank vs Eigenvector centrality | Eigenvector centrality is undirected, and PageRank applies for directed network. However, PageRank uses the indegree as the main measure to estimate the influence level, thus it turns to be a very spe | Pagerank vs Eigenvector centrality
Eigenvector centrality is undirected, and PageRank applies for directed network. However, PageRank uses the indegree as the main measure to estimate the influence level, thus it turns to be a very specific case or variant of Eigenvector centrality. | Pagerank vs Eigenvector centrality
Eigenvector centrality is undirected, and PageRank applies for directed network. However, PageRank uses the indegree as the main measure to estimate the influence level, thus it turns to be a very spe |
37,543 | Comparing unbalanced groups with ANOVA/Kruskal-Wallis when one group has only 1 observation | You can perform inference in one-way-ANOVA type designs where there's a group with only one observation if you make the equal-variance assumption. If you don't assume equal variance (or some other informative variance structure), then you won't have information about variance in the singleton group.
Not all packages will deal with it in their implementation of ANOVA, it depends on how they're set up, but that doesn't mean it can't be done. [I gave an example of performing a t-test with a singleton in another answer on site.]
Here's an example in R with a singleton group both included and omitted for both one-way ANOVA and Kruskal-Wallis:
x=rnorm(100)
g=as.factor(rep(1:5,c(40,30,20,9,1)))
anova(lm(x~g))
Analysis of Variance Table
Response: x
Df Sum Sq Mean Sq F value Pr(>F)
g 4 6.554 1.63839 1.6588 0.166
Residuals 95 93.830 0.98769
anova(lm(x[-100]~g[-100]))
Analysis of Variance Table
Response: x[-100]
Df Sum Sq Mean Sq F value Pr(>F)
g[-100] 3 3.498 1.16608 1.1806 0.3213
Residuals 95 93.830 0.98769
kruskal.test(x~g)
Kruskal-Wallis rank sum test
data: x by g
Kruskal-Wallis chi-squared = 5.9232, df = 4, p-value = 0.205
kruskal.test(x[-100]~g[-100])
Kruskal-Wallis rank sum test
data: x[-100] by g[-100]
Kruskal-Wallis chi-squared = 3.1894, df = 3, p-value = 0.3633 | Comparing unbalanced groups with ANOVA/Kruskal-Wallis when one group has only 1 observation | You can perform inference in one-way-ANOVA type designs where there's a group with only one observation if you make the equal-variance assumption. If you don't assume equal variance (or some other inf | Comparing unbalanced groups with ANOVA/Kruskal-Wallis when one group has only 1 observation
You can perform inference in one-way-ANOVA type designs where there's a group with only one observation if you make the equal-variance assumption. If you don't assume equal variance (or some other informative variance structure), then you won't have information about variance in the singleton group.
Not all packages will deal with it in their implementation of ANOVA, it depends on how they're set up, but that doesn't mean it can't be done. [I gave an example of performing a t-test with a singleton in another answer on site.]
Here's an example in R with a singleton group both included and omitted for both one-way ANOVA and Kruskal-Wallis:
x=rnorm(100)
g=as.factor(rep(1:5,c(40,30,20,9,1)))
anova(lm(x~g))
Analysis of Variance Table
Response: x
Df Sum Sq Mean Sq F value Pr(>F)
g 4 6.554 1.63839 1.6588 0.166
Residuals 95 93.830 0.98769
anova(lm(x[-100]~g[-100]))
Analysis of Variance Table
Response: x[-100]
Df Sum Sq Mean Sq F value Pr(>F)
g[-100] 3 3.498 1.16608 1.1806 0.3213
Residuals 95 93.830 0.98769
kruskal.test(x~g)
Kruskal-Wallis rank sum test
data: x by g
Kruskal-Wallis chi-squared = 5.9232, df = 4, p-value = 0.205
kruskal.test(x[-100]~g[-100])
Kruskal-Wallis rank sum test
data: x[-100] by g[-100]
Kruskal-Wallis chi-squared = 3.1894, df = 3, p-value = 0.3633 | Comparing unbalanced groups with ANOVA/Kruskal-Wallis when one group has only 1 observation
You can perform inference in one-way-ANOVA type designs where there's a group with only one observation if you make the equal-variance assumption. If you don't assume equal variance (or some other inf |
37,544 | Can you use the Kolmogorov-Smirnov test to directly test for equivalence of two distributions? | When conducting the Kolmogorov-Smirnov test, we assume $H_0:$ the two distributions are equivalent. We then calculate a test statistic and, if the corresponding $p$-value is small enough, we reject $H_0$ and conclude $H_A:$ the two distributions are different.
As far as hypothesis tests go, we use a $p$-value to quantify the amount of evidence we have to reject the null hypothesis. A $p$-value of 1 indicates that we have gathered no evidence to reject the null hypothesis. A $p$-value close to 0 indicates there is overwhelming evidence to reject the null hypothesis.
Let's assume we have data and calculate a $p$-value from the K-S test where $p=0.99.$ This indicates there is very little evidence to reject the null hypothesis. However, we cannot establish a standard of $\alpha=0.95$ such that $p>\alpha$ implies that we conclude the null hypothesis is correct. Further, I don't believe there is an alternate test that would allow us to conclude that the two distributions are the same.
What I believe you can do is to be entirely honest in the write-up or discussion. Mention that you ran a K-S test, report a $p$-value, and if the $p$-value is sufficiently high, then articulate that there is very little evidence to suggest that the two distributions are different. So, while you cannot conclude that the distributions are identical, you should be able to note that there is no evidence suggesting that the two distributions are different. As your sample size $n$ increases, the more faith you'll have in this answer.
It's not quite the answer that you were probably looking for, but it's not a total wash, either. Hope this helps! | Can you use the Kolmogorov-Smirnov test to directly test for equivalence of two distributions? | When conducting the Kolmogorov-Smirnov test, we assume $H_0:$ the two distributions are equivalent. We then calculate a test statistic and, if the corresponding $p$-value is small enough, we reject $ | Can you use the Kolmogorov-Smirnov test to directly test for equivalence of two distributions?
When conducting the Kolmogorov-Smirnov test, we assume $H_0:$ the two distributions are equivalent. We then calculate a test statistic and, if the corresponding $p$-value is small enough, we reject $H_0$ and conclude $H_A:$ the two distributions are different.
As far as hypothesis tests go, we use a $p$-value to quantify the amount of evidence we have to reject the null hypothesis. A $p$-value of 1 indicates that we have gathered no evidence to reject the null hypothesis. A $p$-value close to 0 indicates there is overwhelming evidence to reject the null hypothesis.
Let's assume we have data and calculate a $p$-value from the K-S test where $p=0.99.$ This indicates there is very little evidence to reject the null hypothesis. However, we cannot establish a standard of $\alpha=0.95$ such that $p>\alpha$ implies that we conclude the null hypothesis is correct. Further, I don't believe there is an alternate test that would allow us to conclude that the two distributions are the same.
What I believe you can do is to be entirely honest in the write-up or discussion. Mention that you ran a K-S test, report a $p$-value, and if the $p$-value is sufficiently high, then articulate that there is very little evidence to suggest that the two distributions are different. So, while you cannot conclude that the distributions are identical, you should be able to note that there is no evidence suggesting that the two distributions are different. As your sample size $n$ increases, the more faith you'll have in this answer.
It's not quite the answer that you were probably looking for, but it's not a total wash, either. Hope this helps! | Can you use the Kolmogorov-Smirnov test to directly test for equivalence of two distributions?
When conducting the Kolmogorov-Smirnov test, we assume $H_0:$ the two distributions are equivalent. We then calculate a test statistic and, if the corresponding $p$-value is small enough, we reject $ |
37,545 | predictive models for panel data | Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Check out this publication:
Pargent, F., & Albert-von der Gönna, J. (2018). Predictive Modeling With Psychological Panel Data. Zeitschrift Für Psychologie, 226(4), 246–258. https://doi.org/10.1027/2151-2604/a000343 | predictive models for panel data | Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
| predictive models for panel data
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Check out this publication:
Pargent, F., & Albert-von der Gönna, J. (2018). Predictive Modeling With Psychological Panel Data. Zeitschrift Für Psychologie, 226(4), 246–258. https://doi.org/10.1027/2151-2604/a000343 | predictive models for panel data
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
37,546 | predictive models for panel data | When you have panel data, there are a different tasks that you can try to solve. And for each task, there are numerous approaches to solve it. Econometricians are typically interested in panel forecasting. Other common tasks are time series classification or regression.
When you want to use machine learning methods to solve panel forecasting, there are a number of approaches:
Regarding your input data (X), treating units (what you call items) as i.i.d. samples, you can
bin the time series and treat each bin as a separate column, ignoring any temporal ordering, with equal bins for all units, the bin size could of course simply be the observed time series measurement, or you could upsample and aggregate into larger bins, then use standard machine learning algorithms for tabular data,
or extract features from the time series for each unit, and use each extracted feature as a separate columns, again combined with standard tabular algorithms,
or use specialised time series regression/classification algorithms depending on whether you observe continuous or categorical time series data.
Regarding your output data (y), if you want to forecast multiple time points in the future, you can
fit an estimator for each step ahead that you want to forecast, always using the same input data,
or fit a single estimator for the first step ahead and in prediction, roll the input data in time, using the first step predictions to append to the observed input data to make the second step predictions and so on.
All of the approaches above basically reduce the panel forecasting problem to a time series regression or tabular regression problem. Once your data is in the time series or tabular regression format, you can also append any time-invariant features for users.
Of course there are other options to solve the panel forecasting problem, like for example using classical forecasting methods like ARIMA adapted to panel data or deep learning methods that allow you to directly make sequence to sequence predictions. | predictive models for panel data | When you have panel data, there are a different tasks that you can try to solve. And for each task, there are numerous approaches to solve it. Econometricians are typically interested in panel forecas | predictive models for panel data
When you have panel data, there are a different tasks that you can try to solve. And for each task, there are numerous approaches to solve it. Econometricians are typically interested in panel forecasting. Other common tasks are time series classification or regression.
When you want to use machine learning methods to solve panel forecasting, there are a number of approaches:
Regarding your input data (X), treating units (what you call items) as i.i.d. samples, you can
bin the time series and treat each bin as a separate column, ignoring any temporal ordering, with equal bins for all units, the bin size could of course simply be the observed time series measurement, or you could upsample and aggregate into larger bins, then use standard machine learning algorithms for tabular data,
or extract features from the time series for each unit, and use each extracted feature as a separate columns, again combined with standard tabular algorithms,
or use specialised time series regression/classification algorithms depending on whether you observe continuous or categorical time series data.
Regarding your output data (y), if you want to forecast multiple time points in the future, you can
fit an estimator for each step ahead that you want to forecast, always using the same input data,
or fit a single estimator for the first step ahead and in prediction, roll the input data in time, using the first step predictions to append to the observed input data to make the second step predictions and so on.
All of the approaches above basically reduce the panel forecasting problem to a time series regression or tabular regression problem. Once your data is in the time series or tabular regression format, you can also append any time-invariant features for users.
Of course there are other options to solve the panel forecasting problem, like for example using classical forecasting methods like ARIMA adapted to panel data or deep learning methods that allow you to directly make sequence to sequence predictions. | predictive models for panel data
When you have panel data, there are a different tasks that you can try to solve. And for each task, there are numerous approaches to solve it. Econometricians are typically interested in panel forecas |
37,547 | predictive models for panel data | Lots of good references:
Gelman and Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models
Pesaran, H. M., Time Series and Panel Data Econometrics
Gelman and Hill's book is more applied while Pesaran has made original contributions by developing and extending classic univariate time series tests for stationarity, autoregression, unit roots, weak dependence between cross-sections, and so on, to panel data models. | predictive models for panel data | Lots of good references:
Gelman and Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models
Pesaran, H. M., Time Series and Panel Data Econometrics
Gelman and Hill's book is more appli | predictive models for panel data
Lots of good references:
Gelman and Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models
Pesaran, H. M., Time Series and Panel Data Econometrics
Gelman and Hill's book is more applied while Pesaran has made original contributions by developing and extending classic univariate time series tests for stationarity, autoregression, unit roots, weak dependence between cross-sections, and so on, to panel data models. | predictive models for panel data
Lots of good references:
Gelman and Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models
Pesaran, H. M., Time Series and Panel Data Econometrics
Gelman and Hill's book is more appli |
37,548 | What are the reasonable properties of p-value combination methods when all p-values are the same? | Interestingly most of the theoretical work on meta-analysis of significance values is quite old. One important source is
an article by Birnbaum, 1954, Combining Independent Tests of Significance
and I think his abstract is worth quoting in full.
It is shown that no single method of combining independent tests of significance is optimal in general, and hence that the kinds of tests to be combined should be considered in selecting a method of combination. A number of proposed methods of combination are applied to a particular common testing problem. It is shown that for such problems Fisher's method and a method proposed by Tippett have an optimal property.
Those two methods are of course the two you mention.
Two other sources which might shed some light are a paper by Cousins in ArXiv (Annotated Bibliography of Some Papers on Combining Significances or p-values, 2007) and a simulation study by Loughin (Annotated Bibliography of Some Papers on Combining Significances or p-values, 2004).
There is also a 1958 paper which I have not read by T Lipták called On the combination of independent tests in a Hungarian journal which examines the problem from an even more general angle or so I understand from secondary sources. | What are the reasonable properties of p-value combination methods when all p-values are the same? | Interestingly most of the theoretical work on meta-analysis of significance values is quite old. One important source is
an article by Birnbaum, 1954, Combining Independent Tests of Significance
and I | What are the reasonable properties of p-value combination methods when all p-values are the same?
Interestingly most of the theoretical work on meta-analysis of significance values is quite old. One important source is
an article by Birnbaum, 1954, Combining Independent Tests of Significance
and I think his abstract is worth quoting in full.
It is shown that no single method of combining independent tests of significance is optimal in general, and hence that the kinds of tests to be combined should be considered in selecting a method of combination. A number of proposed methods of combination are applied to a particular common testing problem. It is shown that for such problems Fisher's method and a method proposed by Tippett have an optimal property.
Those two methods are of course the two you mention.
Two other sources which might shed some light are a paper by Cousins in ArXiv (Annotated Bibliography of Some Papers on Combining Significances or p-values, 2007) and a simulation study by Loughin (Annotated Bibliography of Some Papers on Combining Significances or p-values, 2004).
There is also a 1958 paper which I have not read by T Lipták called On the combination of independent tests in a Hungarian journal which examines the problem from an even more general angle or so I understand from secondary sources. | What are the reasonable properties of p-value combination methods when all p-values are the same?
Interestingly most of the theoretical work on meta-analysis of significance values is quite old. One important source is
an article by Birnbaum, 1954, Combining Independent Tests of Significance
and I |
37,549 | How do I use weight vector of SVM and logistic regression for feature importance? | 1) Assuming you have properly pre-processed your data then I would consider the absolute value of the weight. Negative value just means that it has a negative impact on the outcome, but a large negative weight is still significant. (note that this does not hold if the data is not standardized)
2) If you are using a non linear kernel then the weight only make sense in the higher dimensional space in which the kernel exists. In the case of the RBF kernel this space has infinite dimension which makes your life harder. If you were using a polynomial kernel, then the weights would still be useful, but some weights would represent power terms or interactions terms. Have a look at this post
How to intuitively explain what a kernel is? | How do I use weight vector of SVM and logistic regression for feature importance? | 1) Assuming you have properly pre-processed your data then I would consider the absolute value of the weight. Negative value just means that it has a negative impact on the outcome, but a large negati | How do I use weight vector of SVM and logistic regression for feature importance?
1) Assuming you have properly pre-processed your data then I would consider the absolute value of the weight. Negative value just means that it has a negative impact on the outcome, but a large negative weight is still significant. (note that this does not hold if the data is not standardized)
2) If you are using a non linear kernel then the weight only make sense in the higher dimensional space in which the kernel exists. In the case of the RBF kernel this space has infinite dimension which makes your life harder. If you were using a polynomial kernel, then the weights would still be useful, but some weights would represent power terms or interactions terms. Have a look at this post
How to intuitively explain what a kernel is? | How do I use weight vector of SVM and logistic regression for feature importance?
1) Assuming you have properly pre-processed your data then I would consider the absolute value of the weight. Negative value just means that it has a negative impact on the outcome, but a large negati |
37,550 | Calculating the Log Likelihood of models in glmnet? | Here is one sure way to compute the log-likelihood of logistic (and probit) regressions, no matter how it is estimated. All you need is the dependent dummy and fitted values.
I tested the function on a model with just a constant and it seems to work well. It is NOT that hard to compute a log likelihood -- so just write it down and compute it by hand. Then, just always use the same function everywhere and your computations will be coherent.
I really don't know why logLik is not yet compatible with glmnet. Penalized pseudo-R2 are often used measures of fit, you need it for information criterion and it just seems more convenient to have that value to compute plenty of test statistics. Anyway, here it is for future reference:
logit_logLik <- function(dummy,fitted_values){
# Description: Computes log-likelihood of a fitted
# logit model
# Format variables
y <- as.matrix(dummy)
p <- as.matrix(fitted_values)
# Adjust dimensions
skip <- dim(y)[1] - dim(p)[1]
y <- as.matrix(y[-c(1:skip),])
# Compute log-likelihood
item <- sapply(1:dim(y)[1], function(i)
y[i,]*log(p[i,]) + (1-y[i,])*log(1-p[i,]))
return(sum(item))
} | Calculating the Log Likelihood of models in glmnet? | Here is one sure way to compute the log-likelihood of logistic (and probit) regressions, no matter how it is estimated. All you need is the dependent dummy and fitted values.
I tested the function on | Calculating the Log Likelihood of models in glmnet?
Here is one sure way to compute the log-likelihood of logistic (and probit) regressions, no matter how it is estimated. All you need is the dependent dummy and fitted values.
I tested the function on a model with just a constant and it seems to work well. It is NOT that hard to compute a log likelihood -- so just write it down and compute it by hand. Then, just always use the same function everywhere and your computations will be coherent.
I really don't know why logLik is not yet compatible with glmnet. Penalized pseudo-R2 are often used measures of fit, you need it for information criterion and it just seems more convenient to have that value to compute plenty of test statistics. Anyway, here it is for future reference:
logit_logLik <- function(dummy,fitted_values){
# Description: Computes log-likelihood of a fitted
# logit model
# Format variables
y <- as.matrix(dummy)
p <- as.matrix(fitted_values)
# Adjust dimensions
skip <- dim(y)[1] - dim(p)[1]
y <- as.matrix(y[-c(1:skip),])
# Compute log-likelihood
item <- sapply(1:dim(y)[1], function(i)
y[i,]*log(p[i,]) + (1-y[i,])*log(1-p[i,]))
return(sum(item))
} | Calculating the Log Likelihood of models in glmnet?
Here is one sure way to compute the log-likelihood of logistic (and probit) regressions, no matter how it is estimated. All you need is the dependent dummy and fitted values.
I tested the function on |
37,551 | How to use a Hidden Markov Model to detect state in a time series? | 1) you should have binomial distribution of output values.
2 ) Baum Welch/ Forward backward are used for training the model. I mean estimation of transition and emission probabilities. Viterbi would give you sequence of hidden states.
3) you get the hidden states and the emission values distribution from all the hidden states. All hidden states would have different emission distribution. Based on emission values, you can say anything about Systole/ Diastole.
This article might help you to understand basics- http://machinelearningstories.blogspot.in/2017/02/hidden-markov-model-session-1.html | How to use a Hidden Markov Model to detect state in a time series? | 1) you should have binomial distribution of output values.
2 ) Baum Welch/ Forward backward are used for training the model. I mean estimation of transition and emission probabilities. Viterbi would g | How to use a Hidden Markov Model to detect state in a time series?
1) you should have binomial distribution of output values.
2 ) Baum Welch/ Forward backward are used for training the model. I mean estimation of transition and emission probabilities. Viterbi would give you sequence of hidden states.
3) you get the hidden states and the emission values distribution from all the hidden states. All hidden states would have different emission distribution. Based on emission values, you can say anything about Systole/ Diastole.
This article might help you to understand basics- http://machinelearningstories.blogspot.in/2017/02/hidden-markov-model-session-1.html | How to use a Hidden Markov Model to detect state in a time series?
1) you should have binomial distribution of output values.
2 ) Baum Welch/ Forward backward are used for training the model. I mean estimation of transition and emission probabilities. Viterbi would g |
37,552 | Two-Way Repeated-Measure design with lme4 | I think I now know which model works, so I can answer the question for myself. Both models work, it depends on the subject-variable.
To get a better understanding of which random parts to use, I have computed four models:
fit <- lme4::lmer(DV ~ group * time + age + education +
(1|lfd) +
(1|group:lfd) +
(1|time:lfd),
data = mydata)
fit2 <- lme4::lmer(DV ~ group * time + age + education +
(1+time|lfd), data = mydata)
fit3 <- lme4::lmer(DV ~ group * time + age + education +
(1|subject), data = mydata)
fit4 <- lme4::lmer(DV ~ group * time + age + education +
(1|lfd), data = mydata)
All four models produce the same (fixed-effects) results. lfd is a repeating number, which repeats an ID 4 times: once per group and once per time (so 2 groups by 2 time points are 4 groups).
subject is a repeated ID for each group in both time points, i.e. I have just 2 groups (group A and B), not further distinguish by time.
For me, the quintessence - after trying to better understand 2-way repeated measures with mixed models - is:
I think that you don't need to worry about nesting as long as you don't repeat subject ID's within treatment groups.
(as already mentioned in this answer, but at that time not understood by me. ;-) ) | Two-Way Repeated-Measure design with lme4 | I think I now know which model works, so I can answer the question for myself. Both models work, it depends on the subject-variable.
To get a better understanding of which random parts to use, I have | Two-Way Repeated-Measure design with lme4
I think I now know which model works, so I can answer the question for myself. Both models work, it depends on the subject-variable.
To get a better understanding of which random parts to use, I have computed four models:
fit <- lme4::lmer(DV ~ group * time + age + education +
(1|lfd) +
(1|group:lfd) +
(1|time:lfd),
data = mydata)
fit2 <- lme4::lmer(DV ~ group * time + age + education +
(1+time|lfd), data = mydata)
fit3 <- lme4::lmer(DV ~ group * time + age + education +
(1|subject), data = mydata)
fit4 <- lme4::lmer(DV ~ group * time + age + education +
(1|lfd), data = mydata)
All four models produce the same (fixed-effects) results. lfd is a repeating number, which repeats an ID 4 times: once per group and once per time (so 2 groups by 2 time points are 4 groups).
subject is a repeated ID for each group in both time points, i.e. I have just 2 groups (group A and B), not further distinguish by time.
For me, the quintessence - after trying to better understand 2-way repeated measures with mixed models - is:
I think that you don't need to worry about nesting as long as you don't repeat subject ID's within treatment groups.
(as already mentioned in this answer, but at that time not understood by me. ;-) ) | Two-Way Repeated-Measure design with lme4
I think I now know which model works, so I can answer the question for myself. Both models work, it depends on the subject-variable.
To get a better understanding of which random parts to use, I have |
37,553 | Bias Correction for Large Scale Logistic Regression with Rare Events | First, I must admit I don't know exactly what you mean by 'online' logistic regression.
Of course, calculation of H is expensive if you really do the matrix operations. However, all that is needed is the diagonal elements of H, who come at much lower cost.
Depending on your explanatory variables, you may be able to group your data such that each covariable/outcome combination can be assigned a frequency count. This speeds up calculations dramatically.
Both these options are implemented (and used by default) in the current version of our R package logistf. | Bias Correction for Large Scale Logistic Regression with Rare Events | First, I must admit I don't know exactly what you mean by 'online' logistic regression.
Of course, calculation of H is expensive if you really do the matrix operations. However, all that is needed is | Bias Correction for Large Scale Logistic Regression with Rare Events
First, I must admit I don't know exactly what you mean by 'online' logistic regression.
Of course, calculation of H is expensive if you really do the matrix operations. However, all that is needed is the diagonal elements of H, who come at much lower cost.
Depending on your explanatory variables, you may be able to group your data such that each covariable/outcome combination can be assigned a frequency count. This speeds up calculations dramatically.
Both these options are implemented (and used by default) in the current version of our R package logistf. | Bias Correction for Large Scale Logistic Regression with Rare Events
First, I must admit I don't know exactly what you mean by 'online' logistic regression.
Of course, calculation of H is expensive if you really do the matrix operations. However, all that is needed is |
37,554 | Nate Silver's Election Prediction Model | There's a description of 538's model here. I'm not sure if it's statistical enough for your liking. | Nate Silver's Election Prediction Model | There's a description of 538's model here. I'm not sure if it's statistical enough for your liking. | Nate Silver's Election Prediction Model
There's a description of 538's model here. I'm not sure if it's statistical enough for your liking. | Nate Silver's Election Prediction Model
There's a description of 538's model here. I'm not sure if it's statistical enough for your liking. |
37,555 | Nate Silver's Election Prediction Model | Silver has written about his affinity for Bayesian methods in The Signal and the Noise and elsewhere. I found this book, which is teaches a bit about Bayesian inference through Python examples was a good read on a complicated topic:
http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
It's available on the web and as an iPython notebook, but you can also buy a hard/e-book copy and support the author's awesome work. | Nate Silver's Election Prediction Model | Silver has written about his affinity for Bayesian methods in The Signal and the Noise and elsewhere. I found this book, which is teaches a bit about Bayesian inference through Python examples was a g | Nate Silver's Election Prediction Model
Silver has written about his affinity for Bayesian methods in The Signal and the Noise and elsewhere. I found this book, which is teaches a bit about Bayesian inference through Python examples was a good read on a complicated topic:
http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
It's available on the web and as an iPython notebook, but you can also buy a hard/e-book copy and support the author's awesome work. | Nate Silver's Election Prediction Model
Silver has written about his affinity for Bayesian methods in The Signal and the Noise and elsewhere. I found this book, which is teaches a bit about Bayesian inference through Python examples was a g |
37,556 | Kolmogorov-Smirnov test: horizontal variant? | My guess as to why people don't use it: if you have a test that looks at horizontal distance it won't be distribution-free (at least not without some modification*).
Consider a continuous cdf and an ecdf plotted on the same axes with the KS-statistic marked in at the point of greatest vertical distance between them.
Note that a completely monotonic transformation of the x-axis will change the horizontal scale but leave the vertical distances unchanged. It's this feature that in essence makes the K-S test work the same for every fully-specified continuous distribution (since you can convert between them by exactly such a transformation).
But if you measure horizontal distance, every non-identity transform is going to change the distribution of horizontal distances.
* It might work if you convert everything back to standard uniform and then measure horizontal distance, but I don't think that's what you're asking about. | Kolmogorov-Smirnov test: horizontal variant? | My guess as to why people don't use it: if you have a test that looks at horizontal distance it won't be distribution-free (at least not without some modification*).
Consider a continuous cdf and an e | Kolmogorov-Smirnov test: horizontal variant?
My guess as to why people don't use it: if you have a test that looks at horizontal distance it won't be distribution-free (at least not without some modification*).
Consider a continuous cdf and an ecdf plotted on the same axes with the KS-statistic marked in at the point of greatest vertical distance between them.
Note that a completely monotonic transformation of the x-axis will change the horizontal scale but leave the vertical distances unchanged. It's this feature that in essence makes the K-S test work the same for every fully-specified continuous distribution (since you can convert between them by exactly such a transformation).
But if you measure horizontal distance, every non-identity transform is going to change the distribution of horizontal distances.
* It might work if you convert everything back to standard uniform and then measure horizontal distance, but I don't think that's what you're asking about. | Kolmogorov-Smirnov test: horizontal variant?
My guess as to why people don't use it: if you have a test that looks at horizontal distance it won't be distribution-free (at least not without some modification*).
Consider a continuous cdf and an e |
37,557 | Propensity score matching with large data | Have you tried the nearest neighbour in MatchIt (method = "nearest")? As it is a "greedy" algorithm, it should be fast even for larger sample sizes. If for some reason that does not work, you could program the nearest neighbour yourself allowing for 3 matches before an observation in the treatment group is "used up". Obviously the matching will be quite suboptimal, but it might be a sensible solution where the dataset is too large for "optimal" matching. | Propensity score matching with large data | Have you tried the nearest neighbour in MatchIt (method = "nearest")? As it is a "greedy" algorithm, it should be fast even for larger sample sizes. If for some reason that does not work, you could pr | Propensity score matching with large data
Have you tried the nearest neighbour in MatchIt (method = "nearest")? As it is a "greedy" algorithm, it should be fast even for larger sample sizes. If for some reason that does not work, you could program the nearest neighbour yourself allowing for 3 matches before an observation in the treatment group is "used up". Obviously the matching will be quite suboptimal, but it might be a sensible solution where the dataset is too large for "optimal" matching. | Propensity score matching with large data
Have you tried the nearest neighbour in MatchIt (method = "nearest")? As it is a "greedy" algorithm, it should be fast even for larger sample sizes. If for some reason that does not work, you could pr |
37,558 | Modelling mortality rates using Poisson regression | Without seeing the dataset (not available) it seems mostly correct. The nice thing about Poisson regressions is that they can provide rates when used as suggested. One thing that may be worth to keep in mind is that there may be overdispersion where you should switch to a negative binomial regression (see the MASS package).
The Poisson regression doesn't care whether the data as aggregated or not, but in practice non-aggregated data is frail and can cause some unexpected errors. Note that you cannot have surv == 0 for any of the cases. When I've tested the estimates are the same:
set.seed(1)
n <- 1500
data <-
data.frame(
dead = sample(0:1, n, replace = TRUE, prob = c(.9, .1)),
surv = ceiling(exp(runif(100))*365),
gender = sample(c("Male", "Female"), n, replace = TRUE),
diagnosis = sample(0:1, n, replace = TRUE),
age = sample(60:80, n, replace = TRUE),
inclusion_year = sample(1998:2011, n, replace = TRUE)
)
library(dplyr)
model <-
data %>%
group_by(gender,
diagnosis,
age,
inclusion_year) %>%
summarise(Deaths = sum(dead),
Person_time = sum(surv)) %>%
glm(Deaths ~ gender + diagnosis + I(age - 70) + I(inclusion_year - 1998) + offset(log(Person_time/10^3/365.25)),
data = . , family = poisson)
alt_model <- glm(dead ~ gender + diagnosis + I(age - 70) + I(inclusion_year - 1998) + offset(log(surv/10^3/365.25)),
data = data , family = poisson)
sum(coef(alt_model) - coef(model))
# > 1.779132e-14
sum(abs(confint(alt_model) - confint(model)))
# > 6.013114e-11
As you get a rate it is important to center the variables so that the intercept is interpretable, e.g.:
> exp(coef(model)["(Intercept)"])
(Intercept)
51.3771
Can be interpreted as the base rate and then the covariates are rate ratios. If we want the base rate after 10 years:
> exp(coef(model)["(Intercept)"] + coef(model)["I(inclusion_year - 1998)"]*10)
(Intercept)
47.427
I've currently modeled the inclusion year as a trend variable but you should probably check for nonlinearities and sometimes it is useful to do a categorization of the time points. I used this approach in this article:
D. Gordon, P. Gillgren, S. Eloranta, H. Olsson, M. Gordon, J. Hansson, and K. E. Smedby, “Time trends in incidence of cutaneous melanoma by detailed anatomical location and patterns of ultraviolet radiation exposure: a retrospective population-based study,” Melanoma Res., vol. 25, no. 4, pp. 348–356, Aug. 2015. | Modelling mortality rates using Poisson regression | Without seeing the dataset (not available) it seems mostly correct. The nice thing about Poisson regressions is that they can provide rates when used as suggested. One thing that may be worth to keep | Modelling mortality rates using Poisson regression
Without seeing the dataset (not available) it seems mostly correct. The nice thing about Poisson regressions is that they can provide rates when used as suggested. One thing that may be worth to keep in mind is that there may be overdispersion where you should switch to a negative binomial regression (see the MASS package).
The Poisson regression doesn't care whether the data as aggregated or not, but in practice non-aggregated data is frail and can cause some unexpected errors. Note that you cannot have surv == 0 for any of the cases. When I've tested the estimates are the same:
set.seed(1)
n <- 1500
data <-
data.frame(
dead = sample(0:1, n, replace = TRUE, prob = c(.9, .1)),
surv = ceiling(exp(runif(100))*365),
gender = sample(c("Male", "Female"), n, replace = TRUE),
diagnosis = sample(0:1, n, replace = TRUE),
age = sample(60:80, n, replace = TRUE),
inclusion_year = sample(1998:2011, n, replace = TRUE)
)
library(dplyr)
model <-
data %>%
group_by(gender,
diagnosis,
age,
inclusion_year) %>%
summarise(Deaths = sum(dead),
Person_time = sum(surv)) %>%
glm(Deaths ~ gender + diagnosis + I(age - 70) + I(inclusion_year - 1998) + offset(log(Person_time/10^3/365.25)),
data = . , family = poisson)
alt_model <- glm(dead ~ gender + diagnosis + I(age - 70) + I(inclusion_year - 1998) + offset(log(surv/10^3/365.25)),
data = data , family = poisson)
sum(coef(alt_model) - coef(model))
# > 1.779132e-14
sum(abs(confint(alt_model) - confint(model)))
# > 6.013114e-11
As you get a rate it is important to center the variables so that the intercept is interpretable, e.g.:
> exp(coef(model)["(Intercept)"])
(Intercept)
51.3771
Can be interpreted as the base rate and then the covariates are rate ratios. If we want the base rate after 10 years:
> exp(coef(model)["(Intercept)"] + coef(model)["I(inclusion_year - 1998)"]*10)
(Intercept)
47.427
I've currently modeled the inclusion year as a trend variable but you should probably check for nonlinearities and sometimes it is useful to do a categorization of the time points. I used this approach in this article:
D. Gordon, P. Gillgren, S. Eloranta, H. Olsson, M. Gordon, J. Hansson, and K. E. Smedby, “Time trends in incidence of cutaneous melanoma by detailed anatomical location and patterns of ultraviolet radiation exposure: a retrospective population-based study,” Melanoma Res., vol. 25, no. 4, pp. 348–356, Aug. 2015. | Modelling mortality rates using Poisson regression
Without seeing the dataset (not available) it seems mostly correct. The nice thing about Poisson regressions is that they can provide rates when used as suggested. One thing that may be worth to keep |
37,559 | Fit stochastic differential equation to data | To answer my own question:
We simulated above system with some chosen parameters m and s (snssde function).
From simulated data we estimated m and s, first with fitsde function and then with above method. Above method works correctly, and its estimates are closer to true values than estimates from fitsde. Besides, in fitsde the Kessler method is the only one (out of four) that gives decent estimates. | Fit stochastic differential equation to data | To answer my own question:
We simulated above system with some chosen parameters m and s (snssde function).
From simulated data we estimated m and s, first with fitsde function and then with above met | Fit stochastic differential equation to data
To answer my own question:
We simulated above system with some chosen parameters m and s (snssde function).
From simulated data we estimated m and s, first with fitsde function and then with above method. Above method works correctly, and its estimates are closer to true values than estimates from fitsde. Besides, in fitsde the Kessler method is the only one (out of four) that gives decent estimates. | Fit stochastic differential equation to data
To answer my own question:
We simulated above system with some chosen parameters m and s (snssde function).
From simulated data we estimated m and s, first with fitsde function and then with above met |
37,560 | Logistic regression with sparse predictor variables | 1) Sparcity of data can be hadnled by L1 regularization.
2) You can also try sub sampling and over sampling of data.(don't forget to calibrate the result based on sampling ration used earlier)
3) Your model will also take care of significance of different variables. | Logistic regression with sparse predictor variables | 1) Sparcity of data can be hadnled by L1 regularization.
2) You can also try sub sampling and over sampling of data.(don't forget to calibrate the result based on sampling ration used earlier)
3) Your | Logistic regression with sparse predictor variables
1) Sparcity of data can be hadnled by L1 regularization.
2) You can also try sub sampling and over sampling of data.(don't forget to calibrate the result based on sampling ration used earlier)
3) Your model will also take care of significance of different variables. | Logistic regression with sparse predictor variables
1) Sparcity of data can be hadnled by L1 regularization.
2) You can also try sub sampling and over sampling of data.(don't forget to calibrate the result based on sampling ration used earlier)
3) Your |
37,561 | Logistic regression with sparse predictor variables | If your data comes with a bit of uncertainty you could create a confidence level around a sparse predictor variable. In your example, a categorical variable where:
0 = certainly not donated > $1M dollars
1 = possibly donated > $1M dollars
2 = certainly donated > $1M dollars
This has worked well for me in the past | Logistic regression with sparse predictor variables | If your data comes with a bit of uncertainty you could create a confidence level around a sparse predictor variable. In your example, a categorical variable where:
0 = certainly not donated > $1M doll | Logistic regression with sparse predictor variables
If your data comes with a bit of uncertainty you could create a confidence level around a sparse predictor variable. In your example, a categorical variable where:
0 = certainly not donated > $1M dollars
1 = possibly donated > $1M dollars
2 = certainly donated > $1M dollars
This has worked well for me in the past | Logistic regression with sparse predictor variables
If your data comes with a bit of uncertainty you could create a confidence level around a sparse predictor variable. In your example, a categorical variable where:
0 = certainly not donated > $1M doll |
37,562 | Demonstration of central limit theorem | I assume that by "demonstration" you mean, "showing what it's about", not a mathematical demonstration.
I would draw a Galton board on the black-board, and simulate what happens as you drop balls, making a random choice each time. You can even ask the students to pick "left or right" randomly a few times, to make it clear that the process is random and you're not deliberately choosing the path (though you should probably do so, in order to get better convergence).
You could also ask all the students their height, and plot a histogram. Why does it look like a bell curve? It's a contribution of many random effects. | Demonstration of central limit theorem | I assume that by "demonstration" you mean, "showing what it's about", not a mathematical demonstration.
I would draw a Galton board on the black-board, and simulate what happens as you drop balls, ma | Demonstration of central limit theorem
I assume that by "demonstration" you mean, "showing what it's about", not a mathematical demonstration.
I would draw a Galton board on the black-board, and simulate what happens as you drop balls, making a random choice each time. You can even ask the students to pick "left or right" randomly a few times, to make it clear that the process is random and you're not deliberately choosing the path (though you should probably do so, in order to get better convergence).
You could also ask all the students their height, and plot a histogram. Why does it look like a bell curve? It's a contribution of many random effects. | Demonstration of central limit theorem
I assume that by "demonstration" you mean, "showing what it's about", not a mathematical demonstration.
I would draw a Galton board on the black-board, and simulate what happens as you drop balls, ma |
37,563 | Demonstration of central limit theorem | If you are in US, this url has statistics on US prisons
http://www.bop.gov/about/statistics
Perhaps you could explore it to see whether some manifestation of the CLT emerges in there. | Demonstration of central limit theorem | If you are in US, this url has statistics on US prisons
http://www.bop.gov/about/statistics
Perhaps you could explore it to see whether some manifestation of the CLT emerges in there. | Demonstration of central limit theorem
If you are in US, this url has statistics on US prisons
http://www.bop.gov/about/statistics
Perhaps you could explore it to see whether some manifestation of the CLT emerges in there. | Demonstration of central limit theorem
If you are in US, this url has statistics on US prisons
http://www.bop.gov/about/statistics
Perhaps you could explore it to see whether some manifestation of the CLT emerges in there. |
37,564 | Demonstration of central limit theorem | A proposal,
tell the people to choose papers (or cards) from a pack of cards where each card has a number from -2 to 2.
Also have 5 boxes (A, B, C, D, E).
At first time tell them to choose only one card each.
Then tell them to place their cards into one of the boxes.
When everyone (including you if you want) has placed her card(s) in a box, count the sum of each box and draw a histogram, this wil be very crude.
Then tell the people to choose more than one card (make sure there are enough cards for the experiment) and place their cards on a box (or even different boxes).
Repeat the counting process, draw a new histogram
Repeat once again with people having even more cards each, repeat the counting process, draw histogram.
One can repeat this process as many times as one wants.
Observe the histograms and their shapes. | Demonstration of central limit theorem | A proposal,
tell the people to choose papers (or cards) from a pack of cards where each card has a number from -2 to 2.
Also have 5 boxes (A, B, C, D, E).
At first time tell them to choose only one c | Demonstration of central limit theorem
A proposal,
tell the people to choose papers (or cards) from a pack of cards where each card has a number from -2 to 2.
Also have 5 boxes (A, B, C, D, E).
At first time tell them to choose only one card each.
Then tell them to place their cards into one of the boxes.
When everyone (including you if you want) has placed her card(s) in a box, count the sum of each box and draw a histogram, this wil be very crude.
Then tell the people to choose more than one card (make sure there are enough cards for the experiment) and place their cards on a box (or even different boxes).
Repeat the counting process, draw a new histogram
Repeat once again with people having even more cards each, repeat the counting process, draw histogram.
One can repeat this process as many times as one wants.
Observe the histograms and their shapes. | Demonstration of central limit theorem
A proposal,
tell the people to choose papers (or cards) from a pack of cards where each card has a number from -2 to 2.
Also have 5 boxes (A, B, C, D, E).
At first time tell them to choose only one c |
37,565 | Demonstration of central limit theorem | Can you bring in dice? (or maybe they already have access to dice). Then have them throw the dice (many times, they have the time ...), draw histograms, calculating mean number of eyes, drawing histograms of that for different $n$, so on ...
With many dice you can even build the histogram directly with the dice. We got this in class: | Demonstration of central limit theorem | Can you bring in dice? (or maybe they already have access to dice). Then have them throw the dice (many times, they have the time ...), draw histograms, calculating mean number of eyes, drawing hist | Demonstration of central limit theorem
Can you bring in dice? (or maybe they already have access to dice). Then have them throw the dice (many times, they have the time ...), draw histograms, calculating mean number of eyes, drawing histograms of that for different $n$, so on ...
With many dice you can even build the histogram directly with the dice. We got this in class: | Demonstration of central limit theorem
Can you bring in dice? (or maybe they already have access to dice). Then have them throw the dice (many times, they have the time ...), draw histograms, calculating mean number of eyes, drawing hist |
37,566 | Polling vs averaging in Random Forest models | This looks like the kind of answer you're looking for: http://people.dsv.su.se/~henke/papers/bostrom07c.pdf
The author looks at using average votes vs average probabilities from the ensemble members as well as a few other approaches to approximate impurity in the leaf nodes. For example, even if you do grow the trees to a maximum depth (as mentioned in the comments) the "Laplace Approximation" could be used to get a non-zero probability for each class by simply adding one to the count of observations of each class in the leaves.
Empirically speaking, the author concludes by saying that using averages of relative class frequencies (on 34 datasets) is better than using average votes (i.e. polling), though it is not better than using some "adjusted" probability average like the Laplace Approximation.
The difference looks pretty slight to me, but take a look at the "Accuracy and AUC" table on page 5. That might convince you one way or another. | Polling vs averaging in Random Forest models | This looks like the kind of answer you're looking for: http://people.dsv.su.se/~henke/papers/bostrom07c.pdf
The author looks at using average votes vs average probabilities from the ensemble members a | Polling vs averaging in Random Forest models
This looks like the kind of answer you're looking for: http://people.dsv.su.se/~henke/papers/bostrom07c.pdf
The author looks at using average votes vs average probabilities from the ensemble members as well as a few other approaches to approximate impurity in the leaf nodes. For example, even if you do grow the trees to a maximum depth (as mentioned in the comments) the "Laplace Approximation" could be used to get a non-zero probability for each class by simply adding one to the count of observations of each class in the leaves.
Empirically speaking, the author concludes by saying that using averages of relative class frequencies (on 34 datasets) is better than using average votes (i.e. polling), though it is not better than using some "adjusted" probability average like the Laplace Approximation.
The difference looks pretty slight to me, but take a look at the "Accuracy and AUC" table on page 5. That might convince you one way or another. | Polling vs averaging in Random Forest models
This looks like the kind of answer you're looking for: http://people.dsv.su.se/~henke/papers/bostrom07c.pdf
The author looks at using average votes vs average probabilities from the ensemble members a |
37,567 | Goodness of fit for nonlinear model | There maybe more to it, but to me it seems that you just want to determine goodness-of-fit (GoF) for a function f(a), fitted to a particular data set (a, f(a)). So, the following only answers your third sub-question (I don't think the first and second are directly relevant to the third one).
Usually, GoF can be determined parametrically (if you know the distribution's function parameters) or non-parametrically (if you don't know them). While you may be able to figure out parameters for the function, as it appears to be exponential or gamma/Weibull (assuming that data is continuous). Nevertheless, I will proceed, as if you didn't know the parameters. In this case, it's a two-step process. First, you need to determine distribution parameters for your data set. Second, you perform a GoF test for the defined distribution. To avoid repeating myself, at this point I will refer you to my earlier answer to a related question, which contains some helpful details. Obviously, this answer can easily be applied to distributions, other than the one mentioned within.
In addition to GoF tests, mentioned there, you may consider another test - chi-square GoF test. Unlike K-S and A-D tests, which are applicable only to continuous distributions, chi-square GoF test is applicable to both discrete and continuous ones. Chi-square GoF test can be performed in R by using one of several packages: stats built-in package (function chisq.test()) and vcd package (function goodfit() - for discrete data only). More details are available in this document. | Goodness of fit for nonlinear model | There maybe more to it, but to me it seems that you just want to determine goodness-of-fit (GoF) for a function f(a), fitted to a particular data set (a, f(a)). So, the following only answers your thi | Goodness of fit for nonlinear model
There maybe more to it, but to me it seems that you just want to determine goodness-of-fit (GoF) for a function f(a), fitted to a particular data set (a, f(a)). So, the following only answers your third sub-question (I don't think the first and second are directly relevant to the third one).
Usually, GoF can be determined parametrically (if you know the distribution's function parameters) or non-parametrically (if you don't know them). While you may be able to figure out parameters for the function, as it appears to be exponential or gamma/Weibull (assuming that data is continuous). Nevertheless, I will proceed, as if you didn't know the parameters. In this case, it's a two-step process. First, you need to determine distribution parameters for your data set. Second, you perform a GoF test for the defined distribution. To avoid repeating myself, at this point I will refer you to my earlier answer to a related question, which contains some helpful details. Obviously, this answer can easily be applied to distributions, other than the one mentioned within.
In addition to GoF tests, mentioned there, you may consider another test - chi-square GoF test. Unlike K-S and A-D tests, which are applicable only to continuous distributions, chi-square GoF test is applicable to both discrete and continuous ones. Chi-square GoF test can be performed in R by using one of several packages: stats built-in package (function chisq.test()) and vcd package (function goodfit() - for discrete data only). More details are available in this document. | Goodness of fit for nonlinear model
There maybe more to it, but to me it seems that you just want to determine goodness-of-fit (GoF) for a function f(a), fitted to a particular data set (a, f(a)). So, the following only answers your thi |
37,568 | Goodness of fit for nonlinear model | Well, in Machine Learning the thing called Cross Validation is performed pretty often for purpose of model testing (test if that type of a model with these hyper-parameters - like number of degrees of freedom or whatever - fits your problem) - you split your data several times into train and test data sets, then run optimization over training set and compute whatever quality over tests data. The most confidential way is to run so called "QxT-fold cross validation". The pseudocode could could like:
cv_values = []
for t in range(T):
split = randomsplit(data, number_of_parst = Q)
for test_id in range(Q):
model.fit(split[:test_id] + split[test_id + 1:] # test on everything excepting test_id
cv_values.append(model.test(split[test_id]))
cv_values.mean() # whatever | Goodness of fit for nonlinear model | Well, in Machine Learning the thing called Cross Validation is performed pretty often for purpose of model testing (test if that type of a model with these hyper-parameters - like number of degrees of | Goodness of fit for nonlinear model
Well, in Machine Learning the thing called Cross Validation is performed pretty often for purpose of model testing (test if that type of a model with these hyper-parameters - like number of degrees of freedom or whatever - fits your problem) - you split your data several times into train and test data sets, then run optimization over training set and compute whatever quality over tests data. The most confidential way is to run so called "QxT-fold cross validation". The pseudocode could could like:
cv_values = []
for t in range(T):
split = randomsplit(data, number_of_parst = Q)
for test_id in range(Q):
model.fit(split[:test_id] + split[test_id + 1:] # test on everything excepting test_id
cv_values.append(model.test(split[test_id]))
cv_values.mean() # whatever | Goodness of fit for nonlinear model
Well, in Machine Learning the thing called Cross Validation is performed pretty often for purpose of model testing (test if that type of a model with these hyper-parameters - like number of degrees of |
37,569 | Product price prediction - include important external factors | The preferred approach is to construct a Transfer Function where Price is the dependent variable and your suggested variables are the predictors. This is also called a dynamic regression. Care should be taken to identify and deal with unusual values that are either one-time events or level/trend shifts. Oftentimes there can be a lead effect on the dependent variable such as holidays. If you have daily data then day-of-the=week patterns and/or weekly patterns my be important. Perhaps you could post your data and I can be of more specific help. | Product price prediction - include important external factors | The preferred approach is to construct a Transfer Function where Price is the dependent variable and your suggested variables are the predictors. This is also called a dynamic regression. Care should | Product price prediction - include important external factors
The preferred approach is to construct a Transfer Function where Price is the dependent variable and your suggested variables are the predictors. This is also called a dynamic regression. Care should be taken to identify and deal with unusual values that are either one-time events or level/trend shifts. Oftentimes there can be a lead effect on the dependent variable such as holidays. If you have daily data then day-of-the=week patterns and/or weekly patterns my be important. Perhaps you could post your data and I can be of more specific help. | Product price prediction - include important external factors
The preferred approach is to construct a Transfer Function where Price is the dependent variable and your suggested variables are the predictors. This is also called a dynamic regression. Care should |
37,570 | Hidden Markov Models with multiple emissions per state | One simple approach to deal with the sparsity of the observation distribution is to model it as a naive Bayes model. You can still use Baum-Welch with a little modification. | Hidden Markov Models with multiple emissions per state | One simple approach to deal with the sparsity of the observation distribution is to model it as a naive Bayes model. You can still use Baum-Welch with a little modification. | Hidden Markov Models with multiple emissions per state
One simple approach to deal with the sparsity of the observation distribution is to model it as a naive Bayes model. You can still use Baum-Welch with a little modification. | Hidden Markov Models with multiple emissions per state
One simple approach to deal with the sparsity of the observation distribution is to model it as a naive Bayes model. You can still use Baum-Welch with a little modification. |
37,571 | Hidden Markov Models with multiple emissions per state | It's been a while since you posted but just in case, the package msm in R may be what you need. The documentation here explains quite well in section 2.18, with examples, but in a nutshell, this package will allow you to simultaneously model the emissions of your states using the argument hmodel with values supplied using hmm-dists and hmmMV. There are many types of distribution supported, including discrete variables. If you believe that your outcome emissions are drawn from the same distribution (conditional upon the state) then you can constrain msm to fit the model that way and estimate a common model based on all the emission observations for a given state. They may also be permitted to have different parameters or distribution forms and fitted as a multivariate model.
However, msm currently does not seem to support the estimation of covariate effects upon the outcome distribution when fitting multivariate models (the reason I found this thread actually, as this is the problem I am having now). In other words, if you do use the multivariate approach (which might not be necessary for you, if all your emissions have the same distribution), msm will only allow your emission model parameters to depend upon state and no other covariates. msm also does not use Baum-Welch, but instead uses the forward algorithm to calculate the likelihood directly with matrix products. | Hidden Markov Models with multiple emissions per state | It's been a while since you posted but just in case, the package msm in R may be what you need. The documentation here explains quite well in section 2.18, with examples, but in a nutshell, this packa | Hidden Markov Models with multiple emissions per state
It's been a while since you posted but just in case, the package msm in R may be what you need. The documentation here explains quite well in section 2.18, with examples, but in a nutshell, this package will allow you to simultaneously model the emissions of your states using the argument hmodel with values supplied using hmm-dists and hmmMV. There are many types of distribution supported, including discrete variables. If you believe that your outcome emissions are drawn from the same distribution (conditional upon the state) then you can constrain msm to fit the model that way and estimate a common model based on all the emission observations for a given state. They may also be permitted to have different parameters or distribution forms and fitted as a multivariate model.
However, msm currently does not seem to support the estimation of covariate effects upon the outcome distribution when fitting multivariate models (the reason I found this thread actually, as this is the problem I am having now). In other words, if you do use the multivariate approach (which might not be necessary for you, if all your emissions have the same distribution), msm will only allow your emission model parameters to depend upon state and no other covariates. msm also does not use Baum-Welch, but instead uses the forward algorithm to calculate the likelihood directly with matrix products. | Hidden Markov Models with multiple emissions per state
It's been a while since you posted but just in case, the package msm in R may be what you need. The documentation here explains quite well in section 2.18, with examples, but in a nutshell, this packa |
37,572 | Calculating CIs for $\eta^2$ via Z scores - sample size? | This is an interesting suggestion. It has one limitation: Fisher's z -- which is the name of this approach -- gives results between -1 and 1 but eta's are only positive. In UniMult, I am using Cox and Hinkley's definition of confidence intervals as the range of possible population values from which the observed value is non-significant. Than a simple loop in a computer program is used to test the range of values. With a bit of patience or the help of a web calculator, this could be done for an occasional eta. | Calculating CIs for $\eta^2$ via Z scores - sample size? | This is an interesting suggestion. It has one limitation: Fisher's z -- which is the name of this approach -- gives results between -1 and 1 but eta's are only positive. In UniMult, I am using Cox and | Calculating CIs for $\eta^2$ via Z scores - sample size?
This is an interesting suggestion. It has one limitation: Fisher's z -- which is the name of this approach -- gives results between -1 and 1 but eta's are only positive. In UniMult, I am using Cox and Hinkley's definition of confidence intervals as the range of possible population values from which the observed value is non-significant. Than a simple loop in a computer program is used to test the range of values. With a bit of patience or the help of a web calculator, this could be done for an occasional eta. | Calculating CIs for $\eta^2$ via Z scores - sample size?
This is an interesting suggestion. It has one limitation: Fisher's z -- which is the name of this approach -- gives results between -1 and 1 but eta's are only positive. In UniMult, I am using Cox and |
37,573 | Calculating CIs for $\eta^2$ via Z scores - sample size? | In case you are still interested in this topic, I would recommend you to take a look at the papers, referenced in my answer, especially the first one (by Lakens). Also, check MBESS R package: see home page and JSS paper (note that the software's current version most likely contains additional features and improvements, not described in the referenced original JSS paper). | Calculating CIs for $\eta^2$ via Z scores - sample size? | In case you are still interested in this topic, I would recommend you to take a look at the papers, referenced in my answer, especially the first one (by Lakens). Also, check MBESS R package: see home | Calculating CIs for $\eta^2$ via Z scores - sample size?
In case you are still interested in this topic, I would recommend you to take a look at the papers, referenced in my answer, especially the first one (by Lakens). Also, check MBESS R package: see home page and JSS paper (note that the software's current version most likely contains additional features and improvements, not described in the referenced original JSS paper). | Calculating CIs for $\eta^2$ via Z scores - sample size?
In case you are still interested in this topic, I would recommend you to take a look at the papers, referenced in my answer, especially the first one (by Lakens). Also, check MBESS R package: see home |
37,574 | Linearized exponential regression by lm() vs. non-linear nls() regression | As I stated in the disclaimer it was a dumb mistake. If I would have plotted the actual data it would become obvious why the models don't fit (as any other exponential model of that kind wouldn't).
It's probably issue of the spectrometer because it's probably not sensible enough to capture that low trasmittance hence there are practcally zeros for all five measurements so fitting an exponential curve to that makes no sense.
I am sorry for wasting your time guys. | Linearized exponential regression by lm() vs. non-linear nls() regression | As I stated in the disclaimer it was a dumb mistake. If I would have plotted the actual data it would become obvious why the models don't fit (as any other exponential model of that kind wouldn't).
It | Linearized exponential regression by lm() vs. non-linear nls() regression
As I stated in the disclaimer it was a dumb mistake. If I would have plotted the actual data it would become obvious why the models don't fit (as any other exponential model of that kind wouldn't).
It's probably issue of the spectrometer because it's probably not sensible enough to capture that low trasmittance hence there are practcally zeros for all five measurements so fitting an exponential curve to that makes no sense.
I am sorry for wasting your time guys. | Linearized exponential regression by lm() vs. non-linear nls() regression
As I stated in the disclaimer it was a dumb mistake. If I would have plotted the actual data it would become obvious why the models don't fit (as any other exponential model of that kind wouldn't).
It |
37,575 | Differences between robustness checks and sensitivity analysis | I don't know of an 'official' answer to this based on universally accepted definitions of those terms. However, it seems to me that they represent a fundamentally similar idea, but are used somewhat differently.
"Robustness check" is often used when running a different model / test that does not require a certain assumption. For example, consider a situation where you are comparing two groups where there may be heteroscedasticity. You could run a standard $t$-test and the Welch $t$-test. If you get the same result both ways, you could say your result is robust to violations of that assumption—it just isn't something you need to be overly worried about.
"Sensitivity analysis" is often used in the context of missing data. Many convenient methods are valid if data are missing at random (MAR), but you can never really be certain that your data are MAR. A way to explore this is to input different values that might be problematic / related to the missingness and refit the model. Again, it is comforting if you get the same result both ways. | Differences between robustness checks and sensitivity analysis | I don't know of an 'official' answer to this based on universally accepted definitions of those terms. However, it seems to me that they represent a fundamentally similar idea, but are used somewhat | Differences between robustness checks and sensitivity analysis
I don't know of an 'official' answer to this based on universally accepted definitions of those terms. However, it seems to me that they represent a fundamentally similar idea, but are used somewhat differently.
"Robustness check" is often used when running a different model / test that does not require a certain assumption. For example, consider a situation where you are comparing two groups where there may be heteroscedasticity. You could run a standard $t$-test and the Welch $t$-test. If you get the same result both ways, you could say your result is robust to violations of that assumption—it just isn't something you need to be overly worried about.
"Sensitivity analysis" is often used in the context of missing data. Many convenient methods are valid if data are missing at random (MAR), but you can never really be certain that your data are MAR. A way to explore this is to input different values that might be problematic / related to the missingness and refit the model. Again, it is comforting if you get the same result both ways. | Differences between robustness checks and sensitivity analysis
I don't know of an 'official' answer to this based on universally accepted definitions of those terms. However, it seems to me that they represent a fundamentally similar idea, but are used somewhat |
37,576 | Differences between robustness checks and sensitivity analysis | Here is the answer your are looking for:
1. A robustness check means that your results are not highly determined by changes to your dataset (i.e. you could use a similar data set, or group your data slightly differently, and still get similar results).
2. Sensitivity analysis means that your results are not highly determined by your model specification (i.e. you could add an additional control variable, or a slightly different functional form, and still get similar results).
Thus, (1) is how stable your results are to inputs and (2) is how reactive your results are to design. | Differences between robustness checks and sensitivity analysis | Here is the answer your are looking for:
1. A robustness check means that your results are not highly determined by changes to your dataset (i.e. you could use a similar data set, or group your data s | Differences between robustness checks and sensitivity analysis
Here is the answer your are looking for:
1. A robustness check means that your results are not highly determined by changes to your dataset (i.e. you could use a similar data set, or group your data slightly differently, and still get similar results).
2. Sensitivity analysis means that your results are not highly determined by your model specification (i.e. you could add an additional control variable, or a slightly different functional form, and still get similar results).
Thus, (1) is how stable your results are to inputs and (2) is how reactive your results are to design. | Differences between robustness checks and sensitivity analysis
Here is the answer your are looking for:
1. A robustness check means that your results are not highly determined by changes to your dataset (i.e. you could use a similar data set, or group your data s |
37,577 | Why not use Beta(1,1) as boundary avoiding prior on a transformed correlation parameter? | In cases where the likelihood function is maximized at $\rho=-1$, using Beta(1,1) over an open interval doesn't help since then there is no well-defined posterior mode. There is no point in the open interval that you could say is the posterior mode.
The book wants the prior to be linear at the boundaries, which uniquely selects Beta(2,2) out of all Beta distributions. But the book never precisely explains why linearity is so important. | Why not use Beta(1,1) as boundary avoiding prior on a transformed correlation parameter? | In cases where the likelihood function is maximized at $\rho=-1$, using Beta(1,1) over an open interval doesn't help since then there is no well-defined posterior mode. There is no point in the open | Why not use Beta(1,1) as boundary avoiding prior on a transformed correlation parameter?
In cases where the likelihood function is maximized at $\rho=-1$, using Beta(1,1) over an open interval doesn't help since then there is no well-defined posterior mode. There is no point in the open interval that you could say is the posterior mode.
The book wants the prior to be linear at the boundaries, which uniquely selects Beta(2,2) out of all Beta distributions. But the book never precisely explains why linearity is so important. | Why not use Beta(1,1) as boundary avoiding prior on a transformed correlation parameter?
In cases where the likelihood function is maximized at $\rho=-1$, using Beta(1,1) over an open interval doesn't help since then there is no well-defined posterior mode. There is no point in the open |
37,578 | Difference between different kinds of entropy | Shannon entropy is a general concept for entropy for any probability distribution. And depending what probability you choose, you get something different.
In particular:
Source entropy is Shannon entropy of probability distribution associated with some source of signals - for example zeros and ones or letter over an alphabet (see C. Shannon, A Mathematical Theory of Communication (1948))
Boltzmann entropy is Shannon entropy of the probability distribution of statistical microstates (same: of probability distribution in the phase space, up to a constant factor)
And about entropies I am not deep into:
Kolmogorov-Sinai Entropy, is (as far I understand) a particular quantity derived from entropy, related to chaotic behavior of dynamic systems (it also happens in the phase space); as you see its formula, its formula involves Shannon entropy for a particular set related to trajectories, but also involves other operations
Topological entropy is a related concept | Difference between different kinds of entropy | Shannon entropy is a general concept for entropy for any probability distribution. And depending what probability you choose, you get something different.
In particular:
Source entropy is Shannon en | Difference between different kinds of entropy
Shannon entropy is a general concept for entropy for any probability distribution. And depending what probability you choose, you get something different.
In particular:
Source entropy is Shannon entropy of probability distribution associated with some source of signals - for example zeros and ones or letter over an alphabet (see C. Shannon, A Mathematical Theory of Communication (1948))
Boltzmann entropy is Shannon entropy of the probability distribution of statistical microstates (same: of probability distribution in the phase space, up to a constant factor)
And about entropies I am not deep into:
Kolmogorov-Sinai Entropy, is (as far I understand) a particular quantity derived from entropy, related to chaotic behavior of dynamic systems (it also happens in the phase space); as you see its formula, its formula involves Shannon entropy for a particular set related to trajectories, but also involves other operations
Topological entropy is a related concept | Difference between different kinds of entropy
Shannon entropy is a general concept for entropy for any probability distribution. And depending what probability you choose, you get something different.
In particular:
Source entropy is Shannon en |
37,579 | Exponential Service Times When a Minimum Service Time is Reasonable | Making comment into answer as requested by OP:
If the minimum service time is very small compared to the mean, the results may still be somewhat useful, but in many cases a better approximation to service time might be a shifted-exponential.
As to when that (or indeed any other) approximation may be useful, that depends on what aspects of the system you're investigating and how much approximation is acceptable. | Exponential Service Times When a Minimum Service Time is Reasonable | Making comment into answer as requested by OP:
If the minimum service time is very small compared to the mean, the results may still be somewhat useful, but in many cases a better approximation to ser | Exponential Service Times When a Minimum Service Time is Reasonable
Making comment into answer as requested by OP:
If the minimum service time is very small compared to the mean, the results may still be somewhat useful, but in many cases a better approximation to service time might be a shifted-exponential.
As to when that (or indeed any other) approximation may be useful, that depends on what aspects of the system you're investigating and how much approximation is acceptable. | Exponential Service Times When a Minimum Service Time is Reasonable
Making comment into answer as requested by OP:
If the minimum service time is very small compared to the mean, the results may still be somewhat useful, but in many cases a better approximation to ser |
37,580 | How and why would MLPs for classification differ from MLPs for regression? Different backpropagation and transfer functions? | The key difference is in the training criterion. A least squares training criterion is often used for regression as this gives (penalised) maximum likelihood estimation of the model parameters assuming Gaussian noise corrupting the response (target) variable. For classification problems it is common to use a cross-entropy training criterion, to give maximum likelihood estimation assuming a Bernoilli or multinomial loss. Either way, the model outputs can be interpreted as estimate of the probability of class membership, but it is common to use logistic or softmax activation functions in the output layer so the outputs are constrained to lie between 0 and 1 and to sum to 1. If you use the tanh function, you can just remap these onto probabilities by adding one and dividing by two (but it is otherwise the same). tanh is a good choice for hidden layer activation functions.
The difference between scaled conjugate gradients and Levenberg-Marquardt are likely to be fairly minor in terms of generalisation performance.
I would strongly recommend the NETLAB toolbox for MATLAB over MATLABs own neural network toolbox. It is probably a good idea to investigate Bayesian regularisation to avoid over-fitting (Chris Bishop's book is well worth reading and most of it is covered in the NETLAB toolbox). | How and why would MLPs for classification differ from MLPs for regression? Different backpropagation | The key difference is in the training criterion. A least squares training criterion is often used for regression as this gives (penalised) maximum likelihood estimation of the model parameters assumi | How and why would MLPs for classification differ from MLPs for regression? Different backpropagation and transfer functions?
The key difference is in the training criterion. A least squares training criterion is often used for regression as this gives (penalised) maximum likelihood estimation of the model parameters assuming Gaussian noise corrupting the response (target) variable. For classification problems it is common to use a cross-entropy training criterion, to give maximum likelihood estimation assuming a Bernoilli or multinomial loss. Either way, the model outputs can be interpreted as estimate of the probability of class membership, but it is common to use logistic or softmax activation functions in the output layer so the outputs are constrained to lie between 0 and 1 and to sum to 1. If you use the tanh function, you can just remap these onto probabilities by adding one and dividing by two (but it is otherwise the same). tanh is a good choice for hidden layer activation functions.
The difference between scaled conjugate gradients and Levenberg-Marquardt are likely to be fairly minor in terms of generalisation performance.
I would strongly recommend the NETLAB toolbox for MATLAB over MATLABs own neural network toolbox. It is probably a good idea to investigate Bayesian regularisation to avoid over-fitting (Chris Bishop's book is well worth reading and most of it is covered in the NETLAB toolbox). | How and why would MLPs for classification differ from MLPs for regression? Different backpropagation
The key difference is in the training criterion. A least squares training criterion is often used for regression as this gives (penalised) maximum likelihood estimation of the model parameters assumi |
37,581 | How to find a random variable that has a given distribution? | This question has a nice visual solution, because $X$ essentially is the "percentage point function" or "inverse CDF" given by $F^{-1}.$
Let's begin with the graph of a generic distribution function $F$:
The general problem illustrated by this plot is that $F$ has no inverse, because (a) its range misses large portions of the interval $[0,1]$, corresponding to the jumps in the graph, and (b) there is an interval of values associated with the same probability, corresponding to the flat region crossing the vertical axis.
We may fix (a) by filling in the region between the graph and the value axis:
The boundary of this region defines an invertible function from the probabilities $[0,1]$ to the support of $F.$ As usual, flip the axes to plot the inverse relation (which I have done by rotating the plot and displaying it from behind):
The horizontal axis depicts "probability space" $[0,1]$ while the vertical axis now depicts the real numbers, or "value space." Due to problem (b) the boundary of the shaded region isn't quite the graph of a function: it has a vertical segment in the middle. That segment spans a set of values with no probability. Except at its endpoints, it doesn't correspond to anything in the support of $F.$ We may therefore select one point in the span, such as the highest point.
The resulting graph plots the random variable $X$ being sought. You will need to verify that it is measurable (which follows from the definition of $F$), but the most important calculation is to establish that the probability law of $X$ really is $F$: namely, that for any $x\in\mathbb{R},$
$$\Pr(X\le x) = F(x).$$
But this is immediate, because the event $X\le x$ consists of all values $p\in[0,1]$ for which $p \le F(x),$ which has probability equal to the length of the interval $[0,F(x)]$ (that is, the Lebesgue measure of $X^{-1}((-\infty, x])$), which obviously is $F(x).$ | How to find a random variable that has a given distribution? | This question has a nice visual solution, because $X$ essentially is the "percentage point function" or "inverse CDF" given by $F^{-1}.$
Let's begin with the graph of a generic distribution function $ | How to find a random variable that has a given distribution?
This question has a nice visual solution, because $X$ essentially is the "percentage point function" or "inverse CDF" given by $F^{-1}.$
Let's begin with the graph of a generic distribution function $F$:
The general problem illustrated by this plot is that $F$ has no inverse, because (a) its range misses large portions of the interval $[0,1]$, corresponding to the jumps in the graph, and (b) there is an interval of values associated with the same probability, corresponding to the flat region crossing the vertical axis.
We may fix (a) by filling in the region between the graph and the value axis:
The boundary of this region defines an invertible function from the probabilities $[0,1]$ to the support of $F.$ As usual, flip the axes to plot the inverse relation (which I have done by rotating the plot and displaying it from behind):
The horizontal axis depicts "probability space" $[0,1]$ while the vertical axis now depicts the real numbers, or "value space." Due to problem (b) the boundary of the shaded region isn't quite the graph of a function: it has a vertical segment in the middle. That segment spans a set of values with no probability. Except at its endpoints, it doesn't correspond to anything in the support of $F.$ We may therefore select one point in the span, such as the highest point.
The resulting graph plots the random variable $X$ being sought. You will need to verify that it is measurable (which follows from the definition of $F$), but the most important calculation is to establish that the probability law of $X$ really is $F$: namely, that for any $x\in\mathbb{R},$
$$\Pr(X\le x) = F(x).$$
But this is immediate, because the event $X\le x$ consists of all values $p\in[0,1]$ for which $p \le F(x),$ which has probability equal to the length of the interval $[0,F(x)]$ (that is, the Lebesgue measure of $X^{-1}((-\infty, x])$), which obviously is $F(x).$ | How to find a random variable that has a given distribution?
This question has a nice visual solution, because $X$ essentially is the "percentage point function" or "inverse CDF" given by $F^{-1}.$
Let's begin with the graph of a generic distribution function $ |
37,582 | How to interpret the lasso selection plot [duplicate] | In regression, you're looking to find the $\beta$ that minimizes:
$ (Y - X_1\beta_1 - X_2\beta_2 - \text{...})^2 $
LASSO applies a penalty term to the minimization problem:
$ (Y - X_1\beta_1 - X_2\beta_2 - \text{...})^2 + \alpha\sum_i{|\beta_i|}$
So when $\alpha$ is zero, there is no penalization, and you have the OLS solution - this is max $|\beta|$ (or since I didn't write it as a vector, max $\sum{|\beta_i|}$).
As the penalization $\alpha$ increases, $\sum{|\beta_i|}$ is pulled towards zero, with the less important parameters being pulled to zero earlier. At some level of $\alpha$, all the $\beta_i$ have been pulled to zero.
This is the x-axis on the graph. Instead of presenting it as high $\alpha$ on the left decreasing to zero when moving right, it presents it as the ratio of the sum of the absolute current estimate over the sum of the absolute OLS estimates. The vertical bars indicate when a variable has been pulled to zero (and appear to be labeled with the number of variables remaining)
For the y-axis being standardized coefficients, generally when running LASSO, you standardize your X variables so that the penalization occurs equally over the variables. If they were measured on different scales, the penalization would be uneven (for example, consider multiplying all the values of one explanatory variable by 0.01 - then the coefficient of the OLS estimate would be 100x the size, and would be pulled harder when running LASSO). | How to interpret the lasso selection plot [duplicate] | In regression, you're looking to find the $\beta$ that minimizes:
$ (Y - X_1\beta_1 - X_2\beta_2 - \text{...})^2 $
LASSO applies a penalty term to the minimization problem:
$ (Y - X_1\beta_1 - X_2\bet | How to interpret the lasso selection plot [duplicate]
In regression, you're looking to find the $\beta$ that minimizes:
$ (Y - X_1\beta_1 - X_2\beta_2 - \text{...})^2 $
LASSO applies a penalty term to the minimization problem:
$ (Y - X_1\beta_1 - X_2\beta_2 - \text{...})^2 + \alpha\sum_i{|\beta_i|}$
So when $\alpha$ is zero, there is no penalization, and you have the OLS solution - this is max $|\beta|$ (or since I didn't write it as a vector, max $\sum{|\beta_i|}$).
As the penalization $\alpha$ increases, $\sum{|\beta_i|}$ is pulled towards zero, with the less important parameters being pulled to zero earlier. At some level of $\alpha$, all the $\beta_i$ have been pulled to zero.
This is the x-axis on the graph. Instead of presenting it as high $\alpha$ on the left decreasing to zero when moving right, it presents it as the ratio of the sum of the absolute current estimate over the sum of the absolute OLS estimates. The vertical bars indicate when a variable has been pulled to zero (and appear to be labeled with the number of variables remaining)
For the y-axis being standardized coefficients, generally when running LASSO, you standardize your X variables so that the penalization occurs equally over the variables. If they were measured on different scales, the penalization would be uneven (for example, consider multiplying all the values of one explanatory variable by 0.01 - then the coefficient of the OLS estimate would be 100x the size, and would be pulled harder when running LASSO). | How to interpret the lasso selection plot [duplicate]
In regression, you're looking to find the $\beta$ that minimizes:
$ (Y - X_1\beta_1 - X_2\beta_2 - \text{...})^2 $
LASSO applies a penalty term to the minimization problem:
$ (Y - X_1\beta_1 - X_2\bet |
37,583 | Using a set of binary logistic regressions with multiple choice categorical response variable | The choice between one multinomial and a series of logistic regressions is in most cases relatively artificial. Since in both approaches you select one baseline category (reference) with regard to which the odds ratios of all other categories are expressed, it usually does not matter if you have the one or the other if the reference category remains equal. The biggest disadavantage is that you cannot test simultanous parameter restrictions across the logistic models, which is rather straight forward in the multinomial case.
Nevertheless I would advise not to use random effects with 13 countries (level 2 units), see e.g. https://www.statmodel.com/download/SRM2012.pdf.
The alternative is to use a fixed effects model, where you include one dummy per country (minus 1). The biggest disadvantage of this prcedure that testing macro-level effects is not feasible. if you don't have any hypotheses in this regard I would go for the fixed effects multinomial model. | Using a set of binary logistic regressions with multiple choice categorical response variable | The choice between one multinomial and a series of logistic regressions is in most cases relatively artificial. Since in both approaches you select one baseline category (reference) with regard to whi | Using a set of binary logistic regressions with multiple choice categorical response variable
The choice between one multinomial and a series of logistic regressions is in most cases relatively artificial. Since in both approaches you select one baseline category (reference) with regard to which the odds ratios of all other categories are expressed, it usually does not matter if you have the one or the other if the reference category remains equal. The biggest disadavantage is that you cannot test simultanous parameter restrictions across the logistic models, which is rather straight forward in the multinomial case.
Nevertheless I would advise not to use random effects with 13 countries (level 2 units), see e.g. https://www.statmodel.com/download/SRM2012.pdf.
The alternative is to use a fixed effects model, where you include one dummy per country (minus 1). The biggest disadvantage of this prcedure that testing macro-level effects is not feasible. if you don't have any hypotheses in this regard I would go for the fixed effects multinomial model. | Using a set of binary logistic regressions with multiple choice categorical response variable
The choice between one multinomial and a series of logistic regressions is in most cases relatively artificial. Since in both approaches you select one baseline category (reference) with regard to whi |
37,584 | Using a set of binary logistic regressions with multiple choice categorical response variable | I would encourage you to run this analysis in one model (in AMOS) and I do not think your data structure is problematic (see for example: Maas, CJM & Hox, JJ (2005) Sufficient sample sizes for multilevel modeling. Methodology, 1, 86-92.).
When you run several models on the same dataset you increase the chance of making type I errors (at the minimum you will need to employ the Bonferroni Correction; which is considered to be a conservative technique). | Using a set of binary logistic regressions with multiple choice categorical response variable | I would encourage you to run this analysis in one model (in AMOS) and I do not think your data structure is problematic (see for example: Maas, CJM & Hox, JJ (2005) Sufficient sample sizes for multile | Using a set of binary logistic regressions with multiple choice categorical response variable
I would encourage you to run this analysis in one model (in AMOS) and I do not think your data structure is problematic (see for example: Maas, CJM & Hox, JJ (2005) Sufficient sample sizes for multilevel modeling. Methodology, 1, 86-92.).
When you run several models on the same dataset you increase the chance of making type I errors (at the minimum you will need to employ the Bonferroni Correction; which is considered to be a conservative technique). | Using a set of binary logistic regressions with multiple choice categorical response variable
I would encourage you to run this analysis in one model (in AMOS) and I do not think your data structure is problematic (see for example: Maas, CJM & Hox, JJ (2005) Sufficient sample sizes for multile |
37,585 | Hierarchical Bayesian analysis on difference of proportions | Since the time for the bounty expired and I received no answers, I'll post the answer I was able to come up with, though my limited experience with Bayesian inference suggests that this should be taken with a healthy dose of skepticism.
I) Setup
I downloaded & installed JAGS 3.4 and R 3.0.1
I installed the packages rjags and coda by initiating R and using install.packages(pkgname)
II) Model & Data - Used the model & data files already detailed in the question. To answer question #1, I added one additional observation onto the data with all four variables as 0.
III) Answering questions
I ran JAGS on the model/data (open the command line, go the the directory with your files, and type > jags-terminal Command.cmd . It ran and output a few files
In R, I used the following commands:
library("rjags") to load the installed package (and its required package coda)
setwd() to get to the directory where the outputfiles were
results=read.coda("STEMchain1.txt","STEMindex.txt")
To answer the first question:
As a PDF plot, "plot(results[,3*N])"
As quantiles, "quantile(results[,3*N],c(0.025,0.25,0.5,0.75,0.975))"
Where N is the number of observations, and the last observation corresponds to the position of the "all 0's" observation. (1 to n is for variable p_A, n+1 to 2n is for p_B, and 2n+1 to 3n is for delta)
To answer the second question, same as above, but change 3*N -> 2*N+y
I'm not sure this is the correct way to get the answer, or whether a more complex model would produce better results, particularly in the case of correlation, but hopefully eventually someone more experienced will chime in... | Hierarchical Bayesian analysis on difference of proportions | Since the time for the bounty expired and I received no answers, I'll post the answer I was able to come up with, though my limited experience with Bayesian inference suggests that this should be take | Hierarchical Bayesian analysis on difference of proportions
Since the time for the bounty expired and I received no answers, I'll post the answer I was able to come up with, though my limited experience with Bayesian inference suggests that this should be taken with a healthy dose of skepticism.
I) Setup
I downloaded & installed JAGS 3.4 and R 3.0.1
I installed the packages rjags and coda by initiating R and using install.packages(pkgname)
II) Model & Data - Used the model & data files already detailed in the question. To answer question #1, I added one additional observation onto the data with all four variables as 0.
III) Answering questions
I ran JAGS on the model/data (open the command line, go the the directory with your files, and type > jags-terminal Command.cmd . It ran and output a few files
In R, I used the following commands:
library("rjags") to load the installed package (and its required package coda)
setwd() to get to the directory where the outputfiles were
results=read.coda("STEMchain1.txt","STEMindex.txt")
To answer the first question:
As a PDF plot, "plot(results[,3*N])"
As quantiles, "quantile(results[,3*N],c(0.025,0.25,0.5,0.75,0.975))"
Where N is the number of observations, and the last observation corresponds to the position of the "all 0's" observation. (1 to n is for variable p_A, n+1 to 2n is for p_B, and 2n+1 to 3n is for delta)
To answer the second question, same as above, but change 3*N -> 2*N+y
I'm not sure this is the correct way to get the answer, or whether a more complex model would produce better results, particularly in the case of correlation, but hopefully eventually someone more experienced will chime in... | Hierarchical Bayesian analysis on difference of proportions
Since the time for the bounty expired and I received no answers, I'll post the answer I was able to come up with, though my limited experience with Bayesian inference suggests that this should be take |
37,586 | Issues with ordinary kriging | I suspect that the quoted formula from the Wikipedia article
results from a confusion in the notations, as if $\gamma$ was intended
to be the covariance in the formula although it was formerly used for
the theoretical semi-variogram, as well as the sample
semi-variogram... As I understand, $x^\star$ and $x_0$ are also a
same thing, the "new" location vector.
To obtain both the same Lagrange multiplier $\mu$ and the vector $\mathbf{w}$ of $n$ kriging weights with the variogram $\gamma$,
you ought to use a different system
$$
\begin{bmatrix}
\boldsymbol{\Gamma} & -\mathbf{1} \\
-\mathbf{1}^\top & 0
\end{bmatrix}
\begin{bmatrix}
\mathbf{w} \\
\mu
\end{bmatrix}
=
\begin{bmatrix}
\boldsymbol{\gamma}^\star \\
-1
\end{bmatrix}
$$
where $\boldsymbol{\Gamma}$ is the $n \times n$ matrix
$\boldsymbol{\Gamma} = \left[ \gamma(\mathbf{x}_i,\,\mathbf{x}_j)\right]_{i,j}$
and $\boldsymbol{\gamma}^\star$ is the vector
$\boldsymbol{\gamma}^\star = \left[ \gamma(\mathbf{x}^\star,\,\mathbf{x}_i)\right]_{i}$
involving the new location $\mathbf{x}^\star$ and $\mathbf{1}$
is a vector of ones with length $n$.
See (up to notations
changes) Statistics for Spatial Data by N. Cressie p. 121 in
the revised edition.
## using the covariance
Acov <- matrix(c(1.0000, 0.7408, 0.5488, 1.0000,
0.7408, 1.0000, 0.7408, 1.0000,
0.5488, 0.7408, 1.0000, 1.0000,
1.0000, 1.0000, 1.0000, 0.0000),
nrow=4)
Bcov <- c(0.4066, 0.5488, 0.7408, 1.0000)
## using the variogram
Avario <- matrix(-1, nrow = 4, ncol = 4)
Avario[1:3, 1:3] <- 1 - Acov[1:3, 1:3]
Avario[4, 4] <- 0
Bvario <- 1 - Bcov
Bvario[4] <- -1
## compare
cbind(cov = solve(Acov, Bcov), vario = solve(Avario, Bvario)) | Issues with ordinary kriging | I suspect that the quoted formula from the Wikipedia article
results from a confusion in the notations, as if $\gamma$ was intended
to be the covariance in the formula although it was formerly used fo | Issues with ordinary kriging
I suspect that the quoted formula from the Wikipedia article
results from a confusion in the notations, as if $\gamma$ was intended
to be the covariance in the formula although it was formerly used for
the theoretical semi-variogram, as well as the sample
semi-variogram... As I understand, $x^\star$ and $x_0$ are also a
same thing, the "new" location vector.
To obtain both the same Lagrange multiplier $\mu$ and the vector $\mathbf{w}$ of $n$ kriging weights with the variogram $\gamma$,
you ought to use a different system
$$
\begin{bmatrix}
\boldsymbol{\Gamma} & -\mathbf{1} \\
-\mathbf{1}^\top & 0
\end{bmatrix}
\begin{bmatrix}
\mathbf{w} \\
\mu
\end{bmatrix}
=
\begin{bmatrix}
\boldsymbol{\gamma}^\star \\
-1
\end{bmatrix}
$$
where $\boldsymbol{\Gamma}$ is the $n \times n$ matrix
$\boldsymbol{\Gamma} = \left[ \gamma(\mathbf{x}_i,\,\mathbf{x}_j)\right]_{i,j}$
and $\boldsymbol{\gamma}^\star$ is the vector
$\boldsymbol{\gamma}^\star = \left[ \gamma(\mathbf{x}^\star,\,\mathbf{x}_i)\right]_{i}$
involving the new location $\mathbf{x}^\star$ and $\mathbf{1}$
is a vector of ones with length $n$.
See (up to notations
changes) Statistics for Spatial Data by N. Cressie p. 121 in
the revised edition.
## using the covariance
Acov <- matrix(c(1.0000, 0.7408, 0.5488, 1.0000,
0.7408, 1.0000, 0.7408, 1.0000,
0.5488, 0.7408, 1.0000, 1.0000,
1.0000, 1.0000, 1.0000, 0.0000),
nrow=4)
Bcov <- c(0.4066, 0.5488, 0.7408, 1.0000)
## using the variogram
Avario <- matrix(-1, nrow = 4, ncol = 4)
Avario[1:3, 1:3] <- 1 - Acov[1:3, 1:3]
Avario[4, 4] <- 0
Bvario <- 1 - Bcov
Bvario[4] <- -1
## compare
cbind(cov = solve(Acov, Bcov), vario = solve(Avario, Bvario)) | Issues with ordinary kriging
I suspect that the quoted formula from the Wikipedia article
results from a confusion in the notations, as if $\gamma$ was intended
to be the covariance in the formula although it was formerly used fo |
37,587 | Why is this representing the left tail? | Why is the spouses' ages at death the left tail?
I would disagree with the authors statement. I guess that spouses' deaths are equally correlated over their joint distribution. It doesn't make sense that younger couples tend to die together rather than older couples. This is what a Clayton-copula would model.
And why is recessionary times the left tail? Is it, because in resessionary times negative returns occur and this is representing the left tail?
This one is easier. The text mentions, that loan defaults are highly correlated. Just assume that a big company defaults in a small town. Therefore it can't pay its liabilities anymore. Probably other companies go bankrupt because they are dependent on this cash inflow. Or the now unemployed can't afford the same life style as before and restaurants go bankrupt. | Why is this representing the left tail? | Why is the spouses' ages at death the left tail?
I would disagree with the authors statement. I guess that spouses' deaths are equally correlated over their joint distribution. It doesn't make sense t | Why is this representing the left tail?
Why is the spouses' ages at death the left tail?
I would disagree with the authors statement. I guess that spouses' deaths are equally correlated over their joint distribution. It doesn't make sense that younger couples tend to die together rather than older couples. This is what a Clayton-copula would model.
And why is recessionary times the left tail? Is it, because in resessionary times negative returns occur and this is representing the left tail?
This one is easier. The text mentions, that loan defaults are highly correlated. Just assume that a big company defaults in a small town. Therefore it can't pay its liabilities anymore. Probably other companies go bankrupt because they are dependent on this cash inflow. Or the now unemployed can't afford the same life style as before and restaurants go bankrupt. | Why is this representing the left tail?
Why is the spouses' ages at death the left tail?
I would disagree with the authors statement. I guess that spouses' deaths are equally correlated over their joint distribution. It doesn't make sense t |
37,588 | Stationarity - assumptions and examination | There are always two ways to calculate statistics with the kinds of things your talking about:
Calculate statistics within one grid.
Calculate statistics between different grids.
Now, there is no reason that the statistical properties within one grid have to match the statistical characteristics between grids. They could conceivably be completely different, i.e. one could be in a minefield with no rats and the other could be in downtown Baltimore. Clearly, the distribution of rats would be quite different depending on which way I slice the data, that is, across grids or within grids.
Stationarity is the assumption that the statistics you calculate are the same regardless of which way you sliced the data. Practically speaking, you can "examine and verify data are stationary" by analyzing means, variances, histograms, etc., within sites, and then across sites, and seeing if they are the same, to within confidence intervals. There are no hard and fast rules; you do the best with the data you have and the techniques at your disposal, try to justify them mathematically, and present practical results. I would say that you can justify your methods if you can show stationarity in this way to some standard confidence interval, say 95% or 99%. | Stationarity - assumptions and examination | There are always two ways to calculate statistics with the kinds of things your talking about:
Calculate statistics within one grid.
Calculate statistics between different grids.
Now, there is no re | Stationarity - assumptions and examination
There are always two ways to calculate statistics with the kinds of things your talking about:
Calculate statistics within one grid.
Calculate statistics between different grids.
Now, there is no reason that the statistical properties within one grid have to match the statistical characteristics between grids. They could conceivably be completely different, i.e. one could be in a minefield with no rats and the other could be in downtown Baltimore. Clearly, the distribution of rats would be quite different depending on which way I slice the data, that is, across grids or within grids.
Stationarity is the assumption that the statistics you calculate are the same regardless of which way you sliced the data. Practically speaking, you can "examine and verify data are stationary" by analyzing means, variances, histograms, etc., within sites, and then across sites, and seeing if they are the same, to within confidence intervals. There are no hard and fast rules; you do the best with the data you have and the techniques at your disposal, try to justify them mathematically, and present practical results. I would say that you can justify your methods if you can show stationarity in this way to some standard confidence interval, say 95% or 99%. | Stationarity - assumptions and examination
There are always two ways to calculate statistics with the kinds of things your talking about:
Calculate statistics within one grid.
Calculate statistics between different grids.
Now, there is no re |
37,589 | Why do copulas need the i.i.d assumption for marginal distribution? | Yes, you need to have independent observations to apply conventional copulas. If you have serial correlation in data, look for "autocopulas", e.g. here "Autocopulas: investigating the interdependence structure of stationary time series" by Rakonczai et al.
The reason is that you're looking for a wrong joint. Consider this, you're trying to recover the joint distribution $F(X,Y)$ with copulas, where $X,Y$ are random variables. However, in case of first order serial correlation in observations (autocorrelation) the joint distribution is $F(X_t,X_{-1},Y_t,Y_{t-1})$ not the one you're trying to recover. | Why do copulas need the i.i.d assumption for marginal distribution? | Yes, you need to have independent observations to apply conventional copulas. If you have serial correlation in data, look for "autocopulas", e.g. here "Autocopulas: investigating the interdependence | Why do copulas need the i.i.d assumption for marginal distribution?
Yes, you need to have independent observations to apply conventional copulas. If you have serial correlation in data, look for "autocopulas", e.g. here "Autocopulas: investigating the interdependence structure of stationary time series" by Rakonczai et al.
The reason is that you're looking for a wrong joint. Consider this, you're trying to recover the joint distribution $F(X,Y)$ with copulas, where $X,Y$ are random variables. However, in case of first order serial correlation in observations (autocorrelation) the joint distribution is $F(X_t,X_{-1},Y_t,Y_{t-1})$ not the one you're trying to recover. | Why do copulas need the i.i.d assumption for marginal distribution?
Yes, you need to have independent observations to apply conventional copulas. If you have serial correlation in data, look for "autocopulas", e.g. here "Autocopulas: investigating the interdependence |
37,590 | Why do copulas need the i.i.d assumption for marginal distribution? | Copulas are based on Sklar's theorem and this theorem does not require independency. Besides, there exists an independence copula such that:
$$F(x_1, \ldots , x_d ) = \Pr(X_1 ≤ x_1, \ldots , X_d ≤ x_d )$$ $$= \Pr(X_1 ≤ x_1)\cdots\Pr(X_d ≤ x_d ) = F_1(x_1)\cdots F_d(x_d)$$ and $$ F(x_1, \ldots , x_d ) $$ $$= C(F_1(x_1), \ldots , F_d(x_d))$$ | Why do copulas need the i.i.d assumption for marginal distribution? | Copulas are based on Sklar's theorem and this theorem does not require independency. Besides, there exists an independence copula such that:
$$F(x_1, \ldots , x_d ) = \Pr(X_1 ≤ x_1, \ldots , X_d ≤ x_d | Why do copulas need the i.i.d assumption for marginal distribution?
Copulas are based on Sklar's theorem and this theorem does not require independency. Besides, there exists an independence copula such that:
$$F(x_1, \ldots , x_d ) = \Pr(X_1 ≤ x_1, \ldots , X_d ≤ x_d )$$ $$= \Pr(X_1 ≤ x_1)\cdots\Pr(X_d ≤ x_d ) = F_1(x_1)\cdots F_d(x_d)$$ and $$ F(x_1, \ldots , x_d ) $$ $$= C(F_1(x_1), \ldots , F_d(x_d))$$ | Why do copulas need the i.i.d assumption for marginal distribution?
Copulas are based on Sklar's theorem and this theorem does not require independency. Besides, there exists an independence copula such that:
$$F(x_1, \ldots , x_d ) = \Pr(X_1 ≤ x_1, \ldots , X_d ≤ x_d |
37,591 | From standard HMM to Bayesian HMM | In terms of the Dirichlet prior, I believe it's saying that you have a set of $n$ variables which are all percentages/proportions between 0 and 1 and all add up to 1. (That is $x_1 \dots x_n$ where $0 \le x_i \le 1$ and $\sum x_i = 1$.) In the case of HMM's, that could be used to model the probability of transitioning to one of $n$ possible states, or the probability of emitting one of $n$ possible symbols.
The Dirichlet wikipedia page says it pretty well, especially the section entitled "Conjugate to categorical/multinomial". | From standard HMM to Bayesian HMM | In terms of the Dirichlet prior, I believe it's saying that you have a set of $n$ variables which are all percentages/proportions between 0 and 1 and all add up to 1. (That is $x_1 \dots x_n$ where $0 | From standard HMM to Bayesian HMM
In terms of the Dirichlet prior, I believe it's saying that you have a set of $n$ variables which are all percentages/proportions between 0 and 1 and all add up to 1. (That is $x_1 \dots x_n$ where $0 \le x_i \le 1$ and $\sum x_i = 1$.) In the case of HMM's, that could be used to model the probability of transitioning to one of $n$ possible states, or the probability of emitting one of $n$ possible symbols.
The Dirichlet wikipedia page says it pretty well, especially the section entitled "Conjugate to categorical/multinomial". | From standard HMM to Bayesian HMM
In terms of the Dirichlet prior, I believe it's saying that you have a set of $n$ variables which are all percentages/proportions between 0 and 1 and all add up to 1. (That is $x_1 \dots x_n$ where $0 |
37,592 | How to compare ranked data? | For your second task, you could consider ordination methods, so that you are plotting the location of individuals within a multivariate 'challenge-space'. Distinct clusters for those with and without HIV would seem to support your hypothesis. | How to compare ranked data? | For your second task, you could consider ordination methods, so that you are plotting the location of individuals within a multivariate 'challenge-space'. Distinct clusters for those with and without | How to compare ranked data?
For your second task, you could consider ordination methods, so that you are plotting the location of individuals within a multivariate 'challenge-space'. Distinct clusters for those with and without HIV would seem to support your hypothesis. | How to compare ranked data?
For your second task, you could consider ordination methods, so that you are plotting the location of individuals within a multivariate 'challenge-space'. Distinct clusters for those with and without |
37,593 | How to compare ranked data? | For your first question, convert your choices into numerical data(in order) for each group and then take the absolute difference between each choice from each person in each group. The ones that have the biggest difference could possibly be considered the ones that each group perceives the most different.
Let's say you have two people and each one belongs to a group A and B respectively. Each person has a rank for 12 items, 1-12. For item 1: A chose 1 and B chose 7. If the rest of the items are constant or very close to zero, groups A and B perceived item 1 different since that item has the biggest difference.
You also need to make a judgement call on whether that makes sense. Maybe come up with a subset of ranks that you are certain, each group would think differently about, and do the difference thing and see if it fits your subset. | How to compare ranked data? | For your first question, convert your choices into numerical data(in order) for each group and then take the absolute difference between each choice from each person in each group. The ones that have | How to compare ranked data?
For your first question, convert your choices into numerical data(in order) for each group and then take the absolute difference between each choice from each person in each group. The ones that have the biggest difference could possibly be considered the ones that each group perceives the most different.
Let's say you have two people and each one belongs to a group A and B respectively. Each person has a rank for 12 items, 1-12. For item 1: A chose 1 and B chose 7. If the rest of the items are constant or very close to zero, groups A and B perceived item 1 different since that item has the biggest difference.
You also need to make a judgement call on whether that makes sense. Maybe come up with a subset of ranks that you are certain, each group would think differently about, and do the difference thing and see if it fits your subset. | How to compare ranked data?
For your first question, convert your choices into numerical data(in order) for each group and then take the absolute difference between each choice from each person in each group. The ones that have |
37,594 | How to compare ranked data? | Define importance score to be the ranks, it takes value 1 to 12, with 1 being least important and 12 being most important
Pick a factor of interest, for example, health, then collect importance scores from group 1 and group 2, for example:
score_health_1 <- c(1,2,3,2,4,1,2,4,3,1,2,2,3,1)
score_health_2 <- c(3,4,5,5,6,1,2,4,6,5,3,3,2,8,7,4)
Then you can do a wilcox.test(score_health_1, score_health_2) or a t-test.
You can do this for each of the 12 factors individually.
If you are interested in multivariate test, for example, heath and social,
Then you can use Hottelling t^2 test, which accounts for correlation in multivariate test. | How to compare ranked data? | Define importance score to be the ranks, it takes value 1 to 12, with 1 being least important and 12 being most important
Pick a factor of interest, for example, health, then collect importance scores | How to compare ranked data?
Define importance score to be the ranks, it takes value 1 to 12, with 1 being least important and 12 being most important
Pick a factor of interest, for example, health, then collect importance scores from group 1 and group 2, for example:
score_health_1 <- c(1,2,3,2,4,1,2,4,3,1,2,2,3,1)
score_health_2 <- c(3,4,5,5,6,1,2,4,6,5,3,3,2,8,7,4)
Then you can do a wilcox.test(score_health_1, score_health_2) or a t-test.
You can do this for each of the 12 factors individually.
If you are interested in multivariate test, for example, heath and social,
Then you can use Hottelling t^2 test, which accounts for correlation in multivariate test. | How to compare ranked data?
Define importance score to be the ranks, it takes value 1 to 12, with 1 being least important and 12 being most important
Pick a factor of interest, for example, health, then collect importance scores |
37,595 | Random music note generation | A very cute question! Here's a partial cute answer: Chopin, mazurkas and Markov chains. I am not a musician myself, so I can't really expand and give a meaningful answer. But you should read that paer. | Random music note generation | A very cute question! Here's a partial cute answer: Chopin, mazurkas and Markov chains. I am not a musician myself, so I can't really expand and give a meaningful answer. But you should read that paer | Random music note generation
A very cute question! Here's a partial cute answer: Chopin, mazurkas and Markov chains. I am not a musician myself, so I can't really expand and give a meaningful answer. But you should read that paer. | Random music note generation
A very cute question! Here's a partial cute answer: Chopin, mazurkas and Markov chains. I am not a musician myself, so I can't really expand and give a meaningful answer. But you should read that paer |
37,596 | Predicting dichotomous outcome of temporal data set with covariates | If you have a LARGE data set, there might be something in the machine learning literature to help you. View it as a classification problem. But since this is a medical example, I suspect the total number of patients is fairly small.
In that case, your best hope lies in being able to specify a model for the time-dependent stuff. For example, if a simple regression relates Day to Blood Value, you could compare the estimated slope parameter to outcome: 2 groups; simple t-test. If you have additional covariates, you could include them as well. You would then have a logistic regression with your slope parameter and covariates in the model. You could fit a more complex functional form if needed.
You might be able to model the blood value component in other ways: try a principal components analysis, and if most of the variation appear to be on the first component, replace the whole series of observations with the PC score. Then proceed as before with a logistic regression.
If you had the same number of "repeated observations" for each patient, you could try a discriminant analysis. This is similar to the PCA mentioned above, except that the components are chosen to best distinguish between the two dichotomous outcome of the last day.
Whatever you do, you can estimate your model from one portion of the data set and test it on the other part -- see how well you can actually predict the outcome. | Predicting dichotomous outcome of temporal data set with covariates | If you have a LARGE data set, there might be something in the machine learning literature to help you. View it as a classification problem. But since this is a medical example, I suspect the total num | Predicting dichotomous outcome of temporal data set with covariates
If you have a LARGE data set, there might be something in the machine learning literature to help you. View it as a classification problem. But since this is a medical example, I suspect the total number of patients is fairly small.
In that case, your best hope lies in being able to specify a model for the time-dependent stuff. For example, if a simple regression relates Day to Blood Value, you could compare the estimated slope parameter to outcome: 2 groups; simple t-test. If you have additional covariates, you could include them as well. You would then have a logistic regression with your slope parameter and covariates in the model. You could fit a more complex functional form if needed.
You might be able to model the blood value component in other ways: try a principal components analysis, and if most of the variation appear to be on the first component, replace the whole series of observations with the PC score. Then proceed as before with a logistic regression.
If you had the same number of "repeated observations" for each patient, you could try a discriminant analysis. This is similar to the PCA mentioned above, except that the components are chosen to best distinguish between the two dichotomous outcome of the last day.
Whatever you do, you can estimate your model from one portion of the data set and test it on the other part -- see how well you can actually predict the outcome. | Predicting dichotomous outcome of temporal data set with covariates
If you have a LARGE data set, there might be something in the machine learning literature to help you. View it as a classification problem. But since this is a medical example, I suspect the total num |
37,597 | Predicting dichotomous outcome of temporal data set with covariates | I think a mixed effects model or a marginal model using generalized estimating equations (GEE) might work for you. Using GEE you could specify a working correlation matrix that designates those observations later in the series as being more highly correlated with one another and you could add a variable into your model for the time component. You could, of course do something similar with lmer and mixed effects (minus the working correlation matrix bit). The mixed effects approach has the added benefit that it isn't using a population averaged approach like GEE.
Taking this a step further, you may even be able to build several predictive models using classical statistical modelling techniques and machine learning techniques like boosted regression trees and then use a machine learning ensemble method to combine them into a single, more powerful predictor. Using Stacking for example, you might build several models and then combined all of the models into one final prediction model. These models generally outperform Bayesian model averaging approaches as well. | Predicting dichotomous outcome of temporal data set with covariates | I think a mixed effects model or a marginal model using generalized estimating equations (GEE) might work for you. Using GEE you could specify a working correlation matrix that designates those obser | Predicting dichotomous outcome of temporal data set with covariates
I think a mixed effects model or a marginal model using generalized estimating equations (GEE) might work for you. Using GEE you could specify a working correlation matrix that designates those observations later in the series as being more highly correlated with one another and you could add a variable into your model for the time component. You could, of course do something similar with lmer and mixed effects (minus the working correlation matrix bit). The mixed effects approach has the added benefit that it isn't using a population averaged approach like GEE.
Taking this a step further, you may even be able to build several predictive models using classical statistical modelling techniques and machine learning techniques like boosted regression trees and then use a machine learning ensemble method to combine them into a single, more powerful predictor. Using Stacking for example, you might build several models and then combined all of the models into one final prediction model. These models generally outperform Bayesian model averaging approaches as well. | Predicting dichotomous outcome of temporal data set with covariates
I think a mixed effects model or a marginal model using generalized estimating equations (GEE) might work for you. Using GEE you could specify a working correlation matrix that designates those obser |
37,598 | Spatial clustering with the constraint that all clusters have equal count | This is not really a clustering task anymore. See: clustering is about discovering structure, but you are forcing formal constraints to be much stronger than the structure.
However, you can look at it from a different angle:
A structure that tries really hard to divide the data into non-overlapping, equally sized "bins" is a balanced tree. So you probably want a spatial tree such as the R*-tree. It will try to partition your data into equally sized partitions.
Now in particular for 2D point data, it is much easier to bulk-load the tree using STR instead of using a full R-tree. Plus, it will actually get you non-overlapping partitions that are also really of equal size. The regular R- and R*-trees will only do this within certain thresholds.
The general process you need is very simple (and this is the consequence of your "equal size" constraint!): Compute sqrt(k) when k is your desired number of partitions.
Sort your data by the x-axis, and divide it into sqrt(k) equally sized partitions. For each of these partitions, sort that part of the data by the y-axis, and divide it again into sqrt(k) partitions. Then you have sqrt(k)^2 = k partitions that have the same size and do not overlap. Plus, it take just O(n log n) time, and this way is much faster than hierarchical clustering. | Spatial clustering with the constraint that all clusters have equal count | This is not really a clustering task anymore. See: clustering is about discovering structure, but you are forcing formal constraints to be much stronger than the structure.
However, you can look at it | Spatial clustering with the constraint that all clusters have equal count
This is not really a clustering task anymore. See: clustering is about discovering structure, but you are forcing formal constraints to be much stronger than the structure.
However, you can look at it from a different angle:
A structure that tries really hard to divide the data into non-overlapping, equally sized "bins" is a balanced tree. So you probably want a spatial tree such as the R*-tree. It will try to partition your data into equally sized partitions.
Now in particular for 2D point data, it is much easier to bulk-load the tree using STR instead of using a full R-tree. Plus, it will actually get you non-overlapping partitions that are also really of equal size. The regular R- and R*-trees will only do this within certain thresholds.
The general process you need is very simple (and this is the consequence of your "equal size" constraint!): Compute sqrt(k) when k is your desired number of partitions.
Sort your data by the x-axis, and divide it into sqrt(k) equally sized partitions. For each of these partitions, sort that part of the data by the y-axis, and divide it again into sqrt(k) partitions. Then you have sqrt(k)^2 = k partitions that have the same size and do not overlap. Plus, it take just O(n log n) time, and this way is much faster than hierarchical clustering. | Spatial clustering with the constraint that all clusters have equal count
This is not really a clustering task anymore. See: clustering is about discovering structure, but you are forcing formal constraints to be much stronger than the structure.
However, you can look at it |
37,599 | Where to start: Unevenly spaced time series, with lots of outliers or randomness | I don't know if can give you an expected answer, but I think some Bayesian approach would be good in this case.
You may want to take a look in particle filters instead of Kalman as I susspect it may be a problem to set up correct model for Kalman filter in this case. If you want to go for Kalman, there are different types of the filter and some of them require good knowledge about error covariance, which may cause troubles, but some can compute it with Mante Carlo. Take a look on unscented Kalman Filter.
You may also like http://www.udacity.com/overview/Course/cs373/CourseRev/apr2012 as it explain some basic about estimation for moving vehicle and google's self-driving car. (and it is in python).
Maybe some more details in your question would be more helpful and you can get more precise answers. | Where to start: Unevenly spaced time series, with lots of outliers or randomness | I don't know if can give you an expected answer, but I think some Bayesian approach would be good in this case.
You may want to take a look in particle filters instead of Kalman as I susspect it may | Where to start: Unevenly spaced time series, with lots of outliers or randomness
I don't know if can give you an expected answer, but I think some Bayesian approach would be good in this case.
You may want to take a look in particle filters instead of Kalman as I susspect it may be a problem to set up correct model for Kalman filter in this case. If you want to go for Kalman, there are different types of the filter and some of them require good knowledge about error covariance, which may cause troubles, but some can compute it with Mante Carlo. Take a look on unscented Kalman Filter.
You may also like http://www.udacity.com/overview/Course/cs373/CourseRev/apr2012 as it explain some basic about estimation for moving vehicle and google's self-driving car. (and it is in python).
Maybe some more details in your question would be more helpful and you can get more precise answers. | Where to start: Unevenly spaced time series, with lots of outliers or randomness
I don't know if can give you an expected answer, but I think some Bayesian approach would be good in this case.
You may want to take a look in particle filters instead of Kalman as I susspect it may |
37,600 | Post hoc test of adjusted means (after ANCOVA) | Did I understand that you were looking for a software capable of calculating ANCOVA based on adjusted means? There is a free statistical software called PAST that does use adjusted means for ANCOVA.
It is available at http://folk.uio.no/ohammer/past/ | Post hoc test of adjusted means (after ANCOVA) | Did I understand that you were looking for a software capable of calculating ANCOVA based on adjusted means? There is a free statistical software called PAST that does use adjusted means for ANCOVA.
| Post hoc test of adjusted means (after ANCOVA)
Did I understand that you were looking for a software capable of calculating ANCOVA based on adjusted means? There is a free statistical software called PAST that does use adjusted means for ANCOVA.
It is available at http://folk.uio.no/ohammer/past/ | Post hoc test of adjusted means (after ANCOVA)
Did I understand that you were looking for a software capable of calculating ANCOVA based on adjusted means? There is a free statistical software called PAST that does use adjusted means for ANCOVA.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.