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
|
|---|---|---|---|---|---|---|
41,801
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
|
(I will delete my other non-answer, the edit of which had this nugget in it)
No. Asymptotically, the 'trivial' upper bound is the least upper bound. To see this, Let $P_n = P(Z = n)$. Trivially, $E[\exp{(Z^2)}] \ge P_n \exp{(n^2)} = L$, where $L$ is the lower bound of interest. Since $Z$ is binomial, we have $P_n = {n\choose n} (n^{-\beta})^n (1-n^{-\beta})^0 = n^{-n\beta}$. Then $\log{L} = -\beta n \log{n} + n^2$. It is easily shown that this is $\Omega{(n^2)}$, and thus, $L$ is $\Omega{(\exp{(n^2)})}$. Thus the trivial upper bound is, asymptotically, the least upper bound, i.e. $E[\exp{(Z^2)}] \in \Theta{(\exp{(n^2)})}$.
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
|
(I will delete my other non-answer, the edit of which had this nugget in it)
No. Asymptotically, the 'trivial' upper bound is the least upper bound. To see this, Let $P_n = P(Z = n)$. Trivially, $E[\e
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
(I will delete my other non-answer, the edit of which had this nugget in it)
No. Asymptotically, the 'trivial' upper bound is the least upper bound. To see this, Let $P_n = P(Z = n)$. Trivially, $E[\exp{(Z^2)}] \ge P_n \exp{(n^2)} = L$, where $L$ is the lower bound of interest. Since $Z$ is binomial, we have $P_n = {n\choose n} (n^{-\beta})^n (1-n^{-\beta})^0 = n^{-n\beta}$. Then $\log{L} = -\beta n \log{n} + n^2$. It is easily shown that this is $\Omega{(n^2)}$, and thus, $L$ is $\Omega{(\exp{(n^2)})}$. Thus the trivial upper bound is, asymptotically, the least upper bound, i.e. $E[\exp{(Z^2)}] \in \Theta{(\exp{(n^2)})}$.
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
(I will delete my other non-answer, the edit of which had this nugget in it)
No. Asymptotically, the 'trivial' upper bound is the least upper bound. To see this, Let $P_n = P(Z = n)$. Trivially, $E[\e
|
41,802
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
|
Numerical experiments (for 2 <= n <= 4000 and all values of beta) indicate the estimate n^2 - (n Ln(n))*beta exceeds the logarithm of the expectation by an amount on the order of beta*Exp(-n). The error appears to increase monotonically in beta for each n. This should provide some useful clues about how to proceed (for those with the time and interest). In particular, an upper bound for the expectation exists of the form Exp(n^2 - (n Ln(n))*beta + C*Exp(-n)*beta) with C << 1.
Update
After staring at the summation expression for the expectation, it became evident where the nLn(n)*beta term comes from: break each binomial coefficient Comb(n,k) into its sum Comb(n-1,k) + Comb(n-1,k-1) and write Exp(k^2) = Exp((k-1)^2)*Exp(2k-1). This decomposes the expectation e(n,beta) into the sum of two parts, one of which looks like the expectation e(n-1,beta) and the other of which is messy (because each term is multiplied by Exp(2k-1)) but can be bounded above by replacing all those exponential terms by their obvious upper bound Exp(2n-1). (This is not too bad, because the last term with the highest exponent strongly dominates the entire sum.) This gives a recursive inequality for the expectation,
e(n,beta) <= (n^-beta * Exp(2n-1) + 1 - n^-beta) * e(n-1,beta)
Doing this n times creates a polynomial whose highest term is in fact Exp(n^2)*n^(-n*beta), with the remaining terms decreasing fairly rapidly. At this point any reasonable bound on the remainder will produce an improved bound for the expectation essentially of the form suggested by the numerical experiments. At this point you have to decide how hard you want to work to obtain a tighter upper bound; the numerical experiments suggest this additional work is not going to pay off unless you're interested in the smallest values of n.
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
|
Numerical experiments (for 2 <= n <= 4000 and all values of beta) indicate the estimate n^2 - (n Ln(n))*beta exceeds the logarithm of the expectation by an amount on the order of beta*Exp(-n). The er
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
Numerical experiments (for 2 <= n <= 4000 and all values of beta) indicate the estimate n^2 - (n Ln(n))*beta exceeds the logarithm of the expectation by an amount on the order of beta*Exp(-n). The error appears to increase monotonically in beta for each n. This should provide some useful clues about how to proceed (for those with the time and interest). In particular, an upper bound for the expectation exists of the form Exp(n^2 - (n Ln(n))*beta + C*Exp(-n)*beta) with C << 1.
Update
After staring at the summation expression for the expectation, it became evident where the nLn(n)*beta term comes from: break each binomial coefficient Comb(n,k) into its sum Comb(n-1,k) + Comb(n-1,k-1) and write Exp(k^2) = Exp((k-1)^2)*Exp(2k-1). This decomposes the expectation e(n,beta) into the sum of two parts, one of which looks like the expectation e(n-1,beta) and the other of which is messy (because each term is multiplied by Exp(2k-1)) but can be bounded above by replacing all those exponential terms by their obvious upper bound Exp(2n-1). (This is not too bad, because the last term with the highest exponent strongly dominates the entire sum.) This gives a recursive inequality for the expectation,
e(n,beta) <= (n^-beta * Exp(2n-1) + 1 - n^-beta) * e(n-1,beta)
Doing this n times creates a polynomial whose highest term is in fact Exp(n^2)*n^(-n*beta), with the remaining terms decreasing fairly rapidly. At this point any reasonable bound on the remainder will produce an improved bound for the expectation essentially of the form suggested by the numerical experiments. At this point you have to decide how hard you want to work to obtain a tighter upper bound; the numerical experiments suggest this additional work is not going to pay off unless you're interested in the smallest values of n.
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
Numerical experiments (for 2 <= n <= 4000 and all values of beta) indicate the estimate n^2 - (n Ln(n))*beta exceeds the logarithm of the expectation by an amount on the order of beta*Exp(-n). The er
|
41,803
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
|
This answer is inspired by shabbychef's answer using the median. By definition:
$E[exp(Z^2)] = \sum_{z=1}^{z=n} exp(z^2) P(z;n,n^{-\beta})$
where,
$P(z;n,n^{-\beta})$ is the binomial probability.
Denote the mode of this binomial distribution by: $m(n,n^{-\beta})$. Thus, by definition we have:
$P(z;n,n^{-\beta}) \le P(m(n,n^{-\beta});n,n^{-\beta}) \ \ \forall z$
Let,
$\bar{P} = P(m(n,n^{-\beta});n,n^{-\beta})$
Thus,
$E[exp(Z^2] \le \sum_{z=1}^{z=n} exp(z^2) \bar{P}$
This upper bound is a function of $n$ and $\beta$ as desired.
Hopefully, this in the right track unlike my previous attempt.
This approach is technically not ok as $Z$ is a discrete variable but can be justified if we take the normal approximation to the binomial.
I am not sure to what extent this is a better bound then the trivial bound but here is one approach. Take the taylor series expansion of $exp(z^2)$ and ignoring terms higher than the second term, you get:
$\int e^{z^2} f(z) dz < \int (1 + z^2) f(z) dz$
Now,
$\int (1 + z^2) f(z) dz = 1 + \int z^2 f(z) dz$
But, we know that:
$\int z^2 f(z) dz = Var(z) + E(z)^2$
Substituting for the variance and mean of the binomial distribution and simplifying, we get:
$\int e^{z^2} f(z) dz < 1 + n^{1-\beta} (1-n^{-\beta} + n^{1-\beta})$
PS: Please check the math as I corrected one error.
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
|
This answer is inspired by shabbychef's answer using the median. By definition:
$E[exp(Z^2)] = \sum_{z=1}^{z=n} exp(z^2) P(z;n,n^{-\beta})$
where,
$P(z;n,n^{-\beta})$ is the binomial probability.
Den
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
This answer is inspired by shabbychef's answer using the median. By definition:
$E[exp(Z^2)] = \sum_{z=1}^{z=n} exp(z^2) P(z;n,n^{-\beta})$
where,
$P(z;n,n^{-\beta})$ is the binomial probability.
Denote the mode of this binomial distribution by: $m(n,n^{-\beta})$. Thus, by definition we have:
$P(z;n,n^{-\beta}) \le P(m(n,n^{-\beta});n,n^{-\beta}) \ \ \forall z$
Let,
$\bar{P} = P(m(n,n^{-\beta});n,n^{-\beta})$
Thus,
$E[exp(Z^2] \le \sum_{z=1}^{z=n} exp(z^2) \bar{P}$
This upper bound is a function of $n$ and $\beta$ as desired.
Hopefully, this in the right track unlike my previous attempt.
This approach is technically not ok as $Z$ is a discrete variable but can be justified if we take the normal approximation to the binomial.
I am not sure to what extent this is a better bound then the trivial bound but here is one approach. Take the taylor series expansion of $exp(z^2)$ and ignoring terms higher than the second term, you get:
$\int e^{z^2} f(z) dz < \int (1 + z^2) f(z) dz$
Now,
$\int (1 + z^2) f(z) dz = 1 + \int z^2 f(z) dz$
But, we know that:
$\int z^2 f(z) dz = Var(z) + E(z)^2$
Substituting for the variance and mean of the binomial distribution and simplifying, we get:
$\int e^{z^2} f(z) dz < 1 + n^{1-\beta} (1-n^{-\beta} + n^{1-\beta})$
PS: Please check the math as I corrected one error.
|
Non-trivial bound for $E[\exp(Z^2)]$ when $Z \sim {\rm Bin}(n, n^{-\beta})$ with $\beta \in (0,1)$
This answer is inspired by shabbychef's answer using the median. By definition:
$E[exp(Z^2)] = \sum_{z=1}^{z=n} exp(z^2) P(z;n,n^{-\beta})$
where,
$P(z;n,n^{-\beta})$ is the binomial probability.
Den
|
41,804
|
How can I apply a Pareto tail to a truncated distribution?
|
The following paper describes a couple of approaches for imputing right censored data in the same domain (i.e. topcoded wage data). They use a truncated normal distribution and describe a single imputation model assuming homoscedasticity, and a multiple imputation model assuming heterscedasticity. Also a second paper of interest, where a generalized beta distribution is assumed, might be closer to what you want.
Multiple Imputation Approaches for Right-Censored Wages in the German IAB-Employment Register
Measuring Inequality Using Censored Data: A Multiple Imputation Approach
|
How can I apply a Pareto tail to a truncated distribution?
|
The following paper describes a couple of approaches for imputing right censored data in the same domain (i.e. topcoded wage data). They use a truncated normal distribution and describe a single impu
|
How can I apply a Pareto tail to a truncated distribution?
The following paper describes a couple of approaches for imputing right censored data in the same domain (i.e. topcoded wage data). They use a truncated normal distribution and describe a single imputation model assuming homoscedasticity, and a multiple imputation model assuming heterscedasticity. Also a second paper of interest, where a generalized beta distribution is assumed, might be closer to what you want.
Multiple Imputation Approaches for Right-Censored Wages in the German IAB-Employment Register
Measuring Inequality Using Censored Data: A Multiple Imputation Approach
|
How can I apply a Pareto tail to a truncated distribution?
The following paper describes a couple of approaches for imputing right censored data in the same domain (i.e. topcoded wage data). They use a truncated normal distribution and describe a single impu
|
41,805
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
|
Well, if you have a point process that you try modeling as a Poisson process, and find it has heavy tails, there are several possibilities. What are the key assumptions for a Poisson Process:
-There is a constant rate function
-Events are memoryless, that is P(E in (t,t+d)) is independent of t and when other events are.
-The waiting time until the next event is exponentially distributed (kinda what the previous two are saying)
So, how can you violate these assumptions to get heavy tails?
-Non-constant rate function. If the rate function switches between, say, two values, you'll have too many short wait-times, and too many long wait-times, given the overall rate function. This can show itself as having heavy tails.
-The waiting time is not exponentially distributed. In which case, you don't have a Poisson process. You have some other sort of point process.
Note that in the extreme case, any point process can be modeled by a NHPP - put a delta function at each event, and set the rate to 0 elsewhere. I think we can all agree that this is a poor model, having little predictive power. So if you are interested in a NHPP, you'll want to think a bit about whether that is the right model, or whether you are overly-adjusting a model to fit your data.
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
|
Well, if you have a point process that you try modeling as a Poisson process, and find it has heavy tails, there are several possibilities. What are the key assumptions for a Poisson Process:
-There
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
Well, if you have a point process that you try modeling as a Poisson process, and find it has heavy tails, there are several possibilities. What are the key assumptions for a Poisson Process:
-There is a constant rate function
-Events are memoryless, that is P(E in (t,t+d)) is independent of t and when other events are.
-The waiting time until the next event is exponentially distributed (kinda what the previous two are saying)
So, how can you violate these assumptions to get heavy tails?
-Non-constant rate function. If the rate function switches between, say, two values, you'll have too many short wait-times, and too many long wait-times, given the overall rate function. This can show itself as having heavy tails.
-The waiting time is not exponentially distributed. In which case, you don't have a Poisson process. You have some other sort of point process.
Note that in the extreme case, any point process can be modeled by a NHPP - put a delta function at each event, and set the rate to 0 elsewhere. I think we can all agree that this is a poor model, having little predictive power. So if you are interested in a NHPP, you'll want to think a bit about whether that is the right model, or whether you are overly-adjusting a model to fit your data.
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
Well, if you have a point process that you try modeling as a Poisson process, and find it has heavy tails, there are several possibilities. What are the key assumptions for a Poisson Process:
-There
|
41,806
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
|
In general there is none. A Poisson process has inter-arrival times that are exponentially distributed, which does not have heavy tails.
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
|
In general there is none. A Poisson process has inter-arrival times that are exponentially distributed, which does not have heavy tails.
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
In general there is none. A Poisson process has inter-arrival times that are exponentially distributed, which does not have heavy tails.
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
In general there is none. A Poisson process has inter-arrival times that are exponentially distributed, which does not have heavy tails.
|
41,807
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
|
The assumption that
Heavy tail distribution for its inter arrival times
along with the assumption that each inter-arrival time is independent, you have a renewal process. There are different ways that a renewal process can have a inhomogeneous marginal rate. Most frequently this is done by stretch time (time-rescaling theorem), or scale the hazard function (multiplication of the rate and the hazard function at each time point). Poisson process is a special case where the inter-arrival time is exponential as user549 answered. However, making inhomogeneous Possion with either method results in the same inter-spike interval distribution.
In summary, inhomogeneous Poisson process cannot have heavy tails.
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
|
The assumption that
Heavy tail distribution for its inter arrival times
along with the assumption that each inter-arrival time is independent, you have a renewal process. There are different ways t
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
The assumption that
Heavy tail distribution for its inter arrival times
along with the assumption that each inter-arrival time is independent, you have a renewal process. There are different ways that a renewal process can have a inhomogeneous marginal rate. Most frequently this is done by stretch time (time-rescaling theorem), or scale the hazard function (multiplication of the rate and the hazard function at each time point). Poisson process is a special case where the inter-arrival time is exponential as user549 answered. However, making inhomogeneous Possion with either method results in the same inter-spike interval distribution.
In summary, inhomogeneous Poisson process cannot have heavy tails.
|
Nonhomogeneous Poisson and Heavy tail inter arrival time distribution
The assumption that
Heavy tail distribution for its inter arrival times
along with the assumption that each inter-arrival time is independent, you have a renewal process. There are different ways t
|
41,808
|
statistical comparison of two markov chain transition matrices
|
The answer by user @krkeane is interesting.
Following is a different kind of answer, which considers the "effective behavior" of the Markov chain transition matrices.
For a given $n$-by-$n$ Markov chain transition matrix, the most important things are:
Does the Stochastic matrix converge? In other words, are the conditions of the Perron–Frobenius theorem satisfied? The original question mentioned the existence of many zeros, which is natural in practice; so to "encourage", but not guarantee, that a typical stochastic matrix with zeros complies with the Perron–Frobenius theorem, it is typical to replace zeros with very small positive values, and re-normalize row sums to 1, prior to the subsequent numerical processing (see next 2 items).
What is the steady-state final probability of residing in each state, i.e., what is the distribution values of the leading eigenvector? (The leading eigenvector $\mathbf{v}_1$ should contain only real non-negative numbers which sum to 1, and whose associated eigenvalue should have a real value $\lambda_1 = 1$.) Thus, the steady-state distribution of 2 stochastic matrices $M_1$ and $M_2$ can be compared simply by considering the leading eigenvector $\mathbf{v}_1(M_1)$ and $\mathbf{v}_1(M_2)$ from each of the pair of stochastic matrices, and the 2 vectors compared as any 2 discrete distributions of length $n$, with for example the Kullback-Leibler (KL) divergence, etc. (Note that this is a comparison of just a pair of length $n$ vectors, in contrast to @krkeane answer which requires $n$ times comparisons of length $n$ pairs of vectors, corresponding to the complete $n \times n$ matrices.)
How fast does the convergence to the steady-state final probabilities occur? I.e., the approximate dynamic behavior. This is typically the ratio of the magnitude of the $2^{nd}$-largest eigenvalue (which is typically complex valued) to the largest eigenvalue (the leading eigenvalue), which should have real value 1: $|\lambda_2|/|\lambda_1| = |\lambda_2|/1 = |\lambda_2|$. The smaller this ratio (actually simply the value of $|\lambda_2|$), the faster the convergence to steady-state. Thus, the 2 stochastic matrices $M_1$ and $M_2$ can be compared by comparing $|\lambda_2(M_1)|$ to $|\lambda_2(M_2)|$
Items 2 and 3 above give 2 comparison conditions, both of which should be passed in order for a pair of stochastic matrices to be considered "effectively equivalent" in terms of their steady-state and approximate dynamic behavior. Item 1 (replacing zeros with very small positive values) is a practical pre-processing for being able to apply items 2 and 3.
Note: Typical convention for a Stochastic matrix is that each of its rows sum to 1. Therefore, the leading eigenvector $\mathbf{v}_1$ mentioned in item 2 is the row eigenvector more commonly known as left eigenvector. However, typical numerical analysis libraries customarily compute the right eigenvector(s), i.e., column eigenvectors. Therefore, in order to use a library which computes the right eigenvector(s), it's simply required to input to it the transpose $M^T$ of the stochastic matrix $M$. Of course, $M^T$ has columns which sum to 1, instead of rows.
|
statistical comparison of two markov chain transition matrices
|
The answer by user @krkeane is interesting.
Following is a different kind of answer, which considers the "effective behavior" of the Markov chain transition matrices.
For a given $n$-by-$n$ Markov cha
|
statistical comparison of two markov chain transition matrices
The answer by user @krkeane is interesting.
Following is a different kind of answer, which considers the "effective behavior" of the Markov chain transition matrices.
For a given $n$-by-$n$ Markov chain transition matrix, the most important things are:
Does the Stochastic matrix converge? In other words, are the conditions of the Perron–Frobenius theorem satisfied? The original question mentioned the existence of many zeros, which is natural in practice; so to "encourage", but not guarantee, that a typical stochastic matrix with zeros complies with the Perron–Frobenius theorem, it is typical to replace zeros with very small positive values, and re-normalize row sums to 1, prior to the subsequent numerical processing (see next 2 items).
What is the steady-state final probability of residing in each state, i.e., what is the distribution values of the leading eigenvector? (The leading eigenvector $\mathbf{v}_1$ should contain only real non-negative numbers which sum to 1, and whose associated eigenvalue should have a real value $\lambda_1 = 1$.) Thus, the steady-state distribution of 2 stochastic matrices $M_1$ and $M_2$ can be compared simply by considering the leading eigenvector $\mathbf{v}_1(M_1)$ and $\mathbf{v}_1(M_2)$ from each of the pair of stochastic matrices, and the 2 vectors compared as any 2 discrete distributions of length $n$, with for example the Kullback-Leibler (KL) divergence, etc. (Note that this is a comparison of just a pair of length $n$ vectors, in contrast to @krkeane answer which requires $n$ times comparisons of length $n$ pairs of vectors, corresponding to the complete $n \times n$ matrices.)
How fast does the convergence to the steady-state final probabilities occur? I.e., the approximate dynamic behavior. This is typically the ratio of the magnitude of the $2^{nd}$-largest eigenvalue (which is typically complex valued) to the largest eigenvalue (the leading eigenvalue), which should have real value 1: $|\lambda_2|/|\lambda_1| = |\lambda_2|/1 = |\lambda_2|$. The smaller this ratio (actually simply the value of $|\lambda_2|$), the faster the convergence to steady-state. Thus, the 2 stochastic matrices $M_1$ and $M_2$ can be compared by comparing $|\lambda_2(M_1)|$ to $|\lambda_2(M_2)|$
Items 2 and 3 above give 2 comparison conditions, both of which should be passed in order for a pair of stochastic matrices to be considered "effectively equivalent" in terms of their steady-state and approximate dynamic behavior. Item 1 (replacing zeros with very small positive values) is a practical pre-processing for being able to apply items 2 and 3.
Note: Typical convention for a Stochastic matrix is that each of its rows sum to 1. Therefore, the leading eigenvector $\mathbf{v}_1$ mentioned in item 2 is the row eigenvector more commonly known as left eigenvector. However, typical numerical analysis libraries customarily compute the right eigenvector(s), i.e., column eigenvectors. Therefore, in order to use a library which computes the right eigenvector(s), it's simply required to input to it the transpose $M^T$ of the stochastic matrix $M$. Of course, $M^T$ has columns which sum to 1, instead of rows.
|
statistical comparison of two markov chain transition matrices
The answer by user @krkeane is interesting.
Following is a different kind of answer, which considers the "effective behavior" of the Markov chain transition matrices.
For a given $n$-by-$n$ Markov cha
|
41,809
|
statistical comparison of two markov chain transition matrices
|
The empirical state transition matrices may be thought of as a collection of (row) histograms of a counting process given an initial state. You could compare the histograms using Kullback-Leibler divergence for the Dirichlet distribution. The row divergences could be combined using estimated state probabilities. This aggregate metric would allow you to rank the similarity of mating dances.
Edit: after further thought, just vectorize the transition count matrices, and do a single KL-divergence computation. Sample MATLAB code is available here for function KL_dirichlet().
Zeros will remain "problematic" without a prior for each matrix. To resolve this, add pseudocounts to your observed counts, for instance add $\frac{1}{m \times n}$ to each element of a state transition matrix of size $m \times n$. Hopefully you are okay with a Bayesian framework.
the diagonal is all zeroes
Given this constraint (apparently $m=n$), omit the diagonal elements from the vectorized representation of the observed state transition (count) matrices. No sense modeling and comparing the probability of something that can't happen.
|
statistical comparison of two markov chain transition matrices
|
The empirical state transition matrices may be thought of as a collection of (row) histograms of a counting process given an initial state. You could compare the histograms using Kullback-Leibler dive
|
statistical comparison of two markov chain transition matrices
The empirical state transition matrices may be thought of as a collection of (row) histograms of a counting process given an initial state. You could compare the histograms using Kullback-Leibler divergence for the Dirichlet distribution. The row divergences could be combined using estimated state probabilities. This aggregate metric would allow you to rank the similarity of mating dances.
Edit: after further thought, just vectorize the transition count matrices, and do a single KL-divergence computation. Sample MATLAB code is available here for function KL_dirichlet().
Zeros will remain "problematic" without a prior for each matrix. To resolve this, add pseudocounts to your observed counts, for instance add $\frac{1}{m \times n}$ to each element of a state transition matrix of size $m \times n$. Hopefully you are okay with a Bayesian framework.
the diagonal is all zeroes
Given this constraint (apparently $m=n$), omit the diagonal elements from the vectorized representation of the observed state transition (count) matrices. No sense modeling and comparing the probability of something that can't happen.
|
statistical comparison of two markov chain transition matrices
The empirical state transition matrices may be thought of as a collection of (row) histograms of a counting process given an initial state. You could compare the histograms using Kullback-Leibler dive
|
41,810
|
Is the converse of de Finetti's theorem true?
|
Finetti's theorem states that you can write an exchangeable multivariate Bernoulli distribution $X_1, X_2, \dots, X_n$ (that can be extended infinitely) as a mixture of multiple identical and independent distributions.
$$P(x_i, x_2, \dots, x_n) = \overbrace{\int_0^1 \underbrace{\sum_{i = 1}^n \theta^{x_i} (1-\theta)^{1-x_i}}_{\text{single multivariate Bernoulli}} f(\theta)\text{d}\theta }^{\text{mixture of multiple iid multivariate Bernoulli} }$$
FT: If the lefthand side has exchangeability then it can be written in a form like the right hand side.
Converse: The converse is also true. If you write something in the form of the right hand side, then the lefthand side will have exchangeability.
The converse is true because each individual term in the integral is exchangeable, and that makes also the mixture exchangeable.
|
Is the converse of de Finetti's theorem true?
|
Finetti's theorem states that you can write an exchangeable multivariate Bernoulli distribution $X_1, X_2, \dots, X_n$ (that can be extended infinitely) as a mixture of multiple identical and independ
|
Is the converse of de Finetti's theorem true?
Finetti's theorem states that you can write an exchangeable multivariate Bernoulli distribution $X_1, X_2, \dots, X_n$ (that can be extended infinitely) as a mixture of multiple identical and independent distributions.
$$P(x_i, x_2, \dots, x_n) = \overbrace{\int_0^1 \underbrace{\sum_{i = 1}^n \theta^{x_i} (1-\theta)^{1-x_i}}_{\text{single multivariate Bernoulli}} f(\theta)\text{d}\theta }^{\text{mixture of multiple iid multivariate Bernoulli} }$$
FT: If the lefthand side has exchangeability then it can be written in a form like the right hand side.
Converse: The converse is also true. If you write something in the form of the right hand side, then the lefthand side will have exchangeability.
The converse is true because each individual term in the integral is exchangeable, and that makes also the mixture exchangeable.
|
Is the converse of de Finetti's theorem true?
Finetti's theorem states that you can write an exchangeable multivariate Bernoulli distribution $X_1, X_2, \dots, X_n$ (that can be extended infinitely) as a mixture of multiple identical and independ
|
41,811
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
|
Below we assume we have a model $y=Xb+e$ where the components of vector $e$ are distributed iid $N(0, \sigma^2)$ and that $H$ is the projection matrix onto the range of $X$. Use a subscript of $r$ to denote corresponding quantities of the restricted model and use $\hat{e} = (I-H)y$ to mean the estimated value of the unknown $e$.
We will make use of some facts about projections shown in the Appendix at the end.
Note that
$RSS = \hat{e}'\hat{e} = y'(I-H)y = e'(I-H)e$
where we have used the fact that
$(I-H)y = (I-H)(Xb+e) = (I-H)e$
Now applying that to both $RSS$ and $RSS_r$ we have that
$RSS_r - RSS = e'(I-H_r)e - e'(I-H)e = e'(H-H_r)e$
$H$ and $H_r$ are projections and their difference is a projection too because the space that $H_r$ projects onto is nested within the space associated with $H$ by our assumptions. Thus $RSS_r - RSS$ is of the form $e'Pe$ where $P = H-H_r$ is an orthogonal projection.
Now it is known that if the components of vector $x$ are iid $N(0, 1)$, which is the case for $e/\sigma$ by assumption, and $Q$ is any orthogonal projection that $x'Qx$ is chi-squared with degrees of freedom equal to the dimension of the space onto which $Q$ projects (and is also equal to the rank of $Q$ and also equal to $trace(Q)$). Thus $(RSS-RSS_r)/\sigma^2$ is chi-squared.
Appendix
An orthogonal projection matrix $Q$ is a matrix which satisfies $Q = Q' = Q^2$. That is it is symmetric and idempotent. This implies that $||Qx||^2 = x'Q'Qx = x'Qx$ where $||.||^2$ means squared length.
If $Q$ is an orthogonal projection then so is $I-Q$.
The range of a matrix is the set of values it maps to. An orthogonal projection is said to project onto its range.
If an orthogonal projection $Q$ projects onto the range of matrix $M$ then $QM=M$ and $(I-Q)M = 0$.
If $Q$ and $Q_0$ are orthogonal projections such that $Q_0$ projects onto a subspace of the set that $Q$ projects onto then $Q$ and $Q_0$ commute and $Q-Q_0$ is an orthogonal projection too. Also $rank(Q-Q_0) = rank(Q) - rank(Q_0)$.
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
|
Below we assume we have a model $y=Xb+e$ where the components of vector $e$ are distributed iid $N(0, \sigma^2)$ and that $H$ is the projection matrix onto the range of $X$. Use a subscript of $r$ to
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
Below we assume we have a model $y=Xb+e$ where the components of vector $e$ are distributed iid $N(0, \sigma^2)$ and that $H$ is the projection matrix onto the range of $X$. Use a subscript of $r$ to denote corresponding quantities of the restricted model and use $\hat{e} = (I-H)y$ to mean the estimated value of the unknown $e$.
We will make use of some facts about projections shown in the Appendix at the end.
Note that
$RSS = \hat{e}'\hat{e} = y'(I-H)y = e'(I-H)e$
where we have used the fact that
$(I-H)y = (I-H)(Xb+e) = (I-H)e$
Now applying that to both $RSS$ and $RSS_r$ we have that
$RSS_r - RSS = e'(I-H_r)e - e'(I-H)e = e'(H-H_r)e$
$H$ and $H_r$ are projections and their difference is a projection too because the space that $H_r$ projects onto is nested within the space associated with $H$ by our assumptions. Thus $RSS_r - RSS$ is of the form $e'Pe$ where $P = H-H_r$ is an orthogonal projection.
Now it is known that if the components of vector $x$ are iid $N(0, 1)$, which is the case for $e/\sigma$ by assumption, and $Q$ is any orthogonal projection that $x'Qx$ is chi-squared with degrees of freedom equal to the dimension of the space onto which $Q$ projects (and is also equal to the rank of $Q$ and also equal to $trace(Q)$). Thus $(RSS-RSS_r)/\sigma^2$ is chi-squared.
Appendix
An orthogonal projection matrix $Q$ is a matrix which satisfies $Q = Q' = Q^2$. That is it is symmetric and idempotent. This implies that $||Qx||^2 = x'Q'Qx = x'Qx$ where $||.||^2$ means squared length.
If $Q$ is an orthogonal projection then so is $I-Q$.
The range of a matrix is the set of values it maps to. An orthogonal projection is said to project onto its range.
If an orthogonal projection $Q$ projects onto the range of matrix $M$ then $QM=M$ and $(I-Q)M = 0$.
If $Q$ and $Q_0$ are orthogonal projections such that $Q_0$ projects onto a subspace of the set that $Q$ projects onto then $Q$ and $Q_0$ commute and $Q-Q_0$ is an orthogonal projection too. Also $rank(Q-Q_0) = rank(Q) - rank(Q_0)$.
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
Below we assume we have a model $y=Xb+e$ where the components of vector $e$ are distributed iid $N(0, \sigma^2)$ and that $H$ is the projection matrix onto the range of $X$. Use a subscript of $r$ to
|
41,812
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
|
Since, there is a sense of ambiguity as to how the 'difference' of residuals of the restricted and unrestricted models leads to the $F$-statistic, it is deemed to be apt enough to briefly sketch the development in a general setting which would provide a better insight.
Theorem $[\rm I]:$ If $\mathbf x\sim \mathsf{MVN}(\boldsymbol\mu,\mathbf V),$
$$\mathbf x^\mathsf T\mathbf A\mathbf x\sim{\chi^2}^\prime\left[r(\mathbf A),\frac12\boldsymbol\mu^\mathsf T\mathbf A\boldsymbol \mu\right]\iff \mathbf{AV}~\text{idempotent}.^1$$
Consider the imposition of the constraint $$\mathbf K^\mathsf T\mathbf b = \mathbf m\tag 1$$ on the model $\mathbf y = \mathbf{Xb} +\mathbf e, $ where $\bf b$ is vector of parameters of order $k,~\mathbf K^\mathsf T $ is a matrix of order $s\times k$ along with the condition $r\left(\mathbf K^\mathsf T\right) = s, ~\mathbf m$ is a constant vector.
What's the effect of $(1) $ on the model? How should the estimator and the associated sum of squares look?
In oder to find the estimator of $\mathbf b,~\left(\tilde{\mathbf b}\right) $ subject to the constraint, one can employ Lagrange multiplier $(2\boldsymbol\lambda) $ in the minimisation of $$\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)^\mathsf T\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)+ 2\boldsymbol\lambda^\mathsf T\left(\mathbf K^\mathsf T\tilde{\mathbf b }-\mathbf m\right)\tag 2$$ w.r.t. $\tilde{\mathbf b}, ~\boldsymbol\lambda.$ Solving the equations
\begin{align}
\mathbf X^\mathsf T\mathbf X\tilde{\mathbf b} + \mathbf K\boldsymbol\lambda &= \mathbf X^\mathsf T\mathbf y\\ \mathbf K^\mathsf T\tilde{\mathbf b } &=\mathbf m,
\end{align}
yield
$$\tilde{\mathbf b }=\hat{\mathbf b }-(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\left[\mathbf K^\mathsf T(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\right]^{-1}\left(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m\right).\tag 3$$
What would be the residual sum of squares? Computing $\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)^\mathsf T\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)$ using the fact that $\mathbf X^\mathsf T(\mathbf y -\mathbf X\hat{\mathbf b})= 0 $ would lead to
\begin{align}&= \left[\mathbf y -\mathbf X\hat{\mathbf b}+ \mathbf X\left(\hat{\mathbf b}-\tilde{\mathbf b}\right)\right]^\mathsf T\left[\mathbf y -\mathbf X\hat{\mathbf b}+ \mathbf X\left(\hat{\mathbf b}-\tilde{\mathbf b}\right)\right]\\&= \left( \mathbf y -\mathbf X\hat{\mathbf b}\right) ^\mathsf T \left( \mathbf y -\mathbf X\hat{\mathbf b}\right)+ \left(\hat{\mathbf b}-\tilde{\mathbf b}\right)^\mathsf T\mathbf X^\mathsf T\mathbf X\left(\hat{\mathbf b}-\tilde{\mathbf b}\right)\\ &\stackrel{(3)}{=} \textrm{SSE} +\underbrace{(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)^\mathsf T\left[\mathbf K^\mathsf T(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\right]^{-1}(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)}_{:= Q};\tag 4 \end{align}
so
$$\textrm{residual(reduced)} = \textrm{residual(full)} + Q. \tag 5^2$$
What is the distribution of $ Q? $
Notice that $\hat{\mathbf b}~\sim\mathsf{MVN}\left(\mathbf b, (\mathbf X^\prime\mathbf X) ^{-1}\sigma^2\right)$ as $\mathbf y \sim \mathsf{MVN}(\mathbf X\mathbf b,\sigma^2\mathbf I).$ Therefore $$\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m\sim\mathsf{MVN}\left(\mathbf K^\mathsf T\mathbf b-\mathbf m,\mathbf K^\mathsf T (\mathbf X^\prime\mathbf X) ^{-1} \mathbf K
\sigma^2\right).\tag 6$$ $Q$ can be seen to be a quadratic in $\mathbf K^\mathsf T\hat{\mathbf b}-\mathbf m, $ with $\left[\mathbf K^\mathsf T (\mathbf X^\prime\mathbf X) ^{-1} \mathbf K\right]^{-1}$ as the matrix of the quadratic. Now is the crucial part: apply Theorem $\rm[I] $ here (what are $\bf A, V$ here?) using $(6) $ to conclude that $$\frac Q{\sigma^2}\sim{\chi^2}^\prime\left[s,\frac{(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)^\mathsf T\left[\mathbf K^\mathsf T(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\right]^{-1}(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)}{2\sigma^2}\right].\tag 7$$ This is the desired result in a general framework. For constructing the required $F$-statistic, it has to be deduced that $Q$ and $\textrm{SSE}$ are independent.
Notes:
$[1] $ To prove this, compute the MGF of the quadratic form and use the property of the eigenvalues of an idempotent matrix.
$[2]$ It is tempting, perhaps, to interpret $Q,$ writing it in the form \begin{align}Q &= \mathbf y^\mathsf T\mathbf y -\text{SSE} -\left[ \mathbf y^\mathsf T\mathbf y - (\text{SSE}+ Q) \right]\\&=\text{SSR}- \left[ \mathbf y^\mathsf T\mathbf y - (\text{SSE}+ Q) \right]\\ &= \textrm{reduction(full)} - \left[ \mathbf y^\mathsf T\mathbf y - (\text{SSE}+ Q) \right],\tag{N1} \end{align} as the "reduction in sum of squares due to fitting of the reduced model" along the line of $(5);$ but this is not true, in general. In fact, the term in parenthesis in $\rm(N1) $ need not be even a sum of squares.
Reference:
Linear Models, S. R. Searle, John Wiley & Sons., $1971.$
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
|
Since, there is a sense of ambiguity as to how the 'difference' of residuals of the restricted and unrestricted models leads to the $F$-statistic, it is deemed to be apt enough to briefly sketch the d
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
Since, there is a sense of ambiguity as to how the 'difference' of residuals of the restricted and unrestricted models leads to the $F$-statistic, it is deemed to be apt enough to briefly sketch the development in a general setting which would provide a better insight.
Theorem $[\rm I]:$ If $\mathbf x\sim \mathsf{MVN}(\boldsymbol\mu,\mathbf V),$
$$\mathbf x^\mathsf T\mathbf A\mathbf x\sim{\chi^2}^\prime\left[r(\mathbf A),\frac12\boldsymbol\mu^\mathsf T\mathbf A\boldsymbol \mu\right]\iff \mathbf{AV}~\text{idempotent}.^1$$
Consider the imposition of the constraint $$\mathbf K^\mathsf T\mathbf b = \mathbf m\tag 1$$ on the model $\mathbf y = \mathbf{Xb} +\mathbf e, $ where $\bf b$ is vector of parameters of order $k,~\mathbf K^\mathsf T $ is a matrix of order $s\times k$ along with the condition $r\left(\mathbf K^\mathsf T\right) = s, ~\mathbf m$ is a constant vector.
What's the effect of $(1) $ on the model? How should the estimator and the associated sum of squares look?
In oder to find the estimator of $\mathbf b,~\left(\tilde{\mathbf b}\right) $ subject to the constraint, one can employ Lagrange multiplier $(2\boldsymbol\lambda) $ in the minimisation of $$\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)^\mathsf T\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)+ 2\boldsymbol\lambda^\mathsf T\left(\mathbf K^\mathsf T\tilde{\mathbf b }-\mathbf m\right)\tag 2$$ w.r.t. $\tilde{\mathbf b}, ~\boldsymbol\lambda.$ Solving the equations
\begin{align}
\mathbf X^\mathsf T\mathbf X\tilde{\mathbf b} + \mathbf K\boldsymbol\lambda &= \mathbf X^\mathsf T\mathbf y\\ \mathbf K^\mathsf T\tilde{\mathbf b } &=\mathbf m,
\end{align}
yield
$$\tilde{\mathbf b }=\hat{\mathbf b }-(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\left[\mathbf K^\mathsf T(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\right]^{-1}\left(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m\right).\tag 3$$
What would be the residual sum of squares? Computing $\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)^\mathsf T\left(\mathbf y -\mathbf X\tilde{\mathbf b}\right)$ using the fact that $\mathbf X^\mathsf T(\mathbf y -\mathbf X\hat{\mathbf b})= 0 $ would lead to
\begin{align}&= \left[\mathbf y -\mathbf X\hat{\mathbf b}+ \mathbf X\left(\hat{\mathbf b}-\tilde{\mathbf b}\right)\right]^\mathsf T\left[\mathbf y -\mathbf X\hat{\mathbf b}+ \mathbf X\left(\hat{\mathbf b}-\tilde{\mathbf b}\right)\right]\\&= \left( \mathbf y -\mathbf X\hat{\mathbf b}\right) ^\mathsf T \left( \mathbf y -\mathbf X\hat{\mathbf b}\right)+ \left(\hat{\mathbf b}-\tilde{\mathbf b}\right)^\mathsf T\mathbf X^\mathsf T\mathbf X\left(\hat{\mathbf b}-\tilde{\mathbf b}\right)\\ &\stackrel{(3)}{=} \textrm{SSE} +\underbrace{(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)^\mathsf T\left[\mathbf K^\mathsf T(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\right]^{-1}(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)}_{:= Q};\tag 4 \end{align}
so
$$\textrm{residual(reduced)} = \textrm{residual(full)} + Q. \tag 5^2$$
What is the distribution of $ Q? $
Notice that $\hat{\mathbf b}~\sim\mathsf{MVN}\left(\mathbf b, (\mathbf X^\prime\mathbf X) ^{-1}\sigma^2\right)$ as $\mathbf y \sim \mathsf{MVN}(\mathbf X\mathbf b,\sigma^2\mathbf I).$ Therefore $$\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m\sim\mathsf{MVN}\left(\mathbf K^\mathsf T\mathbf b-\mathbf m,\mathbf K^\mathsf T (\mathbf X^\prime\mathbf X) ^{-1} \mathbf K
\sigma^2\right).\tag 6$$ $Q$ can be seen to be a quadratic in $\mathbf K^\mathsf T\hat{\mathbf b}-\mathbf m, $ with $\left[\mathbf K^\mathsf T (\mathbf X^\prime\mathbf X) ^{-1} \mathbf K\right]^{-1}$ as the matrix of the quadratic. Now is the crucial part: apply Theorem $\rm[I] $ here (what are $\bf A, V$ here?) using $(6) $ to conclude that $$\frac Q{\sigma^2}\sim{\chi^2}^\prime\left[s,\frac{(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)^\mathsf T\left[\mathbf K^\mathsf T(\mathbf X^\mathsf T\mathbf X)^{-1}\mathbf K\right]^{-1}(\mathbf K^\mathsf T\hat{\mathbf b }-\mathbf m)}{2\sigma^2}\right].\tag 7$$ This is the desired result in a general framework. For constructing the required $F$-statistic, it has to be deduced that $Q$ and $\textrm{SSE}$ are independent.
Notes:
$[1] $ To prove this, compute the MGF of the quadratic form and use the property of the eigenvalues of an idempotent matrix.
$[2]$ It is tempting, perhaps, to interpret $Q,$ writing it in the form \begin{align}Q &= \mathbf y^\mathsf T\mathbf y -\text{SSE} -\left[ \mathbf y^\mathsf T\mathbf y - (\text{SSE}+ Q) \right]\\&=\text{SSR}- \left[ \mathbf y^\mathsf T\mathbf y - (\text{SSE}+ Q) \right]\\ &= \textrm{reduction(full)} - \left[ \mathbf y^\mathsf T\mathbf y - (\text{SSE}+ Q) \right],\tag{N1} \end{align} as the "reduction in sum of squares due to fitting of the reduced model" along the line of $(5);$ but this is not true, in general. In fact, the term in parenthesis in $\rm(N1) $ need not be even a sum of squares.
Reference:
Linear Models, S. R. Searle, John Wiley & Sons., $1971.$
|
Intuition for $RSS_2 - RSS_1$ having chi-square distribution in F-test for linear models
Since, there is a sense of ambiguity as to how the 'difference' of residuals of the restricted and unrestricted models leads to the $F$-statistic, it is deemed to be apt enough to briefly sketch the d
|
41,813
|
Expectation of truncated distribution
|
There are many ways to analyze this. The methods shown in this answer are chosen for their usefulness and helpfulness in understanding expectations and conditional expectations. That is, it is hoped the journey to the result will be more interesting than the result itself.
Because "$\mid Y$" occurs everywhere, let's drop it from the notation as being superfluous. The question therefore concerns the relationship between the expectation $E[X]$ and the expectation of the truncated variable, $E[X\mid X\ge A].$
By defining $Z = X - A$ the question concerns the relation between $E[Z\mid Z \ge 0]$ and $E[Z].$
Writing $S_Z$ for the complementary distribution function of $Z,$ by definition $$S_Z(0) = \Pr(Z\ge 0) = \Pr(X\ge A)$$ and $$1-S_Z(0) = 1 - \Pr(Z \ge 0) = 1 - \Pr(X \ge A) = \Pr(X \lt A).$$
This takes us to the crux of the matter: observe that
$$E[Z \mid Z\lt 0] \le E[0 \mid Z \lt 0] = 0.$$
In other words, when $Z$ is restricted to negative values its expectation cannot exceed $0.$
Finally, notice that $S_Z(0) \le 1$ because $S_Z(0)$ is a probability.
All these observations are trivial. But we may combine them and exploit the linearity properties of expectation (first and last lines below) and the law of iterated expectations (second line) to deduce
$$\begin{aligned}
E[X]-A &= E[X-A] = E[Z] \\&= E[Z\mid Z \lt 0]\Pr(Z \lt 0) +E[Z\mid Z\ge 0]\Pr(Z \ge 0)\\
&= \color{red}{E[Z\mid Z \lt 0](1-S_Z(0)) + E[Z\mid Z\ge 0] S_Z(0)}\\
&\le 0(1-S_Z(0)) + E[Z\mid Z\ge 0]S_Z(0)\\
&= E[Z\mid Z\ge 0]S_Z(0)\\
&\le E[Z\mid Z\ge 0]\\
&= E[X-A\mid X \ge A]\\
&= E[X\mid X \ge A] - A.
\end{aligned}$$
(The expression in red on the third line is particularly memorable and useful: it says the expectation of any random variable $Z$ is a weighted average of the conditional expectations that it is positive and non-positive.)
Upon adding $A$ to both sides the inequality is preserved, becoming
$$E[X] \le E[X\mid X \ge A].$$
By definition, the support of $X$ is the smallest closed set of real numbers $\mathcal{D}_X$ for which $\Pr(X\in \mathcal{D}_X)=1.$ When the support has a lower bound and $A$ is less than or equal to this lower bound, $\Pr(X \ge A)=1$ and so (since $S_Z(0)=1$) the previous inequality becomes an equality. But otherwise--again by the very definition of support--when $A$ exceeds the greatest lower bound of the support, $\Pr(X \ge A)\lt 1$ and the previous inequality is strict.
This analysis can be summarized in these terms as
The conditional expectation of $X$ given $X\ge A$ strictly exceeds the expectation of $X$ when $A$ exceeds all lower bounds of the support of $X.$ Otherwise, the conditional expectation and expectation are equal.
|
Expectation of truncated distribution
|
There are many ways to analyze this. The methods shown in this answer are chosen for their usefulness and helpfulness in understanding expectations and conditional expectations. That is, it is hoped
|
Expectation of truncated distribution
There are many ways to analyze this. The methods shown in this answer are chosen for their usefulness and helpfulness in understanding expectations and conditional expectations. That is, it is hoped the journey to the result will be more interesting than the result itself.
Because "$\mid Y$" occurs everywhere, let's drop it from the notation as being superfluous. The question therefore concerns the relationship between the expectation $E[X]$ and the expectation of the truncated variable, $E[X\mid X\ge A].$
By defining $Z = X - A$ the question concerns the relation between $E[Z\mid Z \ge 0]$ and $E[Z].$
Writing $S_Z$ for the complementary distribution function of $Z,$ by definition $$S_Z(0) = \Pr(Z\ge 0) = \Pr(X\ge A)$$ and $$1-S_Z(0) = 1 - \Pr(Z \ge 0) = 1 - \Pr(X \ge A) = \Pr(X \lt A).$$
This takes us to the crux of the matter: observe that
$$E[Z \mid Z\lt 0] \le E[0 \mid Z \lt 0] = 0.$$
In other words, when $Z$ is restricted to negative values its expectation cannot exceed $0.$
Finally, notice that $S_Z(0) \le 1$ because $S_Z(0)$ is a probability.
All these observations are trivial. But we may combine them and exploit the linearity properties of expectation (first and last lines below) and the law of iterated expectations (second line) to deduce
$$\begin{aligned}
E[X]-A &= E[X-A] = E[Z] \\&= E[Z\mid Z \lt 0]\Pr(Z \lt 0) +E[Z\mid Z\ge 0]\Pr(Z \ge 0)\\
&= \color{red}{E[Z\mid Z \lt 0](1-S_Z(0)) + E[Z\mid Z\ge 0] S_Z(0)}\\
&\le 0(1-S_Z(0)) + E[Z\mid Z\ge 0]S_Z(0)\\
&= E[Z\mid Z\ge 0]S_Z(0)\\
&\le E[Z\mid Z\ge 0]\\
&= E[X-A\mid X \ge A]\\
&= E[X\mid X \ge A] - A.
\end{aligned}$$
(The expression in red on the third line is particularly memorable and useful: it says the expectation of any random variable $Z$ is a weighted average of the conditional expectations that it is positive and non-positive.)
Upon adding $A$ to both sides the inequality is preserved, becoming
$$E[X] \le E[X\mid X \ge A].$$
By definition, the support of $X$ is the smallest closed set of real numbers $\mathcal{D}_X$ for which $\Pr(X\in \mathcal{D}_X)=1.$ When the support has a lower bound and $A$ is less than or equal to this lower bound, $\Pr(X \ge A)=1$ and so (since $S_Z(0)=1$) the previous inequality becomes an equality. But otherwise--again by the very definition of support--when $A$ exceeds the greatest lower bound of the support, $\Pr(X \ge A)\lt 1$ and the previous inequality is strict.
This analysis can be summarized in these terms as
The conditional expectation of $X$ given $X\ge A$ strictly exceeds the expectation of $X$ when $A$ exceeds all lower bounds of the support of $X.$ Otherwise, the conditional expectation and expectation are equal.
|
Expectation of truncated distribution
There are many ways to analyze this. The methods shown in this answer are chosen for their usefulness and helpfulness in understanding expectations and conditional expectations. That is, it is hoped
|
41,814
|
Expectation of truncated distribution
|
Using the law of total probability and $E_{p(x|x<a, y)} \leq a \leq E_{p(x|x\geq a, y)}$, we have
\begin{align*}
E_{p(x|y)}x
&= p(x\geq a) E_{p(x|x\geq a, y)}x + p(x<a) E_{p(x|x<a, y)}x
\\&\leq p(x\geq a) E_{p(x|x\geq a, y)}x + p(x<a) E_{p(x|x\geq a, y)}x
\\&= (p(x\geq a)+p(x<a)) E_{p(x|x\geq a, y)}x
\\&= E_{p(x|x\geq a, y)}x.
\end{align*}
The assumption $E_{p(x|y)}x = 0$ is not needed for this result, but it implies $E_{p(x|x\geq a, y)}x \geq 0$.
|
Expectation of truncated distribution
|
Using the law of total probability and $E_{p(x|x<a, y)} \leq a \leq E_{p(x|x\geq a, y)}$, we have
\begin{align*}
E_{p(x|y)}x
&= p(x\geq a) E_{p(x|x\geq a, y)}x + p(x<a) E_{p(x|x<a, y)}x
\\&\leq p(x\ge
|
Expectation of truncated distribution
Using the law of total probability and $E_{p(x|x<a, y)} \leq a \leq E_{p(x|x\geq a, y)}$, we have
\begin{align*}
E_{p(x|y)}x
&= p(x\geq a) E_{p(x|x\geq a, y)}x + p(x<a) E_{p(x|x<a, y)}x
\\&\leq p(x\geq a) E_{p(x|x\geq a, y)}x + p(x<a) E_{p(x|x\geq a, y)}x
\\&= (p(x\geq a)+p(x<a)) E_{p(x|x\geq a, y)}x
\\&= E_{p(x|x\geq a, y)}x.
\end{align*}
The assumption $E_{p(x|y)}x = 0$ is not needed for this result, but it implies $E_{p(x|x\geq a, y)}x \geq 0$.
|
Expectation of truncated distribution
Using the law of total probability and $E_{p(x|x<a, y)} \leq a \leq E_{p(x|x\geq a, y)}$, we have
\begin{align*}
E_{p(x|y)}x
&= p(x\geq a) E_{p(x|x\geq a, y)}x + p(x<a) E_{p(x|x<a, y)}x
\\&\leq p(x\ge
|
41,815
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in the same direction
|
Here's a very restrictive sufficient condition: both the prior and likelihood are normal.
If the likelihood is normal with known variance $\sigma^2$, and the prior is normal, then the posterior is normal. Say the likelihood is normal centred on $z$ with variance $\sigma^2$, and the prior has mean $\mu_0$ and variance $\sigma_0^2$, then the posterior has mean $\Big(\frac{1}{\sigma_0^2}+\frac{1}{\sigma^2}\Big)^{-1}\Big(\frac{\mu_0}{\sigma_0^2}+\frac{z}{\sigma^2}\Big)$, which is strictly increasing in $z$.
If this is too restrictive, you could consider other conjugate priors: https://en.wikipedia.org/wiki/Conjugate_prior.
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in t
|
Here's a very restrictive sufficient condition: both the prior and likelihood are normal.
If the likelihood is normal with known variance $\sigma^2$, and the prior is normal, then the posterior is nor
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in the same direction
Here's a very restrictive sufficient condition: both the prior and likelihood are normal.
If the likelihood is normal with known variance $\sigma^2$, and the prior is normal, then the posterior is normal. Say the likelihood is normal centred on $z$ with variance $\sigma^2$, and the prior has mean $\mu_0$ and variance $\sigma_0^2$, then the posterior has mean $\Big(\frac{1}{\sigma_0^2}+\frac{1}{\sigma^2}\Big)^{-1}\Big(\frac{\mu_0}{\sigma_0^2}+\frac{z}{\sigma^2}\Big)$, which is strictly increasing in $z$.
If this is too restrictive, you could consider other conjugate priors: https://en.wikipedia.org/wiki/Conjugate_prior.
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in t
Here's a very restrictive sufficient condition: both the prior and likelihood are normal.
If the likelihood is normal with known variance $\sigma^2$, and the prior is normal, then the posterior is nor
|
41,816
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in the same direction
|
It works for all priors in the case that $ \mathcal L $ is normal. The key property is that $ \mathcal L'(\theta) = -\theta \mathcal L(\theta) $.
To see this, start with expressing the expectation under the two hypotheses as
$$ \mathbb E[\theta \mid D] = \frac{\mathbb E[\theta \mathcal L_D(\theta)]}{\mathbb E[\mathcal L_D(\theta)]}, \, \, \mathbb E[\theta \mid D'] = \frac{\mathbb E[\theta \mathcal L_{D'}(\theta)]}{\mathbb E[\mathcal L_{D'}(\theta)]}, $$
where the expectations are taken over the prior distribution $ \mathbb P(\theta) $. Denote $ \mathcal L_D(\theta) = L(\theta) $ so that $ \mathcal L_{D'}(\theta) = L(\theta - x) $. Then what we have to show is that
$$ \frac{\mathbb E[\theta L(\theta)]}{\mathbb E[L(\theta)]} \leq \frac{\mathbb E[\theta L(\theta-x)]}{\mathbb E[L(\theta-x)]} = g(x) $$
or equivalently that the function $ g $ on the right hand side is increasing when seen as a function of $ x $. Differentiating with respect to $ x $ is fine because $ L $ and its derivatives decay very fast at infinity and the prior $ \mathbb P(\theta) $ is $ L^1 $ since it's a probability density. We get
$$ g'(x) = \frac{ -\mathbb E[\theta L'(\theta - x)] \mathbb E[L(\theta - x)] + \mathbb E[\theta L(\theta - x)] \mathbb E[L'(\theta - x)]}{\mathbb E[L(\theta - x)]^2} $$
and we want to show $ g' $ is always greater than or equal to zero.
Now we use the fact that $ L'(\theta) = -\theta L(\theta) $ - any positive proportional constant here is also fine, of course. Substituting directly to the numerator gives
$$ \frac{\mathbb E[\theta (\theta - x) L(\theta - x)]}{\mathbb E[L(\theta - x)]} - \frac{\mathbb E[\theta L(\theta - x)]}{\mathbb E[L(\theta - x)]} \frac{\mathbb E[(\theta - x) L(\theta - x)]}{\mathbb E[L(\theta - x)]} $$
The positivity of this expression is simply the Cauchy-Schwarz inequality for the probability measure on $ \theta $ whose density is
$$ \frac{\mathbb P(\theta) L(\theta - x)}{\int_{\mathbb R} \mathbb P(\theta) L(\theta - x)\, d \theta} $$
so we're done.
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in t
|
It works for all priors in the case that $ \mathcal L $ is normal. The key property is that $ \mathcal L'(\theta) = -\theta \mathcal L(\theta) $.
To see this, start with expressing the expectation und
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in the same direction
It works for all priors in the case that $ \mathcal L $ is normal. The key property is that $ \mathcal L'(\theta) = -\theta \mathcal L(\theta) $.
To see this, start with expressing the expectation under the two hypotheses as
$$ \mathbb E[\theta \mid D] = \frac{\mathbb E[\theta \mathcal L_D(\theta)]}{\mathbb E[\mathcal L_D(\theta)]}, \, \, \mathbb E[\theta \mid D'] = \frac{\mathbb E[\theta \mathcal L_{D'}(\theta)]}{\mathbb E[\mathcal L_{D'}(\theta)]}, $$
where the expectations are taken over the prior distribution $ \mathbb P(\theta) $. Denote $ \mathcal L_D(\theta) = L(\theta) $ so that $ \mathcal L_{D'}(\theta) = L(\theta - x) $. Then what we have to show is that
$$ \frac{\mathbb E[\theta L(\theta)]}{\mathbb E[L(\theta)]} \leq \frac{\mathbb E[\theta L(\theta-x)]}{\mathbb E[L(\theta-x)]} = g(x) $$
or equivalently that the function $ g $ on the right hand side is increasing when seen as a function of $ x $. Differentiating with respect to $ x $ is fine because $ L $ and its derivatives decay very fast at infinity and the prior $ \mathbb P(\theta) $ is $ L^1 $ since it's a probability density. We get
$$ g'(x) = \frac{ -\mathbb E[\theta L'(\theta - x)] \mathbb E[L(\theta - x)] + \mathbb E[\theta L(\theta - x)] \mathbb E[L'(\theta - x)]}{\mathbb E[L(\theta - x)]^2} $$
and we want to show $ g' $ is always greater than or equal to zero.
Now we use the fact that $ L'(\theta) = -\theta L(\theta) $ - any positive proportional constant here is also fine, of course. Substituting directly to the numerator gives
$$ \frac{\mathbb E[\theta (\theta - x) L(\theta - x)]}{\mathbb E[L(\theta - x)]} - \frac{\mathbb E[\theta L(\theta - x)]}{\mathbb E[L(\theta - x)]} \frac{\mathbb E[(\theta - x) L(\theta - x)]}{\mathbb E[L(\theta - x)]} $$
The positivity of this expression is simply the Cauchy-Schwarz inequality for the probability measure on $ \theta $ whose density is
$$ \frac{\mathbb P(\theta) L(\theta - x)}{\int_{\mathbb R} \mathbb P(\theta) L(\theta - x)\, d \theta} $$
so we're done.
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in t
It works for all priors in the case that $ \mathcal L $ is normal. The key property is that $ \mathcal L'(\theta) = -\theta \mathcal L(\theta) $.
To see this, start with expressing the expectation und
|
41,817
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in the same direction
|
Thanks to everyone who contributed. Here are some results I've been able to find in the literature.
The strongest result is that the property holds for any prior when the likelihood function arises from a strongly unimodally distributed observation.
Andrews et al. 1972 (Biometrika, Vol. 59, No. 3 (Dec., 1972), pp. 693-695) use the same approach as Ege Erdil:
Ma 1997 (Statistics & Probability Letters 42 (1999) 33-37) generalises this to any likelihood function arising from an observation whose distribution has $\Theta$ as a location parameter and is strongly unimodally distributed. After noting that "a non-degenerate distribution $F$ is strongly unimodal if and only if it has a density $f$ that is log-concave within some open interval", he proves:
Here is the link to Mitchell 1994 (J. R. Statist. Soc. B (1994) 56, No.4, pp. 605-610).
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in t
|
Thanks to everyone who contributed. Here are some results I've been able to find in the literature.
The strongest result is that the property holds for any prior when the likelihood function arises fr
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in the same direction
Thanks to everyone who contributed. Here are some results I've been able to find in the literature.
The strongest result is that the property holds for any prior when the likelihood function arises from a strongly unimodally distributed observation.
Andrews et al. 1972 (Biometrika, Vol. 59, No. 3 (Dec., 1972), pp. 693-695) use the same approach as Ege Erdil:
Ma 1997 (Statistics & Probability Letters 42 (1999) 33-37) generalises this to any likelihood function arising from an observation whose distribution has $\Theta$ as a location parameter and is strongly unimodally distributed. After noting that "a non-degenerate distribution $F$ is strongly unimodal if and only if it has a density $f$ that is log-concave within some open interval", he proves:
Here is the link to Mitchell 1994 (J. R. Statist. Soc. B (1994) 56, No.4, pp. 605-610).
|
Sufficient condition for when a shifted likelihood function shifts the posterior expected value in t
Thanks to everyone who contributed. Here are some results I've been able to find in the literature.
The strongest result is that the property holds for any prior when the likelihood function arises fr
|
41,818
|
Inferring Causal Direction
|
Causal direction, or causal discovery from data is a large research topic. Causal Discovery Algorithms notebook of Cosma Shalizi given a nice list of approaches. However, one has to distinguish, structure discovery i.e., causal graphs as a separate task than only discovering directions.
A nice overview of, Answering causal questions using observational data, Memorial Nobel prize of 2021, see here.
|
Inferring Causal Direction
|
Causal direction, or causal discovery from data is a large research topic. Causal Discovery Algorithms notebook of Cosma Shalizi given a nice list of approaches. However, one has to distinguish, stru
|
Inferring Causal Direction
Causal direction, or causal discovery from data is a large research topic. Causal Discovery Algorithms notebook of Cosma Shalizi given a nice list of approaches. However, one has to distinguish, structure discovery i.e., causal graphs as a separate task than only discovering directions.
A nice overview of, Answering causal questions using observational data, Memorial Nobel prize of 2021, see here.
|
Inferring Causal Direction
Causal direction, or causal discovery from data is a large research topic. Causal Discovery Algorithms notebook of Cosma Shalizi given a nice list of approaches. However, one has to distinguish, stru
|
41,819
|
Inferring Causal Direction
|
It's tricky to answer this question because you'd have to be much clearer on what you mean by I am already convinced that there is a causal relationship between the two, but let's assume God came down to earth and told you that there is a causal relationship between A and B. In this case, because it's time-series data, if it's possible to identify which one happens before the other, we can say that the one who happened earlier caused the other, since cause always preceding effect in time is a fairly accepted assumption.
However, according to your description, it's possible that you can not identify which one happened first. Granger causality won't help you here, since it's not even able to identify a causal relationship. The causality in its name is pretty unfortunate, according to Granger himself.
Jonas Peters has done some work on this topic and I think a good reading for you is this paper of his: Detecting the direction of causal time series. They fit an autoregressive moving average model and investigate noise to identify ordering of the causal relationship.
|
Inferring Causal Direction
|
It's tricky to answer this question because you'd have to be much clearer on what you mean by I am already convinced that there is a causal relationship between the two, but let's assume God came down
|
Inferring Causal Direction
It's tricky to answer this question because you'd have to be much clearer on what you mean by I am already convinced that there is a causal relationship between the two, but let's assume God came down to earth and told you that there is a causal relationship between A and B. In this case, because it's time-series data, if it's possible to identify which one happens before the other, we can say that the one who happened earlier caused the other, since cause always preceding effect in time is a fairly accepted assumption.
However, according to your description, it's possible that you can not identify which one happened first. Granger causality won't help you here, since it's not even able to identify a causal relationship. The causality in its name is pretty unfortunate, according to Granger himself.
Jonas Peters has done some work on this topic and I think a good reading for you is this paper of his: Detecting the direction of causal time series. They fit an autoregressive moving average model and investigate noise to identify ordering of the causal relationship.
|
Inferring Causal Direction
It's tricky to answer this question because you'd have to be much clearer on what you mean by I am already convinced that there is a causal relationship between the two, but let's assume God came down
|
41,820
|
Inferring Causal Direction
|
Up front, please node that you always have to consider the possibility of latent confounders. Those lead to two random variables being stochastically dependent without causal dependency. They are not measured (that's why they are called latent or sometimes hidden), but are almost always present and usually screw up your data. So if you cannot rule out latent confounders, you have to use methods that allow for latent confounding. It is well known (and has already been known by Granger himself), that, unfortunately, Granger causality cannot deal with this confounding.
Next, some consideration about the data (I will stick to the case of two timeseries, but the methods below also work for more than two timeseries):
If you want to distinguish between the causal influences on $Y$ from the older parts of sequence $X$ compared to the influences on $Y$ from the newer parts of sequence $X$, and maybe the other way around, you would have to consider a timeseries (of data that is aggregated as you described). Otherwise, if you don't care about the difference between older and newer influence, I would just suggest to consider two random variables, $X$ and $Y$, aggregate each of those over intervals $I_i$ (they can be larger than in the timeseries case) ($agg_i(X)$ and $agg_i(Y)$) leading to data pairs $(agg_i(X), agg_i(Y))$ of some new random variables $\cal{X}$ and $\cal{Y}$. And now we would like to know the causal relationship between $\cal{X}$ and $\cal{Y}$.
Note, that especially in the case that you have described, we have to accept the possibility of cyclic causality, i.e. $\cal{X}$ causes $\cal{Y}$ and $\cal{Y}$ causes $\cal{X}$:
$$
\cal{X} \rightleftarrows \cal{Y}.
$$
Figuring out the edges and the arrow heads in causal graphs is sometimes called causal discovery. Causal discovery can be done either by changing the experiment that creates the data in well designed ways (interventions) or by just analysing the provided data.
Of course, the former leads to much better results, but is often not feasible. So lots of research has been and is going into causal discovery just from observational data, i.e. data that has been provided to you without you being able to dictate the design of the experiments.
I presume that you want to know about causal dicovery which in particular is not excluding the cyclic case and the presence of latent confounders. Fortunately, there are quite a number of (relatively new) papers that deal with this problem and even provide ready to use implementations. I cite the most important ones:
Hyttinen, Antti, Frederick Eberhardt, and Patrik O. Hoyer. "Learning linear cyclic causal models with latent variables." The Journal of Machine Learning Research 13.1 (2012): 3387-3439.
Forré, Patrick, and Joris M. Mooij. "Constraint-based causal discovery for non-linear structural causal models with cycles and latent confounders." arXiv preprint arXiv:1807.03024 (2018).
Rantanen, Kari, Antti Hyttinen, and Matti Järvisalo. "Learning Optimal Cyclic Causal Graphs from Interventional Data." International Conference on Probabilistic Graphical Models. PMLR, 2020.
Mooij, Joris M., and Tom Claassen. "Constraint-based causal discovery using partial ancestral graphs in the presence of cycles." Conference on Uncertainty in Artificial Intelligence. PMLR, 2020.
As I said, they all come with impelmentations. They all can deal with cyclic graphs and hidden confounders. The first one (Hyttinen et al.) is for the linear case, the others also cover the nonlinear situation. The second (Forre and Mooij) as well as the third (Rantanen and Hyttinen) give you exact results (mathematically proven correct, in a certain sense), but they don't scale well; you won't be able to analyse networks with more than eight or nine nodes. The first (Hyttinen et al.) and the fourth (Mooij and Claassen) scale better (about 50 and sometimes even 100 and more nodes), but are "not as correct" as the other two.
Those algorithms, if you don't provide them with additional interventional data, can only discover parts of the causal graph, not much more beyond the sceleton of the graph (that is just the edges without the arrow heads). For those, there are further possibilities. E.g., if you are willing to presume that your noise is additive, i.e. you have an ANM (Additive Noise Model), you should read the very cool paper:
Hoyer, Patrik, et al. "Nonlinear causal discovery with additive noise models." Advances in neural information processing systems 21 (2008).
This paper as well as many newer papers that cite this one give you an idea of how to proceed with directing your edges.
|
Inferring Causal Direction
|
Up front, please node that you always have to consider the possibility of latent confounders. Those lead to two random variables being stochastically dependent without causal dependency. They are not
|
Inferring Causal Direction
Up front, please node that you always have to consider the possibility of latent confounders. Those lead to two random variables being stochastically dependent without causal dependency. They are not measured (that's why they are called latent or sometimes hidden), but are almost always present and usually screw up your data. So if you cannot rule out latent confounders, you have to use methods that allow for latent confounding. It is well known (and has already been known by Granger himself), that, unfortunately, Granger causality cannot deal with this confounding.
Next, some consideration about the data (I will stick to the case of two timeseries, but the methods below also work for more than two timeseries):
If you want to distinguish between the causal influences on $Y$ from the older parts of sequence $X$ compared to the influences on $Y$ from the newer parts of sequence $X$, and maybe the other way around, you would have to consider a timeseries (of data that is aggregated as you described). Otherwise, if you don't care about the difference between older and newer influence, I would just suggest to consider two random variables, $X$ and $Y$, aggregate each of those over intervals $I_i$ (they can be larger than in the timeseries case) ($agg_i(X)$ and $agg_i(Y)$) leading to data pairs $(agg_i(X), agg_i(Y))$ of some new random variables $\cal{X}$ and $\cal{Y}$. And now we would like to know the causal relationship between $\cal{X}$ and $\cal{Y}$.
Note, that especially in the case that you have described, we have to accept the possibility of cyclic causality, i.e. $\cal{X}$ causes $\cal{Y}$ and $\cal{Y}$ causes $\cal{X}$:
$$
\cal{X} \rightleftarrows \cal{Y}.
$$
Figuring out the edges and the arrow heads in causal graphs is sometimes called causal discovery. Causal discovery can be done either by changing the experiment that creates the data in well designed ways (interventions) or by just analysing the provided data.
Of course, the former leads to much better results, but is often not feasible. So lots of research has been and is going into causal discovery just from observational data, i.e. data that has been provided to you without you being able to dictate the design of the experiments.
I presume that you want to know about causal dicovery which in particular is not excluding the cyclic case and the presence of latent confounders. Fortunately, there are quite a number of (relatively new) papers that deal with this problem and even provide ready to use implementations. I cite the most important ones:
Hyttinen, Antti, Frederick Eberhardt, and Patrik O. Hoyer. "Learning linear cyclic causal models with latent variables." The Journal of Machine Learning Research 13.1 (2012): 3387-3439.
Forré, Patrick, and Joris M. Mooij. "Constraint-based causal discovery for non-linear structural causal models with cycles and latent confounders." arXiv preprint arXiv:1807.03024 (2018).
Rantanen, Kari, Antti Hyttinen, and Matti Järvisalo. "Learning Optimal Cyclic Causal Graphs from Interventional Data." International Conference on Probabilistic Graphical Models. PMLR, 2020.
Mooij, Joris M., and Tom Claassen. "Constraint-based causal discovery using partial ancestral graphs in the presence of cycles." Conference on Uncertainty in Artificial Intelligence. PMLR, 2020.
As I said, they all come with impelmentations. They all can deal with cyclic graphs and hidden confounders. The first one (Hyttinen et al.) is for the linear case, the others also cover the nonlinear situation. The second (Forre and Mooij) as well as the third (Rantanen and Hyttinen) give you exact results (mathematically proven correct, in a certain sense), but they don't scale well; you won't be able to analyse networks with more than eight or nine nodes. The first (Hyttinen et al.) and the fourth (Mooij and Claassen) scale better (about 50 and sometimes even 100 and more nodes), but are "not as correct" as the other two.
Those algorithms, if you don't provide them with additional interventional data, can only discover parts of the causal graph, not much more beyond the sceleton of the graph (that is just the edges without the arrow heads). For those, there are further possibilities. E.g., if you are willing to presume that your noise is additive, i.e. you have an ANM (Additive Noise Model), you should read the very cool paper:
Hoyer, Patrik, et al. "Nonlinear causal discovery with additive noise models." Advances in neural information processing systems 21 (2008).
This paper as well as many newer papers that cite this one give you an idea of how to proceed with directing your edges.
|
Inferring Causal Direction
Up front, please node that you always have to consider the possibility of latent confounders. Those lead to two random variables being stochastically dependent without causal dependency. They are not
|
41,821
|
Why do we need identification in causal inference?
|
In causal inference you can think about identifiability as the condition that permit to measure causal quantity from observed data. Among parametric models is the condition that permit to estimate causal parameters from regressional. Formally
$E[Y|do(X)] = E[Y|X] $
Can be consider as identifiability condition.
Identifiability condition is one key point of any causal model. In general if you do not have enough assumptions and/or data identification is not possible.
For examples about it read here:
In Berkson's paradox, is $\beta_1 = 0$ or $\ne 0$?
Infer one link of a causal structure, from observations
|
Why do we need identification in causal inference?
|
In causal inference you can think about identifiability as the condition that permit to measure causal quantity from observed data. Among parametric models is the condition that permit to estimate cau
|
Why do we need identification in causal inference?
In causal inference you can think about identifiability as the condition that permit to measure causal quantity from observed data. Among parametric models is the condition that permit to estimate causal parameters from regressional. Formally
$E[Y|do(X)] = E[Y|X] $
Can be consider as identifiability condition.
Identifiability condition is one key point of any causal model. In general if you do not have enough assumptions and/or data identification is not possible.
For examples about it read here:
In Berkson's paradox, is $\beta_1 = 0$ or $\ne 0$?
Infer one link of a causal structure, from observations
|
Why do we need identification in causal inference?
In causal inference you can think about identifiability as the condition that permit to measure causal quantity from observed data. Among parametric models is the condition that permit to estimate cau
|
41,822
|
Why do we need identification in causal inference?
|
Let's say you have a Treatment variable, an Outcome variable and numerous other variables. One could do a regression of one on the other, adjusting by everything else, but we're smarter than this, right? How do we know this measures the direct relationship between treatment and outcome? Maybe we're not adjusting for an important confounder. Maybe we're adjusting for a collider and worsening our estimate, instead of what we really want.
The causal identification step is important to see if it's possible to estimate the effect of Treatment on Outcome. And if it is, how we can do so (backdoor adjustment, frontdoor adjustment, and so on). Sometimes it is not identifiable, and there is nothing we can do :|. Once the identification step is done, you can estimate the causal effect.
|
Why do we need identification in causal inference?
|
Let's say you have a Treatment variable, an Outcome variable and numerous other variables. One could do a regression of one on the other, adjusting by everything else, but we're smarter than this, rig
|
Why do we need identification in causal inference?
Let's say you have a Treatment variable, an Outcome variable and numerous other variables. One could do a regression of one on the other, adjusting by everything else, but we're smarter than this, right? How do we know this measures the direct relationship between treatment and outcome? Maybe we're not adjusting for an important confounder. Maybe we're adjusting for a collider and worsening our estimate, instead of what we really want.
The causal identification step is important to see if it's possible to estimate the effect of Treatment on Outcome. And if it is, how we can do so (backdoor adjustment, frontdoor adjustment, and so on). Sometimes it is not identifiable, and there is nothing we can do :|. Once the identification step is done, you can estimate the causal effect.
|
Why do we need identification in causal inference?
Let's say you have a Treatment variable, an Outcome variable and numerous other variables. One could do a regression of one on the other, adjusting by everything else, but we're smarter than this, rig
|
41,823
|
Why do we need identification in causal inference?
|
This is my understanding. Correct me if I am wrong.
Suppose I am conducting a randomized clinical trial to investigate the difference in means between two treatments, A and B. If I randomize everyone to treatment B with probability 1 then the population mean for treatment A and the difference in means are both unidentifiable. There is no data available to estimate these population quantities.
Suppose I randomize subjects to treatment B with probability 1/2 and during the course of the trial some subjects switch to other therapies. The causal treatment effect (difference in population means between treatment A and B) in the envisioned scenario where post baseline treatment switching does not occur is unidentifiable using the observed data.
In both examples I could use an unverifiable missing data assumption that does make the population treatment effect identifiable.
|
Why do we need identification in causal inference?
|
This is my understanding. Correct me if I am wrong.
Suppose I am conducting a randomized clinical trial to investigate the difference in means between two treatments, A and B. If I randomize everyon
|
Why do we need identification in causal inference?
This is my understanding. Correct me if I am wrong.
Suppose I am conducting a randomized clinical trial to investigate the difference in means between two treatments, A and B. If I randomize everyone to treatment B with probability 1 then the population mean for treatment A and the difference in means are both unidentifiable. There is no data available to estimate these population quantities.
Suppose I randomize subjects to treatment B with probability 1/2 and during the course of the trial some subjects switch to other therapies. The causal treatment effect (difference in population means between treatment A and B) in the envisioned scenario where post baseline treatment switching does not occur is unidentifiable using the observed data.
In both examples I could use an unverifiable missing data assumption that does make the population treatment effect identifiable.
|
Why do we need identification in causal inference?
This is my understanding. Correct me if I am wrong.
Suppose I am conducting a randomized clinical trial to investigate the difference in means between two treatments, A and B. If I randomize everyon
|
41,824
|
What is the role of 'shuffle' in train_test_split()?
|
With time-series data, where you can expect auto-correlation in the data you should not split the data randomly to train and test set, but you should rather split it on time so you train on past values to predict future. Scikit-learn has the TimeSeriesSplit functionality for this.
The shuffle parameter is needed to prevent non-random assignment to to train and test set. With shuffle=True you split the data randomly. For example, say that you have balanced binary classification data and it is ordered by labels. If you split it in 80:20 proportions to train and test, your test data would contain only the labels from one class. Random shuffling prevents this.
If random shuffling would break your data, this is a good argument for not splitting randomly to train and test. In such cases, you would use splits on time, or clustered splits (say you have data on education, so you sample whole schools to train and test, rather than individual students).
When should you use shuffle=False? TL;DR never.
Your data was randomly sampled or was already shuffled. But shuffling one more time wouldn't hurt you. I remember seeing multiple datasets that were supposed to be randomly shuffled but weren't.
Your dataset is huge, so shuffling makes the whole pipeline a little bit slower. If that is the case, you probably don't want to use scikit-learn pipelines for preprocessing as well. If you use instead something else that scales better, still you need to make sure that it shuffles the data.
You don't want to split randomly and your data is already arranged in the way how you want to split it, for example, you have data collected during the 2010-2020 period and you want to split in 80:20 proportions with years 2010-2018 in train set and 2019-2020 in test set. Here it makes sense, but you would probably would like to use the TimeSeriesSplit functionality instead or write the code by hand to have greater control on what you are doing. For example, if you want to split by years, you probably don't want by accident few days of one year to land in other set than the rest of the year--so you would rather do the split manually.
|
What is the role of 'shuffle' in train_test_split()?
|
With time-series data, where you can expect auto-correlation in the data you should not split the data randomly to train and test set, but you should rather split it on time so you train on past value
|
What is the role of 'shuffle' in train_test_split()?
With time-series data, where you can expect auto-correlation in the data you should not split the data randomly to train and test set, but you should rather split it on time so you train on past values to predict future. Scikit-learn has the TimeSeriesSplit functionality for this.
The shuffle parameter is needed to prevent non-random assignment to to train and test set. With shuffle=True you split the data randomly. For example, say that you have balanced binary classification data and it is ordered by labels. If you split it in 80:20 proportions to train and test, your test data would contain only the labels from one class. Random shuffling prevents this.
If random shuffling would break your data, this is a good argument for not splitting randomly to train and test. In such cases, you would use splits on time, or clustered splits (say you have data on education, so you sample whole schools to train and test, rather than individual students).
When should you use shuffle=False? TL;DR never.
Your data was randomly sampled or was already shuffled. But shuffling one more time wouldn't hurt you. I remember seeing multiple datasets that were supposed to be randomly shuffled but weren't.
Your dataset is huge, so shuffling makes the whole pipeline a little bit slower. If that is the case, you probably don't want to use scikit-learn pipelines for preprocessing as well. If you use instead something else that scales better, still you need to make sure that it shuffles the data.
You don't want to split randomly and your data is already arranged in the way how you want to split it, for example, you have data collected during the 2010-2020 period and you want to split in 80:20 proportions with years 2010-2018 in train set and 2019-2020 in test set. Here it makes sense, but you would probably would like to use the TimeSeriesSplit functionality instead or write the code by hand to have greater control on what you are doing. For example, if you want to split by years, you probably don't want by accident few days of one year to land in other set than the rest of the year--so you would rather do the split manually.
|
What is the role of 'shuffle' in train_test_split()?
With time-series data, where you can expect auto-correlation in the data you should not split the data randomly to train and test set, but you should rather split it on time so you train on past value
|
41,825
|
What is the role of 'shuffle' in train_test_split()?
|
Omitting shuffle on a time-sorted DataFrame would lead to a time-based bias where similar periods are in the same dataset. By toggling shuffle=True you make sure that that the data is mixed prior to creation of test/train datasets.
|
What is the role of 'shuffle' in train_test_split()?
|
Omitting shuffle on a time-sorted DataFrame would lead to a time-based bias where similar periods are in the same dataset. By toggling shuffle=True you make sure that that the data is mixed prior to c
|
What is the role of 'shuffle' in train_test_split()?
Omitting shuffle on a time-sorted DataFrame would lead to a time-based bias where similar periods are in the same dataset. By toggling shuffle=True you make sure that that the data is mixed prior to creation of test/train datasets.
|
What is the role of 'shuffle' in train_test_split()?
Omitting shuffle on a time-sorted DataFrame would lead to a time-based bias where similar periods are in the same dataset. By toggling shuffle=True you make sure that that the data is mixed prior to c
|
41,826
|
Intutition of why Bootstrap aggregating reduces overfitting?
|
This is a phenomenon so called weak learners (see) in an ensemble decision yields a good performance. The reason of this explained by Dietterich here:
Uncorrelated errors made by the
individual classifiers can be
removed by voting.
Further explanation or theoretical justification of the statement could be an open research problem.
|
Intutition of why Bootstrap aggregating reduces overfitting?
|
This is a phenomenon so called weak learners (see) in an ensemble decision yields a good performance. The reason of this explained by Dietterich here:
Uncorrelated errors made by the
individual class
|
Intutition of why Bootstrap aggregating reduces overfitting?
This is a phenomenon so called weak learners (see) in an ensemble decision yields a good performance. The reason of this explained by Dietterich here:
Uncorrelated errors made by the
individual classifiers can be
removed by voting.
Further explanation or theoretical justification of the statement could be an open research problem.
|
Intutition of why Bootstrap aggregating reduces overfitting?
This is a phenomenon so called weak learners (see) in an ensemble decision yields a good performance. The reason of this explained by Dietterich here:
Uncorrelated errors made by the
individual class
|
41,827
|
Intutition of why Bootstrap aggregating reduces overfitting?
|
In order to illustrate why averaging reduce the standard deviation and make prediction more accurate i'll give an example.
Let's suppose that we have two models. The predictions are random variables $X_1 \sim N(\mu, \sigma), X_2 \sim N(\mu, \sigma)$
i.e. the prediction has a mean value plus an error term.
Considering that the errors are uncorrelated the average is:
$\frac{X_1 + X_2}{2}$ which is also normally distributed with average of $\mu$ and standard deviation of $\frac{2\sigma}{4} = \frac{\sigma}{2}$
i.e. we were able to reserve the same average while reducing the standard deviation.
Having said that, in reality the errors has some correlation and we can achieve variance reduction, but usually it has some limits and cannot be reduce towards zero by increasing the ensemble size.
|
Intutition of why Bootstrap aggregating reduces overfitting?
|
In order to illustrate why averaging reduce the standard deviation and make prediction more accurate i'll give an example.
Let's suppose that we have two models. The predictions are random variables $
|
Intutition of why Bootstrap aggregating reduces overfitting?
In order to illustrate why averaging reduce the standard deviation and make prediction more accurate i'll give an example.
Let's suppose that we have two models. The predictions are random variables $X_1 \sim N(\mu, \sigma), X_2 \sim N(\mu, \sigma)$
i.e. the prediction has a mean value plus an error term.
Considering that the errors are uncorrelated the average is:
$\frac{X_1 + X_2}{2}$ which is also normally distributed with average of $\mu$ and standard deviation of $\frac{2\sigma}{4} = \frac{\sigma}{2}$
i.e. we were able to reserve the same average while reducing the standard deviation.
Having said that, in reality the errors has some correlation and we can achieve variance reduction, but usually it has some limits and cannot be reduce towards zero by increasing the ensemble size.
|
Intutition of why Bootstrap aggregating reduces overfitting?
In order to illustrate why averaging reduce the standard deviation and make prediction more accurate i'll give an example.
Let's suppose that we have two models. The predictions are random variables $
|
41,828
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing threshold-based metrics?
|
"If neural networks are optimizing a proper scoring rule like cross-entropy loss, how can this be?"
This is likely to be traditional over-fitting of the training data. A deep neural network can implement any mapping that a radial basis function neural network can implement (they are both universal aproximators). Consider a problem with a small data set and a narrow width for the Gaussian radial basis functions. It is possible that you might be able to place a basis function directly over each positive pattern, such that the value has decreased to nearly zero by the time you get to the nearest negative pattern. This model will give a probability of class membership of essentially zero or one for every training pattern (probably way over-confident) and a training set cross-entropy of zero. This means there will also be a zero cross-entropy solution for a suitably large deep neural network as well (the good thing is that solution is a lot harder to find for a DNN - sometimes local minima are a good thing).
Making architecture or hyper-parameter choices gives more ways in which to over-fit the data, but I suspect the largest part of the problem is traditional over-fitting of the training set, unless steps are taken to avoid it.
BTW using cross-entropy as the model selection criterion for tuning the model is not without it's own problems, for instance if you have one very confident miss-classification, then the entire cross-entropy is dominated by the contribution of that one test example. Something a little less sensitive, like the Brier score might be better (if less satisfying).
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing th
|
"If neural networks are optimizing a proper scoring rule like cross-entropy loss, how can this be?"
This is likely to be traditional over-fitting of the training data. A deep neural network can imple
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing threshold-based metrics?
"If neural networks are optimizing a proper scoring rule like cross-entropy loss, how can this be?"
This is likely to be traditional over-fitting of the training data. A deep neural network can implement any mapping that a radial basis function neural network can implement (they are both universal aproximators). Consider a problem with a small data set and a narrow width for the Gaussian radial basis functions. It is possible that you might be able to place a basis function directly over each positive pattern, such that the value has decreased to nearly zero by the time you get to the nearest negative pattern. This model will give a probability of class membership of essentially zero or one for every training pattern (probably way over-confident) and a training set cross-entropy of zero. This means there will also be a zero cross-entropy solution for a suitably large deep neural network as well (the good thing is that solution is a lot harder to find for a DNN - sometimes local minima are a good thing).
Making architecture or hyper-parameter choices gives more ways in which to over-fit the data, but I suspect the largest part of the problem is traditional over-fitting of the training set, unless steps are taken to avoid it.
BTW using cross-entropy as the model selection criterion for tuning the model is not without it's own problems, for instance if you have one very confident miss-classification, then the entire cross-entropy is dominated by the contribution of that one test example. Something a little less sensitive, like the Brier score might be better (if less satisfying).
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing th
"If neural networks are optimizing a proper scoring rule like cross-entropy loss, how can this be?"
This is likely to be traditional over-fitting of the training data. A deep neural network can imple
|
41,829
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing threshold-based metrics?
|
There are some interesting properties about cross entropy loss (well, even logistic loss).
Not only we want to classify the instance correctly, we want strong options
Please check following example, note, weakly and correctly classifying one data point is almost as bad ad wrongly classifying the point.
import numpy as np
def cross_entropy(pred_prob, target):
return -np.sum(np.log(pred_prob) * (target))
target = np.array([1,0,0])
pred_prob = np.array([1/3,1/3,1/3])
print('3 classes, even dist\t',cross_entropy(pred_prob, target))
pred_prob = np.array([0.3334,0.3333,0.3333])
print('3 classes, weakly right \t',cross_entropy(pred_prob, target))
pred_prob = np.array([0.3333,0.3333,0.3334])
print('3 classes, weakly wrong \t',cross_entropy(pred_prob, target))
I also had a related question here
What are the impacts of choosing different loss functions in classification to approximate 0-1 loss
In addition, the as discussed in another answer, one major reason model is confidently wrong is the overfitting.
I recently had some interesting ideas on what may be happening inside DNN. I think essentially the overfitted model is trying to learn some "hash functions" and hardly remember "the has and the target".
In this way, it is easily to get very low loss in training data. And this "hash" is specific to certain training examples, and will very likely to be over confident and have very strong option on one class.
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing th
|
There are some interesting properties about cross entropy loss (well, even logistic loss).
Not only we want to classify the instance correctly, we want strong options
Please check following example, n
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing threshold-based metrics?
There are some interesting properties about cross entropy loss (well, even logistic loss).
Not only we want to classify the instance correctly, we want strong options
Please check following example, note, weakly and correctly classifying one data point is almost as bad ad wrongly classifying the point.
import numpy as np
def cross_entropy(pred_prob, target):
return -np.sum(np.log(pred_prob) * (target))
target = np.array([1,0,0])
pred_prob = np.array([1/3,1/3,1/3])
print('3 classes, even dist\t',cross_entropy(pred_prob, target))
pred_prob = np.array([0.3334,0.3333,0.3333])
print('3 classes, weakly right \t',cross_entropy(pred_prob, target))
pred_prob = np.array([0.3333,0.3333,0.3334])
print('3 classes, weakly wrong \t',cross_entropy(pred_prob, target))
I also had a related question here
What are the impacts of choosing different loss functions in classification to approximate 0-1 loss
In addition, the as discussed in another answer, one major reason model is confidently wrong is the overfitting.
I recently had some interesting ideas on what may be happening inside DNN. I think essentially the overfitted model is trying to learn some "hash functions" and hardly remember "the has and the target".
In this way, it is easily to get very low loss in training data. And this "hash" is specific to certain training examples, and will very likely to be over confident and have very strong option on one class.
|
How much of neural network overconfidence in predictions can be attributed to modelers optimizing th
There are some interesting properties about cross entropy loss (well, even logistic loss).
Not only we want to classify the instance correctly, we want strong options
Please check following example, n
|
41,830
|
variance estimation using order statistics
|
If you know the sample size (as opposed to just knowing that the sample size is between 50 and 200), then maximum likelihood might work in this case. Using Mathematica:
(* Joint distribution of largest 4 order statistics from a sample size of 100 *)
dist = OrderDistribution[{NormalDistribution[0, \[Sigma]], 100}, {97, 98, 99, 100}];
(* Log of the likelihood *)
logL = Log[PDF[dist, {x97, x98, x99, x100}][[1, 1, 1]]];
This can be simplified a bit and upon removing additive constants we have
$$96\log \left(\Phi \left(\frac{x_{97}}{\sigma }\right)\right)-4 \log (\sigma )-\frac{x_{97}^2+x_{98}^2+x_{99}^2+x_{100}^2}{2 \sigma ^2}$$
where $\Phi(.)$ is the unit normal cdf. We just find the value of $\sigma$ that maximizes the above equation. In general if you just have the largest $k$ observations labeled $x_{n-k+1},x_{n-k},\ldots,x_n$ for a sample size of $n$, then the log of the likelihood is (excluding the additive constants):
$$(n-k)\log\left(\Phi\left(x_{n-k+1}/\sigma\right)\right)-k\log(\sigma)-{{1}\over{2\sigma^2}}\sum_{i=n-k+1}^n x_i^2$$
Note that this is highly dependent on being able to assume (as opposed to just being willing to assume) that the samples are all independent and from the same normal distribution with mean 0. It's not often that happens.
(* Generate some data *)
SeedRandom[12345];
x = Sort[RandomVariate[NormalDistribution[0, 1], 100]];
data = {x97 -> x[[97]], x98 -> x[[98]], x99 -> x[[99]], x100 -> x[[100]]};
(* Obtain maximum likelihood estimate of \[Sigma] *)
mle = FindMaximum[{logL /. data, \[Sigma] > 0}, {{\[Mu], 0}, {\[Sigma], 1}}]
(* {2.00775, {\[Sigma] -> 0.931452}} *)
(* Estimated variance and standard error of the estimator of \[Sigma] *)
var\[Sigma] = -1/(D[logL /. data, {\[Sigma], 2}]) /. mle[[2]]
se\[Sigma] = var\[Sigma]^0.5
(* 0.110698 *)
Addition
If there are $s$ independent sets of samples of size $n_i$ where only the last $k_i$ observations are available (with $i=1,2,\ldots,s$), then one can sum the individual log likelihoods and maximize that function to get the maximum likelihood estimate:
$$\log{L}=-\frac{\sum _{i=1}^s \sum _{j=-k_i+n_i+1}^{n_i} x_{i,j}}{2 \sigma ^2}+\sum _{i=1}^s (n_i-k_i) \log \left(\Phi \left(\frac{x_{i,n_i-k_i+1}}{\sigma }\right)\right)-\log (\sigma ) \sum _{i=1}^s k_i$$
Then take the reciprocal of minus the second derivative of $\log{L}$ with respect to $\sigma$ and plug in $\hat{\sigma}$ for $\sigma$ to get an estimate of the variance.
While a symbolic representation of the estimated variance can be obtained, in practice that is probably not very useful. Whatever optimization routine is used will likely produce something that will get you what you need. Consider the single set of observations and the use of R:
# Generate some data
n <- 100 # Sample size
sigma <- 1
set.seed(12345)
x <- sigma*rnorm(n) # Normal with mean zero and sd sigma
# Now keep just the highest 4 values
x <- x[order(x)][(n-3):n]
# Define log likelihood function
logL <- function(sigma, n, x) {
k <- length(x)
(n-k)*log(pnorm(x[1]/sigma)) - k*log(sigma) - sum((x/sigma)^2)/2
}
# Find maximum likelihood estimate of sigma
# Using mean(x)/2 is a reasonable starting value when n=100
result <- optim(mean(x)/2, logL, n=n, x=x, method="L-BFGS-B",
lower=0, upper=Inf, control=list(fnscale=-1), hessian=TRUE)
result$par
# 1.111482
# Now estimate the standard error
se <- (-solve(result$hessian))^0.5
se
# 0.1376703
For multiple sets of data it depends on how you set up the data structure. In the example below I put the information for each set of data in a separate list element.
# Generate some data
nSets = 4 # Number of data sets
n <- pmax(100,rpois(nSets, 150)) # Sample size
k <- pmax(2, rpois(nSets, 5)) # Largest k observations available
sigma <- 1
set.seed(12345)
y <- vector(mode = "list", length = nSets) # Empty list
for (i in 1:nSets) {
y[[i]]$n <- n[i]
x = sigma*rnorm(n[i]) # Normal with mean zero and sd sigma
# Now keep just the highest k[i] values
x <- x[order(x)][(n[i]-k[i]+1):n[i]]
y[[i]]$x <- x
}
# Define log likelihood function
logL <- function(sigma, n, x) {
k <- length(x)
(n-k)*log(pnorm(x[1]/sigma)) - k*log(sigma) - sum((x/sigma)^2)/2
}
# Define sum of log likelihood functions
sumlogL <- function(sigma, y) {
s = 0
for (i in 1:length(y)) {
s = s + logL(sigma, y[[i]]$n, y[[i]]$x)
}
s
}
# Find maximum likelihood estimate of sigma
result <- optim(mean(y[[1]]$x)/2, sumlogL, y=y, method="L-BFGS-B",
lower=0, upper=Inf, control=list(fnscale=-1), hessian=TRUE)
result$par
# 1.058365
# Now estimate the standard error
se <- (-solve(result$hessian))^0.5
se
# 0.05002775
Alternatively if the $k_i$ are all equal and the $n_i$ are close to being equal, then just take the mean of the individual estimates and use the usual formula for a sample standard deviation to obtain an estimate of $\sigma$.
|
variance estimation using order statistics
|
If you know the sample size (as opposed to just knowing that the sample size is between 50 and 200), then maximum likelihood might work in this case. Using Mathematica:
(* Joint distribution of large
|
variance estimation using order statistics
If you know the sample size (as opposed to just knowing that the sample size is between 50 and 200), then maximum likelihood might work in this case. Using Mathematica:
(* Joint distribution of largest 4 order statistics from a sample size of 100 *)
dist = OrderDistribution[{NormalDistribution[0, \[Sigma]], 100}, {97, 98, 99, 100}];
(* Log of the likelihood *)
logL = Log[PDF[dist, {x97, x98, x99, x100}][[1, 1, 1]]];
This can be simplified a bit and upon removing additive constants we have
$$96\log \left(\Phi \left(\frac{x_{97}}{\sigma }\right)\right)-4 \log (\sigma )-\frac{x_{97}^2+x_{98}^2+x_{99}^2+x_{100}^2}{2 \sigma ^2}$$
where $\Phi(.)$ is the unit normal cdf. We just find the value of $\sigma$ that maximizes the above equation. In general if you just have the largest $k$ observations labeled $x_{n-k+1},x_{n-k},\ldots,x_n$ for a sample size of $n$, then the log of the likelihood is (excluding the additive constants):
$$(n-k)\log\left(\Phi\left(x_{n-k+1}/\sigma\right)\right)-k\log(\sigma)-{{1}\over{2\sigma^2}}\sum_{i=n-k+1}^n x_i^2$$
Note that this is highly dependent on being able to assume (as opposed to just being willing to assume) that the samples are all independent and from the same normal distribution with mean 0. It's not often that happens.
(* Generate some data *)
SeedRandom[12345];
x = Sort[RandomVariate[NormalDistribution[0, 1], 100]];
data = {x97 -> x[[97]], x98 -> x[[98]], x99 -> x[[99]], x100 -> x[[100]]};
(* Obtain maximum likelihood estimate of \[Sigma] *)
mle = FindMaximum[{logL /. data, \[Sigma] > 0}, {{\[Mu], 0}, {\[Sigma], 1}}]
(* {2.00775, {\[Sigma] -> 0.931452}} *)
(* Estimated variance and standard error of the estimator of \[Sigma] *)
var\[Sigma] = -1/(D[logL /. data, {\[Sigma], 2}]) /. mle[[2]]
se\[Sigma] = var\[Sigma]^0.5
(* 0.110698 *)
Addition
If there are $s$ independent sets of samples of size $n_i$ where only the last $k_i$ observations are available (with $i=1,2,\ldots,s$), then one can sum the individual log likelihoods and maximize that function to get the maximum likelihood estimate:
$$\log{L}=-\frac{\sum _{i=1}^s \sum _{j=-k_i+n_i+1}^{n_i} x_{i,j}}{2 \sigma ^2}+\sum _{i=1}^s (n_i-k_i) \log \left(\Phi \left(\frac{x_{i,n_i-k_i+1}}{\sigma }\right)\right)-\log (\sigma ) \sum _{i=1}^s k_i$$
Then take the reciprocal of minus the second derivative of $\log{L}$ with respect to $\sigma$ and plug in $\hat{\sigma}$ for $\sigma$ to get an estimate of the variance.
While a symbolic representation of the estimated variance can be obtained, in practice that is probably not very useful. Whatever optimization routine is used will likely produce something that will get you what you need. Consider the single set of observations and the use of R:
# Generate some data
n <- 100 # Sample size
sigma <- 1
set.seed(12345)
x <- sigma*rnorm(n) # Normal with mean zero and sd sigma
# Now keep just the highest 4 values
x <- x[order(x)][(n-3):n]
# Define log likelihood function
logL <- function(sigma, n, x) {
k <- length(x)
(n-k)*log(pnorm(x[1]/sigma)) - k*log(sigma) - sum((x/sigma)^2)/2
}
# Find maximum likelihood estimate of sigma
# Using mean(x)/2 is a reasonable starting value when n=100
result <- optim(mean(x)/2, logL, n=n, x=x, method="L-BFGS-B",
lower=0, upper=Inf, control=list(fnscale=-1), hessian=TRUE)
result$par
# 1.111482
# Now estimate the standard error
se <- (-solve(result$hessian))^0.5
se
# 0.1376703
For multiple sets of data it depends on how you set up the data structure. In the example below I put the information for each set of data in a separate list element.
# Generate some data
nSets = 4 # Number of data sets
n <- pmax(100,rpois(nSets, 150)) # Sample size
k <- pmax(2, rpois(nSets, 5)) # Largest k observations available
sigma <- 1
set.seed(12345)
y <- vector(mode = "list", length = nSets) # Empty list
for (i in 1:nSets) {
y[[i]]$n <- n[i]
x = sigma*rnorm(n[i]) # Normal with mean zero and sd sigma
# Now keep just the highest k[i] values
x <- x[order(x)][(n[i]-k[i]+1):n[i]]
y[[i]]$x <- x
}
# Define log likelihood function
logL <- function(sigma, n, x) {
k <- length(x)
(n-k)*log(pnorm(x[1]/sigma)) - k*log(sigma) - sum((x/sigma)^2)/2
}
# Define sum of log likelihood functions
sumlogL <- function(sigma, y) {
s = 0
for (i in 1:length(y)) {
s = s + logL(sigma, y[[i]]$n, y[[i]]$x)
}
s
}
# Find maximum likelihood estimate of sigma
result <- optim(mean(y[[1]]$x)/2, sumlogL, y=y, method="L-BFGS-B",
lower=0, upper=Inf, control=list(fnscale=-1), hessian=TRUE)
result$par
# 1.058365
# Now estimate the standard error
se <- (-solve(result$hessian))^0.5
se
# 0.05002775
Alternatively if the $k_i$ are all equal and the $n_i$ are close to being equal, then just take the mean of the individual estimates and use the usual formula for a sample standard deviation to obtain an estimate of $\sigma$.
|
variance estimation using order statistics
If you know the sample size (as opposed to just knowing that the sample size is between 50 and 200), then maximum likelihood might work in this case. Using Mathematica:
(* Joint distribution of large
|
41,831
|
variance estimation using order statistics
|
Comment: This the germ of an idea, not yet a solution. [I am assuming the mean $\mu$ is also unknown.]
Suppose $n = 100$ observations from a standard normal distribution.
You might find the distance $D$ between order statistics 97 and 100.
Then $1/D$ should estimate $1.$ Several runs give various answers. In R,
set.seed(123)
diff(sort(rnorm(100))[c(97,100)])
[1] 0.4004199
diff(sort(rnorm(100))[c(97,100)])
[1] 1.243827
diff(sort(rnorm(100))[c(97,100)])
[1] 0.337785
diff(sort(rnorm(100))[c(97,100)])
[1] 0.8870224
Find the average of a million runs:
set.seed(2021)
d.4 = replicate(10^6, diff( sort(rnorm(100))[c(97,100)] ) )
mean(d.4)
[1] 0.7060959
sg.est = d.4/.706
mean(sg.est); sd(sg.est)
[1] 1.000136
[1] 0.5530556
So, on average the distance between the 97th and 100th order statistics
divided by 0.706 estimates $\sigma$ with standard error about 0.553.
Here is a histogram of such estimates of $\sigma$ along with quantiles 0.025 and 0.975
of the estimates.
hist(d.4/.706, prob=T, col="skyblue2")
abline(v=quantile(sg.est, c(.975,.025)), col="red")
Maybe we can find normal quantiles that give approximately 0.706, without
simulation. One possibility:
diff(qnorm(c(.97,.995)))
[1] 0.6950357
Something like this might generalize for other values of $n$ between 50 and 200.
|
variance estimation using order statistics
|
Comment: This the germ of an idea, not yet a solution. [I am assuming the mean $\mu$ is also unknown.]
Suppose $n = 100$ observations from a standard normal distribution.
You might find the distance $
|
variance estimation using order statistics
Comment: This the germ of an idea, not yet a solution. [I am assuming the mean $\mu$ is also unknown.]
Suppose $n = 100$ observations from a standard normal distribution.
You might find the distance $D$ between order statistics 97 and 100.
Then $1/D$ should estimate $1.$ Several runs give various answers. In R,
set.seed(123)
diff(sort(rnorm(100))[c(97,100)])
[1] 0.4004199
diff(sort(rnorm(100))[c(97,100)])
[1] 1.243827
diff(sort(rnorm(100))[c(97,100)])
[1] 0.337785
diff(sort(rnorm(100))[c(97,100)])
[1] 0.8870224
Find the average of a million runs:
set.seed(2021)
d.4 = replicate(10^6, diff( sort(rnorm(100))[c(97,100)] ) )
mean(d.4)
[1] 0.7060959
sg.est = d.4/.706
mean(sg.est); sd(sg.est)
[1] 1.000136
[1] 0.5530556
So, on average the distance between the 97th and 100th order statistics
divided by 0.706 estimates $\sigma$ with standard error about 0.553.
Here is a histogram of such estimates of $\sigma$ along with quantiles 0.025 and 0.975
of the estimates.
hist(d.4/.706, prob=T, col="skyblue2")
abline(v=quantile(sg.est, c(.975,.025)), col="red")
Maybe we can find normal quantiles that give approximately 0.706, without
simulation. One possibility:
diff(qnorm(c(.97,.995)))
[1] 0.6950357
Something like this might generalize for other values of $n$ between 50 and 200.
|
variance estimation using order statistics
Comment: This the germ of an idea, not yet a solution. [I am assuming the mean $\mu$ is also unknown.]
Suppose $n = 100$ observations from a standard normal distribution.
You might find the distance $
|
41,832
|
Basis dimension (k) too low for the smooth term in a GAMM
|
It's not a huge problem in your case.
The best I can find on it is p.330-331 of this guide by Simon Wood.
Because the edf is way below the basis dimension I don't see it as a problem (quote from Wood on page 331: "The...test still gives a low p-value, but since the edf is...below the basis dimension, and increasing the basis dimension barely changes the fitted values,...stick with k=100...").
So, fitting more basis functions by setting higher k would not make much logical sense given the size of the data set.
The book also talks about finding the best k, but in the case of your data allowing the default seems fine as the model will converge to a straight line (edf = 1).
|
Basis dimension (k) too low for the smooth term in a GAMM
|
It's not a huge problem in your case.
The best I can find on it is p.330-331 of this guide by Simon Wood.
Because the edf is way below the basis dimension I don't see it as a problem (quote from Wood
|
Basis dimension (k) too low for the smooth term in a GAMM
It's not a huge problem in your case.
The best I can find on it is p.330-331 of this guide by Simon Wood.
Because the edf is way below the basis dimension I don't see it as a problem (quote from Wood on page 331: "The...test still gives a low p-value, but since the edf is...below the basis dimension, and increasing the basis dimension barely changes the fitted values,...stick with k=100...").
So, fitting more basis functions by setting higher k would not make much logical sense given the size of the data set.
The book also talks about finding the best k, but in the case of your data allowing the default seems fine as the model will converge to a straight line (edf = 1).
|
Basis dimension (k) too low for the smooth term in a GAMM
It's not a huge problem in your case.
The best I can find on it is p.330-331 of this guide by Simon Wood.
Because the edf is way below the basis dimension I don't see it as a problem (quote from Wood
|
41,833
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
|
Time-to-ruin in the discrete-time random walk: From your question, I take it that you are referring to a discrete-time version of the gambler's ruin problem. Without loss of generality we can consider the wealth of the gambler denominated in units equivalent to the betting amount. We will assume that the wealth of the gambler is a positive whole number of such units, and we denote the starting wealth as $w_0 \in \mathbb{N}$. Then the time-to-ruin is defined as:
$$T \equiv \min \{ t \in \mathbb{N} | w_t = 0 \},$$
where the wealth follows the unit random walk process:
$$w_t = w_0 + \sum_{i=1}^t \Delta_i
\quad \quad \quad \mathbb{P}(\Delta_i = -1) = \mathbb{P}(\Delta_i = 1) = \frac{1}{2}.$$
The time-to-ruin is the "hitting time" for the state $w=0$ in this stochastic process. You can determine the distribution of the time-to-ruin by looking at the distributions of the hitting times. Here it is useful to appeal to a special result for random walks called the "hitting time theorem" (see e.g., Van Der Hofstad and Keane 2008 and Kager 2017), which shows that:
$$\mathbb{P}(T=t) = \frac{w_0}{t} \cdot \mathbb{P}(w_t = 0).$$
Below we will use this result to derive a useful distribution that is closely related to the distribution of the time-to-ruin. The result is a discrete phase-type distribution, which is a type of distribution used to model the hitting time to the absorbing state of a Markov chain.
Deriving the distribution of the time-to-ruin: Looking at the nature of the random walk, it is easy to see that the time-to-ruin must occur somewhere over the support $t = w_0, w_0 + 2, w_0 + 4, w_0 + 6, ...$. This is quite an intuitive result --- we need to have at least $w_0$ bets to lose the starting wealth, and any additional bets leading to ruin must come in pairs, each with one win and one loss cancelling each other out. Thus, to facilitate our analysis, it is useful to work with the total number of winning bets in the time-to-ruin:
$$R \equiv \frac{T - w_0}{2},$$
which has support $r = 0,1,2,3,...$. Now, applying the hitting time theorem above, we get:
$$\begin{align}
\mathbb{P}(R=r)
= \mathbb{P} \Bigg( \frac{T - w_0}{2} = r \Bigg)
&= \mathbb{P} ( T = w_0 + 2r ) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \mathbb{P} ( w_{w_0 + 2r} = 0 ) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \mathbb{P} \Bigg( w_0 + \sum_{i=1}^{w_0 + 2r} \Delta_i = 0 \Bigg) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \mathbb{P} \Bigg( \sum_{i=1}^{w_0 + 2r} \mathbb{I}(\Delta_i=1) = r \Bigg) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \text{Bin} ( r | w_0 + 2r, \tfrac{1}{2} ) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \frac{(w_0 + 2r)!}{(w_0+r)! r!} \cdot \frac{1}{2^{w_0 + 2r}} \\[6pt]
&= \frac{w_0}{2^{w_0}} \cdot \frac{(w_0 + 2r - 1)!}{(w_0+r)! r!} \cdot \frac{1}{4^r} \\[6pt]
\end{align}$$
It is simplest to frame the gambler's ruin problem in terms of this distribution. However, we can convert back to the distribution for $T$. For any value $t = w_0, w_0 + 2, w_0 + 4, w_0 + 6, ...$ in the support for the time-to-ruin, we have:
$$\mathbb{P}(T=t) = w_0 \cdot \frac{(t - 1)!}{(\tfrac{t+w_0}{2})! (\tfrac{t-w_0}{2})!} \cdot \frac{1}{2^t}.$$
Implementation in R: We can program this density function using standard syntax for probability distribution as follows. In this function the input t is a vectorised input for the time-to-ruin. The function produces density values by default, but you can use the log input to produce log-densities instead.
druintime <- function(t, w, log = FALSE) {
#Check inputs
if (!is.numeric(t)) { stop('Error: Input t should be numeric') }
if (!is.numeric(w)) { stop('Error: Input w must be a positive integer') }
if (length(wealth) != 1) { stop('Error: Input w must be a single value') }
if (as.integer(w) != w) { stop('Error: Input w must be a positive integer') }
if (min(wealth) < 1) { stop('Error: Input w must be a positive integer') }
if (!is.logical(log)) { stop('Error: Input log must be a logical value') }
if (length(log) != 1) { stop('Error: Input log must be a single value') }
#Compute number of successes in each time-to-ruin
#and set indicators for integer values
n <- length(t)
r <- (t - w)/2
IND <- (as.integer(r) == r)&(r >= 0)
#Compute log-density
LOGDEN <- rep(-Inf, n)
LOGDEN[IND] <- log(w) - log(w + 2*r[IND]) +
dbinom(r[IND], size = w + 2*r[IND], prob = 1/2, log = TRUE)
#Give output
if (log) { LOGDEN } else { exp(LOGDEN) } }
Implementing this with starting wealth $w_0 = 6$ gives the following probability mass function.
#Compute probability mass function over a set of input values
t <- 0:200
w0 <- 6
DENS <- druintime(t, w = w0)
#Plot the mass function
t.names <- rep(NA, length(t))
for (i in 0:20) { t.names[1+10*i] <- t[1+10*i] }
barplot(DENS, names.arg = t.names,
main = 'Probability Mass Function for Time-to-Ruin', col = 'red',
xlab = 'Time-to-Ruin', ylab = 'Probability')
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
|
Time-to-ruin in the discrete-time random walk: From your question, I take it that you are referring to a discrete-time version of the gambler's ruin problem. Without loss of generality we can conside
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
Time-to-ruin in the discrete-time random walk: From your question, I take it that you are referring to a discrete-time version of the gambler's ruin problem. Without loss of generality we can consider the wealth of the gambler denominated in units equivalent to the betting amount. We will assume that the wealth of the gambler is a positive whole number of such units, and we denote the starting wealth as $w_0 \in \mathbb{N}$. Then the time-to-ruin is defined as:
$$T \equiv \min \{ t \in \mathbb{N} | w_t = 0 \},$$
where the wealth follows the unit random walk process:
$$w_t = w_0 + \sum_{i=1}^t \Delta_i
\quad \quad \quad \mathbb{P}(\Delta_i = -1) = \mathbb{P}(\Delta_i = 1) = \frac{1}{2}.$$
The time-to-ruin is the "hitting time" for the state $w=0$ in this stochastic process. You can determine the distribution of the time-to-ruin by looking at the distributions of the hitting times. Here it is useful to appeal to a special result for random walks called the "hitting time theorem" (see e.g., Van Der Hofstad and Keane 2008 and Kager 2017), which shows that:
$$\mathbb{P}(T=t) = \frac{w_0}{t} \cdot \mathbb{P}(w_t = 0).$$
Below we will use this result to derive a useful distribution that is closely related to the distribution of the time-to-ruin. The result is a discrete phase-type distribution, which is a type of distribution used to model the hitting time to the absorbing state of a Markov chain.
Deriving the distribution of the time-to-ruin: Looking at the nature of the random walk, it is easy to see that the time-to-ruin must occur somewhere over the support $t = w_0, w_0 + 2, w_0 + 4, w_0 + 6, ...$. This is quite an intuitive result --- we need to have at least $w_0$ bets to lose the starting wealth, and any additional bets leading to ruin must come in pairs, each with one win and one loss cancelling each other out. Thus, to facilitate our analysis, it is useful to work with the total number of winning bets in the time-to-ruin:
$$R \equiv \frac{T - w_0}{2},$$
which has support $r = 0,1,2,3,...$. Now, applying the hitting time theorem above, we get:
$$\begin{align}
\mathbb{P}(R=r)
= \mathbb{P} \Bigg( \frac{T - w_0}{2} = r \Bigg)
&= \mathbb{P} ( T = w_0 + 2r ) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \mathbb{P} ( w_{w_0 + 2r} = 0 ) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \mathbb{P} \Bigg( w_0 + \sum_{i=1}^{w_0 + 2r} \Delta_i = 0 \Bigg) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \mathbb{P} \Bigg( \sum_{i=1}^{w_0 + 2r} \mathbb{I}(\Delta_i=1) = r \Bigg) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \text{Bin} ( r | w_0 + 2r, \tfrac{1}{2} ) \\[6pt]
&= \frac{w_0}{w_0 + 2r} \cdot \frac{(w_0 + 2r)!}{(w_0+r)! r!} \cdot \frac{1}{2^{w_0 + 2r}} \\[6pt]
&= \frac{w_0}{2^{w_0}} \cdot \frac{(w_0 + 2r - 1)!}{(w_0+r)! r!} \cdot \frac{1}{4^r} \\[6pt]
\end{align}$$
It is simplest to frame the gambler's ruin problem in terms of this distribution. However, we can convert back to the distribution for $T$. For any value $t = w_0, w_0 + 2, w_0 + 4, w_0 + 6, ...$ in the support for the time-to-ruin, we have:
$$\mathbb{P}(T=t) = w_0 \cdot \frac{(t - 1)!}{(\tfrac{t+w_0}{2})! (\tfrac{t-w_0}{2})!} \cdot \frac{1}{2^t}.$$
Implementation in R: We can program this density function using standard syntax for probability distribution as follows. In this function the input t is a vectorised input for the time-to-ruin. The function produces density values by default, but you can use the log input to produce log-densities instead.
druintime <- function(t, w, log = FALSE) {
#Check inputs
if (!is.numeric(t)) { stop('Error: Input t should be numeric') }
if (!is.numeric(w)) { stop('Error: Input w must be a positive integer') }
if (length(wealth) != 1) { stop('Error: Input w must be a single value') }
if (as.integer(w) != w) { stop('Error: Input w must be a positive integer') }
if (min(wealth) < 1) { stop('Error: Input w must be a positive integer') }
if (!is.logical(log)) { stop('Error: Input log must be a logical value') }
if (length(log) != 1) { stop('Error: Input log must be a single value') }
#Compute number of successes in each time-to-ruin
#and set indicators for integer values
n <- length(t)
r <- (t - w)/2
IND <- (as.integer(r) == r)&(r >= 0)
#Compute log-density
LOGDEN <- rep(-Inf, n)
LOGDEN[IND] <- log(w) - log(w + 2*r[IND]) +
dbinom(r[IND], size = w + 2*r[IND], prob = 1/2, log = TRUE)
#Give output
if (log) { LOGDEN } else { exp(LOGDEN) } }
Implementing this with starting wealth $w_0 = 6$ gives the following probability mass function.
#Compute probability mass function over a set of input values
t <- 0:200
w0 <- 6
DENS <- druintime(t, w = w0)
#Plot the mass function
t.names <- rep(NA, length(t))
for (i in 0:20) { t.names[1+10*i] <- t[1+10*i] }
barplot(DENS, names.arg = t.names,
main = 'Probability Mass Function for Time-to-Ruin', col = 'red',
xlab = 'Time-to-Ruin', ylab = 'Probability')
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
Time-to-ruin in the discrete-time random walk: From your question, I take it that you are referring to a discrete-time version of the gambler's ruin problem. Without loss of generality we can conside
|
41,834
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
|
Say your starting wealth is $W(0) = 6$ and we take 20 steps of the random walk, where a gambler has fifty-fifty probability to loose or win 1, then probability distribution for wealth looks like a (scaled and shifted) binomial distribution.
Obviously the cases with $W(20) \leq 0$ have gone bankrupt. But the amount of bankrupt gambler's is larger. Due to the symmetry of the steps — after hitting zero one is as likely to reach a certain positive value as a certain negative value — for every case of a gambler that is at a value below zero, there is an equivalent case that is above zero. To get to know the amount of gamblers that have still positive wealth we need to subtract that part. This is also called the reflection principle.
So we can model the cumulative distribution function for bankruptcy after $n=w(0)+2x$ steps as
$$F_{bankrupt}(n) = F_\text{binom}\left(\frac{n-w(0)}{2},n,p=0.5\right) + F_\text{binom}\left(\frac{n-w(0)}{2}-1,n,p=0.5\right)$$
n = seq(6,100,2)
yF = pbinom((n-6)/2,n,0.5)+pbinom((n-6)/2-1,n,0.5)
yf = diff(c(0,yF))
plot(n,yf, type = "h", lwd = 3, main = "probability distribution for \n bankruptcy after n steps if w(0)=6", ylab = "probability")
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
|
Say your starting wealth is $W(0) = 6$ and we take 20 steps of the random walk, where a gambler has fifty-fifty probability to loose or win 1, then probability distribution for wealth looks like a (sc
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
Say your starting wealth is $W(0) = 6$ and we take 20 steps of the random walk, where a gambler has fifty-fifty probability to loose or win 1, then probability distribution for wealth looks like a (scaled and shifted) binomial distribution.
Obviously the cases with $W(20) \leq 0$ have gone bankrupt. But the amount of bankrupt gambler's is larger. Due to the symmetry of the steps — after hitting zero one is as likely to reach a certain positive value as a certain negative value — for every case of a gambler that is at a value below zero, there is an equivalent case that is above zero. To get to know the amount of gamblers that have still positive wealth we need to subtract that part. This is also called the reflection principle.
So we can model the cumulative distribution function for bankruptcy after $n=w(0)+2x$ steps as
$$F_{bankrupt}(n) = F_\text{binom}\left(\frac{n-w(0)}{2},n,p=0.5\right) + F_\text{binom}\left(\frac{n-w(0)}{2}-1,n,p=0.5\right)$$
n = seq(6,100,2)
yF = pbinom((n-6)/2,n,0.5)+pbinom((n-6)/2-1,n,0.5)
yf = diff(c(0,yF))
plot(n,yf, type = "h", lwd = 3, main = "probability distribution for \n bankruptcy after n steps if w(0)=6", ylab = "probability")
|
What is the distribution of time's to ruin in the gambler's ruin problem (random walk)?
Say your starting wealth is $W(0) = 6$ and we take 20 steps of the random walk, where a gambler has fifty-fifty probability to loose or win 1, then probability distribution for wealth looks like a (sc
|
41,835
|
What is the name of this metric?
|
No, there is not, at least according to what I could find in Google and Wikipedia.
I would argue that, while that can be an interesting metric to characterize errors, it does not convey any new information that the habitual metrics didn't already.
|
What is the name of this metric?
|
No, there is not, at least according to what I could find in Google and Wikipedia.
I would argue that, while that can be an interesting metric to characterize errors, it does not convey any new inform
|
What is the name of this metric?
No, there is not, at least according to what I could find in Google and Wikipedia.
I would argue that, while that can be an interesting metric to characterize errors, it does not convey any new information that the habitual metrics didn't already.
|
What is the name of this metric?
No, there is not, at least according to what I could find in Google and Wikipedia.
I would argue that, while that can be an interesting metric to characterize errors, it does not convey any new inform
|
41,836
|
What is the name of this metric?
|
I once (can't remember when or where) saw a journal article in which authors called it "harmfulness". In that article FP was "worse kind of error" than FN (it had something to do with amputations). So FP/(FP+FN) was measuring how harmfull a diagnostic method is when it actually "makes" a mistake.
|
What is the name of this metric?
|
I once (can't remember when or where) saw a journal article in which authors called it "harmfulness". In that article FP was "worse kind of error" than FN (it had something to do with amputations). So
|
What is the name of this metric?
I once (can't remember when or where) saw a journal article in which authors called it "harmfulness". In that article FP was "worse kind of error" than FN (it had something to do with amputations). So FP/(FP+FN) was measuring how harmfull a diagnostic method is when it actually "makes" a mistake.
|
What is the name of this metric?
I once (can't remember when or where) saw a journal article in which authors called it "harmfulness". In that article FP was "worse kind of error" than FN (it had something to do with amputations). So
|
41,837
|
Causal Bayesian network, causal diagram, structural causal model and marginal structural model: what do they exactly mean?
|
I will give my answer based on Pearl's other book (Causality)
First, some terminology: there are 3 types of queries: observational, interventional, and counterfactual.
For observational queries, you only need a joint distribution
For interventional queries, you also need a directed graph (e.g. a Bayesian Network(BN), and especially a Causal Bayesian Network(CBN).) As you quoted, CBNs are required to be able to see how the variables influence each other (hence a graph is used). On a high level, the takeaway should be this simple: you need a graph. The CBN is a BN where you interpret the probabilities in another way.
For counterfactual queries, you also need to know the quantitative relationship between the different variables. So here you need a graph and a parametrization that describes these functional relationships.
A causal diagram is a directed acyclic graph (DAG)
This provides all we need to answer your first question
Answer to question 1:
TL;DR: SCM = causal diagram + functions for each edge
The causal diagram is a graph that describes what variables relate to each other, whereas an SCM additionally gives a quantitative description of these relationships,
P.S.: I cannot find "causal structural models" in the linked book with the search function.
My guess based on Google searches (the term arises in a paper co-authored by Pearl) that they are the same
|
Causal Bayesian network, causal diagram, structural causal model and marginal structural model: what
|
I will give my answer based on Pearl's other book (Causality)
First, some terminology: there are 3 types of queries: observational, interventional, and counterfactual.
For observational queries, you
|
Causal Bayesian network, causal diagram, structural causal model and marginal structural model: what do they exactly mean?
I will give my answer based on Pearl's other book (Causality)
First, some terminology: there are 3 types of queries: observational, interventional, and counterfactual.
For observational queries, you only need a joint distribution
For interventional queries, you also need a directed graph (e.g. a Bayesian Network(BN), and especially a Causal Bayesian Network(CBN).) As you quoted, CBNs are required to be able to see how the variables influence each other (hence a graph is used). On a high level, the takeaway should be this simple: you need a graph. The CBN is a BN where you interpret the probabilities in another way.
For counterfactual queries, you also need to know the quantitative relationship between the different variables. So here you need a graph and a parametrization that describes these functional relationships.
A causal diagram is a directed acyclic graph (DAG)
This provides all we need to answer your first question
Answer to question 1:
TL;DR: SCM = causal diagram + functions for each edge
The causal diagram is a graph that describes what variables relate to each other, whereas an SCM additionally gives a quantitative description of these relationships,
P.S.: I cannot find "causal structural models" in the linked book with the search function.
My guess based on Google searches (the term arises in a paper co-authored by Pearl) that they are the same
|
Causal Bayesian network, causal diagram, structural causal model and marginal structural model: what
I will give my answer based on Pearl's other book (Causality)
First, some terminology: there are 3 types of queries: observational, interventional, and counterfactual.
For observational queries, you
|
41,838
|
Regression With Uncertainty/Range In Target Variable
|
This can be modeled as interval censored data. Most references you will find on interval censoring are in the survival time context, but the same techniques apply to any measurement that is censored. The survival package in R has the required methods for this. I suggest the accelerated failure model.
E.g.
N <- 100
set.seed(123455)
X <- data.frame(
bathrooms = sample(1:3, size = N, replace = TRUE),
bedrooms = sample(1:4, size = N, replace = TRUE)
)
Y <- rlnorm(N, log(10000 + X$bathrooms*10000 + X$bedrooms*30000), 2)
hist(log10(Y))
Ycensleft <- floor(Y/10000) * 10000
Ycensright <- ceiling(Y/10000) * 10000
require(survival)
Ysurv <- Surv(time = Ycensleft, time2 = Ycensright, event = rep(3, N), type = 'interval')
sv1 <- survreg(Ysurv ~ bathrooms + bedrooms, data = X, dist = "gaussian")
summary(sv1)
```
|
Regression With Uncertainty/Range In Target Variable
|
This can be modeled as interval censored data. Most references you will find on interval censoring are in the survival time context, but the same techniques apply to any measurement that is censored.
|
Regression With Uncertainty/Range In Target Variable
This can be modeled as interval censored data. Most references you will find on interval censoring are in the survival time context, but the same techniques apply to any measurement that is censored. The survival package in R has the required methods for this. I suggest the accelerated failure model.
E.g.
N <- 100
set.seed(123455)
X <- data.frame(
bathrooms = sample(1:3, size = N, replace = TRUE),
bedrooms = sample(1:4, size = N, replace = TRUE)
)
Y <- rlnorm(N, log(10000 + X$bathrooms*10000 + X$bedrooms*30000), 2)
hist(log10(Y))
Ycensleft <- floor(Y/10000) * 10000
Ycensright <- ceiling(Y/10000) * 10000
require(survival)
Ysurv <- Surv(time = Ycensleft, time2 = Ycensright, event = rep(3, N), type = 'interval')
sv1 <- survreg(Ysurv ~ bathrooms + bedrooms, data = X, dist = "gaussian")
summary(sv1)
```
|
Regression With Uncertainty/Range In Target Variable
This can be modeled as interval censored data. Most references you will find on interval censoring are in the survival time context, but the same techniques apply to any measurement that is censored.
|
41,839
|
When a classifier predicting probability should be calibrated?
|
There are several possible scenarios when one would think about calibrating probabilities:
The model is misspecified or not optimally trained. That will be the case when non-linear relationships are modeled with a linear learner; or model is too rigid due to excessive regularization (model underfits); or to the contrary, the model is too flexible (overfit or data memorization). Under/over-fit may also be due to having too few/many learning epochs or bagged trees.
A wrong objective function for predicting probabilities was chosen. That will be the case for distorted probabilities predicted by sklearn RandomForest, where they use "gini" or "entropy" for objective function. Classifiers with logloss as objective function are supposed to produce non-biased probability estimates given they have enough data to learn from. Onesidedness of probabilities may explain probability distortions near interval end, but that would not explain distortions in the middle.
Using optimized objective function instead of exact one. This is the case with XGBoost Random Forest implementation:
XGBoost uses 2nd order approximation to the objective function. This can lead to results that differ from a random forest implementation that uses the exact value of the objective function.
In all three scenarios (including having too little data, where it's unclear if calibration results will generalize well when new data arrives), calibration time is better spent on (1) correct model specification (2) choosing right metric (objective function) to optimize (3) collecting more data.
Case 1. Right objective, enough data (Logistic Regression from sklearn)
Case 2. Wrong objective (Random Forest from sklearn)
Case 3. Right objective, needs more data (Random Forest from XGBoost)
Case 4. Right objective, needs more data
PS
There is nothing wrong with the "wrong" metric as all the classifiers, including sklearn's Random Forest, Naïve Bayes, or SVC, perform very well for certain tasks. The expectation these will behave well for predicting probabilities is wrong and misspecified.
Calibrating well specified and well trained models, even though may show better in-sample result, most probably is fitting to test and will lead to worse generalization to new data.
|
When a classifier predicting probability should be calibrated?
|
There are several possible scenarios when one would think about calibrating probabilities:
The model is misspecified or not optimally trained. That will be the case when non-linear relationships are
|
When a classifier predicting probability should be calibrated?
There are several possible scenarios when one would think about calibrating probabilities:
The model is misspecified or not optimally trained. That will be the case when non-linear relationships are modeled with a linear learner; or model is too rigid due to excessive regularization (model underfits); or to the contrary, the model is too flexible (overfit or data memorization). Under/over-fit may also be due to having too few/many learning epochs or bagged trees.
A wrong objective function for predicting probabilities was chosen. That will be the case for distorted probabilities predicted by sklearn RandomForest, where they use "gini" or "entropy" for objective function. Classifiers with logloss as objective function are supposed to produce non-biased probability estimates given they have enough data to learn from. Onesidedness of probabilities may explain probability distortions near interval end, but that would not explain distortions in the middle.
Using optimized objective function instead of exact one. This is the case with XGBoost Random Forest implementation:
XGBoost uses 2nd order approximation to the objective function. This can lead to results that differ from a random forest implementation that uses the exact value of the objective function.
In all three scenarios (including having too little data, where it's unclear if calibration results will generalize well when new data arrives), calibration time is better spent on (1) correct model specification (2) choosing right metric (objective function) to optimize (3) collecting more data.
Case 1. Right objective, enough data (Logistic Regression from sklearn)
Case 2. Wrong objective (Random Forest from sklearn)
Case 3. Right objective, needs more data (Random Forest from XGBoost)
Case 4. Right objective, needs more data
PS
There is nothing wrong with the "wrong" metric as all the classifiers, including sklearn's Random Forest, Naïve Bayes, or SVC, perform very well for certain tasks. The expectation these will behave well for predicting probabilities is wrong and misspecified.
Calibrating well specified and well trained models, even though may show better in-sample result, most probably is fitting to test and will lead to worse generalization to new data.
|
When a classifier predicting probability should be calibrated?
There are several possible scenarios when one would think about calibrating probabilities:
The model is misspecified or not optimally trained. That will be the case when non-linear relationships are
|
41,840
|
Can I scale and then interpret shap values as percent contribution to the prediction?
|
Almost yes. There are a few caveats regarding directly interpreting the scaled SHAP values, as the percentage contributions of our final classification prediction for a single observation.
Raw SHAP values for classification tasks are often shown as additive contribution in the log-odds domain. That means that it is not a linear scale we are dealing with and scaling them will not massively simplify that. (Some implementation transform them to probabilities but that's not always the case.)
SHAP values' baseline is always relative based on the average of all predictions; i.e. the contribution (SHAP value) of feature X regards the difference between the actual prediction and the mean prediction. Therefore they do not fully explain how a singe prediction came to be. (This may vary a bit based on the implementation but worth checking.)
Depending on the learner used if the features A, B and C are on different scales, their coefficient values in the log-odds domain might not be directly comparable. (Usually not a big problem because often the features are binned when it comes to feature importance and/or we pre-process the data but it can happen.)
SHAP (and Shapley) values are approximations of the model's behaviour. They are not guarantee to account perfectly on how a model works. (Obvious point but sometimes forgotten.)
The above being noted, what you describe (summing the absolute SHAP values for an individual prediction and normalising them to get percentage of contribution) is reasonable. It is actually how we calculate overall feature importances with SHAP values. In this more general case, we sum the absolute values per feature across all our observations (and potentially normalise them afterwards). These overall feature contributions will be against our mean prediction of course; as we are examining relative importance for a classifier's overall output this is perfectly fine.
For a single point it can be argued that any of the caveats mentioned above partially invalidates our proposed interpretation but realistically the contribution of each feature would "thereabouts" in terms of percentages for the prediction of a single observation.
|
Can I scale and then interpret shap values as percent contribution to the prediction?
|
Almost yes. There are a few caveats regarding directly interpreting the scaled SHAP values, as the percentage contributions of our final classification prediction for a single observation.
Raw SHAP v
|
Can I scale and then interpret shap values as percent contribution to the prediction?
Almost yes. There are a few caveats regarding directly interpreting the scaled SHAP values, as the percentage contributions of our final classification prediction for a single observation.
Raw SHAP values for classification tasks are often shown as additive contribution in the log-odds domain. That means that it is not a linear scale we are dealing with and scaling them will not massively simplify that. (Some implementation transform them to probabilities but that's not always the case.)
SHAP values' baseline is always relative based on the average of all predictions; i.e. the contribution (SHAP value) of feature X regards the difference between the actual prediction and the mean prediction. Therefore they do not fully explain how a singe prediction came to be. (This may vary a bit based on the implementation but worth checking.)
Depending on the learner used if the features A, B and C are on different scales, their coefficient values in the log-odds domain might not be directly comparable. (Usually not a big problem because often the features are binned when it comes to feature importance and/or we pre-process the data but it can happen.)
SHAP (and Shapley) values are approximations of the model's behaviour. They are not guarantee to account perfectly on how a model works. (Obvious point but sometimes forgotten.)
The above being noted, what you describe (summing the absolute SHAP values for an individual prediction and normalising them to get percentage of contribution) is reasonable. It is actually how we calculate overall feature importances with SHAP values. In this more general case, we sum the absolute values per feature across all our observations (and potentially normalise them afterwards). These overall feature contributions will be against our mean prediction of course; as we are examining relative importance for a classifier's overall output this is perfectly fine.
For a single point it can be argued that any of the caveats mentioned above partially invalidates our proposed interpretation but realistically the contribution of each feature would "thereabouts" in terms of percentages for the prediction of a single observation.
|
Can I scale and then interpret shap values as percent contribution to the prediction?
Almost yes. There are a few caveats regarding directly interpreting the scaled SHAP values, as the percentage contributions of our final classification prediction for a single observation.
Raw SHAP v
|
41,841
|
Sampling uniformly from the set of partitions of a set?
|
The "appropriate exponential distribution" for the number of bins $K$ is not exponential by any means. It actually is the discrete distribution of parameter $n$ given by
$$\Pr(K=k)\ \propto\ \frac{k^n}{k!}\tag{1.4}$$
for $k=1, 2, \ldots.$
In the original paper, A. J. Stam argued as follows. When a partition $\pi$ consists of $|\pi|\ge 1$ nonempty subsets of $\{1,2,\ldots,n\},$ the conditional probability of realizing $\pi$ under this sample scheme after randomly choosing $K=k$ bins is
$$\Pr(\pi\mid K=k) = k^{(|\pi|)}k^{-n} = \frac{k(k-1)\cdots(k-|\pi|+1)}{k^n}.\tag{1.5}$$
(The equation numbering is Stam's, but I have slightly changed the notation of the variables.)
Let's justify this formula. The denominator counts the number of sequences of bin choices: each random toss can land in one of the $k$ bins and all $n$ tosses are independent. Thus each sequence of tosses has chance $k^{-n}.$ However, two sequences of tosses determine the same partition when the bins for one can be re-ordered to correspond to the bins of the other. If we order the bins so that the first partition occupies bins $1,2,\ldots, |\pi|,$ then the possible equivalent re-orderings are determined by putting bin $1$ at one of the $k$ positions, bin $2$ at one of the $k-1$ remaining positions, and so on, until we have repositioned bin $|\pi|.$ Thus, any partition $\pi$ of $|\pi|$ pieces created by tossing $n$ numbers into $k$ bins shows up multiple times as counted by the numerator of $(1.5).$
In conjunction with $(1.4),$ the unconditional probability may be found by summing over all possible values of $K.$ Evidently values $K=0, 1, \ldots, |\pi|-1$ cannot give $\pi,$ justifying the change in the summation index in the penultimate step:
$$\begin{aligned}
\Pr(\pi) &= \sum_{k=0}^\infty\Pr(\pi\mid K=k)\Pr(K=k) \\
&\propto\sum_{k=0}^\infty\frac{k(k-1)\cdots(k-|\pi|+1)}{k^n}\,\frac{k^n}{k!}\\
&= \sum_{k=|\pi|}^\infty\frac{1}{(k-|\pi|)!} = \sum_{i=0}^\infty \frac{1}{i!} = e.
\end{aligned}$$
Because this probability does not depend on $\pi,$ the distribution is uniform, QED.
As a consequence of this argument we recover Dobinski's formula for the number of partitions $T_n$ of $\{1,2,\ldots, n\},$ because it must be the normalizing constant of this distribution, whence (employing $(1.4)$)
$$T_n = \Pr(\pi)^{-1} = \left(\frac{e}{\sum_{k=1}^\infty \Pr(K=k)}\right)^{-1} = \frac{1}{e}\sum_{k=1} \frac{k^n}{k!}.\tag{1.1}$$
For ways to sample from discrete distributions like $(1.4),$ see our thread on this topic. The alias method is efficient.
|
Sampling uniformly from the set of partitions of a set?
|
The "appropriate exponential distribution" for the number of bins $K$ is not exponential by any means. It actually is the discrete distribution of parameter $n$ given by
$$\Pr(K=k)\ \propto\ \frac{k^
|
Sampling uniformly from the set of partitions of a set?
The "appropriate exponential distribution" for the number of bins $K$ is not exponential by any means. It actually is the discrete distribution of parameter $n$ given by
$$\Pr(K=k)\ \propto\ \frac{k^n}{k!}\tag{1.4}$$
for $k=1, 2, \ldots.$
In the original paper, A. J. Stam argued as follows. When a partition $\pi$ consists of $|\pi|\ge 1$ nonempty subsets of $\{1,2,\ldots,n\},$ the conditional probability of realizing $\pi$ under this sample scheme after randomly choosing $K=k$ bins is
$$\Pr(\pi\mid K=k) = k^{(|\pi|)}k^{-n} = \frac{k(k-1)\cdots(k-|\pi|+1)}{k^n}.\tag{1.5}$$
(The equation numbering is Stam's, but I have slightly changed the notation of the variables.)
Let's justify this formula. The denominator counts the number of sequences of bin choices: each random toss can land in one of the $k$ bins and all $n$ tosses are independent. Thus each sequence of tosses has chance $k^{-n}.$ However, two sequences of tosses determine the same partition when the bins for one can be re-ordered to correspond to the bins of the other. If we order the bins so that the first partition occupies bins $1,2,\ldots, |\pi|,$ then the possible equivalent re-orderings are determined by putting bin $1$ at one of the $k$ positions, bin $2$ at one of the $k-1$ remaining positions, and so on, until we have repositioned bin $|\pi|.$ Thus, any partition $\pi$ of $|\pi|$ pieces created by tossing $n$ numbers into $k$ bins shows up multiple times as counted by the numerator of $(1.5).$
In conjunction with $(1.4),$ the unconditional probability may be found by summing over all possible values of $K.$ Evidently values $K=0, 1, \ldots, |\pi|-1$ cannot give $\pi,$ justifying the change in the summation index in the penultimate step:
$$\begin{aligned}
\Pr(\pi) &= \sum_{k=0}^\infty\Pr(\pi\mid K=k)\Pr(K=k) \\
&\propto\sum_{k=0}^\infty\frac{k(k-1)\cdots(k-|\pi|+1)}{k^n}\,\frac{k^n}{k!}\\
&= \sum_{k=|\pi|}^\infty\frac{1}{(k-|\pi|)!} = \sum_{i=0}^\infty \frac{1}{i!} = e.
\end{aligned}$$
Because this probability does not depend on $\pi,$ the distribution is uniform, QED.
As a consequence of this argument we recover Dobinski's formula for the number of partitions $T_n$ of $\{1,2,\ldots, n\},$ because it must be the normalizing constant of this distribution, whence (employing $(1.4)$)
$$T_n = \Pr(\pi)^{-1} = \left(\frac{e}{\sum_{k=1}^\infty \Pr(K=k)}\right)^{-1} = \frac{1}{e}\sum_{k=1} \frac{k^n}{k!}.\tag{1.1}$$
For ways to sample from discrete distributions like $(1.4),$ see our thread on this topic. The alias method is efficient.
|
Sampling uniformly from the set of partitions of a set?
The "appropriate exponential distribution" for the number of bins $K$ is not exponential by any means. It actually is the discrete distribution of parameter $n$ given by
$$\Pr(K=k)\ \propto\ \frac{k^
|
41,842
|
What's the DGP in causal inference?
|
The Data Generating Process interpretation is matter of debate. For examples read here: What is a 'true' model? and What does a data-generating process (DGP) actually mean?
If we want make causal inference properly we have to intend the DGP as in Pearl literature, then his properties are encoded in a Pearl Structural Causal Models (SCM). So if the DGP is known we can consider DGP and SCM as synonyms, otherwise the SCM encode all we know/assume about the DGP. For an exhaustive exposition of SCM read here: do(x) operator meaning? (the Carlos Cinelli answer).
The linear true model is the more used object/name in econometrics literature in place of DGP. In econometric literature the role of causality is important even if many times is not properly treated (for example read: Under which assumptions a regression can be interpreted causally? and Is the linearity assumption in linear regression merely a definition of $\epsilon$? and references therein). Now, remaining simple and closest as possible to the econometrics literature the proper way for make causal inference is consider the true model as an linear SCM.
So:
$y = X’ \theta + \epsilon$
we can interpret all three objects $[y,X, \epsilon]$ as random variables ($X$ is a vector). Read here for more details: linear causal model
Then, the following conditions hold:
In the SCM the sign $=$ stand for “:=” (definition). The causality, implied by definition/assumption, move from the right to the left. Given the variables involved, the SCM is not another representation for the joint probability distribution of them; the SCM is related but different thing. Indeed, in general, for any SCM is possible to find many joint distributions that caracterize the variables involved and, conversely, for any joint distribution of them is possible to find many SCM which these variables come from. However any SCM imply some restrictions for the joint distribution of the variables. These restrictions are the basis for any causal inference.
In our case (above), even if $y$ and $X$ can be observable variables we do not stay in a situation like regression case, where given $(y,X)$, as a consequence, the errors/residuals and parameters are given too (read here: Zero conditional expectation of error in OLS regression )
Indeed $\epsilon$ and $X$ are completely free random variables, and $\theta$s free parameters, and for this reason we can have both situations: $\epsilon$ is a structural causal error that can be exogenous $E[\epsilon|X]=0$ or not $E[\epsilon|X] \neq 0$. The only usual implicit assumption is that $\epsilon$ have zero mean; quite obvious assumption for any kind of errors. Note that about exogeneity the notation $E[]$ do not stand for usual expectation but for interventional expectation. More formally, and for avoid ambiguity, do-operator would be needed. Exogenous error $E[\epsilon|do(X)]=0$ or not $E[\epsilon|do(X)] \neq 0$. Read here for more about that: conditional and interventional expectation and again here do(x) operator meaning?
The above SCM can be interpreted as a decomposition where things that we put on the right and side part, represent causal assumptions (also the linearity is an implicit causal assumption here). In particular what we put in $X$ and what remain in $\epsilon$ is an assumption too and, then, exogeneity or not is a restriction/assumption about both.
It is easy to simulate $y$ starting from $X$ and $\epsilon$; the previous sign $:=$ stand for that. I talked about random variables in a single equation but the extension to random processes and/or system follow naturally.
People can says: "but in real data I can observe $y$ and $X$ not $\epsilon$". It’s true, indeed $\epsilon$, the structural causal error, is an unobservable variable and, at least in general, exogeneity is an untestable assumption about that.
Moreover people have to refrain them to “visualize” the structural error and its properties, exogeneity as first, from something like data fitting … this is precisely a pure statistical procedure that we have to avoid.
If some identification condition (that are causal assumptions too, like exogeneity) are assumed … is possible to arrive at testable (in statistical sense) implications.
This list is surely uncompleted and, even if I can try to defend what I said, I do not give any warranty about these. I stay here for learn. I’m happy if something above can be add and/or correct. The only condition I want is that all can be documented in causal inference literature.
|
What's the DGP in causal inference?
|
The Data Generating Process interpretation is matter of debate. For examples read here: What is a 'true' model? and What does a data-generating process (DGP) actually mean?
If we want make causal infe
|
What's the DGP in causal inference?
The Data Generating Process interpretation is matter of debate. For examples read here: What is a 'true' model? and What does a data-generating process (DGP) actually mean?
If we want make causal inference properly we have to intend the DGP as in Pearl literature, then his properties are encoded in a Pearl Structural Causal Models (SCM). So if the DGP is known we can consider DGP and SCM as synonyms, otherwise the SCM encode all we know/assume about the DGP. For an exhaustive exposition of SCM read here: do(x) operator meaning? (the Carlos Cinelli answer).
The linear true model is the more used object/name in econometrics literature in place of DGP. In econometric literature the role of causality is important even if many times is not properly treated (for example read: Under which assumptions a regression can be interpreted causally? and Is the linearity assumption in linear regression merely a definition of $\epsilon$? and references therein). Now, remaining simple and closest as possible to the econometrics literature the proper way for make causal inference is consider the true model as an linear SCM.
So:
$y = X’ \theta + \epsilon$
we can interpret all three objects $[y,X, \epsilon]$ as random variables ($X$ is a vector). Read here for more details: linear causal model
Then, the following conditions hold:
In the SCM the sign $=$ stand for “:=” (definition). The causality, implied by definition/assumption, move from the right to the left. Given the variables involved, the SCM is not another representation for the joint probability distribution of them; the SCM is related but different thing. Indeed, in general, for any SCM is possible to find many joint distributions that caracterize the variables involved and, conversely, for any joint distribution of them is possible to find many SCM which these variables come from. However any SCM imply some restrictions for the joint distribution of the variables. These restrictions are the basis for any causal inference.
In our case (above), even if $y$ and $X$ can be observable variables we do not stay in a situation like regression case, where given $(y,X)$, as a consequence, the errors/residuals and parameters are given too (read here: Zero conditional expectation of error in OLS regression )
Indeed $\epsilon$ and $X$ are completely free random variables, and $\theta$s free parameters, and for this reason we can have both situations: $\epsilon$ is a structural causal error that can be exogenous $E[\epsilon|X]=0$ or not $E[\epsilon|X] \neq 0$. The only usual implicit assumption is that $\epsilon$ have zero mean; quite obvious assumption for any kind of errors. Note that about exogeneity the notation $E[]$ do not stand for usual expectation but for interventional expectation. More formally, and for avoid ambiguity, do-operator would be needed. Exogenous error $E[\epsilon|do(X)]=0$ or not $E[\epsilon|do(X)] \neq 0$. Read here for more about that: conditional and interventional expectation and again here do(x) operator meaning?
The above SCM can be interpreted as a decomposition where things that we put on the right and side part, represent causal assumptions (also the linearity is an implicit causal assumption here). In particular what we put in $X$ and what remain in $\epsilon$ is an assumption too and, then, exogeneity or not is a restriction/assumption about both.
It is easy to simulate $y$ starting from $X$ and $\epsilon$; the previous sign $:=$ stand for that. I talked about random variables in a single equation but the extension to random processes and/or system follow naturally.
People can says: "but in real data I can observe $y$ and $X$ not $\epsilon$". It’s true, indeed $\epsilon$, the structural causal error, is an unobservable variable and, at least in general, exogeneity is an untestable assumption about that.
Moreover people have to refrain them to “visualize” the structural error and its properties, exogeneity as first, from something like data fitting … this is precisely a pure statistical procedure that we have to avoid.
If some identification condition (that are causal assumptions too, like exogeneity) are assumed … is possible to arrive at testable (in statistical sense) implications.
This list is surely uncompleted and, even if I can try to defend what I said, I do not give any warranty about these. I stay here for learn. I’m happy if something above can be add and/or correct. The only condition I want is that all can be documented in causal inference literature.
|
What's the DGP in causal inference?
The Data Generating Process interpretation is matter of debate. For examples read here: What is a 'true' model? and What does a data-generating process (DGP) actually mean?
If we want make causal infe
|
41,843
|
Does it make sense to regularize the loss function for binary/multi-class classification?
|
Depending on what you are trying to do with your CNN, regularization may indeed make sense. Pruning your network by regularization to make it sparse has two main advantages:
It simplifies the network, making training and computation faster and easier;
It prevents overfitting, and allows to make sure your network will generalize well on new data.
An intuitive way to reach these objectives is to perform $L_0$ regularization, which penalizes parameters than are not strictly equal to 0. This induces sparsity in the network. This procedure is described in the following paper : https://arxiv.org/abs/1712.01312
The authors also discuss other kinds of regularization (namely $L_1$ regularization).
|
Does it make sense to regularize the loss function for binary/multi-class classification?
|
Depending on what you are trying to do with your CNN, regularization may indeed make sense. Pruning your network by regularization to make it sparse has two main advantages:
It simplifies the network
|
Does it make sense to regularize the loss function for binary/multi-class classification?
Depending on what you are trying to do with your CNN, regularization may indeed make sense. Pruning your network by regularization to make it sparse has two main advantages:
It simplifies the network, making training and computation faster and easier;
It prevents overfitting, and allows to make sure your network will generalize well on new data.
An intuitive way to reach these objectives is to perform $L_0$ regularization, which penalizes parameters than are not strictly equal to 0. This induces sparsity in the network. This procedure is described in the following paper : https://arxiv.org/abs/1712.01312
The authors also discuss other kinds of regularization (namely $L_1$ regularization).
|
Does it make sense to regularize the loss function for binary/multi-class classification?
Depending on what you are trying to do with your CNN, regularization may indeed make sense. Pruning your network by regularization to make it sparse has two main advantages:
It simplifies the network
|
41,844
|
What is the name of this quantity?
|
This is a measure of squared dispersion between two sets of values but not between paired values. I doubt it has a name.
Indeed you do not need to have the same number of $x$ and $y$ values, and using the $\frac1n$ calculation of variance, you can say:
$$\frac{1}{mn}\sum_{i=1}^m\sum_{j=1}^n(x_i-y_j)^2\qquad \\\qquad\qquad= (\bar x - \bar y)^2 + \widehat{\text{Var}}(x) +\widehat{\text{Var}}(y)$$
so a combination of the squared distance between the centres of the two sets plus the square dispersions of the individual sets.
|
What is the name of this quantity?
|
This is a measure of squared dispersion between two sets of values but not between paired values. I doubt it has a name.
Indeed you do not need to have the same number of $x$ and $y$ values, and using
|
What is the name of this quantity?
This is a measure of squared dispersion between two sets of values but not between paired values. I doubt it has a name.
Indeed you do not need to have the same number of $x$ and $y$ values, and using the $\frac1n$ calculation of variance, you can say:
$$\frac{1}{mn}\sum_{i=1}^m\sum_{j=1}^n(x_i-y_j)^2\qquad \\\qquad\qquad= (\bar x - \bar y)^2 + \widehat{\text{Var}}(x) +\widehat{\text{Var}}(y)$$
so a combination of the squared distance between the centres of the two sets plus the square dispersions of the individual sets.
|
What is the name of this quantity?
This is a measure of squared dispersion between two sets of values but not between paired values. I doubt it has a name.
Indeed you do not need to have the same number of $x$ and $y$ values, and using
|
41,845
|
Gelman & Hill's 'no', 'complete' and 'partial' pooling in the context of longitudinal data
|
It's helpful to start with the equation of the multilevel model, which applies whether the data is cross-sectional (multilevel) or person-period (longitudinal):
At level 1 (within cluster): $y_{ij} = \beta_{0j} + e_{ij}, e_{ij}\sim N(0, \sigma_e^2)$
and at level 2 (between cluster): $\beta_{0j} = \gamma_{00} + u_{0j}, u_{0j}\sim N(0, \sigma_u^2)$
In the longitudinal context, $\gamma_{00}$ is the grand mean estimated from all the observed data points - the average value of the outcome y. If not all individuals are measured the same number of times, then this is becomes a weighted mean of the outcome. The random intercept $u_{0j}$ is how much each person's mean outcome value deviates from the grand mean. The spread of person mean deviations around $\gamma_{00}$ can be summarized by a variance estimate ($\sigma_u^2$).
Partial pooling is determined by the number of repeated observations and the level 1 and level 2 variances (essentially how much of the total variation is at the person level). So if person A had outcome data on two occasions and person B had outcome data on 5 occasions, the $u_{0j}$ prediction for person A is going to be pulled back toward $\gamma_{00}$ moreso than the prediction for person B.
Translating these ideas back and forth between the multilevel (groups as clusters) and the longitudinal (persons as clusters) cases takes time and effort, but is a critical part of fully understanding mixed effects models. If something still isn't clear, please post a comment.
|
Gelman & Hill's 'no', 'complete' and 'partial' pooling in the context of longitudinal data
|
It's helpful to start with the equation of the multilevel model, which applies whether the data is cross-sectional (multilevel) or person-period (longitudinal):
At level 1 (within cluster): $y_{ij} =
|
Gelman & Hill's 'no', 'complete' and 'partial' pooling in the context of longitudinal data
It's helpful to start with the equation of the multilevel model, which applies whether the data is cross-sectional (multilevel) or person-period (longitudinal):
At level 1 (within cluster): $y_{ij} = \beta_{0j} + e_{ij}, e_{ij}\sim N(0, \sigma_e^2)$
and at level 2 (between cluster): $\beta_{0j} = \gamma_{00} + u_{0j}, u_{0j}\sim N(0, \sigma_u^2)$
In the longitudinal context, $\gamma_{00}$ is the grand mean estimated from all the observed data points - the average value of the outcome y. If not all individuals are measured the same number of times, then this is becomes a weighted mean of the outcome. The random intercept $u_{0j}$ is how much each person's mean outcome value deviates from the grand mean. The spread of person mean deviations around $\gamma_{00}$ can be summarized by a variance estimate ($\sigma_u^2$).
Partial pooling is determined by the number of repeated observations and the level 1 and level 2 variances (essentially how much of the total variation is at the person level). So if person A had outcome data on two occasions and person B had outcome data on 5 occasions, the $u_{0j}$ prediction for person A is going to be pulled back toward $\gamma_{00}$ moreso than the prediction for person B.
Translating these ideas back and forth between the multilevel (groups as clusters) and the longitudinal (persons as clusters) cases takes time and effort, but is a critical part of fully understanding mixed effects models. If something still isn't clear, please post a comment.
|
Gelman & Hill's 'no', 'complete' and 'partial' pooling in the context of longitudinal data
It's helpful to start with the equation of the multilevel model, which applies whether the data is cross-sectional (multilevel) or person-period (longitudinal):
At level 1 (within cluster): $y_{ij} =
|
41,846
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standard confidence intervals?
|
You always have to be careful about how closely your data fit the underlying assumptions of the model. In your linear regression, the severe heteroscedasticity and occasional large outliers, with most of the highest-magnitude outliers tending to be positive rather than negative, probably play the biggest part in the (relatively minor) widening of your bootstrapped confidence intervals versus those from OLS. Those characteristics are not consistent with the normal-distribution constant-variance assumptions about errors that underlie OLS. Also, remember that bootstrapping necessarily omits about 1/3 of data points from each sample while it double-counts a similar proportion of the data. So slopes from samples that omit the large outliers could differ substantially from those that double-count them, leading to larger variance among bootstrap slope estimates.
In terms of learning about how to fix the regression, don't be afraid to do a log transform on the prices. I doubt that any of the actual prices were negative or 0,* so there's no theoretical reason to avoid such a transformation. Interpretation of regression coefficients is easy. Say you do a log2 transformation of the prices. Then the coefficient for SqFtLot is doublings in price per extra square foot rather than extra dollars (or other currency amount) per extra square foot. The confidence intervals for regression coefficients will also be expressed in the log2 scale. If you transform them back to dollars they will be skewed about the point estimate, but they still are confidence intervals with the same coverage.
The log transform would also prevent you from predicting unrealistic negative prices for some of the transactions, as your model does.
In terms of learning about bootstrap estimates of confidence intervals, you should be aware that these are not always so straightforward as they can seem at first. If the quantity that you're calculating isn't what's called pivotal (having a distribution that is independent of unknown parameter values), then bootstrapping can lead to unreliable results. This becomes a particular problem when the quantity has a built-in bias; then the point estimate from the data can lie outside the naively calculated bootstrap CI! There are several ways to calculate bootstrap CI that often (but not always) can mitigate these problems. See this extensive discussion or the hundreds of other links on this site tagged confidence-interval and bootstrap.
*There can be 0-price sales, but those are typically special deals like within-family transactions or property swaps that should not be included in this type of analysis. Cleaning the data appropriately to the intended analysis is always an important early step.
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standa
|
You always have to be careful about how closely your data fit the underlying assumptions of the model. In your linear regression, the severe heteroscedasticity and occasional large outliers, with most
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standard confidence intervals?
You always have to be careful about how closely your data fit the underlying assumptions of the model. In your linear regression, the severe heteroscedasticity and occasional large outliers, with most of the highest-magnitude outliers tending to be positive rather than negative, probably play the biggest part in the (relatively minor) widening of your bootstrapped confidence intervals versus those from OLS. Those characteristics are not consistent with the normal-distribution constant-variance assumptions about errors that underlie OLS. Also, remember that bootstrapping necessarily omits about 1/3 of data points from each sample while it double-counts a similar proportion of the data. So slopes from samples that omit the large outliers could differ substantially from those that double-count them, leading to larger variance among bootstrap slope estimates.
In terms of learning about how to fix the regression, don't be afraid to do a log transform on the prices. I doubt that any of the actual prices were negative or 0,* so there's no theoretical reason to avoid such a transformation. Interpretation of regression coefficients is easy. Say you do a log2 transformation of the prices. Then the coefficient for SqFtLot is doublings in price per extra square foot rather than extra dollars (or other currency amount) per extra square foot. The confidence intervals for regression coefficients will also be expressed in the log2 scale. If you transform them back to dollars they will be skewed about the point estimate, but they still are confidence intervals with the same coverage.
The log transform would also prevent you from predicting unrealistic negative prices for some of the transactions, as your model does.
In terms of learning about bootstrap estimates of confidence intervals, you should be aware that these are not always so straightforward as they can seem at first. If the quantity that you're calculating isn't what's called pivotal (having a distribution that is independent of unknown parameter values), then bootstrapping can lead to unreliable results. This becomes a particular problem when the quantity has a built-in bias; then the point estimate from the data can lie outside the naively calculated bootstrap CI! There are several ways to calculate bootstrap CI that often (but not always) can mitigate these problems. See this extensive discussion or the hundreds of other links on this site tagged confidence-interval and bootstrap.
*There can be 0-price sales, but those are typically special deals like within-family transactions or property swaps that should not be included in this type of analysis. Cleaning the data appropriately to the intended analysis is always an important early step.
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standa
You always have to be careful about how closely your data fit the underlying assumptions of the model. In your linear regression, the severe heteroscedasticity and occasional large outliers, with most
|
41,847
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standard confidence intervals?
|
This can happen when your data are not independent but instead have some dependence structure. For example, consider homes from across the country with some being in large expensive cities while some are in more affordable small towns. Homes in the same locale are likely to have similar prices and to have prices vary similarly.
Overall, we may not care explicitly about a given locale: we just want a model for something we think is stationary like sale price per square foot of living space. We might then estimate a fixed effect for each town or locale to compensate for differences in the mean price per square foot.
However, we might only care about the divergences of price/sqft from the overall average, and we may want to allow for uncertainty in pricing that is related to locale. One way to model this is to have a random effect for the town or locale. This doesn't affect the fixed parameter estimates, but it does tend to account for the data not all being independent. (Random effects are a way of doing correlation modeling.) Thus standard errors are larger.
I suspect if you had included random effects or done some correlation modeling, your confidence intervals would be closer to what you see with the bootstrap. Finally, the fact that your data are not independent also can bias the bootstrap estimates. It is possible that a better model which accounts for correlations or random effect would have larger confidence intervals than your bootstrap intervals.
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standa
|
This can happen when your data are not independent but instead have some dependence structure. For example, consider homes from across the country with some being in large expensive cities while some
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standard confidence intervals?
This can happen when your data are not independent but instead have some dependence structure. For example, consider homes from across the country with some being in large expensive cities while some are in more affordable small towns. Homes in the same locale are likely to have similar prices and to have prices vary similarly.
Overall, we may not care explicitly about a given locale: we just want a model for something we think is stationary like sale price per square foot of living space. We might then estimate a fixed effect for each town or locale to compensate for differences in the mean price per square foot.
However, we might only care about the divergences of price/sqft from the overall average, and we may want to allow for uncertainty in pricing that is related to locale. One way to model this is to have a random effect for the town or locale. This doesn't affect the fixed parameter estimates, but it does tend to account for the data not all being independent. (Random effects are a way of doing correlation modeling.) Thus standard errors are larger.
I suspect if you had included random effects or done some correlation modeling, your confidence intervals would be closer to what you see with the bootstrap. Finally, the fact that your data are not independent also can bias the bootstrap estimates. It is possible that a better model which accounts for correlations or random effect would have larger confidence intervals than your bootstrap intervals.
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standa
This can happen when your data are not independent but instead have some dependence structure. For example, consider homes from across the country with some being in large expensive cities while some
|
41,848
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standard confidence intervals?
|
CI from OLS assume normal distribution of coefficient estimators. When using bootstrap you are characterizing the empirical distribution of coefficient estimators (which could be non-normal). Hence if there exist some deviations of OLS assumptions (conditional normality, homoscedasticity and independent observations), the empirical distribution of coefficient estimators will be different from the theoretical normal distribution and the CI will be different.
As your graph of residuals shows you have problems on the OLS assumptions. Have you done a normality test on the residuals? I would bet that they do not pass a normality test.
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standa
|
CI from OLS assume normal distribution of coefficient estimators. When using bootstrap you are characterizing the empirical distribution of coefficient estimators (which could be non-normal). Hence if
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standard confidence intervals?
CI from OLS assume normal distribution of coefficient estimators. When using bootstrap you are characterizing the empirical distribution of coefficient estimators (which could be non-normal). Hence if there exist some deviations of OLS assumptions (conditional normality, homoscedasticity and independent observations), the empirical distribution of coefficient estimators will be different from the theoretical normal distribution and the CI will be different.
As your graph of residuals shows you have problems on the OLS assumptions. Have you done a normality test on the residuals? I would bet that they do not pass a normality test.
|
Why are my bootstrap confidence intervals for regression coefficients consistently wider than standa
CI from OLS assume normal distribution of coefficient estimators. When using bootstrap you are characterizing the empirical distribution of coefficient estimators (which could be non-normal). Hence if
|
41,849
|
How to handle different important variables, including overlapping information, in regression?
|
Should I adjust for town or not? It seems, et adding town kills the effect. How you handle such situations?
Yes, you will want to include town in your model because it is a confounder according to the DAG.
How does it differ if "town" is added as a another level into model + (1 |town)?
Not only is it a confounder according to your DAG but you also have repeated measures. Provided you have sufficient of them, random intercepts are a good way to do this. Fitting fixed effects will also achieve the same thing. You might want to check the answer here, to a related question:
How do random effects adjust for confounding in a model?
|
How to handle different important variables, including overlapping information, in regression?
|
Should I adjust for town or not? It seems, et adding town kills the effect. How you handle such situations?
Yes, you will want to include town in your model because it is a confounder according to t
|
How to handle different important variables, including overlapping information, in regression?
Should I adjust for town or not? It seems, et adding town kills the effect. How you handle such situations?
Yes, you will want to include town in your model because it is a confounder according to the DAG.
How does it differ if "town" is added as a another level into model + (1 |town)?
Not only is it a confounder according to your DAG but you also have repeated measures. Provided you have sufficient of them, random intercepts are a good way to do this. Fitting fixed effects will also achieve the same thing. You might want to check the answer here, to a related question:
How do random effects adjust for confounding in a model?
|
How to handle different important variables, including overlapping information, in regression?
Should I adjust for town or not? It seems, et adding town kills the effect. How you handle such situations?
Yes, you will want to include town in your model because it is a confounder according to t
|
41,850
|
How to interprete Discriminator and Generator loss in WGAN
|
A few points to make
You mentioned you're using WGAN, I strongly suggest using gradient penalty instead of clipping if you aren't already.
The generator loss is not very meaningful in WGAN. Also in general, there is nothing wrong with negative numbers at all.
Read the WGAN paper. The theory is dense, but there are important details there.
For example, you should train your discriminator more than your generator. Recommended values are 5-10 discriminator iters per generator iter.
The discriminator loss is (an approximation of) the negative Wasserstein distance between the generator distribution and the data distribution. So it's actually very interpretable and useful for diagnostics.
|
How to interprete Discriminator and Generator loss in WGAN
|
A few points to make
You mentioned you're using WGAN, I strongly suggest using gradient penalty instead of clipping if you aren't already.
The generator loss is not very meaningful in WGAN. Also in g
|
How to interprete Discriminator and Generator loss in WGAN
A few points to make
You mentioned you're using WGAN, I strongly suggest using gradient penalty instead of clipping if you aren't already.
The generator loss is not very meaningful in WGAN. Also in general, there is nothing wrong with negative numbers at all.
Read the WGAN paper. The theory is dense, but there are important details there.
For example, you should train your discriminator more than your generator. Recommended values are 5-10 discriminator iters per generator iter.
The discriminator loss is (an approximation of) the negative Wasserstein distance between the generator distribution and the data distribution. So it's actually very interpretable and useful for diagnostics.
|
How to interprete Discriminator and Generator loss in WGAN
A few points to make
You mentioned you're using WGAN, I strongly suggest using gradient penalty instead of clipping if you aren't already.
The generator loss is not very meaningful in WGAN. Also in g
|
41,851
|
What exactly does a proper scoring rule want to do?
|
Your thinking is correct. I recommend Gneiting & Raftery (2007, JASA) for an in-depth discussion of scoring rules.
A scoring rule $S$ is a mapping that takes a probabilistic prediction $\hat{p}$ and a corresponding observed outcome $y$ to a loss value $S(\hat{p},y)$. In our application, $\hat{p}$ is just a single number (that will depend on predictors, see below), but in a numerical prediction, it will be an entire predictive density. We typically take averages of this loss value over multiple instances $y_i$, each with its own (predictor-dependent) prediction $\hat{p}_i$. And we usually aim at minimizing this average loss (though the opposite convention also exists; it's always a good idea to verify how a particular paper's scoring rules are oriented).
A scoring rule is proper if it is minimized in expectation by the true probability.
Now, in the present case, the key aspect is that we have only two predictors, both of which can only take the values $0$ and $1$. In this setting, we cannot distinguish between two instances with different outcomes $y$ but the same predictor settings, so we cannot have different (probabilistic) predictions for two instances with the same predictor settings. Having a hard $0$ prediction for an instance with $y=0$, but a hard $1$ prediction for an instance with $y=1$ is simply not possible if the two instances have the same predictor values. All we can have is a probabilistic prediction $\hat{p}_{ij}$ in the case where the first predictor has value $i$ and the second predictor has value $j$.
Now, let's assume that the true probability of $y=1$, given that the first predictor has value $i$ and the second predictor has value $j$, is $p_{ij}$. What is the expected value of the Brier score of our probabilistic prediction $\hat{p}_{ij}$?
Well, with a probability of $p_{ij}$, we have $y=1$ and a contribution of $(1-\hat{p}_{ij})^2$ to the Brier score, and with a probability of $1-p_{ij}$, we have $y=0$ and a contribution of $\hat{p}_{ij}^2$ to the Brier score. The total expected constribution to the Brier score is
$$ p_{ij}(1-\hat{p}_{ij})^2+(1-p_{ij})\hat{p}_{ij}^2. $$
Differentiating this expression with respect to $\hat{p}_{ij}$ and setting the derivative equal to zero, we find that this expected score is minimized when $\hat{p}_{ij}=p_{ij}$, so we have found that the Brier score is proper in our situation. It aims at getting the correct (specifically: calibrated and sharp) probabilistic prediction.
And of course, if now a third predictor turns up that would allow perfect $0-1$ predictions, then the Brier score of this expanded model would be lower than that of the two-predictor model's predictions (namely, zero). Which is exactly how it should be.
|
What exactly does a proper scoring rule want to do?
|
Your thinking is correct. I recommend Gneiting & Raftery (2007, JASA) for an in-depth discussion of scoring rules.
A scoring rule $S$ is a mapping that takes a probabilistic prediction $\hat{p}$ and a
|
What exactly does a proper scoring rule want to do?
Your thinking is correct. I recommend Gneiting & Raftery (2007, JASA) for an in-depth discussion of scoring rules.
A scoring rule $S$ is a mapping that takes a probabilistic prediction $\hat{p}$ and a corresponding observed outcome $y$ to a loss value $S(\hat{p},y)$. In our application, $\hat{p}$ is just a single number (that will depend on predictors, see below), but in a numerical prediction, it will be an entire predictive density. We typically take averages of this loss value over multiple instances $y_i$, each with its own (predictor-dependent) prediction $\hat{p}_i$. And we usually aim at minimizing this average loss (though the opposite convention also exists; it's always a good idea to verify how a particular paper's scoring rules are oriented).
A scoring rule is proper if it is minimized in expectation by the true probability.
Now, in the present case, the key aspect is that we have only two predictors, both of which can only take the values $0$ and $1$. In this setting, we cannot distinguish between two instances with different outcomes $y$ but the same predictor settings, so we cannot have different (probabilistic) predictions for two instances with the same predictor settings. Having a hard $0$ prediction for an instance with $y=0$, but a hard $1$ prediction for an instance with $y=1$ is simply not possible if the two instances have the same predictor values. All we can have is a probabilistic prediction $\hat{p}_{ij}$ in the case where the first predictor has value $i$ and the second predictor has value $j$.
Now, let's assume that the true probability of $y=1$, given that the first predictor has value $i$ and the second predictor has value $j$, is $p_{ij}$. What is the expected value of the Brier score of our probabilistic prediction $\hat{p}_{ij}$?
Well, with a probability of $p_{ij}$, we have $y=1$ and a contribution of $(1-\hat{p}_{ij})^2$ to the Brier score, and with a probability of $1-p_{ij}$, we have $y=0$ and a contribution of $\hat{p}_{ij}^2$ to the Brier score. The total expected constribution to the Brier score is
$$ p_{ij}(1-\hat{p}_{ij})^2+(1-p_{ij})\hat{p}_{ij}^2. $$
Differentiating this expression with respect to $\hat{p}_{ij}$ and setting the derivative equal to zero, we find that this expected score is minimized when $\hat{p}_{ij}=p_{ij}$, so we have found that the Brier score is proper in our situation. It aims at getting the correct (specifically: calibrated and sharp) probabilistic prediction.
And of course, if now a third predictor turns up that would allow perfect $0-1$ predictions, then the Brier score of this expanded model would be lower than that of the two-predictor model's predictions (namely, zero). Which is exactly how it should be.
|
What exactly does a proper scoring rule want to do?
Your thinking is correct. I recommend Gneiting & Raftery (2007, JASA) for an in-depth discussion of scoring rules.
A scoring rule $S$ is a mapping that takes a probabilistic prediction $\hat{p}$ and a
|
41,852
|
What exactly does a proper scoring rule want to do?
|
I kind of figured out the answer as I was writing the question, so a few days later, I'm going to write a self-answer.
The right answer is that the distribution of $Y$ when $x_1=0$ and $x_2=0$ is that $P(Y=1) = 0.73$. We get a discrete outcome of either a $0$ or a $1$, but the model should be able figure out that the distribution is $Bernoulli(0.73)$. If the model misses this fact, the (proper) scoring rule should penalize the model.
Ditto for the other combinations of $x_1$ and $x_2$.
Thinking about a more real-life problem, a photograph might look like it is of a dog, and perhaps there is a $99.99\%$ chance of being a dog; given $10,000$ such photos, all but $1$ would be a dog. However, one of those times, it would happen to be a cat. A good model will pick up on the fact that such a photo could, occasionally, be of a cat, and the proper scoring wants to find the model that is able to say that a cat might occasionally look like that dog.
|
What exactly does a proper scoring rule want to do?
|
I kind of figured out the answer as I was writing the question, so a few days later, I'm going to write a self-answer.
The right answer is that the distribution of $Y$ when $x_1=0$ and $x_2=0$ is that
|
What exactly does a proper scoring rule want to do?
I kind of figured out the answer as I was writing the question, so a few days later, I'm going to write a self-answer.
The right answer is that the distribution of $Y$ when $x_1=0$ and $x_2=0$ is that $P(Y=1) = 0.73$. We get a discrete outcome of either a $0$ or a $1$, but the model should be able figure out that the distribution is $Bernoulli(0.73)$. If the model misses this fact, the (proper) scoring rule should penalize the model.
Ditto for the other combinations of $x_1$ and $x_2$.
Thinking about a more real-life problem, a photograph might look like it is of a dog, and perhaps there is a $99.99\%$ chance of being a dog; given $10,000$ such photos, all but $1$ would be a dog. However, one of those times, it would happen to be a cat. A good model will pick up on the fact that such a photo could, occasionally, be of a cat, and the proper scoring wants to find the model that is able to say that a cat might occasionally look like that dog.
|
What exactly does a proper scoring rule want to do?
I kind of figured out the answer as I was writing the question, so a few days later, I'm going to write a self-answer.
The right answer is that the distribution of $Y$ when $x_1=0$ and $x_2=0$ is that
|
41,853
|
What exactly does a proper scoring rule want to do?
|
Scoring rules assess the quality of a probabilistic forecast; i.e. a prediction with some uncertainty measure associated to it. This could be something simple like a mean and standard deviation, or it could be a full probability distribution (or something in between!). The idea behind a (proper) scoring rule is to encourage 'honest' probabilistic predictions. Suppose I am estimating an unknown parameter $\theta$ by some probability distribution $P(\hat{\theta})$, and suppose we are using a positively oriented score (bigger is better). I will increase my score if
The mean implied by $P(\hat{\theta})$ is close to $\theta$ and the uncertainty is relatively small
The mean implied by $P(\hat{\theta})$ is far from $\theta$ but my uncertainty is relatively large
If I get small uncertainty with large error, I will have poor score. Likewise, an accurate but uncertain forecast will be penalised.
Essentially, I am trying to create a well-calibrated forecast. I am embracing uncertainty, and trying to identify an appropriate amount of uncertainty in my predictions.
|
What exactly does a proper scoring rule want to do?
|
Scoring rules assess the quality of a probabilistic forecast; i.e. a prediction with some uncertainty measure associated to it. This could be something simple like a mean and standard deviation, or it
|
What exactly does a proper scoring rule want to do?
Scoring rules assess the quality of a probabilistic forecast; i.e. a prediction with some uncertainty measure associated to it. This could be something simple like a mean and standard deviation, or it could be a full probability distribution (or something in between!). The idea behind a (proper) scoring rule is to encourage 'honest' probabilistic predictions. Suppose I am estimating an unknown parameter $\theta$ by some probability distribution $P(\hat{\theta})$, and suppose we are using a positively oriented score (bigger is better). I will increase my score if
The mean implied by $P(\hat{\theta})$ is close to $\theta$ and the uncertainty is relatively small
The mean implied by $P(\hat{\theta})$ is far from $\theta$ but my uncertainty is relatively large
If I get small uncertainty with large error, I will have poor score. Likewise, an accurate but uncertain forecast will be penalised.
Essentially, I am trying to create a well-calibrated forecast. I am embracing uncertainty, and trying to identify an appropriate amount of uncertainty in my predictions.
|
What exactly does a proper scoring rule want to do?
Scoring rules assess the quality of a probabilistic forecast; i.e. a prediction with some uncertainty measure associated to it. This could be something simple like a mean and standard deviation, or it
|
41,854
|
Mixed Effects Model: Writing out and interpreting coefficients on Level 1, 2, and 3 Models
|
Question: Have I written formulas that convey the correct mathematical representation for my three-level model? Is my written interpretation of the coefficients in the equations correct?
Unfortunately, no. The model you are fitting:
lmer(value ~ A + B + C + (1|ID/stimulus_num), data = data)
has the following features:
A global intercept (fixed effect)
Fixed effects for A, B and C, which vary at the participant level, $i$, so these will generate 3 fixed effects estimates
Random intercepts for ID and the ID:stimulus_num interaction, which means that stimulus_num is nested in ID, so this will generate 2 random intercepts estimates
Therefore we expect the model to produce 7 estimates (4 fixed effects, 2 random interecps and 1 unit-level residual). When writing out the mathematics of a specific model it is always good to know how many, and what kind of, estimates are expected
It looks like your equations are on the right track, but note that, for level 2 and 3 you only need the first equation - the others would be needed only if you were fitting random slopes. So the level 2 and 3 equations are only random intercepts. Also, your index notation is not quite right because, with the usual convention, the first index should refer to the lowest level, not the highest. Perhaps you were confused because commonly $i$,$j$ and $k$ refer to levels 1, 2 and 3, whereas you are using $t$,$k$ and $i$
Also, you have the fixed effects indexed by $ikt$ which, apart from being in the wrong order is incorect because they only vary at the the individual ($i$) level.
Thus to write the mutilevel model equations we will adopt standard notation (for instance in the book by Snijders and Bosker), using subscripts ordered from level 1 to level 3. For example $Y_{tki}$ refers to time point $t$ in stimulus $k$ in participant $i$.
Thus, for level 1 we can write:
$$
Y_{tki} = \beta_{0ki} + \beta_{1}A_{i} + \beta_{2}B_{i} + \beta_{3}C_{i} + e_{tki}
$$
where $\beta_{0ki}$ is the intercept in level-2 unit (stimulus) $k$ within level-3 unit (participant) $i$. For this we have the level 2 model:
$$
\beta_{0ki} = \gamma_{00i} + u_{0ki}
$$
where $\gamma_{00i}$ is the average intercept in level-3 unit (participant) $i$. For this average intercept we have the level-3 model:
$$
\gamma_{00i} = \pi_{000} + r_{00i}
$$
Putting it all together we have:
$$
Y_{tki} = \pi_{000} + r_{00i} + u_{0ki} + \beta_{1}A_{i} + \beta_{2}B_{i} + \beta_{3}C_{i} + e_{tki}
$$
and this would result in 7 estimates from the model, as expected - 4 fixed effects: $\pi_{000}$, $\beta_1$, $\beta_2$, and $\beta_3$; and 3 random effects: $r_{00i}$, $u_{0ki}$, and $e_{tki}$
Regarding interpretation:
$\pi_{000}$ is the global intercept: it is the mean of the time series' when the fixed effects, A, B and C are all at zero.
$\beta_1$, represent the expected difference in the time series' for a 1 unit change in A, with the other fixed effects held constant. Sinmilarly for $\beta_2$ and $\beta_3$
$r_{00i}$ is the random intercept for individuals and the software will estimate a variance for this
$u_{0ki}$ is the random intercept for stimulus and the software will estimate a variance for this
$e_{tki}$ is the unit-level (time series level) residual and the software will estimate a variance for this.
|
Mixed Effects Model: Writing out and interpreting coefficients on Level 1, 2, and 3 Models
|
Question: Have I written formulas that convey the correct mathematical representation for my three-level model? Is my written interpretation of the coefficients in the equations correct?
Unfortunatel
|
Mixed Effects Model: Writing out and interpreting coefficients on Level 1, 2, and 3 Models
Question: Have I written formulas that convey the correct mathematical representation for my three-level model? Is my written interpretation of the coefficients in the equations correct?
Unfortunately, no. The model you are fitting:
lmer(value ~ A + B + C + (1|ID/stimulus_num), data = data)
has the following features:
A global intercept (fixed effect)
Fixed effects for A, B and C, which vary at the participant level, $i$, so these will generate 3 fixed effects estimates
Random intercepts for ID and the ID:stimulus_num interaction, which means that stimulus_num is nested in ID, so this will generate 2 random intercepts estimates
Therefore we expect the model to produce 7 estimates (4 fixed effects, 2 random interecps and 1 unit-level residual). When writing out the mathematics of a specific model it is always good to know how many, and what kind of, estimates are expected
It looks like your equations are on the right track, but note that, for level 2 and 3 you only need the first equation - the others would be needed only if you were fitting random slopes. So the level 2 and 3 equations are only random intercepts. Also, your index notation is not quite right because, with the usual convention, the first index should refer to the lowest level, not the highest. Perhaps you were confused because commonly $i$,$j$ and $k$ refer to levels 1, 2 and 3, whereas you are using $t$,$k$ and $i$
Also, you have the fixed effects indexed by $ikt$ which, apart from being in the wrong order is incorect because they only vary at the the individual ($i$) level.
Thus to write the mutilevel model equations we will adopt standard notation (for instance in the book by Snijders and Bosker), using subscripts ordered from level 1 to level 3. For example $Y_{tki}$ refers to time point $t$ in stimulus $k$ in participant $i$.
Thus, for level 1 we can write:
$$
Y_{tki} = \beta_{0ki} + \beta_{1}A_{i} + \beta_{2}B_{i} + \beta_{3}C_{i} + e_{tki}
$$
where $\beta_{0ki}$ is the intercept in level-2 unit (stimulus) $k$ within level-3 unit (participant) $i$. For this we have the level 2 model:
$$
\beta_{0ki} = \gamma_{00i} + u_{0ki}
$$
where $\gamma_{00i}$ is the average intercept in level-3 unit (participant) $i$. For this average intercept we have the level-3 model:
$$
\gamma_{00i} = \pi_{000} + r_{00i}
$$
Putting it all together we have:
$$
Y_{tki} = \pi_{000} + r_{00i} + u_{0ki} + \beta_{1}A_{i} + \beta_{2}B_{i} + \beta_{3}C_{i} + e_{tki}
$$
and this would result in 7 estimates from the model, as expected - 4 fixed effects: $\pi_{000}$, $\beta_1$, $\beta_2$, and $\beta_3$; and 3 random effects: $r_{00i}$, $u_{0ki}$, and $e_{tki}$
Regarding interpretation:
$\pi_{000}$ is the global intercept: it is the mean of the time series' when the fixed effects, A, B and C are all at zero.
$\beta_1$, represent the expected difference in the time series' for a 1 unit change in A, with the other fixed effects held constant. Sinmilarly for $\beta_2$ and $\beta_3$
$r_{00i}$ is the random intercept for individuals and the software will estimate a variance for this
$u_{0ki}$ is the random intercept for stimulus and the software will estimate a variance for this
$e_{tki}$ is the unit-level (time series level) residual and the software will estimate a variance for this.
|
Mixed Effects Model: Writing out and interpreting coefficients on Level 1, 2, and 3 Models
Question: Have I written formulas that convey the correct mathematical representation for my three-level model? Is my written interpretation of the coefficients in the equations correct?
Unfortunatel
|
41,855
|
Does this distribution have a name? $p(x) \propto |x|^a \exp\left(-\frac{1}{2} (x-b)^2 \right)$
|
TL;DR We can develop a uniformly bounded rejection sampler, which will generate a variate from the desired density requiring an expected (worst case) $\approx 4.75$ independent uniform variates. Although the set-up is fairly straightforward/fast, it is non-trivial and this approach may be slow with varying parameters (e.g., Gibbs Sampling).
This is a tricky distribution. As mentioned in the comments, this is nearly the Generalized Gamma distribution (with $p=2$ and $d =a+1$), except for the fact that $b$ is not a true location parameter because it occurs only in the second term. I have been searching for a while now, and am unable to find a reference to this distribution anywhere.
A Uniformly Bounded Rejection Sampler
In this paper by Luc Devroye, a uniformly bounded rejection sampler is constructed for the Generalized Inverse Gaussian distribution, and we can follow a similar approach.
Let me redefine the density (up to a constant) as
$$f(x) = x^{\alpha -1}\exp{\left(-\gamma(x-\mu)^2\right)}, x > 0$$
First step is to prove that the density is log-concave. This can be done by showing that
$f'(x)/f(x)$ is monotone decreasing for $x > 0$
$(\log f(x))'' < 0$ for all $x > 0$.
These properties hold whenever $\alpha > 1$. Next, we note that the mode occurs at
$$m = \frac{\mu}{2} + \frac{1}{2\gamma}\sqrt{\gamma\left(2\alpha + \gamma\mu^2 -2\right)}.$$ Define
\begin{align*}
\phi(x) &= f(m)^{-1}f(x+m) \\
\psi(x) &= \log \phi(x) = (\alpha-1)\log(x+m) - \gamma(x+m-\mu)^2 - \log f(m)
\end{align*}
so that $\phi(0) = 1$ and $\psi(0) = 0$. We will also need the derivative of $\psi(x)$
$$\psi'(x) = \frac{\alpha-1}{x+m} - 2\gamma(x+m-\mu).$$
Finally, you will need to find $s, t > 0$ such that $\psi(-s) = \psi(t) = -1.$ Newton-Raphson should converge fairly quickly, by iterating
$$t_0 > 0, \ t_{n+1} = t_n - \frac{\psi(t_n) + 1}{\psi'(t_n)} \quad\text{and}\quad s_0 < 0, \ s_{n+1} = s_n + \frac{\psi(-s_n) + 1}{\psi'(-s_n)}.$$
The Algorithm
INPUTS: s, t, psi, psi'
Compute p = 1/psi'(-s)
Compute r = -1/psi'(t)
Compute t' = t + r*psi(t)
Compute s' = s + p*psi(-s)
Compute q = t' + s'
REPEAT
Generate U, V, W ~ U(0, 1)
if U < q/(q + r + p) then X = -s' + qV
elseif U < (q + r)/(q + r + p) then X = t' - r*log(V)
else X = -s' + p*log(V)
if X > t' then chi = exp(psi(t) + psi'(t)*(x - t))
elseif X > -s' then chi = 1
else chi = exp(psi(-s) + psi'(-s)*(x + s))
UNTIL log(W) <= psi(X) - log(chi)
RETURN X + m
Discussion
This approach has some advantages as well as some important disadvantages. The main advantage is that the algorithm is uniformly bounded.
Theorem. Using the algorithm above, the expected number of iterations required to generate a sample is at most $1.581977\ldots$.
Since three independent uniform variates are required at each iteration, we expect that a draw from $f$ can be generated at the (worst case) cost of generating $\approx 4.75$ uniform variates.
Unfortunately, the set-up is non-trivial. In particular, Newton-Raphson is required to find $s$ and $t$. This approach can be approved by explicitly finding $s, t > 0$ such that $\psi(-s) = \psi(t) = -\rho$ for any $\rho > 0$. I am working on this right now, but have yet to find anything. It is also worth noting that this approach may fail when $\alpha < 1$, which may or may not be a problem depending on the application.
In summary, if you are looking to draw a large number of samples from $f$ for fixed parameters, then this method is robust and efficient. If you are looking for a single draw with varying parameters (e.g., Gibbs Sampling) then the required set-up of this algorithm is a substantial disadvantage.
|
Does this distribution have a name? $p(x) \propto |x|^a \exp\left(-\frac{1}{2} (x-b)^2 \right)$
|
TL;DR We can develop a uniformly bounded rejection sampler, which will generate a variate from the desired density requiring an expected (worst case) $\approx 4.75$ independent uniform variates. Altho
|
Does this distribution have a name? $p(x) \propto |x|^a \exp\left(-\frac{1}{2} (x-b)^2 \right)$
TL;DR We can develop a uniformly bounded rejection sampler, which will generate a variate from the desired density requiring an expected (worst case) $\approx 4.75$ independent uniform variates. Although the set-up is fairly straightforward/fast, it is non-trivial and this approach may be slow with varying parameters (e.g., Gibbs Sampling).
This is a tricky distribution. As mentioned in the comments, this is nearly the Generalized Gamma distribution (with $p=2$ and $d =a+1$), except for the fact that $b$ is not a true location parameter because it occurs only in the second term. I have been searching for a while now, and am unable to find a reference to this distribution anywhere.
A Uniformly Bounded Rejection Sampler
In this paper by Luc Devroye, a uniformly bounded rejection sampler is constructed for the Generalized Inverse Gaussian distribution, and we can follow a similar approach.
Let me redefine the density (up to a constant) as
$$f(x) = x^{\alpha -1}\exp{\left(-\gamma(x-\mu)^2\right)}, x > 0$$
First step is to prove that the density is log-concave. This can be done by showing that
$f'(x)/f(x)$ is monotone decreasing for $x > 0$
$(\log f(x))'' < 0$ for all $x > 0$.
These properties hold whenever $\alpha > 1$. Next, we note that the mode occurs at
$$m = \frac{\mu}{2} + \frac{1}{2\gamma}\sqrt{\gamma\left(2\alpha + \gamma\mu^2 -2\right)}.$$ Define
\begin{align*}
\phi(x) &= f(m)^{-1}f(x+m) \\
\psi(x) &= \log \phi(x) = (\alpha-1)\log(x+m) - \gamma(x+m-\mu)^2 - \log f(m)
\end{align*}
so that $\phi(0) = 1$ and $\psi(0) = 0$. We will also need the derivative of $\psi(x)$
$$\psi'(x) = \frac{\alpha-1}{x+m} - 2\gamma(x+m-\mu).$$
Finally, you will need to find $s, t > 0$ such that $\psi(-s) = \psi(t) = -1.$ Newton-Raphson should converge fairly quickly, by iterating
$$t_0 > 0, \ t_{n+1} = t_n - \frac{\psi(t_n) + 1}{\psi'(t_n)} \quad\text{and}\quad s_0 < 0, \ s_{n+1} = s_n + \frac{\psi(-s_n) + 1}{\psi'(-s_n)}.$$
The Algorithm
INPUTS: s, t, psi, psi'
Compute p = 1/psi'(-s)
Compute r = -1/psi'(t)
Compute t' = t + r*psi(t)
Compute s' = s + p*psi(-s)
Compute q = t' + s'
REPEAT
Generate U, V, W ~ U(0, 1)
if U < q/(q + r + p) then X = -s' + qV
elseif U < (q + r)/(q + r + p) then X = t' - r*log(V)
else X = -s' + p*log(V)
if X > t' then chi = exp(psi(t) + psi'(t)*(x - t))
elseif X > -s' then chi = 1
else chi = exp(psi(-s) + psi'(-s)*(x + s))
UNTIL log(W) <= psi(X) - log(chi)
RETURN X + m
Discussion
This approach has some advantages as well as some important disadvantages. The main advantage is that the algorithm is uniformly bounded.
Theorem. Using the algorithm above, the expected number of iterations required to generate a sample is at most $1.581977\ldots$.
Since three independent uniform variates are required at each iteration, we expect that a draw from $f$ can be generated at the (worst case) cost of generating $\approx 4.75$ uniform variates.
Unfortunately, the set-up is non-trivial. In particular, Newton-Raphson is required to find $s$ and $t$. This approach can be approved by explicitly finding $s, t > 0$ such that $\psi(-s) = \psi(t) = -\rho$ for any $\rho > 0$. I am working on this right now, but have yet to find anything. It is also worth noting that this approach may fail when $\alpha < 1$, which may or may not be a problem depending on the application.
In summary, if you are looking to draw a large number of samples from $f$ for fixed parameters, then this method is robust and efficient. If you are looking for a single draw with varying parameters (e.g., Gibbs Sampling) then the required set-up of this algorithm is a substantial disadvantage.
|
Does this distribution have a name? $p(x) \propto |x|^a \exp\left(-\frac{1}{2} (x-b)^2 \right)$
TL;DR We can develop a uniformly bounded rejection sampler, which will generate a variate from the desired density requiring an expected (worst case) $\approx 4.75$ independent uniform variates. Altho
|
41,856
|
Intuitive explanation of PSIS-LOO cross-validation
|
I'm a scientist, not a statistician, but given that it has been almost a year since this question was first asked and it still has not received any answers, I will do my best to provide some insight. Revisions/corrections to my answer are welcome as I have also spent considerable time and effort trying to figure out this paper. I'll mention here that I too have been pleased by this method's performance and will encourage anyone reading this answer to give it a shot if you have not already.
To start from the top: importance sampling is useful when you are interested in a probability distribution $f(x)$ but are unable to sample from it using MCMC due to computational and/or practical constraints. Fortunately, you can instead sample from an approximating distribution $g(x)$ and use those samples to make inferences about $f(x)$. To do so, simply adjust the weight of each sample to $f(x)/g(x)$. In principle, this adjustment corrects both 1) the overrepresentation of samples that are more prevalent in the sampling distribution $g(x)$ than in the target distribution $f(x)$, and 2) the underrepresentation of samples that are rare in $g(x)$ but common in $f(x)$.
The problems that are commonly described about importance sampling arise from this second set of samples. Depending on the overlap between the sampling distribution and the target distribution, cases that are rare in $g(x)$ but common in $f(x)$ will have huge importance weights and will strongly influence any inferences you make about the composition of the target distribution $f(x)$. Often, the tails of the resulting distribution are erratic. Based on my understanding, the primary contribution of the PSIS paper is to observe that these weights follow the Pareto principle, sometimes called the "80/20 rule" (although the numbers in this case are arbitrary). Therefore, rather than take these weights at face value, the authors demonstrate that you can fit them to a generalized Pareto distribution, thus smoothing over their values and removing many of these issues observed with importance sampling in general.
So what does this have to do with leave-one-out cross-validation (LOO-CV)? To recap LOO-CV, you are typically interested in gathering uncertainty statistics about your model by iterating through your dataset, removing a data point, and repeating the analysis (e.g. MCMC sampling). Most of us would describe the tediousness of this process, namely the resampling step, as a "computational and/or practical constraint", and the authors of this paper appear to agree. Their solution is to skip resampling entirely and instead use PSIS to reweigh the samples obtained the first time with the complete dataset, thus saving considerable amounts of time while still providing the uncertainty statistics of interest. As they demonstrate, this provides results that are nearly identical to classical LOO-CV, but with a far lower computational footprint.
To summarize PSIS-LOO:
Use the complete data set to generate a large pool of samples from the sampling distribution $g(x)$.
Iterate through each data point and remove it from the data set.
Use Pareto-smoothed importance sampling to reweigh the samples obtained in step one to this new target distribution $f(x)$.
After repeating for the full dataset, compute the parameter statistics using LOO-CV as you previously would.
Again, if you are a statistician reading this and you are thinking "this answer is wrong", then I would appreciate any corrections, revisions, or addendums.
|
Intuitive explanation of PSIS-LOO cross-validation
|
I'm a scientist, not a statistician, but given that it has been almost a year since this question was first asked and it still has not received any answers, I will do my best to provide some insight.
|
Intuitive explanation of PSIS-LOO cross-validation
I'm a scientist, not a statistician, but given that it has been almost a year since this question was first asked and it still has not received any answers, I will do my best to provide some insight. Revisions/corrections to my answer are welcome as I have also spent considerable time and effort trying to figure out this paper. I'll mention here that I too have been pleased by this method's performance and will encourage anyone reading this answer to give it a shot if you have not already.
To start from the top: importance sampling is useful when you are interested in a probability distribution $f(x)$ but are unable to sample from it using MCMC due to computational and/or practical constraints. Fortunately, you can instead sample from an approximating distribution $g(x)$ and use those samples to make inferences about $f(x)$. To do so, simply adjust the weight of each sample to $f(x)/g(x)$. In principle, this adjustment corrects both 1) the overrepresentation of samples that are more prevalent in the sampling distribution $g(x)$ than in the target distribution $f(x)$, and 2) the underrepresentation of samples that are rare in $g(x)$ but common in $f(x)$.
The problems that are commonly described about importance sampling arise from this second set of samples. Depending on the overlap between the sampling distribution and the target distribution, cases that are rare in $g(x)$ but common in $f(x)$ will have huge importance weights and will strongly influence any inferences you make about the composition of the target distribution $f(x)$. Often, the tails of the resulting distribution are erratic. Based on my understanding, the primary contribution of the PSIS paper is to observe that these weights follow the Pareto principle, sometimes called the "80/20 rule" (although the numbers in this case are arbitrary). Therefore, rather than take these weights at face value, the authors demonstrate that you can fit them to a generalized Pareto distribution, thus smoothing over their values and removing many of these issues observed with importance sampling in general.
So what does this have to do with leave-one-out cross-validation (LOO-CV)? To recap LOO-CV, you are typically interested in gathering uncertainty statistics about your model by iterating through your dataset, removing a data point, and repeating the analysis (e.g. MCMC sampling). Most of us would describe the tediousness of this process, namely the resampling step, as a "computational and/or practical constraint", and the authors of this paper appear to agree. Their solution is to skip resampling entirely and instead use PSIS to reweigh the samples obtained the first time with the complete dataset, thus saving considerable amounts of time while still providing the uncertainty statistics of interest. As they demonstrate, this provides results that are nearly identical to classical LOO-CV, but with a far lower computational footprint.
To summarize PSIS-LOO:
Use the complete data set to generate a large pool of samples from the sampling distribution $g(x)$.
Iterate through each data point and remove it from the data set.
Use Pareto-smoothed importance sampling to reweigh the samples obtained in step one to this new target distribution $f(x)$.
After repeating for the full dataset, compute the parameter statistics using LOO-CV as you previously would.
Again, if you are a statistician reading this and you are thinking "this answer is wrong", then I would appreciate any corrections, revisions, or addendums.
|
Intuitive explanation of PSIS-LOO cross-validation
I'm a scientist, not a statistician, but given that it has been almost a year since this question was first asked and it still has not received any answers, I will do my best to provide some insight.
|
41,857
|
Why is bootstrapping p-values not just finding the null in the bootstrap samples?
|
Hi: I think what you're missing is that, for bootstrapping to work, not only does the distribution of the "thing" being bootstrapped have to converge to a distibution under the null but that "thing" has to be pivotal. By pivotal, it is meant that the statistic being bootstrapped doesn't depend on the parameter being tested under the null.
But, if we use the bootstrapped samples themselves, then, clearly, that's not true. If we generate samples from the original population, then the bootstrapped distribution of the sample clearly depends on the value of $\mu$.
The idea of bootstrapping is to be able to avoid a distributional assumption about the original sample by using the fact that the constructed pivotal statistic from the sample ( hopefully) converges to a distribution. This way, we can look at the resulting distribution of the pivotal statistic and see where the actual statistic from the original sample falls within that distribution. I hope that helps.
|
Why is bootstrapping p-values not just finding the null in the bootstrap samples?
|
Hi: I think what you're missing is that, for bootstrapping to work, not only does the distribution of the "thing" being bootstrapped have to converge to a distibution under the null but that "thing"
|
Why is bootstrapping p-values not just finding the null in the bootstrap samples?
Hi: I think what you're missing is that, for bootstrapping to work, not only does the distribution of the "thing" being bootstrapped have to converge to a distibution under the null but that "thing" has to be pivotal. By pivotal, it is meant that the statistic being bootstrapped doesn't depend on the parameter being tested under the null.
But, if we use the bootstrapped samples themselves, then, clearly, that's not true. If we generate samples from the original population, then the bootstrapped distribution of the sample clearly depends on the value of $\mu$.
The idea of bootstrapping is to be able to avoid a distributional assumption about the original sample by using the fact that the constructed pivotal statistic from the sample ( hopefully) converges to a distribution. This way, we can look at the resulting distribution of the pivotal statistic and see where the actual statistic from the original sample falls within that distribution. I hope that helps.
|
Why is bootstrapping p-values not just finding the null in the bootstrap samples?
Hi: I think what you're missing is that, for bootstrapping to work, not only does the distribution of the "thing" being bootstrapped have to converge to a distibution under the null but that "thing"
|
41,858
|
How do I find the UMVUE of $\sqrt{\alpha}$ here?
|
You are going down the correct path—when you are looking for the UMVUE in a parametric problem, the simplest method in most cases is to use the Lehmann–Scheffé theorem, which says that if you can form an unbiased estimator from a complete sufficient statistic, then that estimator is the unique UMVUE. Now, from your stipulated distribution, you get the likelihood function:
$$\begin{aligned}
L_\mathbf{x}(\alpha)
&= \prod_{i=1}^n f_X(x_i|\alpha) \\[6pt]
&= \prod_{i=1}^n 2 \alpha x_i \exp(-\alpha x_i^2) \\[6pt]
&= (2 \alpha)^n \bigg( \prod_{i=1}^n x_i \bigg) \exp \bigg( -\alpha \sum_{i=1}^n x_i^2 \bigg). \\[6pt]
\end{aligned}$$
This likelihood function can be decomposed as:
$$L_\mathbf{x}(\alpha) = h(\mathbf{x}) g_\alpha(T(\mathbf{x})),$$
using the sufficient statistic $T(\mathbf{x}) \equiv \sum_{i=1}^n x_i^2$. With some additional work (which I will leave to you) it can be shown that this statistic is complete, so we can use it as a basis for the Lehmann–Scheffé method. This all simply repeats what you have already figured out, but with some clearer presentation.
To actually form an estimator from this complete sufficient statistic, you will generally need to find its distribution, so that you can form an appropriate function of the statistic to obtain an unbiased estimator. Letting $Y_i = X_i^2$ we have $Y_1,...,Y_n \sim \text{IID Exp}(\alpha)$ (where $\alpha$ is the rate parameter), so you then obtain $T(\mathbf{X}) = \sum_{i=1}^n X_i^2 \sim \text{Gamma}(n, \alpha)$. If you have a look at the moments of this distribution, you will see that the expected value is $n/\alpha$, so at the moment the parameter of interest is entering into the expectation in an inverted form. To deal with that, you may be able to form an unbiased estimator of the form:
$$\widehat{\sqrt{\alpha}} \equiv \frac{\text{const}}{\sqrt{T(\mathbf{x})}} \sim \text{InvNakagami}(\text{parameters}).$$
where the estimator has a scaled inverse-Nakagami distribution with some parameters to be determined. With a bit of work, you should be able to find the appropriate parameters for this distribution and the appropriate scaling constant to get an unbiased estimator. Using the Lehmann–Scheffé theorem, we then conclude that this is the unique UMVUE in this problem. Once you have the form of this estimator, and its distribution, it should also be easy to find its variance, and compare this to the Cramer-Rao lower bound.
|
How do I find the UMVUE of $\sqrt{\alpha}$ here?
|
You are going down the correct path—when you are looking for the UMVUE in a parametric problem, the simplest method in most cases is to use the Lehmann–Scheffé theorem, which says that if you can form
|
How do I find the UMVUE of $\sqrt{\alpha}$ here?
You are going down the correct path—when you are looking for the UMVUE in a parametric problem, the simplest method in most cases is to use the Lehmann–Scheffé theorem, which says that if you can form an unbiased estimator from a complete sufficient statistic, then that estimator is the unique UMVUE. Now, from your stipulated distribution, you get the likelihood function:
$$\begin{aligned}
L_\mathbf{x}(\alpha)
&= \prod_{i=1}^n f_X(x_i|\alpha) \\[6pt]
&= \prod_{i=1}^n 2 \alpha x_i \exp(-\alpha x_i^2) \\[6pt]
&= (2 \alpha)^n \bigg( \prod_{i=1}^n x_i \bigg) \exp \bigg( -\alpha \sum_{i=1}^n x_i^2 \bigg). \\[6pt]
\end{aligned}$$
This likelihood function can be decomposed as:
$$L_\mathbf{x}(\alpha) = h(\mathbf{x}) g_\alpha(T(\mathbf{x})),$$
using the sufficient statistic $T(\mathbf{x}) \equiv \sum_{i=1}^n x_i^2$. With some additional work (which I will leave to you) it can be shown that this statistic is complete, so we can use it as a basis for the Lehmann–Scheffé method. This all simply repeats what you have already figured out, but with some clearer presentation.
To actually form an estimator from this complete sufficient statistic, you will generally need to find its distribution, so that you can form an appropriate function of the statistic to obtain an unbiased estimator. Letting $Y_i = X_i^2$ we have $Y_1,...,Y_n \sim \text{IID Exp}(\alpha)$ (where $\alpha$ is the rate parameter), so you then obtain $T(\mathbf{X}) = \sum_{i=1}^n X_i^2 \sim \text{Gamma}(n, \alpha)$. If you have a look at the moments of this distribution, you will see that the expected value is $n/\alpha$, so at the moment the parameter of interest is entering into the expectation in an inverted form. To deal with that, you may be able to form an unbiased estimator of the form:
$$\widehat{\sqrt{\alpha}} \equiv \frac{\text{const}}{\sqrt{T(\mathbf{x})}} \sim \text{InvNakagami}(\text{parameters}).$$
where the estimator has a scaled inverse-Nakagami distribution with some parameters to be determined. With a bit of work, you should be able to find the appropriate parameters for this distribution and the appropriate scaling constant to get an unbiased estimator. Using the Lehmann–Scheffé theorem, we then conclude that this is the unique UMVUE in this problem. Once you have the form of this estimator, and its distribution, it should also be easy to find its variance, and compare this to the Cramer-Rao lower bound.
|
How do I find the UMVUE of $\sqrt{\alpha}$ here?
You are going down the correct path—when you are looking for the UMVUE in a parametric problem, the simplest method in most cases is to use the Lehmann–Scheffé theorem, which says that if you can form
|
41,859
|
auto.arima vs arima.sim
|
No, you did not make an error in your code (that I can see).
It is unfortunately the case that automatic ARIMA model selection rarely recovers the model that was used to simulate the input data. This is simply a consequence of there usually being very little data compared to the number of parameters to be estimated. After all, we can't just count the two AR parameters the true data generating process used - auto.arima() searches through many different possible models. And if seasonality might be an issue, the number of possible models increases yet further.
I have long had a nagging suspicion that the main reason why ARIMA is popular is not because it does a great job in modeling real time series, but because it is a time series model that you can actually prove mathematical theorems about. (Exponential smoothing, as an alternative, used to be mainly a heuristic, and was only put on solid mathematical grounds via state space models about 15 years ago.) This suspicion of mine is reinforced by the description of how the original forecasting competition by Makridakis - where ARIMA method already performed poorly - was received by statisticians (Hyndman, 2020, IJF - very much recommended):
Many of the discussants seem to have been enamoured with ARIMA models. ... At times, the discussion degenerated to questioning the competency of the authors.
Also, it seems like there are few truly convincing real-life examples of moving average processes. If you restricted your search to AR(p) models only, auto.arima() might be better at finding the true model. And even then, the parameters would only be estimated and differ from the true values, of course.
Note that I do not think this is a shortcoming of the auto.arima() implementation. Quite to the contrary. There are few approaches to fitting ARIMA models that I would trust more. Rob Hyndman is probably the one person who knows most about this. For instance, I would not assume that a Box-Jenkins approach would be better.
In any case, what you did is a great exercise to understand the shortcomings of ARIMA fitting. I wish many more time series analysis and forecasting courses included such a short lesson in humility. I would encourage you to play around a little more with your approach, maybe include seasonal models, or other AR or even MA parameters, or allow or disallow the Box-Cox transformation.
All that said, why do you want to fit an ARIMA model? Most people will want to do so to forecast. (Yes, there are also other motivations.) In this case, it would make sense to expand your experiments to also include the forecasting step. This is what I do below. I simulated 100 (or 1000) historical data points plus 50 holdout data points using arima.sim(), then fitted an ARIMA model using auto.arima(), calculated 90% interval forecasts using forecast(), counted how often these interval forecasts covered the true value and finally plotted the average coverage against the forecast horizon. Results and code are below. It would seem to me that at least the interval forecasts are "good enough". (The apparent upward trend in the plot for a history length of 100 looks intriguing. I don't know where it comes from.)
library(forecast)
n_sims <- 1000
n_history <- 100
n_forecast <- 50
true_model <- list(ar=c(0.3,0.5))
confidence_level <- 0.9
hit <- matrix(NA,nrow=n_sims,ncol=n_forecast)
pb <- winProgressBar(max=n_sims)
for ( ii in 1:n_sims ) {
setWinProgressBar(pb,ii,paste(ii,"of",n_sims))
set.seed(ii) # for reproducibility
actuals <- arima.sim(model=true_model,n=n_history+n_forecast)
model <- auto.arima(actuals[1:n_history])
fcst <- forecast(model,h=n_forecast,level=confidence_level)
hit[ii,] <- fcst$lower<=tail(actuals,n_forecast) & tail(actuals,n_forecast)<=fcst$upper
}
close(pb)
coverage <- apply(hit,2,sum)/n_sims
plot(coverage,xlab="Forecast horizon",ylab="Coverage",las=1,
main=paste("History length:",n_history),
type="o",pch=19,ylim=range(c(coverage,confidence_level)))
abline(h=confidence_level,lwd=2,col="red")
An alternative you might want to explore would be to compare the expectation point forecast against various possible "optimal" cases, e.g.:
against the point forecast if the true model is known (including the parameters)
against the point forecast if the true model and the Box-Cox transformation is known, but the parameters need to be estimated
against the point forecast if the true model is known, but the Box-Cox transformation and the parameters need to be estimated
against the point forecast if auto.arima() can only choose among AR(p) models for $p=0, \dots, 5$ or so
...
|
auto.arima vs arima.sim
|
No, you did not make an error in your code (that I can see).
It is unfortunately the case that automatic ARIMA model selection rarely recovers the model that was used to simulate the input data. This
|
auto.arima vs arima.sim
No, you did not make an error in your code (that I can see).
It is unfortunately the case that automatic ARIMA model selection rarely recovers the model that was used to simulate the input data. This is simply a consequence of there usually being very little data compared to the number of parameters to be estimated. After all, we can't just count the two AR parameters the true data generating process used - auto.arima() searches through many different possible models. And if seasonality might be an issue, the number of possible models increases yet further.
I have long had a nagging suspicion that the main reason why ARIMA is popular is not because it does a great job in modeling real time series, but because it is a time series model that you can actually prove mathematical theorems about. (Exponential smoothing, as an alternative, used to be mainly a heuristic, and was only put on solid mathematical grounds via state space models about 15 years ago.) This suspicion of mine is reinforced by the description of how the original forecasting competition by Makridakis - where ARIMA method already performed poorly - was received by statisticians (Hyndman, 2020, IJF - very much recommended):
Many of the discussants seem to have been enamoured with ARIMA models. ... At times, the discussion degenerated to questioning the competency of the authors.
Also, it seems like there are few truly convincing real-life examples of moving average processes. If you restricted your search to AR(p) models only, auto.arima() might be better at finding the true model. And even then, the parameters would only be estimated and differ from the true values, of course.
Note that I do not think this is a shortcoming of the auto.arima() implementation. Quite to the contrary. There are few approaches to fitting ARIMA models that I would trust more. Rob Hyndman is probably the one person who knows most about this. For instance, I would not assume that a Box-Jenkins approach would be better.
In any case, what you did is a great exercise to understand the shortcomings of ARIMA fitting. I wish many more time series analysis and forecasting courses included such a short lesson in humility. I would encourage you to play around a little more with your approach, maybe include seasonal models, or other AR or even MA parameters, or allow or disallow the Box-Cox transformation.
All that said, why do you want to fit an ARIMA model? Most people will want to do so to forecast. (Yes, there are also other motivations.) In this case, it would make sense to expand your experiments to also include the forecasting step. This is what I do below. I simulated 100 (or 1000) historical data points plus 50 holdout data points using arima.sim(), then fitted an ARIMA model using auto.arima(), calculated 90% interval forecasts using forecast(), counted how often these interval forecasts covered the true value and finally plotted the average coverage against the forecast horizon. Results and code are below. It would seem to me that at least the interval forecasts are "good enough". (The apparent upward trend in the plot for a history length of 100 looks intriguing. I don't know where it comes from.)
library(forecast)
n_sims <- 1000
n_history <- 100
n_forecast <- 50
true_model <- list(ar=c(0.3,0.5))
confidence_level <- 0.9
hit <- matrix(NA,nrow=n_sims,ncol=n_forecast)
pb <- winProgressBar(max=n_sims)
for ( ii in 1:n_sims ) {
setWinProgressBar(pb,ii,paste(ii,"of",n_sims))
set.seed(ii) # for reproducibility
actuals <- arima.sim(model=true_model,n=n_history+n_forecast)
model <- auto.arima(actuals[1:n_history])
fcst <- forecast(model,h=n_forecast,level=confidence_level)
hit[ii,] <- fcst$lower<=tail(actuals,n_forecast) & tail(actuals,n_forecast)<=fcst$upper
}
close(pb)
coverage <- apply(hit,2,sum)/n_sims
plot(coverage,xlab="Forecast horizon",ylab="Coverage",las=1,
main=paste("History length:",n_history),
type="o",pch=19,ylim=range(c(coverage,confidence_level)))
abline(h=confidence_level,lwd=2,col="red")
An alternative you might want to explore would be to compare the expectation point forecast against various possible "optimal" cases, e.g.:
against the point forecast if the true model is known (including the parameters)
against the point forecast if the true model and the Box-Cox transformation is known, but the parameters need to be estimated
against the point forecast if the true model is known, but the Box-Cox transformation and the parameters need to be estimated
against the point forecast if auto.arima() can only choose among AR(p) models for $p=0, \dots, 5$ or so
...
|
auto.arima vs arima.sim
No, you did not make an error in your code (that I can see).
It is unfortunately the case that automatic ARIMA model selection rarely recovers the model that was used to simulate the input data. This
|
41,860
|
Problem 2.4.1 part a) from Pearl et al. "Causal Inference in Statistics: A Primer"
|
I think your code for simulating the data has a typo. In the line beginning with set.seed(6) $Z_1$ should be $Z_3$.
|
Problem 2.4.1 part a) from Pearl et al. "Causal Inference in Statistics: A Primer"
|
I think your code for simulating the data has a typo. In the line beginning with set.seed(6) $Z_1$ should be $Z_3$.
|
Problem 2.4.1 part a) from Pearl et al. "Causal Inference in Statistics: A Primer"
I think your code for simulating the data has a typo. In the line beginning with set.seed(6) $Z_1$ should be $Z_3$.
|
Problem 2.4.1 part a) from Pearl et al. "Causal Inference in Statistics: A Primer"
I think your code for simulating the data has a typo. In the line beginning with set.seed(6) $Z_1$ should be $Z_3$.
|
41,861
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
|
I think your reasoning is basically correct: we could use an iterative solver like Newton's method to get a really good approximation to the optimal $\gamma$, but that's a lot of work.
The xgboost software uses a second-order Taylor expansion of $(3)$ because quadratics are easy to optimize. (Described in https://xgboost.readthedocs.io/en/latest/tutorials/model.html; scroll down to the section "Structure Score.") Because of its simplicity, I wouldn't be surprised if this is the approach taken in most boosting libraries.
An extensive answer about xgboost can be found here: XGBoost Loss function Approximation With Taylor Expansion
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
|
I think your reasoning is basically correct: we could use an iterative solver like Newton's method to get a really good approximation to the optimal $\gamma$, but that's a lot of work.
The xgboost so
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
I think your reasoning is basically correct: we could use an iterative solver like Newton's method to get a really good approximation to the optimal $\gamma$, but that's a lot of work.
The xgboost software uses a second-order Taylor expansion of $(3)$ because quadratics are easy to optimize. (Described in https://xgboost.readthedocs.io/en/latest/tutorials/model.html; scroll down to the section "Structure Score.") Because of its simplicity, I wouldn't be surprised if this is the approach taken in most boosting libraries.
An extensive answer about xgboost can be found here: XGBoost Loss function Approximation With Taylor Expansion
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
I think your reasoning is basically correct: we could use an iterative solver like Newton's method to get a really good approximation to the optimal $\gamma$, but that's a lot of work.
The xgboost so
|
41,862
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
|
I would say that expand equation 3 using taylor series until seconnd order polynomial and then set the derivative of this modified equation wrt gamma equal to zero to get the gamma optimal..this is equivalent to performing only one iteration of newtons method for optimization. you should get the gamma as sum(residuals)/sum(p*(1-p)
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
|
I would say that expand equation 3 using taylor series until seconnd order polynomial and then set the derivative of this modified equation wrt gamma equal to zero to get the gamma optimal..this is eq
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
I would say that expand equation 3 using taylor series until seconnd order polynomial and then set the derivative of this modified equation wrt gamma equal to zero to get the gamma optimal..this is equivalent to performing only one iteration of newtons method for optimization. you should get the gamma as sum(residuals)/sum(p*(1-p)
|
Spelling out a detail in the gradient boosting machine algorithm for binary classification
I would say that expand equation 3 using taylor series until seconnd order polynomial and then set the derivative of this modified equation wrt gamma equal to zero to get the gamma optimal..this is eq
|
41,863
|
Are dependent variables necessarily functions of one another?
|
This question is interesting because it concerns the general problem of regression in the sense of characterizing (or estimating based on data) the conditional distribution of one variable, $X_1,$ based on values of another variable $X_2.$ Their lack of statistical independence implies there is something to be gained from this.
We may take our cues from the theory of Generalized Linear Models (GLMs), which suppose the conditional distribution of $X_1$ is a member of a finitely parameterized family of distributions and the parameters depend first on a linear function of $X_2$ and, usually, by a nonlinear transformation of that result (aka the "link function"). In the present question no such parametric assumption is made. We should therefore work with the conditional distribution of $X_1$ directly.
Suppose, then, that $X_2=x_2$ is a given value and that we can make sense of the conditional distribution of $X_1$ given $X_2=x_2.$ Let this distribution function be $F_{x_2}.$ (For the moment, let's drop the $x_2$ subscript for brevity.) By definition, for any number $x_1,$
$$\Pr(X_1 \le x_1\mid X_2=x_2) = F(x_1).$$
The axioms of probability imply $F$ has a right inverse $F^{-1}$ characterized by
$$F\left(F^{-1}(p)\right) = p$$
for all $0\lt p \lt 1.$
Let $Z$ be a random variable with a uniform distribution on the interval $(0,1).$ This means that for all $0\le p\le 1,$ $\Pr(Z \le p) = p$. Note that for any number $x,$
$$\Pr\left(F^{-1}(Z) \le x\right) = \Pr\left(F(F^{-1}(Z)) \le F(x)\right) = \Pr\left(Z \le F(x)\right) = F(x).$$
This shows that the distribution function of the random variable $F^{-1}(Z)$ is $F.$
Suppose it is possible to find such a uniform $Z$ that is independent of $X_2.$ (One can always do this by enlarging the original probability space if necessary.) In this case the foregoing result holds for every possible value $x_2.$ Consequently, if we define the function $f:\mathbb{R}^2\to \mathbb{R}$ by
$$f(x_2, z) = F_{x_2}^{-1}(z),$$
then $(f(X_2,Z), X_2)$ is a bivariate random variable for which
Its second component, $X_2,$ is identical to the second component of the original variable $(X_1,X_2);$ and
The conditional distribution of its first component equals the conditional distribution of $X_1$ given $X_2.$
Consequently,
The random variables $(X_1,X_2)$ and $(f(X_2,Z), X_2)$ are equal in distribution.
A fortiori, $f(X_2,Z)$ and $X_1$ are equal in distribution.
Examples
As the first example, consider the intriguing illustration presented in the reply by Dave at https://stats.stackexchange.com/a/443150/919/. It displays a $42$-element dataset consisting of a sequence of ordered pairs
$$(x_1,x_2) = (i/10, \pm i/10)$$
as $i$ ranges from $-20$ to $20$ inclusive. (The value $(0,0)$ is included twice, even though that is not apparent from the scatterplot.) We may conceive of this in terms of its empirical distribution, which assigns the probability $1/42$ to each element of the dataset, thereby defining a bivariate random variable $(X_1,X_2).$
In this case we will need to define $F_{x_2}$ for each value $x_2$ that appears as a second coordinate in the dataset (it doesn't matter how we define $F_{x_2}$ elsewhere, because those values have no probability). With this in mind, compute
$$F_{i}(x) = \left\{\matrix{0 & x \lt -|i| \\ 1/2 & -|i| \le x \lt |i| \\ 1 & \text{otherwise}}\right.$$
for any number $i.$ One right inverse of $F_{i}$ maps the interval $[0,1/2]$ to $-|i|$ and the interval $(1/2,1]$ to $|i|.$ You can see this implemented in the code below.
The claim is that
the distribution of $(X_1, X_2)$ is the same as that of $(F_{X_2}^{-1}(Z), X_2).$
Rather than do a direct calculation, let's have the computer simulate the latter using R, to be compared to the scatterplot of $(X_1, X_2)$ in Dave's reply:
set.seed(17)
n <- 1e5 # Simulation size
f <- function(i, p) ifelse (p <= 1/2, -1, 1) * abs(i) # Inverse conditional distribution
X.2 <- sample((-20):20 / 10, n, replace=TRUE) # Sample of X[2]
Z <- runif(n) # Independent sample of Z
X.1 <- f(X.2, Z) # Construction of X[1]
This scatterplot confirms it works correctly:
Another example suggested in comments is a uniform distribution on a circle:
Generating these data required only two changes to the code: $(1+X_2)/2$ has a Beta$(1/2,1/2)$ distribution and $F^{-1}$ now reflects the equation of the circle:
X.2 <- rbeta(n, 1/2, 1/2) * 2 - 1
F.inv <- function(p, i) ifelse (p <= 1/2, -1, 1) * sqrt(1 - i^2)
Finally, the more difficult situations occur when the scatterplot cannot be conceived of as exhibiting either of the $X_i$ as a function of the other, as in this uniform distribution on a square:
Here, the marginal distribution of $X_2$ is a mixture of a uniform distribution on the interval $[-1,1]$ and equal point masses at $\pm 1,$ which can be simulated via
X.2 <- pmax(-1, pmin(1, runif(n, -2, 2)))
The function $F^{-1}_{i}$ depends on whether its argument is in the interval $(-1,1)$ or equal to $\pm1;$ it can be implemented as
F.inv <- function(p, i) ifelse (abs(i)==1, 2*p - 1, ifelse (p <= 1/2, -1, 1))
|
Are dependent variables necessarily functions of one another?
|
This question is interesting because it concerns the general problem of regression in the sense of characterizing (or estimating based on data) the conditional distribution of one variable, $X_1,$ bas
|
Are dependent variables necessarily functions of one another?
This question is interesting because it concerns the general problem of regression in the sense of characterizing (or estimating based on data) the conditional distribution of one variable, $X_1,$ based on values of another variable $X_2.$ Their lack of statistical independence implies there is something to be gained from this.
We may take our cues from the theory of Generalized Linear Models (GLMs), which suppose the conditional distribution of $X_1$ is a member of a finitely parameterized family of distributions and the parameters depend first on a linear function of $X_2$ and, usually, by a nonlinear transformation of that result (aka the "link function"). In the present question no such parametric assumption is made. We should therefore work with the conditional distribution of $X_1$ directly.
Suppose, then, that $X_2=x_2$ is a given value and that we can make sense of the conditional distribution of $X_1$ given $X_2=x_2.$ Let this distribution function be $F_{x_2}.$ (For the moment, let's drop the $x_2$ subscript for brevity.) By definition, for any number $x_1,$
$$\Pr(X_1 \le x_1\mid X_2=x_2) = F(x_1).$$
The axioms of probability imply $F$ has a right inverse $F^{-1}$ characterized by
$$F\left(F^{-1}(p)\right) = p$$
for all $0\lt p \lt 1.$
Let $Z$ be a random variable with a uniform distribution on the interval $(0,1).$ This means that for all $0\le p\le 1,$ $\Pr(Z \le p) = p$. Note that for any number $x,$
$$\Pr\left(F^{-1}(Z) \le x\right) = \Pr\left(F(F^{-1}(Z)) \le F(x)\right) = \Pr\left(Z \le F(x)\right) = F(x).$$
This shows that the distribution function of the random variable $F^{-1}(Z)$ is $F.$
Suppose it is possible to find such a uniform $Z$ that is independent of $X_2.$ (One can always do this by enlarging the original probability space if necessary.) In this case the foregoing result holds for every possible value $x_2.$ Consequently, if we define the function $f:\mathbb{R}^2\to \mathbb{R}$ by
$$f(x_2, z) = F_{x_2}^{-1}(z),$$
then $(f(X_2,Z), X_2)$ is a bivariate random variable for which
Its second component, $X_2,$ is identical to the second component of the original variable $(X_1,X_2);$ and
The conditional distribution of its first component equals the conditional distribution of $X_1$ given $X_2.$
Consequently,
The random variables $(X_1,X_2)$ and $(f(X_2,Z), X_2)$ are equal in distribution.
A fortiori, $f(X_2,Z)$ and $X_1$ are equal in distribution.
Examples
As the first example, consider the intriguing illustration presented in the reply by Dave at https://stats.stackexchange.com/a/443150/919/. It displays a $42$-element dataset consisting of a sequence of ordered pairs
$$(x_1,x_2) = (i/10, \pm i/10)$$
as $i$ ranges from $-20$ to $20$ inclusive. (The value $(0,0)$ is included twice, even though that is not apparent from the scatterplot.) We may conceive of this in terms of its empirical distribution, which assigns the probability $1/42$ to each element of the dataset, thereby defining a bivariate random variable $(X_1,X_2).$
In this case we will need to define $F_{x_2}$ for each value $x_2$ that appears as a second coordinate in the dataset (it doesn't matter how we define $F_{x_2}$ elsewhere, because those values have no probability). With this in mind, compute
$$F_{i}(x) = \left\{\matrix{0 & x \lt -|i| \\ 1/2 & -|i| \le x \lt |i| \\ 1 & \text{otherwise}}\right.$$
for any number $i.$ One right inverse of $F_{i}$ maps the interval $[0,1/2]$ to $-|i|$ and the interval $(1/2,1]$ to $|i|.$ You can see this implemented in the code below.
The claim is that
the distribution of $(X_1, X_2)$ is the same as that of $(F_{X_2}^{-1}(Z), X_2).$
Rather than do a direct calculation, let's have the computer simulate the latter using R, to be compared to the scatterplot of $(X_1, X_2)$ in Dave's reply:
set.seed(17)
n <- 1e5 # Simulation size
f <- function(i, p) ifelse (p <= 1/2, -1, 1) * abs(i) # Inverse conditional distribution
X.2 <- sample((-20):20 / 10, n, replace=TRUE) # Sample of X[2]
Z <- runif(n) # Independent sample of Z
X.1 <- f(X.2, Z) # Construction of X[1]
This scatterplot confirms it works correctly:
Another example suggested in comments is a uniform distribution on a circle:
Generating these data required only two changes to the code: $(1+X_2)/2$ has a Beta$(1/2,1/2)$ distribution and $F^{-1}$ now reflects the equation of the circle:
X.2 <- rbeta(n, 1/2, 1/2) * 2 - 1
F.inv <- function(p, i) ifelse (p <= 1/2, -1, 1) * sqrt(1 - i^2)
Finally, the more difficult situations occur when the scatterplot cannot be conceived of as exhibiting either of the $X_i$ as a function of the other, as in this uniform distribution on a square:
Here, the marginal distribution of $X_2$ is a mixture of a uniform distribution on the interval $[-1,1]$ and equal point masses at $\pm 1,$ which can be simulated via
X.2 <- pmax(-1, pmin(1, runif(n, -2, 2)))
The function $F^{-1}_{i}$ depends on whether its argument is in the interval $(-1,1)$ or equal to $\pm1;$ it can be implemented as
F.inv <- function(p, i) ifelse (abs(i)==1, 2*p - 1, ifelse (p <= 1/2, -1, 1))
|
Are dependent variables necessarily functions of one another?
This question is interesting because it concerns the general problem of regression in the sense of characterizing (or estimating based on data) the conditional distribution of one variable, $X_1,$ bas
|
41,864
|
Are dependent variables necessarily functions of one another?
|
I think this is a good place to use a picture.
x0 <- x1 <- seq(-2,2,0.1)
y0 <- x0
y1 <- -x1
x <- c(x0,x1)
y <- c(y0,y1)
plot(x,y)
I think the lack of independence is evident. However, the relationship cannot be functional, as a large value of $X1$, say $X1=2$, results in either $X2=2$ or $X2=-2$, and there's the usual business about a function having a unique output for each input.
(I considered that we could call it functional if we see the output as the vector $[-2,2]$ or the set $\{-2,2\}$, but I don't think those work. The relationship is to select one of those values, not a vector of possible values or the entire set of possible values.)
|
Are dependent variables necessarily functions of one another?
|
I think this is a good place to use a picture.
x0 <- x1 <- seq(-2,2,0.1)
y0 <- x0
y1 <- -x1
x <- c(x0,x1)
y <- c(y0,y1)
plot(x,y)
I think the lack of independence is evident. However, the relations
|
Are dependent variables necessarily functions of one another?
I think this is a good place to use a picture.
x0 <- x1 <- seq(-2,2,0.1)
y0 <- x0
y1 <- -x1
x <- c(x0,x1)
y <- c(y0,y1)
plot(x,y)
I think the lack of independence is evident. However, the relationship cannot be functional, as a large value of $X1$, say $X1=2$, results in either $X2=2$ or $X2=-2$, and there's the usual business about a function having a unique output for each input.
(I considered that we could call it functional if we see the output as the vector $[-2,2]$ or the set $\{-2,2\}$, but I don't think those work. The relationship is to select one of those values, not a vector of possible values or the entire set of possible values.)
|
Are dependent variables necessarily functions of one another?
I think this is a good place to use a picture.
x0 <- x1 <- seq(-2,2,0.1)
y0 <- x0
y1 <- -x1
x <- c(x0,x1)
y <- c(y0,y1)
plot(x,y)
I think the lack of independence is evident. However, the relations
|
41,865
|
Are dependent variables necessarily functions of one another?
|
In common factor models, observed variables dependent on the same common factor covary and yet are conditionally independent given the common factor upon which they are jointly dependent. In the literature on graphical causal models, this structure--two variables jointly dependent on a third variable but with no relation between themselves--identifies the third variable as a "confounder," because it produces covariance between variables without a causal relation (see Felix Elwert's very nice introduction).
Alternatively, the two variables may be causes of a third variable. This marks the third variable as a "collider." Here, conditioning on the third variable (which is a mistake) creates a dependency between the first two, even though there is no functional relation between them.
|
Are dependent variables necessarily functions of one another?
|
In common factor models, observed variables dependent on the same common factor covary and yet are conditionally independent given the common factor upon which they are jointly dependent. In the liter
|
Are dependent variables necessarily functions of one another?
In common factor models, observed variables dependent on the same common factor covary and yet are conditionally independent given the common factor upon which they are jointly dependent. In the literature on graphical causal models, this structure--two variables jointly dependent on a third variable but with no relation between themselves--identifies the third variable as a "confounder," because it produces covariance between variables without a causal relation (see Felix Elwert's very nice introduction).
Alternatively, the two variables may be causes of a third variable. This marks the third variable as a "collider." Here, conditioning on the third variable (which is a mistake) creates a dependency between the first two, even though there is no functional relation between them.
|
Are dependent variables necessarily functions of one another?
In common factor models, observed variables dependent on the same common factor covary and yet are conditionally independent given the common factor upon which they are jointly dependent. In the liter
|
41,866
|
Mixed Effects Model
|
I fitted variables TEMPS (time) and GROUPE (Gender) like fixed effects and NUMERO (Subjects) like random effect. I am wondering if that is right.
Yes, you have repeated measures within individuals so fitting random intercepts for this factor accounts for the correlation between measurements within each individual.
Now I am wondering why I cannot put in random terms my variable GROUPE, something like this ~1+GROUPE|NUMERO, or like this ~1+TEMPS+GROUPE|NUMERO
You can. The variables to the left of the | symbol specify random slopes. This means that you are allowing whatever variable appears on the left side to vary within whatever is on the right side. So in your case 1+GROUPE|NUMERO means that the effect of gender can be different for each individual. You should ask yourself whether this makes sense within your particular specialty (since gender usually does not change within individuals, I expect that this would not make sense). ~1+TEMPS+GROUPE|NUMERO additionally allows the effect of time to be different for each individual.
Though, the way I interpret this result is that the score is significantly higher in men (Homme) than in women. So, the treatment improve better the mental state in women (lowest score), a result I was not expecting for. This make me wondering about about the way I computed the model.
Yes, your interpretation is correct. The estimate for GROUPEHomme can be interpreted as the difference in ScoreHamilton between the reference level for GROUPE and for GROUPE=Homme, where the other fixed effects remain constant, and conditional on the random effects estimated.
I have additional questions. My variable VISIT was factor which I turned into numeric. Could it change something whether my variable VISIT is factor or numeric?
Yes it could. I don't see VISIT in your model. From your question it appears that TEMPS is the variable that was created from VISIT. I am assuming that the original factor variable had levels such as "10 days", "20 days", "25 days" "..." and you converted these to a numeric variable 10, 20, 25, ... By doing this your model estimates a linear effect for TEMPS. By keeping the variable as a factor then you allow for non linearity. If there are few levels / values then this does not matter too much, but if you have many levels then retaining the variable as a factor will lead to a model with many estimates for each level, which becomes difficult to interpret. If you want to allow for non-linearity, one way is to use the numeric variable and specify a quadratic (and higher order) terms for it, or to use splines. Since you have 8 measurement occasions, I would be inclined to use the numeric variable with splines.
Could it change something about my results whether I used na.omit or not in the model, since my dataset has a lot of missing values?
In lme missing data causes an error, so using na.omit = TRUE is the only way to make it run. This removes rows containing any missing data, and this can lead to substantial bias. Depending on the reasons for missingness and the extent of missingness, you would be well-advised to consider using multiple imputation to address this problem.
Final note: nlme is an old package. lme4 was subsequently developed by the same people and is a better choice in most situations.
|
Mixed Effects Model
|
I fitted variables TEMPS (time) and GROUPE (Gender) like fixed effects and NUMERO (Subjects) like random effect. I am wondering if that is right.
Yes, you have repeated measures within individuals so
|
Mixed Effects Model
I fitted variables TEMPS (time) and GROUPE (Gender) like fixed effects and NUMERO (Subjects) like random effect. I am wondering if that is right.
Yes, you have repeated measures within individuals so fitting random intercepts for this factor accounts for the correlation between measurements within each individual.
Now I am wondering why I cannot put in random terms my variable GROUPE, something like this ~1+GROUPE|NUMERO, or like this ~1+TEMPS+GROUPE|NUMERO
You can. The variables to the left of the | symbol specify random slopes. This means that you are allowing whatever variable appears on the left side to vary within whatever is on the right side. So in your case 1+GROUPE|NUMERO means that the effect of gender can be different for each individual. You should ask yourself whether this makes sense within your particular specialty (since gender usually does not change within individuals, I expect that this would not make sense). ~1+TEMPS+GROUPE|NUMERO additionally allows the effect of time to be different for each individual.
Though, the way I interpret this result is that the score is significantly higher in men (Homme) than in women. So, the treatment improve better the mental state in women (lowest score), a result I was not expecting for. This make me wondering about about the way I computed the model.
Yes, your interpretation is correct. The estimate for GROUPEHomme can be interpreted as the difference in ScoreHamilton between the reference level for GROUPE and for GROUPE=Homme, where the other fixed effects remain constant, and conditional on the random effects estimated.
I have additional questions. My variable VISIT was factor which I turned into numeric. Could it change something whether my variable VISIT is factor or numeric?
Yes it could. I don't see VISIT in your model. From your question it appears that TEMPS is the variable that was created from VISIT. I am assuming that the original factor variable had levels such as "10 days", "20 days", "25 days" "..." and you converted these to a numeric variable 10, 20, 25, ... By doing this your model estimates a linear effect for TEMPS. By keeping the variable as a factor then you allow for non linearity. If there are few levels / values then this does not matter too much, but if you have many levels then retaining the variable as a factor will lead to a model with many estimates for each level, which becomes difficult to interpret. If you want to allow for non-linearity, one way is to use the numeric variable and specify a quadratic (and higher order) terms for it, or to use splines. Since you have 8 measurement occasions, I would be inclined to use the numeric variable with splines.
Could it change something about my results whether I used na.omit or not in the model, since my dataset has a lot of missing values?
In lme missing data causes an error, so using na.omit = TRUE is the only way to make it run. This removes rows containing any missing data, and this can lead to substantial bias. Depending on the reasons for missingness and the extent of missingness, you would be well-advised to consider using multiple imputation to address this problem.
Final note: nlme is an old package. lme4 was subsequently developed by the same people and is a better choice in most situations.
|
Mixed Effects Model
I fitted variables TEMPS (time) and GROUPE (Gender) like fixed effects and NUMERO (Subjects) like random effect. I am wondering if that is right.
Yes, you have repeated measures within individuals so
|
41,867
|
Confidence interval for mean of Poisson with only zero counts
|
The standard procedure (Hahn & Meeker, section 7.2.2) exploits the basic relationship between Poisson and Chi-squared variates; namely, when $F_{\lambda}$ is the Poisson PDF of parameter $\lambda$ and $G_{\nu}$ is the Chi-squared PDF of parameter $\nu,$ then for any $k\in\{0,1,2,\ldots\},$
$$1-F_\lambda(k) = G_{2k+2}(2\lambda).\tag{1}$$
An upper confidence limit of size $1-\alpha$ for $\lambda$ based on observing a Poisson variable $K_\lambda$ is, by definition, a function $u$ for which
$$1-\alpha = \inf_{\lambda\in\mathbb{R}^+}\Pr(\lambda \le u(K_\lambda)).$$
If we choose a suitable inverse of $u$ and write $k=K_\lambda$ for the observed value, we may exploit $(1)$ to re-express this criterion as
$$\eqalign{
1-\alpha &= \inf_{\lambda\in\mathbb{R}^+}\Pr(u^{-1}(\lambda) \le K_\lambda) \\
&= \inf_{\lambda\in\mathbb{R}^+}1-F_\lambda(k)) \\
&= \inf_{\lambda\in\mathbb{R}^+}G_{2k+2}(2\lambda),
}$$
with unique solution
$$\lambda_+(\alpha) = \frac{1}{2} G^{-1}_{2k+2}(1-\alpha).$$
Similar reasoning arrives at a lower $1-\alpha$ confidence limit
$$\lambda_{-}(\alpha) = \frac{1}{2} G^{-1}_{2k}(\alpha).$$
One of the many possible two-sided confidence interval procedures splits the risk between the upper and lower endpoints by using $[\lambda_{-}(\alpha/2), \lambda_{+}(\alpha/2)].$
When $k=0,$ the function $G_{0},$ or the distribution of a "chi-squared variate with zero degrees of freedom," has to be understood as the distribution of the constant zero, whence "$G^{-1}_0(\alpha)$" is always zero no matter what $\alpha\gt 0$ may be. In this case $G_{2k+2} = G_2$ is the Exponential distribution with scale factor $2,$ entailing
$$\lambda_{+}(\alpha/2) = G^{-1}_2(1-\alpha/2) = -2\log(\alpha/2).$$
For instance, with $\alpha=5\%$ this UCL is $7.38,$ whereas the one-sided upper confidence limit for the same $\alpha$ is only $3.00.$ If you are tempted to use the latter because it produces a shorter confidence interval, consider these simulation results for a large range of $\lambda$ (from $0.1$ to $1,000,$ after which a Normal approximation will work well):
"Coverage" is the proportion of samples for which the confidence interval, nominally set at $1-\alpha = 95\%,$ includes $\lambda.$ Each red point in this plot summarizes 400,000 independently simulated samples. The gray graph is the calculated coverage based on Poisson probabilities only.
The discreteness of the Poisson distributions causes the actual coverage to oscillate, but a trend is clear: coverage really is close to the nominal value for large $\lambda,$ but can be substantially greater for small $\lambda.$
Some of the conclusions we may draw are
The foregoing analysis produces confidence intervals with the correct coverage.
The coverage tends to be higher than intended (greater than $1-\alpha$) when $\lambda$ is smaller than $10$ or so, approaching $100\%$ in the limit as $\lambda\to 0.$
In retrospect this behavior is obvious: because the confidence limits depend only on $k,$ the limits for $k=0$ have to be fairly large to allow for the possibility that $\lambda$ is fairly large. Consequently, when $\lambda$ actually is small, the coverage must be greater than the nominal coverage.
If you know (or assume) $\lambda$ is small at the outset, you could modify this procedure accordingly to produce confidence intervals that tend to be shorter.
Reference
G. J. Hahn and W. Q. Meeker (1991), Statistical Intervals. A Guide for Practitioners. J. Wiley & Sons.
Code
#
# Poisson confidence intervals (symmetric, two-sided).
# `k` may be a vector of observations.
#
ci <- function(k, alpha=0.05) {
matrix(qchisq(c(alpha/2, 1-alpha/2), rbind(2*k, 2*k+2))/2, 2)
}
#
# Simulation study of coverage.
# Takes a few seconds with n=4e5.
#
n <- 4e5
lambda <- 10^seq(-1, 3, length.out=21)
set.seed(17)
coverage <- sapply(lambda, function(lambda) {
mean((function(x) x[1,] <= lambda & lambda <= x[2,])(ci(rpois(n, lambda))))
})
#
# Calculation of coverage.
#
lambda.calc <- 10^seq(-1, 3, length.out=4021)
x <- max(lambda.calc)
CI <- ci(k <- 0:(x + 8*sqrt(x)))
coverage.calc <- sapply(lambda.calc, function(l) {
covers <- CI[1,] <= l & l <= CI[2,]
sum(dpois(k, l)[covers])
})
#
# Plot of results.
#
library(ggplot2)
ggplot(data.frame(lambda=lambda, Coverage=coverage),
aes(lambda, Coverage)) +
geom_line(data=data.frame(lambda=lambda.calc, Coverage=coverage.calc), col="#a0a0a0") +
geom_point(color="Red") +
scale_x_log10() +
coord_cartesian(ylim=c(min(0.9499, min(coverage.calc)), 1), expand=FALSE) +
geom_hline(yintercept=0.95) +
xlab(expression(lambda)) +
ggtitle("Simulated Coverage Rates of 95% Two-Sided Poisson Confidence Intervals")
|
Confidence interval for mean of Poisson with only zero counts
|
The standard procedure (Hahn & Meeker, section 7.2.2) exploits the basic relationship between Poisson and Chi-squared variates; namely, when $F_{\lambda}$ is the Poisson PDF of parameter $\lambda$ and
|
Confidence interval for mean of Poisson with only zero counts
The standard procedure (Hahn & Meeker, section 7.2.2) exploits the basic relationship between Poisson and Chi-squared variates; namely, when $F_{\lambda}$ is the Poisson PDF of parameter $\lambda$ and $G_{\nu}$ is the Chi-squared PDF of parameter $\nu,$ then for any $k\in\{0,1,2,\ldots\},$
$$1-F_\lambda(k) = G_{2k+2}(2\lambda).\tag{1}$$
An upper confidence limit of size $1-\alpha$ for $\lambda$ based on observing a Poisson variable $K_\lambda$ is, by definition, a function $u$ for which
$$1-\alpha = \inf_{\lambda\in\mathbb{R}^+}\Pr(\lambda \le u(K_\lambda)).$$
If we choose a suitable inverse of $u$ and write $k=K_\lambda$ for the observed value, we may exploit $(1)$ to re-express this criterion as
$$\eqalign{
1-\alpha &= \inf_{\lambda\in\mathbb{R}^+}\Pr(u^{-1}(\lambda) \le K_\lambda) \\
&= \inf_{\lambda\in\mathbb{R}^+}1-F_\lambda(k)) \\
&= \inf_{\lambda\in\mathbb{R}^+}G_{2k+2}(2\lambda),
}$$
with unique solution
$$\lambda_+(\alpha) = \frac{1}{2} G^{-1}_{2k+2}(1-\alpha).$$
Similar reasoning arrives at a lower $1-\alpha$ confidence limit
$$\lambda_{-}(\alpha) = \frac{1}{2} G^{-1}_{2k}(\alpha).$$
One of the many possible two-sided confidence interval procedures splits the risk between the upper and lower endpoints by using $[\lambda_{-}(\alpha/2), \lambda_{+}(\alpha/2)].$
When $k=0,$ the function $G_{0},$ or the distribution of a "chi-squared variate with zero degrees of freedom," has to be understood as the distribution of the constant zero, whence "$G^{-1}_0(\alpha)$" is always zero no matter what $\alpha\gt 0$ may be. In this case $G_{2k+2} = G_2$ is the Exponential distribution with scale factor $2,$ entailing
$$\lambda_{+}(\alpha/2) = G^{-1}_2(1-\alpha/2) = -2\log(\alpha/2).$$
For instance, with $\alpha=5\%$ this UCL is $7.38,$ whereas the one-sided upper confidence limit for the same $\alpha$ is only $3.00.$ If you are tempted to use the latter because it produces a shorter confidence interval, consider these simulation results for a large range of $\lambda$ (from $0.1$ to $1,000,$ after which a Normal approximation will work well):
"Coverage" is the proportion of samples for which the confidence interval, nominally set at $1-\alpha = 95\%,$ includes $\lambda.$ Each red point in this plot summarizes 400,000 independently simulated samples. The gray graph is the calculated coverage based on Poisson probabilities only.
The discreteness of the Poisson distributions causes the actual coverage to oscillate, but a trend is clear: coverage really is close to the nominal value for large $\lambda,$ but can be substantially greater for small $\lambda.$
Some of the conclusions we may draw are
The foregoing analysis produces confidence intervals with the correct coverage.
The coverage tends to be higher than intended (greater than $1-\alpha$) when $\lambda$ is smaller than $10$ or so, approaching $100\%$ in the limit as $\lambda\to 0.$
In retrospect this behavior is obvious: because the confidence limits depend only on $k,$ the limits for $k=0$ have to be fairly large to allow for the possibility that $\lambda$ is fairly large. Consequently, when $\lambda$ actually is small, the coverage must be greater than the nominal coverage.
If you know (or assume) $\lambda$ is small at the outset, you could modify this procedure accordingly to produce confidence intervals that tend to be shorter.
Reference
G. J. Hahn and W. Q. Meeker (1991), Statistical Intervals. A Guide for Practitioners. J. Wiley & Sons.
Code
#
# Poisson confidence intervals (symmetric, two-sided).
# `k` may be a vector of observations.
#
ci <- function(k, alpha=0.05) {
matrix(qchisq(c(alpha/2, 1-alpha/2), rbind(2*k, 2*k+2))/2, 2)
}
#
# Simulation study of coverage.
# Takes a few seconds with n=4e5.
#
n <- 4e5
lambda <- 10^seq(-1, 3, length.out=21)
set.seed(17)
coverage <- sapply(lambda, function(lambda) {
mean((function(x) x[1,] <= lambda & lambda <= x[2,])(ci(rpois(n, lambda))))
})
#
# Calculation of coverage.
#
lambda.calc <- 10^seq(-1, 3, length.out=4021)
x <- max(lambda.calc)
CI <- ci(k <- 0:(x + 8*sqrt(x)))
coverage.calc <- sapply(lambda.calc, function(l) {
covers <- CI[1,] <= l & l <= CI[2,]
sum(dpois(k, l)[covers])
})
#
# Plot of results.
#
library(ggplot2)
ggplot(data.frame(lambda=lambda, Coverage=coverage),
aes(lambda, Coverage)) +
geom_line(data=data.frame(lambda=lambda.calc, Coverage=coverage.calc), col="#a0a0a0") +
geom_point(color="Red") +
scale_x_log10() +
coord_cartesian(ylim=c(min(0.9499, min(coverage.calc)), 1), expand=FALSE) +
geom_hline(yintercept=0.95) +
xlab(expression(lambda)) +
ggtitle("Simulated Coverage Rates of 95% Two-Sided Poisson Confidence Intervals")
|
Confidence interval for mean of Poisson with only zero counts
The standard procedure (Hahn & Meeker, section 7.2.2) exploits the basic relationship between Poisson and Chi-squared variates; namely, when $F_{\lambda}$ is the Poisson PDF of parameter $\lambda$ and
|
41,868
|
Confidence interval for mean of Poisson with only zero counts
|
I answered my own question after some research. Please comment if something is wrong.
Frequentist confidence interval
An exact confidence interval can be derived based on the probability mass function for a Poisson distribution,
$$ P(X \le k) = \frac{\lambda^ke^{-\lambda}}{k!} $$
in which $k$ is some possible count and $\lambda$ is the mean and variance.
In our case, with a count of zero, $k = 0$, so
$$ P(X = 0) = \frac{\lambda^0e^{-\lambda}}{0!}=e^{-\lambda} $$
For a given level of confidence, $1-\alpha$, we can use this to solve for an upper bound on the estimate of $\lambda$:
$$ \alpha = e^{-\lambda}$$
$$ log(\alpha) = log(e^{-\lambda})$$
$$ log(\alpha) = -\lambda$$
$$ \hat{\lambda}_{upper} = -log(\alpha)$$
For a 95% confidence interval the upper confidence limit for a single observation of a Poisson random variable with a count of zero is $-log(.05)=2.995732$, and for a 99% confidence interval the upper limit is $-log(.01)=4.60517$.
The sum of multiple Poisson random variables is also a Poisson random variable, with mean $n\lambda$, so to convert these confidence limits for our case with 50 observations, we can simply divide by 50.
$$UCL_{95}=2.995732/50=0.05991464$$
$$UCL_{99}=4.60517/50=0.0921034$$
Bayesian credible interval
The likelihood is from a Poisson distribution:
$$L(\lambda|x)=\prod_{i=1}^n\frac{e^{-\lambda}\lambda^{x_i}}{x_i!}=\frac{e^{-n\lambda}\lambda^{\sum x_i}}{\prod_{i=1}^n(x_i!)} $$
If you make the prior a $gamma(\alpha,\beta)$:
$$p(\lambda)=\frac{\beta^{\alpha}}{\Gamma(\alpha)}\lambda^{\alpha-1}e^{-\beta\lambda} $$
then the posterior is a $gamma(\sum x_i + \alpha, n+\beta) $:
$$p(\lambda|x)=\frac{p(x|\lambda)p(\lambda)}{p(x)}\propto p(x|\lambda)p(\lambda) $$
$$p(\lambda|x) \propto e^{-n\lambda}\lambda^{\sum x_i}\lambda^{\alpha-1}e^{-\beta\lambda} = \lambda^{\sum x_i + \alpha - 1} e^{-(n+\beta)\lambda} $$
If you use $\alpha = 1$ and $\beta = 0$ in the prior then the upper credible limits are the same as the upper confidence limits.
For this particular case, we can use the 95th and 99th percentiles of a $gamma(1, 50)$ distribution to get the upper limits of 95% and 99% credible intervals (remember the $\sum x_i = 0$ for this particular case).
In R you could use:
> qgamma(.95, shape = 1, rate = 50)
[1] 0.05991465
> qgamma(.99, shape = 1, rate = 50)
[1] 0.0921034
Difference in approaches
The two approaches result in the same interval bounds, but they have different estimates.
For the frequentist approach, the point estimate for the Poisson mean is the maximum likelihood estimate, which for a Poisson distribution is just the average of the sample: $$\hat{\lambda}=\frac{0}{50}= 0$$
For the Bayesian approach, the point estimate for the Poisson mean is the mean of the posterior distribution, which is a $gamma(1, 50)$:
$$\hat{\lambda}=\frac{\alpha}{\beta}=\frac{1}{50}= 0.02$$
|
Confidence interval for mean of Poisson with only zero counts
|
I answered my own question after some research. Please comment if something is wrong.
Frequentist confidence interval
An exact confidence interval can be derived based on the probability mass function
|
Confidence interval for mean of Poisson with only zero counts
I answered my own question after some research. Please comment if something is wrong.
Frequentist confidence interval
An exact confidence interval can be derived based on the probability mass function for a Poisson distribution,
$$ P(X \le k) = \frac{\lambda^ke^{-\lambda}}{k!} $$
in which $k$ is some possible count and $\lambda$ is the mean and variance.
In our case, with a count of zero, $k = 0$, so
$$ P(X = 0) = \frac{\lambda^0e^{-\lambda}}{0!}=e^{-\lambda} $$
For a given level of confidence, $1-\alpha$, we can use this to solve for an upper bound on the estimate of $\lambda$:
$$ \alpha = e^{-\lambda}$$
$$ log(\alpha) = log(e^{-\lambda})$$
$$ log(\alpha) = -\lambda$$
$$ \hat{\lambda}_{upper} = -log(\alpha)$$
For a 95% confidence interval the upper confidence limit for a single observation of a Poisson random variable with a count of zero is $-log(.05)=2.995732$, and for a 99% confidence interval the upper limit is $-log(.01)=4.60517$.
The sum of multiple Poisson random variables is also a Poisson random variable, with mean $n\lambda$, so to convert these confidence limits for our case with 50 observations, we can simply divide by 50.
$$UCL_{95}=2.995732/50=0.05991464$$
$$UCL_{99}=4.60517/50=0.0921034$$
Bayesian credible interval
The likelihood is from a Poisson distribution:
$$L(\lambda|x)=\prod_{i=1}^n\frac{e^{-\lambda}\lambda^{x_i}}{x_i!}=\frac{e^{-n\lambda}\lambda^{\sum x_i}}{\prod_{i=1}^n(x_i!)} $$
If you make the prior a $gamma(\alpha,\beta)$:
$$p(\lambda)=\frac{\beta^{\alpha}}{\Gamma(\alpha)}\lambda^{\alpha-1}e^{-\beta\lambda} $$
then the posterior is a $gamma(\sum x_i + \alpha, n+\beta) $:
$$p(\lambda|x)=\frac{p(x|\lambda)p(\lambda)}{p(x)}\propto p(x|\lambda)p(\lambda) $$
$$p(\lambda|x) \propto e^{-n\lambda}\lambda^{\sum x_i}\lambda^{\alpha-1}e^{-\beta\lambda} = \lambda^{\sum x_i + \alpha - 1} e^{-(n+\beta)\lambda} $$
If you use $\alpha = 1$ and $\beta = 0$ in the prior then the upper credible limits are the same as the upper confidence limits.
For this particular case, we can use the 95th and 99th percentiles of a $gamma(1, 50)$ distribution to get the upper limits of 95% and 99% credible intervals (remember the $\sum x_i = 0$ for this particular case).
In R you could use:
> qgamma(.95, shape = 1, rate = 50)
[1] 0.05991465
> qgamma(.99, shape = 1, rate = 50)
[1] 0.0921034
Difference in approaches
The two approaches result in the same interval bounds, but they have different estimates.
For the frequentist approach, the point estimate for the Poisson mean is the maximum likelihood estimate, which for a Poisson distribution is just the average of the sample: $$\hat{\lambda}=\frac{0}{50}= 0$$
For the Bayesian approach, the point estimate for the Poisson mean is the mean of the posterior distribution, which is a $gamma(1, 50)$:
$$\hat{\lambda}=\frac{\alpha}{\beta}=\frac{1}{50}= 0.02$$
|
Confidence interval for mean of Poisson with only zero counts
I answered my own question after some research. Please comment if something is wrong.
Frequentist confidence interval
An exact confidence interval can be derived based on the probability mass function
|
41,869
|
Is the sample correlation always positively correlated with the sample variance?
|
TL;dr
The off-diagonal entries of the sample covariance will generally be correlated with the diagonal entries because $E(XY^3) - E(XY)E(Y^2) = 0$ only when special conditions of the mixed 4th order moments hold. When $(X,Y)$ is bivariate Gaussian, these conditions hold only when $X$ is independent of $Y$.
Details
There is an asymptotic result that can be shown here by examining the limiting distribution of $\sqrt n$-times the sample covariance (by the CLT, it's going to be multivariate normal) and then applying the delta method. This unfortunately means we'll have to take detour through a derivation of the distribution of the sample covariance$^1$ since I can't find any good references to it online. Alternately, if you are willing to assume normality, then knowledge of the covariance of the Wishart distribution would let you skip directly to section 2.
1 The asymptotic distribution of the sample covariance
Let $V_1, \dotsc, V_n$ be an iid sample from a bivariate distribution $V_i = \begin{pmatrix} X_i \\ Y_i \end{pmatrix}$ with finite fourth moments, and let
$$
\text{Cov}(V_i) =
\begin{pmatrix} \sigma^2 & \rho \sigma \tau \\ \rho \sigma \tau & \tau^2 \end{pmatrix} = \Sigma.
$$
Without loss of generality and to avoid some annoying additional bookkeeping we'll assume
$E(V_i) = \mathbf{0}$.
Then by the linearity of expectation and the weak law of large numbers, the sample covariance
$$
S_n = \frac{1}{n-1} \sum_{i=1}^n (V_i - \bar V_n) (V_i - \bar V_n)^T = \frac{1}{n-1}\sum_{i=1} V_i V_i^T - \frac{n}{n-1} \bar V_n \bar V_n^T
$$
is unbiased and consistent for $\Sigma$, and in fact
$$
\sqrt{n} (S_n - \Sigma) \rightarrow_d N(0, \Lambda).
$$
The exercise thus passes to determining $\Lambda$. For a symmetric matrix $\mathbf{A} = \begin{pmatrix} a & b \\ b & c \end{pmatrix}$, let $\tilde{\mathbf{A}} = (a, b, c)^T$ be the "vectorization" of its upper triangle. Now consider a single element of the average that enters into the leading term (the scatter matrix) of $S_n$:
$$
\tilde Z_i = \widetilde{V_i V_i^T} =
\begin{pmatrix}
X_i^2 \\
X_i Y_i \\
Y_i^2
\end{pmatrix}.
$$
Clearly by the zero-mean assumption, already $E(Z_i) = \tilde \Sigma$ and by considering the powers of $X$ and $Y$ that appear in $\tilde{Z}_i \tilde{Z}_i^T$ we can just write
$$
\text{Cov}(\tilde Z_i) = E(\tilde Z_i \tilde Z_i^T) - E(\tilde Z_i) E(\tilde Z_i)^T =
\begin{pmatrix}
\kappa_{40} \sigma^4 & \kappa_{31} \sigma^2 \tau & \kappa_{22} \sigma^2 \tau^2 \\
\kappa_{31} \sigma^2 \tau & \kappa_{22} \sigma^2 \tau^2 & \kappa_{13} \sigma \tau^3 \\
\kappa_{22} \sigma^2 \tau^2 & \kappa_{13} \sigma \tau^3 & \kappa_{04} \tau^4
\end{pmatrix} - \tilde \Sigma \tilde \Sigma^T.
$$
Here $$
\kappa_{ij} = E \left[ \left( \frac{X_i}{\sigma} \right)^i \left( \frac{Y_i}{\tau} \right)^j \right]
$$ indicates the $ij$th mixed standardized moment (about the mean, but we assumed mean zero at the onset).
Alternately, we have the factorization
$$
\text{Cov}(\tilde Z_i) = D(\sigma, \tau) [ K - R(\rho) R(\rho)^T ] D(\sigma, \tau), \quad (1)
$$
where $D(\sigma, \tau) = \text{diag}(\sigma^2, \sigma \tau, \tau^2)$, $R(\rho) = (1, \rho, 1)^T$ and
$$
K = \begin{pmatrix}
\kappa_{04} & \kappa_{31} & \kappa_{22} \\
\kappa_{31} & \kappa_{22} & \kappa_{13} \\
\kappa_{22} & \kappa_{13} & \kappa_{04}
\end{pmatrix}.
$$
Thus we have that $Z_{11}$ and $Z_{12}$, representing the sample variance of $X$ and the covariance of $X,Y$ are correlated unless $\rho = \kappa_{31}$. When $V_i$ is multivariate normal, this occurs only when $\rho = 0$.
2 The correlation coefficient
Now consider the transformation $g(x, y, z) = (x, \frac{y}{\sqrt{z}\sqrt{x}})$ on $\tilde{S_n}$. This provides the bivariate distribution of the sample correlation coefficient and the sample variance of x. By the delta method and asymptotic normality of $S_n$,
$$
\sqrt{n}( g(\tilde{S_n}) - (\rho, \sigma^2)^T ) \rightarrow N(0, \mathbf{J}(\tilde \Sigma)^T \tilde \Lambda \mathbf{J}(\tilde \Sigma)),
$$
where $\mathbf{J}(\tilde \Sigma) = [\nabla g_1^T, \nabla g_2^T]^T$ is the jacobian of $g$.
I find (though you probably want to check my algebra..) that the gradient of the second component of $g$ is
$$
\nabla g_2 (\sigma^2, \rho \sigma \tau, \tau^2) = \left( -\frac{\rho}{2\sigma^2}, \frac{1}{\sigma \tau}, -\frac{\rho}{2 \tau^2} \right)^T,
$$
So
$$
J(\sigma, \rho, \tau) =
\begin{pmatrix}
1 & -\frac{\rho}{2\sigma^2} \\
0 & \frac{1}{\sigma \tau} \\
0 & -\frac{\rho}{2 \tau^2}
\end{pmatrix}.
$$
Putting it all together with the factorization in equation (1) yields
$$
J(\sigma, \rho, \tau)^T D(\sigma, \tau) [ K - R(\rho) R(\rho)^T ] D(\sigma, \tau) J(\sigma, \rho, \tau).
$$
Plugging in some easy to use numbers, say $\sigma = \tau = 1$ and $\rho = .5$, we'd have for
$$
J(\sigma, \rho, \tau)^T D(\sigma, \tau) [ K - R(\rho) R(\rho)^T ] D(\sigma, \tau)J(\sigma, \rho, \tau) = \begin{pmatrix}
-1/4 & 1 & -1/4 \\
1 & 0 & 0
\end{pmatrix} \mathbf I
\Omega
\mathbf I
\begin{pmatrix}
-1/4 & 1 \\
1 & 0 \\
-1/4 & 0
\end{pmatrix} = \mathbf{Q},
$$
where $\Omega = K - R(\rho) R(\rho)^T$ is generally some dense matrix. Courtesy of Mathematica, I expanded this product in terms of entries in $K$ and recount below $Q_{12}$
$$
n \times Q_{12} = n \times \text{Cov}(r, s^2_x) = \kappa_{31} -\frac{\kappa_{04} + \kappa_{22}}{4} \quad (2)
$$
which is an opaque expression in terms of the mixed moments, but certainly doesn't seem like it's going to be zero, generally.
3 Specializing to the normal case
Isserlis theorem provides a way to derive the mixed moments of a Gaussian. Again assuming $\sigma = \tau = 1$ and $\rho = .5$, we'd have
$\kappa_{31} = 3/2, \kappa_{04} = 3, \kappa_{22} = 3/2$, thus
$Q_{12} = 3/2 - (3 + 3/2)/4 = 3/8 > 0$, as you observe.
4 Simulation and Example
Below find a simulation verifying equation (1). For $n=100$ and $n=1000$ (in red and blue, respectively) iid observations from a multivariate normal, I derive the covariance of $\sqrt{n} \tilde S_n$ by bootstrap. The covariance between $S_{xy}$ and $S_{xx}$ is plotted on y axis as $\rho$ varies from $-.9$ to $.9$. The theoretical value from equation (1) and using facts about the 4th order moments of the bivariate Gaussian is plotted in a dashed black line.
A fun exercise would be to try to find a family of copula that for any value of $\rho$ would render $\text{Cov}(S_{xy}, S_{xx}) = 0$...
library(mvtnorm)
library(tidyverse)
library(boot)
params = expand.grid(sx = 1, sy = 1, n = c(100, 1000), rho = seq(-.9, .9, by = .1), replicate = 1:10) %>% mutate(k04 = 3*sx^4, k31 = 3*sx*rho*sx*sy, q12 = k31 - rho*sx*sy)
Sn_tilde = function(dat, idx){
Sn = cov(dat[idx,,drop =FALSE])*sqrt(length(idx))
Sn[upper.tri(Sn, diag = TRUE)]
}
out = params %>% group_by_all() %>% do({
x = with(., rmvnorm(n = .$n, sigma = matrix(c(sx^2, rho*sx*sy,
rho*sx*sy, sy^2), nrow = 2)))
colnames(x) = c('X', 'Y')
b = boot(x, Sn_tilde, R = 500)
cov_Sn = cov(b$t)
rownames(cov_Sn) = colnames(cov_Sn) = c('Sxx', 'Sxy', 'Syy')
as_tibble(cov_Sn, rownames = 'j')
})
ggplot(filter(out, j == 'Sxx'), aes(x = rho, y = Sxy, color = factor(n))) + geom_point(size = .5, alpha = .5) + geom_smooth(method = 'lm') + geom_line(data = filter(params, replicate == 1, n == 100), aes(y = q12), lty = 2, color = 'black') + theme_minimal() + ylab('Cov(Sxy, Sxx)')
$^1$ This heavily uses Michael Perlman's lecture notes on probability and mathematical statistics, which I really wish were available as a electronically so I could replace mine when they wear out...
|
Is the sample correlation always positively correlated with the sample variance?
|
TL;dr
The off-diagonal entries of the sample covariance will generally be correlated with the diagonal entries because $E(XY^3) - E(XY)E(Y^2) = 0$ only when special conditions of the mixed 4th order m
|
Is the sample correlation always positively correlated with the sample variance?
TL;dr
The off-diagonal entries of the sample covariance will generally be correlated with the diagonal entries because $E(XY^3) - E(XY)E(Y^2) = 0$ only when special conditions of the mixed 4th order moments hold. When $(X,Y)$ is bivariate Gaussian, these conditions hold only when $X$ is independent of $Y$.
Details
There is an asymptotic result that can be shown here by examining the limiting distribution of $\sqrt n$-times the sample covariance (by the CLT, it's going to be multivariate normal) and then applying the delta method. This unfortunately means we'll have to take detour through a derivation of the distribution of the sample covariance$^1$ since I can't find any good references to it online. Alternately, if you are willing to assume normality, then knowledge of the covariance of the Wishart distribution would let you skip directly to section 2.
1 The asymptotic distribution of the sample covariance
Let $V_1, \dotsc, V_n$ be an iid sample from a bivariate distribution $V_i = \begin{pmatrix} X_i \\ Y_i \end{pmatrix}$ with finite fourth moments, and let
$$
\text{Cov}(V_i) =
\begin{pmatrix} \sigma^2 & \rho \sigma \tau \\ \rho \sigma \tau & \tau^2 \end{pmatrix} = \Sigma.
$$
Without loss of generality and to avoid some annoying additional bookkeeping we'll assume
$E(V_i) = \mathbf{0}$.
Then by the linearity of expectation and the weak law of large numbers, the sample covariance
$$
S_n = \frac{1}{n-1} \sum_{i=1}^n (V_i - \bar V_n) (V_i - \bar V_n)^T = \frac{1}{n-1}\sum_{i=1} V_i V_i^T - \frac{n}{n-1} \bar V_n \bar V_n^T
$$
is unbiased and consistent for $\Sigma$, and in fact
$$
\sqrt{n} (S_n - \Sigma) \rightarrow_d N(0, \Lambda).
$$
The exercise thus passes to determining $\Lambda$. For a symmetric matrix $\mathbf{A} = \begin{pmatrix} a & b \\ b & c \end{pmatrix}$, let $\tilde{\mathbf{A}} = (a, b, c)^T$ be the "vectorization" of its upper triangle. Now consider a single element of the average that enters into the leading term (the scatter matrix) of $S_n$:
$$
\tilde Z_i = \widetilde{V_i V_i^T} =
\begin{pmatrix}
X_i^2 \\
X_i Y_i \\
Y_i^2
\end{pmatrix}.
$$
Clearly by the zero-mean assumption, already $E(Z_i) = \tilde \Sigma$ and by considering the powers of $X$ and $Y$ that appear in $\tilde{Z}_i \tilde{Z}_i^T$ we can just write
$$
\text{Cov}(\tilde Z_i) = E(\tilde Z_i \tilde Z_i^T) - E(\tilde Z_i) E(\tilde Z_i)^T =
\begin{pmatrix}
\kappa_{40} \sigma^4 & \kappa_{31} \sigma^2 \tau & \kappa_{22} \sigma^2 \tau^2 \\
\kappa_{31} \sigma^2 \tau & \kappa_{22} \sigma^2 \tau^2 & \kappa_{13} \sigma \tau^3 \\
\kappa_{22} \sigma^2 \tau^2 & \kappa_{13} \sigma \tau^3 & \kappa_{04} \tau^4
\end{pmatrix} - \tilde \Sigma \tilde \Sigma^T.
$$
Here $$
\kappa_{ij} = E \left[ \left( \frac{X_i}{\sigma} \right)^i \left( \frac{Y_i}{\tau} \right)^j \right]
$$ indicates the $ij$th mixed standardized moment (about the mean, but we assumed mean zero at the onset).
Alternately, we have the factorization
$$
\text{Cov}(\tilde Z_i) = D(\sigma, \tau) [ K - R(\rho) R(\rho)^T ] D(\sigma, \tau), \quad (1)
$$
where $D(\sigma, \tau) = \text{diag}(\sigma^2, \sigma \tau, \tau^2)$, $R(\rho) = (1, \rho, 1)^T$ and
$$
K = \begin{pmatrix}
\kappa_{04} & \kappa_{31} & \kappa_{22} \\
\kappa_{31} & \kappa_{22} & \kappa_{13} \\
\kappa_{22} & \kappa_{13} & \kappa_{04}
\end{pmatrix}.
$$
Thus we have that $Z_{11}$ and $Z_{12}$, representing the sample variance of $X$ and the covariance of $X,Y$ are correlated unless $\rho = \kappa_{31}$. When $V_i$ is multivariate normal, this occurs only when $\rho = 0$.
2 The correlation coefficient
Now consider the transformation $g(x, y, z) = (x, \frac{y}{\sqrt{z}\sqrt{x}})$ on $\tilde{S_n}$. This provides the bivariate distribution of the sample correlation coefficient and the sample variance of x. By the delta method and asymptotic normality of $S_n$,
$$
\sqrt{n}( g(\tilde{S_n}) - (\rho, \sigma^2)^T ) \rightarrow N(0, \mathbf{J}(\tilde \Sigma)^T \tilde \Lambda \mathbf{J}(\tilde \Sigma)),
$$
where $\mathbf{J}(\tilde \Sigma) = [\nabla g_1^T, \nabla g_2^T]^T$ is the jacobian of $g$.
I find (though you probably want to check my algebra..) that the gradient of the second component of $g$ is
$$
\nabla g_2 (\sigma^2, \rho \sigma \tau, \tau^2) = \left( -\frac{\rho}{2\sigma^2}, \frac{1}{\sigma \tau}, -\frac{\rho}{2 \tau^2} \right)^T,
$$
So
$$
J(\sigma, \rho, \tau) =
\begin{pmatrix}
1 & -\frac{\rho}{2\sigma^2} \\
0 & \frac{1}{\sigma \tau} \\
0 & -\frac{\rho}{2 \tau^2}
\end{pmatrix}.
$$
Putting it all together with the factorization in equation (1) yields
$$
J(\sigma, \rho, \tau)^T D(\sigma, \tau) [ K - R(\rho) R(\rho)^T ] D(\sigma, \tau) J(\sigma, \rho, \tau).
$$
Plugging in some easy to use numbers, say $\sigma = \tau = 1$ and $\rho = .5$, we'd have for
$$
J(\sigma, \rho, \tau)^T D(\sigma, \tau) [ K - R(\rho) R(\rho)^T ] D(\sigma, \tau)J(\sigma, \rho, \tau) = \begin{pmatrix}
-1/4 & 1 & -1/4 \\
1 & 0 & 0
\end{pmatrix} \mathbf I
\Omega
\mathbf I
\begin{pmatrix}
-1/4 & 1 \\
1 & 0 \\
-1/4 & 0
\end{pmatrix} = \mathbf{Q},
$$
where $\Omega = K - R(\rho) R(\rho)^T$ is generally some dense matrix. Courtesy of Mathematica, I expanded this product in terms of entries in $K$ and recount below $Q_{12}$
$$
n \times Q_{12} = n \times \text{Cov}(r, s^2_x) = \kappa_{31} -\frac{\kappa_{04} + \kappa_{22}}{4} \quad (2)
$$
which is an opaque expression in terms of the mixed moments, but certainly doesn't seem like it's going to be zero, generally.
3 Specializing to the normal case
Isserlis theorem provides a way to derive the mixed moments of a Gaussian. Again assuming $\sigma = \tau = 1$ and $\rho = .5$, we'd have
$\kappa_{31} = 3/2, \kappa_{04} = 3, \kappa_{22} = 3/2$, thus
$Q_{12} = 3/2 - (3 + 3/2)/4 = 3/8 > 0$, as you observe.
4 Simulation and Example
Below find a simulation verifying equation (1). For $n=100$ and $n=1000$ (in red and blue, respectively) iid observations from a multivariate normal, I derive the covariance of $\sqrt{n} \tilde S_n$ by bootstrap. The covariance between $S_{xy}$ and $S_{xx}$ is plotted on y axis as $\rho$ varies from $-.9$ to $.9$. The theoretical value from equation (1) and using facts about the 4th order moments of the bivariate Gaussian is plotted in a dashed black line.
A fun exercise would be to try to find a family of copula that for any value of $\rho$ would render $\text{Cov}(S_{xy}, S_{xx}) = 0$...
library(mvtnorm)
library(tidyverse)
library(boot)
params = expand.grid(sx = 1, sy = 1, n = c(100, 1000), rho = seq(-.9, .9, by = .1), replicate = 1:10) %>% mutate(k04 = 3*sx^4, k31 = 3*sx*rho*sx*sy, q12 = k31 - rho*sx*sy)
Sn_tilde = function(dat, idx){
Sn = cov(dat[idx,,drop =FALSE])*sqrt(length(idx))
Sn[upper.tri(Sn, diag = TRUE)]
}
out = params %>% group_by_all() %>% do({
x = with(., rmvnorm(n = .$n, sigma = matrix(c(sx^2, rho*sx*sy,
rho*sx*sy, sy^2), nrow = 2)))
colnames(x) = c('X', 'Y')
b = boot(x, Sn_tilde, R = 500)
cov_Sn = cov(b$t)
rownames(cov_Sn) = colnames(cov_Sn) = c('Sxx', 'Sxy', 'Syy')
as_tibble(cov_Sn, rownames = 'j')
})
ggplot(filter(out, j == 'Sxx'), aes(x = rho, y = Sxy, color = factor(n))) + geom_point(size = .5, alpha = .5) + geom_smooth(method = 'lm') + geom_line(data = filter(params, replicate == 1, n == 100), aes(y = q12), lty = 2, color = 'black') + theme_minimal() + ylab('Cov(Sxy, Sxx)')
$^1$ This heavily uses Michael Perlman's lecture notes on probability and mathematical statistics, which I really wish were available as a electronically so I could replace mine when they wear out...
|
Is the sample correlation always positively correlated with the sample variance?
TL;dr
The off-diagonal entries of the sample covariance will generally be correlated with the diagonal entries because $E(XY^3) - E(XY)E(Y^2) = 0$ only when special conditions of the mixed 4th order m
|
41,870
|
Is the sample correlation always positively correlated with the sample variance?
|
Edit: This answer is incorrect. I'm not sure whether it's better to leave it here for the record, or to just delete it.
Yes, it does hold asymptotically regardless of the distribution of X and Y. I was on the right track with the Taylor expansion:
|
Is the sample correlation always positively correlated with the sample variance?
|
Edit: This answer is incorrect. I'm not sure whether it's better to leave it here for the record, or to just delete it.
Yes, it does hold asymptotically regardless of the distribution of X and Y. I wa
|
Is the sample correlation always positively correlated with the sample variance?
Edit: This answer is incorrect. I'm not sure whether it's better to leave it here for the record, or to just delete it.
Yes, it does hold asymptotically regardless of the distribution of X and Y. I was on the right track with the Taylor expansion:
|
Is the sample correlation always positively correlated with the sample variance?
Edit: This answer is incorrect. I'm not sure whether it's better to leave it here for the record, or to just delete it.
Yes, it does hold asymptotically regardless of the distribution of X and Y. I wa
|
41,871
|
Is the sample correlation always positively correlated with the sample variance?
|
It will depend on the joint distribution. For the example you mention, the bivariate (zero-mean) Normal distribution is characterized by the $\rho, \sigma_x, \sigma_y$. It follows that one can have all possible combinations of values of these three parameters, implying that no relation between $\rho$ and the standard deviations can be established.
For other bivariate distributions, the correlation coefficient may be fundamentally a function of the standard deviations (essentially both will be functions of more primitive parameters), in which case one can examine whether a monotonic relation exists.
|
Is the sample correlation always positively correlated with the sample variance?
|
It will depend on the joint distribution. For the example you mention, the bivariate (zero-mean) Normal distribution is characterized by the $\rho, \sigma_x, \sigma_y$. It follows that one can have al
|
Is the sample correlation always positively correlated with the sample variance?
It will depend on the joint distribution. For the example you mention, the bivariate (zero-mean) Normal distribution is characterized by the $\rho, \sigma_x, \sigma_y$. It follows that one can have all possible combinations of values of these three parameters, implying that no relation between $\rho$ and the standard deviations can be established.
For other bivariate distributions, the correlation coefficient may be fundamentally a function of the standard deviations (essentially both will be functions of more primitive parameters), in which case one can examine whether a monotonic relation exists.
|
Is the sample correlation always positively correlated with the sample variance?
It will depend on the joint distribution. For the example you mention, the bivariate (zero-mean) Normal distribution is characterized by the $\rho, \sigma_x, \sigma_y$. It follows that one can have al
|
41,872
|
Can AdaBoost be used for regression?
|
AdaBoost is a meta-algorithm, which means it can be used together with other algorithms for perfomance improvement. Indeed, the concept of boosting is a type of linear regression.
Now, specifically answering your question, AdaBoost is actually intented for classification and regression problems. Scikit-Learn, for example, has an implemetation of an Adaboost regressor:
An AdaBoost regressor is a meta-estimator that begins by fitting a
regressor on the original dataset and then fits additional copies of
the regressor on the same dataset but where the weights of instances
are adjusted according to the error of the current prediction. As
such, subsequent regressors focus more on difficult cases.
|
Can AdaBoost be used for regression?
|
AdaBoost is a meta-algorithm, which means it can be used together with other algorithms for perfomance improvement. Indeed, the concept of boosting is a type of linear regression.
Now, specifically an
|
Can AdaBoost be used for regression?
AdaBoost is a meta-algorithm, which means it can be used together with other algorithms for perfomance improvement. Indeed, the concept of boosting is a type of linear regression.
Now, specifically answering your question, AdaBoost is actually intented for classification and regression problems. Scikit-Learn, for example, has an implemetation of an Adaboost regressor:
An AdaBoost regressor is a meta-estimator that begins by fitting a
regressor on the original dataset and then fits additional copies of
the regressor on the same dataset but where the weights of instances
are adjusted according to the error of the current prediction. As
such, subsequent regressors focus more on difficult cases.
|
Can AdaBoost be used for regression?
AdaBoost is a meta-algorithm, which means it can be used together with other algorithms for perfomance improvement. Indeed, the concept of boosting is a type of linear regression.
Now, specifically an
|
41,873
|
Do there exist adaptive step size methods for Newton-Raphson optimization?
|
In a sense, Newton Raphson is automatically doing the adaptive step size; it's adapting the step in each dimension (which changes the direction) according to the rate of change of the gradient. If the function is quadratic, this the "optimal" update in that in converges in one step.
Of course, generally the target function is not quadratic, or we don't need the iterative Newton Raphson algorithm as there is a closed form solution (i.e., the first step). However, if the problem is convex, we can show that the algorithm will still converge. If the function is particularly unstable (i.e., Hessian is very non-stationary), it's often a good idea to use a line-search method to, for example, check whether half stepping actually decreases the target function more than the full step proposed by vanilla Newton-Raphson.
In general, I cannot see any good reason for an adaptive step size outside using a line search. Adaptive step sizes for first order methods are strongly motivated by trying to adapt the step size by the Hessian, which Newton Raphson already does. An interesting case of why you might want to is if you are doing something like mini-batch updates, where you are approximating the target function by only using a small portion of the full data (I mention this because the SGD tag was used). Then, the fact that Newton Raphson is making an adapted step is actually bad; you don't want to immediately optimize the approximated function because you will be jumping too far and will never converge. However, generally the problems that mini-batching is useful for are the problems for which Newton Raphson cannot handle; they are often highly-multimodal and very high dimensional, so forming and solving for the full Hessian (even from just subsample of the data) is prohibitive.
EDIT:
In the comments, the OP asks about using path history to inform the step size. This is very common in improving first order methods, i.e., ADAM. One thing to note about here is that in the first order methods, one is typically trying to capture 2nd order information about the gradients to update the step. This is useful in the case that the Hessian is relatively stable; if the Hessian varied wildly over the path, using path history to estimate the current Hessian may not be very useful! Shortly, I will argue why in many maximum likelihood problems, we should expect the Hessian to be fairly stable.
So we could extend this concept to second order problems. Recall that each step of Newton Raphson updates according to a local quadratic approximation of the target function. As such, the error in a single step is directly related to the 3rd derivative along the path recommended by the Newton Raphson step. This suggests that learning from the path would improve Newton Raphson in the case where we believe the 3rd derivative will be relatively large relative to the second derivative and somewhat constant. There may well be literature about this out there, but I'm not aware of it.
Interestingly, we can show that this condition of large 3rd derivatives relative to the 2nd derivatives will not happen in the case of either having a large sample size, relative to the number of parameters estimated or the model is heavily penalized with an $L_2$ penalty. The $L_2$ penalty example is easy to show: an $L_2$ penalty affects the second derivative but not the third. If we have a large sample size to parameters estimated ratio, we can defer to maximum likelihood estimation theory; the distribution of the MLE asymptotically approaches a normal distribution. This implies that the log-likelihood approaches a quadratic function...which means that asymptotically, vanilla Newton Raphson's should behave really well! It's been my (by no means exhaustive) experience that on many statistical problems, Newton Raphson only has problems with smaller datasets, and typically converges in less than 10 iterations for moderate to large sample sizes.
None of this discredits the possibility for adaptive update learning improving Newton Raphson. But it does suggest the limited nature of applications where this could be helpful: for problems with lots of data for each parameter estimated, we should expect Newton Raphson to perform well. For extremely high dimensional problems, we can't form and solve for the Hessian anyways. This leaves us with a relatively small class of statistical problems which Newton Raphson can be significantly improved.
|
Do there exist adaptive step size methods for Newton-Raphson optimization?
|
In a sense, Newton Raphson is automatically doing the adaptive step size; it's adapting the step in each dimension (which changes the direction) according to the rate of change of the gradient. If the
|
Do there exist adaptive step size methods for Newton-Raphson optimization?
In a sense, Newton Raphson is automatically doing the adaptive step size; it's adapting the step in each dimension (which changes the direction) according to the rate of change of the gradient. If the function is quadratic, this the "optimal" update in that in converges in one step.
Of course, generally the target function is not quadratic, or we don't need the iterative Newton Raphson algorithm as there is a closed form solution (i.e., the first step). However, if the problem is convex, we can show that the algorithm will still converge. If the function is particularly unstable (i.e., Hessian is very non-stationary), it's often a good idea to use a line-search method to, for example, check whether half stepping actually decreases the target function more than the full step proposed by vanilla Newton-Raphson.
In general, I cannot see any good reason for an adaptive step size outside using a line search. Adaptive step sizes for first order methods are strongly motivated by trying to adapt the step size by the Hessian, which Newton Raphson already does. An interesting case of why you might want to is if you are doing something like mini-batch updates, where you are approximating the target function by only using a small portion of the full data (I mention this because the SGD tag was used). Then, the fact that Newton Raphson is making an adapted step is actually bad; you don't want to immediately optimize the approximated function because you will be jumping too far and will never converge. However, generally the problems that mini-batching is useful for are the problems for which Newton Raphson cannot handle; they are often highly-multimodal and very high dimensional, so forming and solving for the full Hessian (even from just subsample of the data) is prohibitive.
EDIT:
In the comments, the OP asks about using path history to inform the step size. This is very common in improving first order methods, i.e., ADAM. One thing to note about here is that in the first order methods, one is typically trying to capture 2nd order information about the gradients to update the step. This is useful in the case that the Hessian is relatively stable; if the Hessian varied wildly over the path, using path history to estimate the current Hessian may not be very useful! Shortly, I will argue why in many maximum likelihood problems, we should expect the Hessian to be fairly stable.
So we could extend this concept to second order problems. Recall that each step of Newton Raphson updates according to a local quadratic approximation of the target function. As such, the error in a single step is directly related to the 3rd derivative along the path recommended by the Newton Raphson step. This suggests that learning from the path would improve Newton Raphson in the case where we believe the 3rd derivative will be relatively large relative to the second derivative and somewhat constant. There may well be literature about this out there, but I'm not aware of it.
Interestingly, we can show that this condition of large 3rd derivatives relative to the 2nd derivatives will not happen in the case of either having a large sample size, relative to the number of parameters estimated or the model is heavily penalized with an $L_2$ penalty. The $L_2$ penalty example is easy to show: an $L_2$ penalty affects the second derivative but not the third. If we have a large sample size to parameters estimated ratio, we can defer to maximum likelihood estimation theory; the distribution of the MLE asymptotically approaches a normal distribution. This implies that the log-likelihood approaches a quadratic function...which means that asymptotically, vanilla Newton Raphson's should behave really well! It's been my (by no means exhaustive) experience that on many statistical problems, Newton Raphson only has problems with smaller datasets, and typically converges in less than 10 iterations for moderate to large sample sizes.
None of this discredits the possibility for adaptive update learning improving Newton Raphson. But it does suggest the limited nature of applications where this could be helpful: for problems with lots of data for each parameter estimated, we should expect Newton Raphson to perform well. For extremely high dimensional problems, we can't form and solve for the Hessian anyways. This leaves us with a relatively small class of statistical problems which Newton Raphson can be significantly improved.
|
Do there exist adaptive step size methods for Newton-Raphson optimization?
In a sense, Newton Raphson is automatically doing the adaptive step size; it's adapting the step in each dimension (which changes the direction) according to the rate of change of the gradient. If the
|
41,874
|
What is the PDF for a log-log-normal distribution?
|
With $\mu$ and $\sigma$ being the mean and standard deviation of the underlying normal process:
$f(x) = \displaystyle \frac{1}{\sqrt{2\pi\sigma}x\ln(x)}\exp\Bigg({\frac{-\big(\ln(\ln(x)) - \mu\big)^2}{2\sigma^2}}\Bigg) \quad x \geq 1$
|
What is the PDF for a log-log-normal distribution?
|
With $\mu$ and $\sigma$ being the mean and standard deviation of the underlying normal process:
$f(x) = \displaystyle \frac{1}{\sqrt{2\pi\sigma}x\ln(x)}\exp\Bigg({\frac{-\big(\ln(\ln(x)) - \mu\big)^2}
|
What is the PDF for a log-log-normal distribution?
With $\mu$ and $\sigma$ being the mean and standard deviation of the underlying normal process:
$f(x) = \displaystyle \frac{1}{\sqrt{2\pi\sigma}x\ln(x)}\exp\Bigg({\frac{-\big(\ln(\ln(x)) - \mu\big)^2}{2\sigma^2}}\Bigg) \quad x \geq 1$
|
What is the PDF for a log-log-normal distribution?
With $\mu$ and $\sigma$ being the mean and standard deviation of the underlying normal process:
$f(x) = \displaystyle \frac{1}{\sqrt{2\pi\sigma}x\ln(x)}\exp\Bigg({\frac{-\big(\ln(\ln(x)) - \mu\big)^2}
|
41,875
|
Does AUC/ROC curve return a p-value?
|
No, it doesn't. p-values from ROC areas are new to me, but I read the following:
Mason and Graham (2002) show that the ROC area is equivalent to the Mann–Whitney U-statistic testing the significance of forecast event probabilities for cases where events actually occurred with those where events did not occur.
Function roc.area() of R-package verification applies this approach and uses function wilcox.test() to calculate the p-value. To me, it looks like this was done in the paper you referenced.
|
Does AUC/ROC curve return a p-value?
|
No, it doesn't. p-values from ROC areas are new to me, but I read the following:
Mason and Graham (2002) show that the ROC area is equivalent to the Mann–Whitney U-statistic testing the significance o
|
Does AUC/ROC curve return a p-value?
No, it doesn't. p-values from ROC areas are new to me, but I read the following:
Mason and Graham (2002) show that the ROC area is equivalent to the Mann–Whitney U-statistic testing the significance of forecast event probabilities for cases where events actually occurred with those where events did not occur.
Function roc.area() of R-package verification applies this approach and uses function wilcox.test() to calculate the p-value. To me, it looks like this was done in the paper you referenced.
|
Does AUC/ROC curve return a p-value?
No, it doesn't. p-values from ROC areas are new to me, but I read the following:
Mason and Graham (2002) show that the ROC area is equivalent to the Mann–Whitney U-statistic testing the significance o
|
41,876
|
Who invented the independence notation $\perp \!\!\! \perp$?
|
I have often seen it associated with AP Dawid 1979, "Conditional Independence in Statistical Theory." For example page 373 of these notes. I have no idea if Dawid actually invented it or popularized it.
Update 8/17/19: According to Wikipedia, the symbol was introduced by Elfving: "Elfving introduced the statistical symbol for probabilistic independence ⊥⊥, which is a stronger condition than orthogonality ⊥, by the 1950s."
|
Who invented the independence notation $\perp \!\!\! \perp$?
|
I have often seen it associated with AP Dawid 1979, "Conditional Independence in Statistical Theory." For example page 373 of these notes. I have no idea if Dawid actually invented it or popularized i
|
Who invented the independence notation $\perp \!\!\! \perp$?
I have often seen it associated with AP Dawid 1979, "Conditional Independence in Statistical Theory." For example page 373 of these notes. I have no idea if Dawid actually invented it or popularized it.
Update 8/17/19: According to Wikipedia, the symbol was introduced by Elfving: "Elfving introduced the statistical symbol for probabilistic independence ⊥⊥, which is a stronger condition than orthogonality ⊥, by the 1950s."
|
Who invented the independence notation $\perp \!\!\! \perp$?
I have often seen it associated with AP Dawid 1979, "Conditional Independence in Statistical Theory." For example page 373 of these notes. I have no idea if Dawid actually invented it or popularized i
|
41,877
|
Where is my mistake in this definition of Bayes Factor?
|
My deepest apologies, there is a typo in the final expression! Indeed, here is the complete text from my book (p.231):
Definition 5.5. The Bayes factor is the ratio of the posterior probabilities of the null and the alternative hypotheses over the
ratio of the prior probabilities of the null and the alternative
hypotheses, i.e., $$ B^\pi_{01}(x) = {P(\theta \in \Theta_ 0\mid x)
\over P(\theta \in \Theta_1\mid x)} \bigg/ {\pi(\theta \in \Theta_ 0)
\over \pi(\theta \in \Theta_ 1)}. $$ This ratio evaluates the
modification of the odds of $\Theta_0$ against $\Theta_1$ due to the
\obs\ and can naturally be compared to $1$, although an exact
comparison scale can only be based upon a loss function. In the
particular case where $\Theta_0=\{\theta_0\}$ and
$\Theta_1=\{\theta_1\}$, the Bayes factor simplifies to the usual
likelihood ratio $$ B^\pi_{01} (x) = {f(x|\theta_0)\over
f(x|\theta_1)}. $$ In general, the Bayes factor depends on prior
information, but is still proposed as an ``objective'' Bayesian
answer, since it partly eliminates the influence of the prior modeling
and emphasizes the role of the observations. Actually, it can be
perceived as a Bayesian likelihood ratio since, if $\pi_0$ is the
prior distribution under $H_0$ and $\pi_1$ the prior distribution
under $H_1$, $B^\pi_{01}(x)$ can be written as \begin{equation}
B^\pi_{01} (x) = {\int_{\Theta_0} f(x|\theta_0)\pi_0(\theta)
\,\text{d}\theta \over \int_{\Theta_1} f(x|\theta_1)\pi_1(\theta)
\,\text{d}\theta}
=\frac{m_0(x)}{m_1(x)}\,, \end{equation} thus replacing the likelihoods with the marginals under both hypotheses.
The prior is thus defined as a mixture:
$$\pi(\theta)=\pi(\theta \in \Theta_ 0)\times\pi_0(\theta)\times\mathbb{I}_{\Theta_0}(\theta)+\pi(\theta \in \Theta_ 1)\times\pi_1(\theta)\times\mathbb{I}_{\Theta_1}(\theta)$$where
$$\pi(\theta \in \Theta_ 0)=\rho_0\qquad\text{and}\qquad\pi(\theta \in \Theta_ 1)=1-\rho_0\stackrel{\text{def}}{=}\rho_1$$
are the prior weights of both hypotheses and
$$\int_{\Theta_0} \pi_0(\theta_0)\text{d}\theta_0=\int_{\Theta_1} \pi_1(\theta_1)\text{d}\theta_1=1$$Therefore
\begin{align*}P(\theta \in \Theta_ 0|x)=\int_{\Theta_0} \pi(\theta_0|x)\text{d}\theta_0&=\int_{\Theta_0} \pi(\theta_0|x)\text{d}\theta_0\\
&= \frac{\int_{\Theta_0} \pi(\theta_0)f(x|\theta_0)\text{d}\theta_0}{\int_{\Theta_0} \pi(\theta_0)f(x|\theta_0)\text{d}\theta_0+\int_{\Theta_1} \pi(\theta_1)f(x|\theta_1)\text{d}\theta_1}\\
&=\frac{\int_{\Theta_0} \rho_0\pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0}{\int_{\Theta_0} \rho_0\pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0+\int_{\Theta_1} \rho_1\pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}
\end{align*}
and
$$P(\theta \in \Theta_1\mid x)=\frac{\int_{\Theta_1} \rho_1\pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}{\int_{\Theta_0} \rho_0\pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0+\int_{\Theta_1} \rho_1\pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}$$Hence,
$$\frac{P(\theta \in \Theta_ 0|x)}{P(\theta \in \Theta_1\mid x)}=\frac{\rho_0\int_{\Theta_0} \pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0}{\rho_1\int_{\Theta_1} \pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}=\frac{\rho_0}{1-\rho_0}B^\pi_{01}(x)$$
This hopefully explains where the final expression comes from.
Alas, there is a mistake in the last ratio of integrals in the quoted text (presumably due to a cut & paste)
$$B_{01}^{\pi}=\frac{\int_{\Theta_{0}}f(x|\theta_{0})\pi_{0}(\theta)d\theta}{\int_{\Theta_{1}}f(x|\theta_{1})\pi_{1}(\theta)d\theta}$$
which should be (when identifying the integrands differently in the two integrals to signify that the integrals are over two different parameter spaces)
$$B_{01}^{\pi}=\frac{\int_{\Theta_{0}}f(x|\theta_{0})\pi_{0}(\theta_0)d\theta_0}{\int_{\Theta_{1}}f(x|\theta_{1})\pi_{1}(\theta_1)d\theta_1}$$or (with another choice of representation of the integrands)
$$B_{01}^{\pi}=\frac{\int_{\Theta_{0}}f(x|\theta)\pi_{0}(\theta)d\theta}{\int_{\Theta_{1}}f(x|\theta)\pi_{1}(\theta)d\theta}$$
The only case when the notations $\theta_0$ and $\theta_1$ are important is when both null and alternative hypotheses are point hypotheses, i.e., when $\Theta_0=\{\theta_0\}$ and $\Theta_1=\{\theta_1\}$, since both symbols then take specific values, like $\theta_0=3$ and $\theta_1=-2$. In this specific case, the posterior is concentrated on $\{\theta_0,\theta_1\}$ and the Bayes factor writes $$ B^\pi_{01} (x) = {f(x|\theta_0)\over f(x|\theta_1)}$$ since
$$P(\theta=\theta_0|x)=\frac{\overbrace{\pi(\theta_0)}^{\rho_0}f(x|\theta_0)}{\pi(\theta_0)f(x|\theta_0)+\underbrace{\pi(\theta_1)}_{\rho_1}f(x|\theta_1)}$$
Thank you for pointing out this error, to be added to the list of typos.
|
Where is my mistake in this definition of Bayes Factor?
|
My deepest apologies, there is a typo in the final expression! Indeed, here is the complete text from my book (p.231):
Definition 5.5. The Bayes factor is the ratio of the posterior probabilities of
|
Where is my mistake in this definition of Bayes Factor?
My deepest apologies, there is a typo in the final expression! Indeed, here is the complete text from my book (p.231):
Definition 5.5. The Bayes factor is the ratio of the posterior probabilities of the null and the alternative hypotheses over the
ratio of the prior probabilities of the null and the alternative
hypotheses, i.e., $$ B^\pi_{01}(x) = {P(\theta \in \Theta_ 0\mid x)
\over P(\theta \in \Theta_1\mid x)} \bigg/ {\pi(\theta \in \Theta_ 0)
\over \pi(\theta \in \Theta_ 1)}. $$ This ratio evaluates the
modification of the odds of $\Theta_0$ against $\Theta_1$ due to the
\obs\ and can naturally be compared to $1$, although an exact
comparison scale can only be based upon a loss function. In the
particular case where $\Theta_0=\{\theta_0\}$ and
$\Theta_1=\{\theta_1\}$, the Bayes factor simplifies to the usual
likelihood ratio $$ B^\pi_{01} (x) = {f(x|\theta_0)\over
f(x|\theta_1)}. $$ In general, the Bayes factor depends on prior
information, but is still proposed as an ``objective'' Bayesian
answer, since it partly eliminates the influence of the prior modeling
and emphasizes the role of the observations. Actually, it can be
perceived as a Bayesian likelihood ratio since, if $\pi_0$ is the
prior distribution under $H_0$ and $\pi_1$ the prior distribution
under $H_1$, $B^\pi_{01}(x)$ can be written as \begin{equation}
B^\pi_{01} (x) = {\int_{\Theta_0} f(x|\theta_0)\pi_0(\theta)
\,\text{d}\theta \over \int_{\Theta_1} f(x|\theta_1)\pi_1(\theta)
\,\text{d}\theta}
=\frac{m_0(x)}{m_1(x)}\,, \end{equation} thus replacing the likelihoods with the marginals under both hypotheses.
The prior is thus defined as a mixture:
$$\pi(\theta)=\pi(\theta \in \Theta_ 0)\times\pi_0(\theta)\times\mathbb{I}_{\Theta_0}(\theta)+\pi(\theta \in \Theta_ 1)\times\pi_1(\theta)\times\mathbb{I}_{\Theta_1}(\theta)$$where
$$\pi(\theta \in \Theta_ 0)=\rho_0\qquad\text{and}\qquad\pi(\theta \in \Theta_ 1)=1-\rho_0\stackrel{\text{def}}{=}\rho_1$$
are the prior weights of both hypotheses and
$$\int_{\Theta_0} \pi_0(\theta_0)\text{d}\theta_0=\int_{\Theta_1} \pi_1(\theta_1)\text{d}\theta_1=1$$Therefore
\begin{align*}P(\theta \in \Theta_ 0|x)=\int_{\Theta_0} \pi(\theta_0|x)\text{d}\theta_0&=\int_{\Theta_0} \pi(\theta_0|x)\text{d}\theta_0\\
&= \frac{\int_{\Theta_0} \pi(\theta_0)f(x|\theta_0)\text{d}\theta_0}{\int_{\Theta_0} \pi(\theta_0)f(x|\theta_0)\text{d}\theta_0+\int_{\Theta_1} \pi(\theta_1)f(x|\theta_1)\text{d}\theta_1}\\
&=\frac{\int_{\Theta_0} \rho_0\pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0}{\int_{\Theta_0} \rho_0\pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0+\int_{\Theta_1} \rho_1\pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}
\end{align*}
and
$$P(\theta \in \Theta_1\mid x)=\frac{\int_{\Theta_1} \rho_1\pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}{\int_{\Theta_0} \rho_0\pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0+\int_{\Theta_1} \rho_1\pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}$$Hence,
$$\frac{P(\theta \in \Theta_ 0|x)}{P(\theta \in \Theta_1\mid x)}=\frac{\rho_0\int_{\Theta_0} \pi_0(\theta_0)f(x|\theta_0)\text{d}\theta_0}{\rho_1\int_{\Theta_1} \pi_1(\theta_1)f(x|\theta_1)\text{d}\theta_1}=\frac{\rho_0}{1-\rho_0}B^\pi_{01}(x)$$
This hopefully explains where the final expression comes from.
Alas, there is a mistake in the last ratio of integrals in the quoted text (presumably due to a cut & paste)
$$B_{01}^{\pi}=\frac{\int_{\Theta_{0}}f(x|\theta_{0})\pi_{0}(\theta)d\theta}{\int_{\Theta_{1}}f(x|\theta_{1})\pi_{1}(\theta)d\theta}$$
which should be (when identifying the integrands differently in the two integrals to signify that the integrals are over two different parameter spaces)
$$B_{01}^{\pi}=\frac{\int_{\Theta_{0}}f(x|\theta_{0})\pi_{0}(\theta_0)d\theta_0}{\int_{\Theta_{1}}f(x|\theta_{1})\pi_{1}(\theta_1)d\theta_1}$$or (with another choice of representation of the integrands)
$$B_{01}^{\pi}=\frac{\int_{\Theta_{0}}f(x|\theta)\pi_{0}(\theta)d\theta}{\int_{\Theta_{1}}f(x|\theta)\pi_{1}(\theta)d\theta}$$
The only case when the notations $\theta_0$ and $\theta_1$ are important is when both null and alternative hypotheses are point hypotheses, i.e., when $\Theta_0=\{\theta_0\}$ and $\Theta_1=\{\theta_1\}$, since both symbols then take specific values, like $\theta_0=3$ and $\theta_1=-2$. In this specific case, the posterior is concentrated on $\{\theta_0,\theta_1\}$ and the Bayes factor writes $$ B^\pi_{01} (x) = {f(x|\theta_0)\over f(x|\theta_1)}$$ since
$$P(\theta=\theta_0|x)=\frac{\overbrace{\pi(\theta_0)}^{\rho_0}f(x|\theta_0)}{\pi(\theta_0)f(x|\theta_0)+\underbrace{\pi(\theta_1)}_{\rho_1}f(x|\theta_1)}$$
Thank you for pointing out this error, to be added to the list of typos.
|
Where is my mistake in this definition of Bayes Factor?
My deepest apologies, there is a typo in the final expression! Indeed, here is the complete text from my book (p.231):
Definition 5.5. The Bayes factor is the ratio of the posterior probabilities of
|
41,878
|
Gradient boosting regression trained on skewed data
|
I think we must first consider if the outliers are "true data" or just simply noise/corrupted input.
If they are corrupted data (e.g. an adult human weighting 775 kg) then it is perfectly reasonable to exclude these instances from further analysis. If these instances though are reasonable data we might want to work with them, rather than around them. A first obvious fix that does not involve data transformations, would be to employ a custom objective function approximating a MAE, a Huberised loss or a quantile loss. That would allow minimising the effect of instances that might seem highly unnatural. In general and without containing yourself to gradient boosting, I would suggest looking into robust statistics to get a better idea of how one would classically deal with potentially noisy and/or skewed data (for example using a GAM with a scaled-T distribution for the family of the response).
As you say, potentially transforming then back-transforming your data (log(x+1) being a common choice of strictly non-negative data) is also a potentially reasonable approach. Go for it, just do not get too crazy because while model interpretability is not a prime concern when predicting, if the transformation is just too convoluted (e.g. through some arbitrary power tranformation), debugging and/or improving an existing model becomes even more complicated than it should.
Finally, I would suggest you look into some data competitions that are concerned with skewed variables themselves (e.g. the Allstate Insurance claims severity predictions), these guys have some nifty ideas too!
|
Gradient boosting regression trained on skewed data
|
I think we must first consider if the outliers are "true data" or just simply noise/corrupted input.
If they are corrupted data (e.g. an adult human weighting 775 kg) then it is perfectly reasonable
|
Gradient boosting regression trained on skewed data
I think we must first consider if the outliers are "true data" or just simply noise/corrupted input.
If they are corrupted data (e.g. an adult human weighting 775 kg) then it is perfectly reasonable to exclude these instances from further analysis. If these instances though are reasonable data we might want to work with them, rather than around them. A first obvious fix that does not involve data transformations, would be to employ a custom objective function approximating a MAE, a Huberised loss or a quantile loss. That would allow minimising the effect of instances that might seem highly unnatural. In general and without containing yourself to gradient boosting, I would suggest looking into robust statistics to get a better idea of how one would classically deal with potentially noisy and/or skewed data (for example using a GAM with a scaled-T distribution for the family of the response).
As you say, potentially transforming then back-transforming your data (log(x+1) being a common choice of strictly non-negative data) is also a potentially reasonable approach. Go for it, just do not get too crazy because while model interpretability is not a prime concern when predicting, if the transformation is just too convoluted (e.g. through some arbitrary power tranformation), debugging and/or improving an existing model becomes even more complicated than it should.
Finally, I would suggest you look into some data competitions that are concerned with skewed variables themselves (e.g. the Allstate Insurance claims severity predictions), these guys have some nifty ideas too!
|
Gradient boosting regression trained on skewed data
I think we must first consider if the outliers are "true data" or just simply noise/corrupted input.
If they are corrupted data (e.g. an adult human weighting 775 kg) then it is perfectly reasonable
|
41,879
|
huge difference between estimates of binomial regresssion when including random effect vs when not
|
There is enough information in the question to clear this up. lsmeans is simply using the coefficients to obtain the group predicted probabilities.
So for the GLM, OP's implied model is:
\begin{equation}
\hat\pi=\frac{1}{1+e^{-(-1.9684+0.2139\times d)}}
\end{equation}
where $d$ is an indicator for membership in group 2. So the predicted probabilities are: $(1+e^{-(-1.9684)})^{-1}$ and $(1+e^{-(-1.9684+0.2139)})^{-1}$ for groups 1 and 2 respectively. These result in predicted probabilities of about $12.25\%$ and $14.75\%$ respectively.
For the multilevel model (or GLMM), OP's implied model is:
\begin{equation}
\hat\pi=\frac{1}{1+e^{-(-3.0571+0.3915\times d+1.881\times \hat{u})}}
\end{equation}
where $\hat{u}$ is the random intercept assumed to be standard normal. The predicted probabilities from lsmeans assume a random intercept value of zero $(\hat{u}=0)$ resulting in: $(1+e^{-(-3.0571)})^{-1}$ and $(1+e^{-(-3.0571+0.3915)})^{-1}$ for groups 1 and 2 respectively. These result in predicted probabilities of about $4.49\%$ and $6.50\%$ respectively. These are the lsmeans GLMM results.
An issue is the intercept in GLMM is the expected log-odds of success for someone who is "average" relative to others. So using this as a basis for reporting the whole model is an issue. About the other coefficient, one suggestion for why the group difference coefficient increases is that the model quality is better so the coefficient increases, search for collapsible on this website or see Is meta-analysis of odds ratios essentially hopeless?.
To make the lsmeans GLMM results comparable to the lsmeans GLM results. We have to use the observed values of the random intercept, $\hat{u}$. One can simulate random intercepts to match OP's specific model:
set.seed(12345)
u_hat <- rnorm(1553, 0, 1.881)
d <- c(rep(0, 1434), rep(1, 119))
# predicted log odds:
pred_log_odds <- -3.0571 + 0.3915 * d + u_hat
pred_prob <- plogis(pred_log_odds)
coef(lm(pred_prob ~ 0 + factor(d)))
factor(d)0 factor(d)1
0.1189244 0.1490395
In this simulated example, these values are a lot closer to the lsmeans GLM results. If you run something like the syntax below on your data:
lm(fitted(model) ~ 0 + df$student_type)
where model is the GLMM, you should get values quite close to the lsmeans values. I'm assuming that when you call fitted() on glmer(), it also includes the random intercept and the values that are returned are probabilities.
In your situation where the groups are naturally occurring, an additional thing to explore in the data is the differing group variances on the random intercept, so a model like:
glmer(cbind(total_correct, total_ans-total_correct) ~
(0 + student_type || student) + student_type,
family = binomial, data = sub_df,
control = glmerControl(optimizer = "nloptwrap", calc.derivs = FALSE))
might be worth exploring since right now, you're assuming the random intercept variances do not differ by group. I used the || so lme4 does not attempt to correlate the two random intercepts.
I did not know that one could add a random intercept for each student when they essentially have only one row in the data. But I am rationalizing it away by assuming that the trial vs. failures per row amount to several rows in long form.
|
huge difference between estimates of binomial regresssion when including random effect vs when not
|
There is enough information in the question to clear this up. lsmeans is simply using the coefficients to obtain the group predicted probabilities.
So for the GLM, OP's implied model is:
\begin{equati
|
huge difference between estimates of binomial regresssion when including random effect vs when not
There is enough information in the question to clear this up. lsmeans is simply using the coefficients to obtain the group predicted probabilities.
So for the GLM, OP's implied model is:
\begin{equation}
\hat\pi=\frac{1}{1+e^{-(-1.9684+0.2139\times d)}}
\end{equation}
where $d$ is an indicator for membership in group 2. So the predicted probabilities are: $(1+e^{-(-1.9684)})^{-1}$ and $(1+e^{-(-1.9684+0.2139)})^{-1}$ for groups 1 and 2 respectively. These result in predicted probabilities of about $12.25\%$ and $14.75\%$ respectively.
For the multilevel model (or GLMM), OP's implied model is:
\begin{equation}
\hat\pi=\frac{1}{1+e^{-(-3.0571+0.3915\times d+1.881\times \hat{u})}}
\end{equation}
where $\hat{u}$ is the random intercept assumed to be standard normal. The predicted probabilities from lsmeans assume a random intercept value of zero $(\hat{u}=0)$ resulting in: $(1+e^{-(-3.0571)})^{-1}$ and $(1+e^{-(-3.0571+0.3915)})^{-1}$ for groups 1 and 2 respectively. These result in predicted probabilities of about $4.49\%$ and $6.50\%$ respectively. These are the lsmeans GLMM results.
An issue is the intercept in GLMM is the expected log-odds of success for someone who is "average" relative to others. So using this as a basis for reporting the whole model is an issue. About the other coefficient, one suggestion for why the group difference coefficient increases is that the model quality is better so the coefficient increases, search for collapsible on this website or see Is meta-analysis of odds ratios essentially hopeless?.
To make the lsmeans GLMM results comparable to the lsmeans GLM results. We have to use the observed values of the random intercept, $\hat{u}$. One can simulate random intercepts to match OP's specific model:
set.seed(12345)
u_hat <- rnorm(1553, 0, 1.881)
d <- c(rep(0, 1434), rep(1, 119))
# predicted log odds:
pred_log_odds <- -3.0571 + 0.3915 * d + u_hat
pred_prob <- plogis(pred_log_odds)
coef(lm(pred_prob ~ 0 + factor(d)))
factor(d)0 factor(d)1
0.1189244 0.1490395
In this simulated example, these values are a lot closer to the lsmeans GLM results. If you run something like the syntax below on your data:
lm(fitted(model) ~ 0 + df$student_type)
where model is the GLMM, you should get values quite close to the lsmeans values. I'm assuming that when you call fitted() on glmer(), it also includes the random intercept and the values that are returned are probabilities.
In your situation where the groups are naturally occurring, an additional thing to explore in the data is the differing group variances on the random intercept, so a model like:
glmer(cbind(total_correct, total_ans-total_correct) ~
(0 + student_type || student) + student_type,
family = binomial, data = sub_df,
control = glmerControl(optimizer = "nloptwrap", calc.derivs = FALSE))
might be worth exploring since right now, you're assuming the random intercept variances do not differ by group. I used the || so lme4 does not attempt to correlate the two random intercepts.
I did not know that one could add a random intercept for each student when they essentially have only one row in the data. But I am rationalizing it away by assuming that the trial vs. failures per row amount to several rows in long form.
|
huge difference between estimates of binomial regresssion when including random effect vs when not
There is enough information in the question to clear this up. lsmeans is simply using the coefficients to obtain the group predicted probabilities.
So for the GLM, OP's implied model is:
\begin{equati
|
41,880
|
huge difference between estimates of binomial regresssion when including random effect vs when not
|
Model 1, Logistic regression without random effect:
$$\mathrm{Logit}(\Pr(Y=1)) = X\beta$$
We know MLE $\hat \beta$ is asymptotically unbiased. But
$$\hat Pr(Y=1) = \mathrm{Logit}^{-1}(X\hat\beta)$$ is biased estimate of $\Pr(Y=1)$, because the non-linearity of the logit function. But asymptotically it is unbiased. So for model 1, $\hat Pr(Y=1) = \mathrm{Logit}^{-1}(X\hat\beta)$ is acceptable.
Model 2, Logistic regression with random intercept:
$$\mathrm{Logit}(\Pr(Y_{ij}=1)) = X_{ij}\beta + \gamma_i$$
$$\gamma \sim N(0,\sigma^2)$$
In this situation, the common mistake is
$$\Pr(Y=1|X) = \mathrm{E}(Y|X) = \mathrm{E}(\mathrm{Logit}^{-1}(X\beta + \gamma_i)) =\mathrm{Logit}^{-1}( \mathrm{E}(X\beta + \gamma_i)) = \mathrm{Logit}^{-1}(X\beta) $$
In this process the non-linearity of the logit function is totally igored.
So the following output is very misleading. It gives a idear that for group 1 student, Probability of correction is 4.5%.
student_type prob SE df asymp.LCL asymp.UCL
student_group_1 0.04491007 0.004626728 NA 0.03666574 0.0549025
student_group_2 0.06503249 0.015117905 NA 0.04097546 0.1017156
The mistake above cannot be contributed to mixed effect logistic regression, should come from the misinterpretation of the results.
Let look how to correctly derived the marginal mean of $Y$.
$$\Pr(Y=1|X) = \mathrm{E}(Y|X) = \mathrm{E}(\mathrm{Logit}^{-1}(X\beta + \gamma_i)) =\int_{-\infty}^{\infty} \mathrm{Logit}^{-1}(z)\phi(z)dz$$
where $z=X\beta + \gamma_i$ and $\phi$ is pdf of $N(X\beta, \sigma^2)$
For Group 1 student, the results indicate that $X\beta= -3.0571$, $\sigma = 1.881$. Using Gauss–Hermite quadrature method with 20 points, I got $\Pr(Y=1|X=0) = 0.1172$. similarly, $\Pr(Y=1|X=0) = 0.1492$.
|
huge difference between estimates of binomial regresssion when including random effect vs when not
|
Model 1, Logistic regression without random effect:
$$\mathrm{Logit}(\Pr(Y=1)) = X\beta$$
We know MLE $\hat \beta$ is asymptotically unbiased. But
$$\hat Pr(Y=1) = \mathrm{Logit}^{-1}(X\hat\beta)$$ is
|
huge difference between estimates of binomial regresssion when including random effect vs when not
Model 1, Logistic regression without random effect:
$$\mathrm{Logit}(\Pr(Y=1)) = X\beta$$
We know MLE $\hat \beta$ is asymptotically unbiased. But
$$\hat Pr(Y=1) = \mathrm{Logit}^{-1}(X\hat\beta)$$ is biased estimate of $\Pr(Y=1)$, because the non-linearity of the logit function. But asymptotically it is unbiased. So for model 1, $\hat Pr(Y=1) = \mathrm{Logit}^{-1}(X\hat\beta)$ is acceptable.
Model 2, Logistic regression with random intercept:
$$\mathrm{Logit}(\Pr(Y_{ij}=1)) = X_{ij}\beta + \gamma_i$$
$$\gamma \sim N(0,\sigma^2)$$
In this situation, the common mistake is
$$\Pr(Y=1|X) = \mathrm{E}(Y|X) = \mathrm{E}(\mathrm{Logit}^{-1}(X\beta + \gamma_i)) =\mathrm{Logit}^{-1}( \mathrm{E}(X\beta + \gamma_i)) = \mathrm{Logit}^{-1}(X\beta) $$
In this process the non-linearity of the logit function is totally igored.
So the following output is very misleading. It gives a idear that for group 1 student, Probability of correction is 4.5%.
student_type prob SE df asymp.LCL asymp.UCL
student_group_1 0.04491007 0.004626728 NA 0.03666574 0.0549025
student_group_2 0.06503249 0.015117905 NA 0.04097546 0.1017156
The mistake above cannot be contributed to mixed effect logistic regression, should come from the misinterpretation of the results.
Let look how to correctly derived the marginal mean of $Y$.
$$\Pr(Y=1|X) = \mathrm{E}(Y|X) = \mathrm{E}(\mathrm{Logit}^{-1}(X\beta + \gamma_i)) =\int_{-\infty}^{\infty} \mathrm{Logit}^{-1}(z)\phi(z)dz$$
where $z=X\beta + \gamma_i$ and $\phi$ is pdf of $N(X\beta, \sigma^2)$
For Group 1 student, the results indicate that $X\beta= -3.0571$, $\sigma = 1.881$. Using Gauss–Hermite quadrature method with 20 points, I got $\Pr(Y=1|X=0) = 0.1172$. similarly, $\Pr(Y=1|X=0) = 0.1492$.
|
huge difference between estimates of binomial regresssion when including random effect vs when not
Model 1, Logistic regression without random effect:
$$\mathrm{Logit}(\Pr(Y=1)) = X\beta$$
We know MLE $\hat \beta$ is asymptotically unbiased. But
$$\hat Pr(Y=1) = \mathrm{Logit}^{-1}(X\hat\beta)$$ is
|
41,881
|
RKHS norm and Fourier transform link
|
I'm also learning this stuff and was unable to find a proof so I took a swing at one.
There's a couple things we need to know about RKHS and Fourier analysis before we start (that I think are well established online if you're unfamiliar):
The word "reproducing" in RKHS comes from the fact that if we take the inner product of some function $f \in \mathcal{H}$ (where $\mathcal{H}$ is our RKHS) with a kernel function centered at $\mathbf{x}$, that's the same thing as evaluting our function at $\mathbf{x}$: $\langle f, k(.,\mathbf{x})\rangle = f(\mathbf{x})$.
If $h(\mathbf{x}) = f(\mathbf{x} - \mathbf{x}_0)$, then $\hat{h}(\mathbf{t}) = e^{-2\pi i \mathbf{x}_0^\top\mathbf{t}} \hat{f}(\mathbf{t})$, so the Fourier transforms of a function and a shifted version of that function are related.
I'm going to do this proof in the context of a general stationary covariance function $k$, but it would be straightforward to plug in your Gaussian kernel if you are exclusively interested in that. Since it's stationary, our kernel function may be expressed as $k(\mathbf{x}, \mathbf{y}) = d(\mathbf{x}-\mathbf{y})$ for some function $d$ ($d(\mathbf{x}) = e^{-\frac{||\mathbf{x}||_2^2}{\sigma^2}} $in the Gaussian case).
We want to show the following:
$ \langle f, g \rangle_{\mathcal{C}} := \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) \overline{\hat{g}(\mathbf{t})}}{\hat{d}(\mathbf{t})} d\mathbf{t} =\langle f, g \rangle_{\mathcal{H}} \,\,\,\,\, \forall f,g \in \mathcal{H}$
or, in words, that our candidate inner product $ \langle f, g \rangle_{\mathcal{C}}$ agrees with our actual RKHS inner product $\langle f, g \rangle_{\mathcal{H}}$ for all possible $f, g \in \mathcal{H}$ (the result you ask about regarding $||f||_\mathcal{H}$ follows immediately from this result about the inner product).
The strategy for the proof will be to take our candidate inner product $\langle f, g \rangle_{\mathcal{C}}$ and show that it satisfies the reproducing property, that is, that $\langle f, k(.,\mathbf{x}) \rangle_{\mathcal{C}} = f(\mathbf{x})$, and then to expand on this to show that the inner products agree no matter which 2 functions we want to compute it between.
To this end, we will examine the quantity:
$ \langle f, k(., \mathbf{x}) \rangle_{\mathcal{C}} = \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) \overline{\hat{k(.,\mathbf{x})}(\mathbf{t})}}{\hat{d}(\mathbf{t})} d\mathbf{t}$
To proceed, let us evaluate $\hat{k(.,\mathbf{x})}(\mathbf{t})$. Since $k$ is stationary, $k(\mathbf{y}, \mathbf{x})=d(\mathbf{y}-\mathbf{x})$, and given fact (2) above, we thus know that $\hat{k(.,\mathbf{x})}(\mathbf{t}) = e^{-2\pi i \mathbf{x}^\top\mathbf{t}} \hat{d}(\mathbf{t})$. Substitution yields:
$ \langle f, k(., \mathbf{x}) \rangle_{\mathcal{C}} = \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) \overline{e^{-2\pi i \mathbf{x}^\top\mathbf{t}} \hat{d}(\mathbf{t})}}{\hat{d}(\mathbf{t})} d\mathbf{t}$
Since $d$ is real and symmetric, $\overline{\hat{d}(\mathbf{t})} = \hat{d}(\mathbf{t})$, and we have:
$ \langle f, k(., \mathbf{x}) \rangle_{\mathcal{C}} = \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) e^{2\pi i \mathbf{x}^\top\mathbf{t}} \hat{d}(\mathbf{t})}{\hat{d}(\mathbf{t})} d\mathbf{t} = \int_{\mathbb{R}^d} \hat{f}(\mathbf{t})e^{2\pi i \mathbf{x}^\top\mathbf{t}} d\mathbf{t} = f(\mathbf{x}) = \langle f, k(.,\mathbf{x})\rangle_{\mathcal{H}}$
since this is the inverse of the Fourier Transform (notice the negative sign in the exponential term cancelled with complex conjugation). So we've shown that the inner product is the same when the first argument is a function and the second a kernel. Now to generalize.
Consider:
$
\langle f, g \rangle_{\mathcal{C}} =
\langle f, \sum_{i} a_i k(.,\mathbf{x}_i)\rangle_{\mathcal{C}} =
\sum_{i} a_i \langle f, k(.,\mathbf{x}_i)\rangle_{\mathcal{C}} =
\sum_{i} a_i \langle f, k(.,\mathbf{x}_i)\rangle_{\mathcal{H}} =
\langle f, \sum_{i} a_i k(.,\mathbf{x}_i)\rangle_{\mathcal{H}} =
\langle f, g \rangle_{\mathcal{H}}
$
which establishes that the inner product agrees for all $f,g$. To establish the result you were interested in, explicitly plug in the form of the Gaussian kernel's Fourier transform, and examine the inner product between a function and itself.
|
RKHS norm and Fourier transform link
|
I'm also learning this stuff and was unable to find a proof so I took a swing at one.
There's a couple things we need to know about RKHS and Fourier analysis before we start (that I think are well est
|
RKHS norm and Fourier transform link
I'm also learning this stuff and was unable to find a proof so I took a swing at one.
There's a couple things we need to know about RKHS and Fourier analysis before we start (that I think are well established online if you're unfamiliar):
The word "reproducing" in RKHS comes from the fact that if we take the inner product of some function $f \in \mathcal{H}$ (where $\mathcal{H}$ is our RKHS) with a kernel function centered at $\mathbf{x}$, that's the same thing as evaluting our function at $\mathbf{x}$: $\langle f, k(.,\mathbf{x})\rangle = f(\mathbf{x})$.
If $h(\mathbf{x}) = f(\mathbf{x} - \mathbf{x}_0)$, then $\hat{h}(\mathbf{t}) = e^{-2\pi i \mathbf{x}_0^\top\mathbf{t}} \hat{f}(\mathbf{t})$, so the Fourier transforms of a function and a shifted version of that function are related.
I'm going to do this proof in the context of a general stationary covariance function $k$, but it would be straightforward to plug in your Gaussian kernel if you are exclusively interested in that. Since it's stationary, our kernel function may be expressed as $k(\mathbf{x}, \mathbf{y}) = d(\mathbf{x}-\mathbf{y})$ for some function $d$ ($d(\mathbf{x}) = e^{-\frac{||\mathbf{x}||_2^2}{\sigma^2}} $in the Gaussian case).
We want to show the following:
$ \langle f, g \rangle_{\mathcal{C}} := \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) \overline{\hat{g}(\mathbf{t})}}{\hat{d}(\mathbf{t})} d\mathbf{t} =\langle f, g \rangle_{\mathcal{H}} \,\,\,\,\, \forall f,g \in \mathcal{H}$
or, in words, that our candidate inner product $ \langle f, g \rangle_{\mathcal{C}}$ agrees with our actual RKHS inner product $\langle f, g \rangle_{\mathcal{H}}$ for all possible $f, g \in \mathcal{H}$ (the result you ask about regarding $||f||_\mathcal{H}$ follows immediately from this result about the inner product).
The strategy for the proof will be to take our candidate inner product $\langle f, g \rangle_{\mathcal{C}}$ and show that it satisfies the reproducing property, that is, that $\langle f, k(.,\mathbf{x}) \rangle_{\mathcal{C}} = f(\mathbf{x})$, and then to expand on this to show that the inner products agree no matter which 2 functions we want to compute it between.
To this end, we will examine the quantity:
$ \langle f, k(., \mathbf{x}) \rangle_{\mathcal{C}} = \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) \overline{\hat{k(.,\mathbf{x})}(\mathbf{t})}}{\hat{d}(\mathbf{t})} d\mathbf{t}$
To proceed, let us evaluate $\hat{k(.,\mathbf{x})}(\mathbf{t})$. Since $k$ is stationary, $k(\mathbf{y}, \mathbf{x})=d(\mathbf{y}-\mathbf{x})$, and given fact (2) above, we thus know that $\hat{k(.,\mathbf{x})}(\mathbf{t}) = e^{-2\pi i \mathbf{x}^\top\mathbf{t}} \hat{d}(\mathbf{t})$. Substitution yields:
$ \langle f, k(., \mathbf{x}) \rangle_{\mathcal{C}} = \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) \overline{e^{-2\pi i \mathbf{x}^\top\mathbf{t}} \hat{d}(\mathbf{t})}}{\hat{d}(\mathbf{t})} d\mathbf{t}$
Since $d$ is real and symmetric, $\overline{\hat{d}(\mathbf{t})} = \hat{d}(\mathbf{t})$, and we have:
$ \langle f, k(., \mathbf{x}) \rangle_{\mathcal{C}} = \int_{\mathbb{R}^d} \frac{\hat{f}(\mathbf{t}) e^{2\pi i \mathbf{x}^\top\mathbf{t}} \hat{d}(\mathbf{t})}{\hat{d}(\mathbf{t})} d\mathbf{t} = \int_{\mathbb{R}^d} \hat{f}(\mathbf{t})e^{2\pi i \mathbf{x}^\top\mathbf{t}} d\mathbf{t} = f(\mathbf{x}) = \langle f, k(.,\mathbf{x})\rangle_{\mathcal{H}}$
since this is the inverse of the Fourier Transform (notice the negative sign in the exponential term cancelled with complex conjugation). So we've shown that the inner product is the same when the first argument is a function and the second a kernel. Now to generalize.
Consider:
$
\langle f, g \rangle_{\mathcal{C}} =
\langle f, \sum_{i} a_i k(.,\mathbf{x}_i)\rangle_{\mathcal{C}} =
\sum_{i} a_i \langle f, k(.,\mathbf{x}_i)\rangle_{\mathcal{C}} =
\sum_{i} a_i \langle f, k(.,\mathbf{x}_i)\rangle_{\mathcal{H}} =
\langle f, \sum_{i} a_i k(.,\mathbf{x}_i)\rangle_{\mathcal{H}} =
\langle f, g \rangle_{\mathcal{H}}
$
which establishes that the inner product agrees for all $f,g$. To establish the result you were interested in, explicitly plug in the form of the Gaussian kernel's Fourier transform, and examine the inner product between a function and itself.
|
RKHS norm and Fourier transform link
I'm also learning this stuff and was unable to find a proof so I took a swing at one.
There's a couple things we need to know about RKHS and Fourier analysis before we start (that I think are well est
|
41,882
|
Effective sample size of a weighted sample
|
Can weights be regarded as introducing some kind of correlation into the data?
Assume you have two uncorrelated standard normal variables with lots of samples. If all points on / closest to a positively sloped line are heavily weighted relative to other points, you would induce positive correlation. Similarly, if all points on / closest to a negatively sloped line are heavily weighted relative to other points, you would induce negative correlation.
Sometimes weighting points near a line is intentional, see for instance RANSAC (random sample consensus).
I am trying to understand the meaning of the effective sample size when we have weights for the sample.
In a sample with independent identically distributed (i.i.d.) observations, precision (inverse of variance) of parameter estimates (e.g. mean $\hat{\mu}$) is additive, accumulating over the sample observations. If you weight your sample observations or your sample is not i.i.d, the precision of your parameter estimate and the effective size of your sample is reduced relative to an equally weighted i.i.d. sample with the same number of observations.
Intuitively effective sample size is your actual sample size scaled by the ratio of precision of a parameter estimate using your weighted sample divided by the precision of the same parameter estimate in a counterfactual i.i.d. sample.
For purposes of intuitively understanding reduced effective sample size, consider
$$N_\textrm{effective} \approx
N_\textrm{actual} \frac{\textrm{Precision}_W(\hat{\mu})}{\textrm{Precision}_\textrm{iid}(\hat{\mu})} =
N_\textrm{actual} \frac{\textrm{Var}_\textrm{iid}(\hat{\mu})}{\textrm{Var}_W(\hat{\mu})}
$$
See discussion and references in Effective sample size for more details.
|
Effective sample size of a weighted sample
|
Can weights be regarded as introducing some kind of correlation into the data?
Assume you have two uncorrelated standard normal variables with lots of samples. If all points on / closest to a positi
|
Effective sample size of a weighted sample
Can weights be regarded as introducing some kind of correlation into the data?
Assume you have two uncorrelated standard normal variables with lots of samples. If all points on / closest to a positively sloped line are heavily weighted relative to other points, you would induce positive correlation. Similarly, if all points on / closest to a negatively sloped line are heavily weighted relative to other points, you would induce negative correlation.
Sometimes weighting points near a line is intentional, see for instance RANSAC (random sample consensus).
I am trying to understand the meaning of the effective sample size when we have weights for the sample.
In a sample with independent identically distributed (i.i.d.) observations, precision (inverse of variance) of parameter estimates (e.g. mean $\hat{\mu}$) is additive, accumulating over the sample observations. If you weight your sample observations or your sample is not i.i.d, the precision of your parameter estimate and the effective size of your sample is reduced relative to an equally weighted i.i.d. sample with the same number of observations.
Intuitively effective sample size is your actual sample size scaled by the ratio of precision of a parameter estimate using your weighted sample divided by the precision of the same parameter estimate in a counterfactual i.i.d. sample.
For purposes of intuitively understanding reduced effective sample size, consider
$$N_\textrm{effective} \approx
N_\textrm{actual} \frac{\textrm{Precision}_W(\hat{\mu})}{\textrm{Precision}_\textrm{iid}(\hat{\mu})} =
N_\textrm{actual} \frac{\textrm{Var}_\textrm{iid}(\hat{\mu})}{\textrm{Var}_W(\hat{\mu})}
$$
See discussion and references in Effective sample size for more details.
|
Effective sample size of a weighted sample
Can weights be regarded as introducing some kind of correlation into the data?
Assume you have two uncorrelated standard normal variables with lots of samples. If all points on / closest to a positi
|
41,883
|
Significance vs. goodness-of-fit in regression
|
Yes, the p-values that come with standard regression output are testing if the associated beta (slope coefficient) is $0$. (It is possible to get p-values for tests against other values, but you have to know how to set that up—it isn't what software does by default, and it really isn't very common.)
Yes, you can have high p-values for individual coefficients with a good fit and low p-values with a poor fit. The reason for this is straightforward: goodness of fit is a different question than whether the slope of the $X,\ Y$ relationship is $0$ in the population. Generally, when running a regression, we are trying to determine a fitted line that traces the conditional means of $Y$ at different values of $X$. (It is also possible to wonder about other aspects of a model, but that is the most basic and common feature.) Thus, a goodness of fit assessment is whether the model's fitted conditional means actually match the data's conditional means. The answer to this latter question can be either yes or no independently of whether the best estimate of the slope is $0$.
Consider the following examples, which are coded in R. (I don't have access to MATLAB, but the code here is intended to be as close to pseudocode as I can make it.)
##### high p-value, good fit
set.seed(6462) # this makes the example exactly reproducible
x1 = runif(100, min=-5, max=5) # the x-variables are uniformly distributed
x2 = runif(100, min=-5, max=5) # between -5 and 5
e = rnorm(100, mean=0, sd=1) # these are the errors
y = 0 + 0*x1 + 0*x2 + e # the true intercept & sloes are 0
m1 = lm(y~x1+x2)
summary(m1)
# ...
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -0.1257881 0.0992355 -1.268 0.208 # these p-values are
# x1 0.0009124 0.0307466 0.030 0.976 # high & non-significant
# x2 -0.0243975 0.0316458 -0.771 0.443
#
# Residual standard error: 0.9884 on 97 degrees of freedom
# Multiple R-squared: 0.006149, Adjusted R-squared: -0.01434
# F-statistic: 0.3001 on 2 and 97 DF, p-value: 0.7415 # the whole model is ns
##### low p-values, poor fit
# the true intercept & sloes are not 0, but the relationships are curvilinear
y2 = 5 + 0.65*x1 + -0.17*x1^2 + 0.65*x2 + -0.17*x2^2 + e
m2 = lm(y2~x1+x2)
summary(m2)
# ...
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 1.42633 0.21650 6.588 2.31e-09 *** # very low p-values
# x1 0.64189 0.06708 9.569 1.14e-15 ***
# x2 0.58869 0.06904 8.527 2.01e-13 ***
# ...
#
# Residual standard error: 2.156 on 97 degrees of freedom
# Multiple R-squared: 0.6152, Adjusted R-squared: 0.6073
# F-statistic: 77.54 on 2 and 97 DF, p-value: < 2.2e-16
What these examples show are a model that has high / non-significant p-values, but a good fit for the predicted means (because the true slopes are $0$), and a model with very low / highly significant p-values, but a poor fit for the predicted means (because, although the slopes within the regions spanned by the data are far from $0$, they are also not very close to straight lines). The p-values are easy to see and understand in the output. To see the quality of the models' fits to the conditional means, I plotted the true data generating process (in this case I have it, because the data are simulated, but in general you won't). In a more typical case, you would just see if the predicted means do a reasonable job of tracing the observed conditional means in your dataset; here I did that by plotting LOWESS lines. (The plots only display x1, and collapse over x2, but I could make analogous plots with x2, or various kinds of fancy plots with both x1 and x2, and they would show the same thing.)
|
Significance vs. goodness-of-fit in regression
|
Yes, the p-values that come with standard regression output are testing if the associated beta (slope coefficient) is $0$. (It is possible to get p-values for tests against other values, but you have
|
Significance vs. goodness-of-fit in regression
Yes, the p-values that come with standard regression output are testing if the associated beta (slope coefficient) is $0$. (It is possible to get p-values for tests against other values, but you have to know how to set that up—it isn't what software does by default, and it really isn't very common.)
Yes, you can have high p-values for individual coefficients with a good fit and low p-values with a poor fit. The reason for this is straightforward: goodness of fit is a different question than whether the slope of the $X,\ Y$ relationship is $0$ in the population. Generally, when running a regression, we are trying to determine a fitted line that traces the conditional means of $Y$ at different values of $X$. (It is also possible to wonder about other aspects of a model, but that is the most basic and common feature.) Thus, a goodness of fit assessment is whether the model's fitted conditional means actually match the data's conditional means. The answer to this latter question can be either yes or no independently of whether the best estimate of the slope is $0$.
Consider the following examples, which are coded in R. (I don't have access to MATLAB, but the code here is intended to be as close to pseudocode as I can make it.)
##### high p-value, good fit
set.seed(6462) # this makes the example exactly reproducible
x1 = runif(100, min=-5, max=5) # the x-variables are uniformly distributed
x2 = runif(100, min=-5, max=5) # between -5 and 5
e = rnorm(100, mean=0, sd=1) # these are the errors
y = 0 + 0*x1 + 0*x2 + e # the true intercept & sloes are 0
m1 = lm(y~x1+x2)
summary(m1)
# ...
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -0.1257881 0.0992355 -1.268 0.208 # these p-values are
# x1 0.0009124 0.0307466 0.030 0.976 # high & non-significant
# x2 -0.0243975 0.0316458 -0.771 0.443
#
# Residual standard error: 0.9884 on 97 degrees of freedom
# Multiple R-squared: 0.006149, Adjusted R-squared: -0.01434
# F-statistic: 0.3001 on 2 and 97 DF, p-value: 0.7415 # the whole model is ns
##### low p-values, poor fit
# the true intercept & sloes are not 0, but the relationships are curvilinear
y2 = 5 + 0.65*x1 + -0.17*x1^2 + 0.65*x2 + -0.17*x2^2 + e
m2 = lm(y2~x1+x2)
summary(m2)
# ...
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 1.42633 0.21650 6.588 2.31e-09 *** # very low p-values
# x1 0.64189 0.06708 9.569 1.14e-15 ***
# x2 0.58869 0.06904 8.527 2.01e-13 ***
# ...
#
# Residual standard error: 2.156 on 97 degrees of freedom
# Multiple R-squared: 0.6152, Adjusted R-squared: 0.6073
# F-statistic: 77.54 on 2 and 97 DF, p-value: < 2.2e-16
What these examples show are a model that has high / non-significant p-values, but a good fit for the predicted means (because the true slopes are $0$), and a model with very low / highly significant p-values, but a poor fit for the predicted means (because, although the slopes within the regions spanned by the data are far from $0$, they are also not very close to straight lines). The p-values are easy to see and understand in the output. To see the quality of the models' fits to the conditional means, I plotted the true data generating process (in this case I have it, because the data are simulated, but in general you won't). In a more typical case, you would just see if the predicted means do a reasonable job of tracing the observed conditional means in your dataset; here I did that by plotting LOWESS lines. (The plots only display x1, and collapse over x2, but I could make analogous plots with x2, or various kinds of fancy plots with both x1 and x2, and they would show the same thing.)
|
Significance vs. goodness-of-fit in regression
Yes, the p-values that come with standard regression output are testing if the associated beta (slope coefficient) is $0$. (It is possible to get p-values for tests against other values, but you have
|
41,884
|
Significance vs. goodness-of-fit in regression
|
To add to the answer by @gung let's assume a simpler model of
$$
Y=\beta_0 + \beta_1 X + e
$$
where we are estimating $Y$ using
$$
\hat Y=\hat \beta_0 + \hat \beta_1 X.
$$
we have $n$ data points $x_i$ and $y_i$, $i=1,...,n$.
p-values for coefficients are calculated as:
$$
PV_i = Pr(t>t_i )
$$
where
$$
t_i=\frac{|\hat \beta_i|}{SE(\beta_i)},
$$
$Pr$ is the probablity that $t$ (with t-distribution with $n-2$ degrees of freedom) is bigger than $t_i$ and $SE$ is standard error.
Larger $t_i$ leads to smaller p-value and higher significance of the coefficients.
$$
SE(\beta_1)= \frac{\sigma_e}{\sqrt{n} \sigma_X}
$$
and thus
$$
t_1= \sqrt{n} \hat \beta_1 \frac{\sigma_X}{\sigma_e}. \tag 1
$$
on the other hand adjusted R-squared is obtained as:
$$
R^2=1- \frac{1}{ \beta^2_1 \frac{\sigma^2_X}{\sigma^2_e} +1} \tag 2
$$
According to (1) p-values can be made arbitrarily small by increasing $n$. At the same time R-squared can be made smaller by decreasing signal to error ratio $\frac{\sigma^2_X}{\sigma^2_e}$, either owing to modelling error (neglecting important terms) or just random error. Hence you can have a bad fit and at the same time have low p-values for all of your coefficients.
The following combinations are possible:
Good fit-bad $R^2$-high or low p-value: This is possible if the model chosen correctly, but signal to error ratio $\frac{\sigma^2_X}{\sigma^2_e}$ is low. P-value $PV_1$ can be made arbitrarily large or small by changing $n$ if $\hat \beta_1 \neq 0$.
Bad fit-good $R^2$-high or low p-value: This is possible if model is chosen wrongly but $\beta^2_1 \sigma^2_X$ is very large. Again P-value can be made arbitrarily large or small by changing $n$.
Obvious cases are bad fit-bad $R^2$ and good fit-good $R^2$.
To write this answer, I used the formulas listed in this pdf.
|
Significance vs. goodness-of-fit in regression
|
To add to the answer by @gung let's assume a simpler model of
$$
Y=\beta_0 + \beta_1 X + e
$$
where we are estimating $Y$ using
$$
\hat Y=\hat \beta_0 + \hat \beta_1 X.
$$
we have $n$ data points $
|
Significance vs. goodness-of-fit in regression
To add to the answer by @gung let's assume a simpler model of
$$
Y=\beta_0 + \beta_1 X + e
$$
where we are estimating $Y$ using
$$
\hat Y=\hat \beta_0 + \hat \beta_1 X.
$$
we have $n$ data points $x_i$ and $y_i$, $i=1,...,n$.
p-values for coefficients are calculated as:
$$
PV_i = Pr(t>t_i )
$$
where
$$
t_i=\frac{|\hat \beta_i|}{SE(\beta_i)},
$$
$Pr$ is the probablity that $t$ (with t-distribution with $n-2$ degrees of freedom) is bigger than $t_i$ and $SE$ is standard error.
Larger $t_i$ leads to smaller p-value and higher significance of the coefficients.
$$
SE(\beta_1)= \frac{\sigma_e}{\sqrt{n} \sigma_X}
$$
and thus
$$
t_1= \sqrt{n} \hat \beta_1 \frac{\sigma_X}{\sigma_e}. \tag 1
$$
on the other hand adjusted R-squared is obtained as:
$$
R^2=1- \frac{1}{ \beta^2_1 \frac{\sigma^2_X}{\sigma^2_e} +1} \tag 2
$$
According to (1) p-values can be made arbitrarily small by increasing $n$. At the same time R-squared can be made smaller by decreasing signal to error ratio $\frac{\sigma^2_X}{\sigma^2_e}$, either owing to modelling error (neglecting important terms) or just random error. Hence you can have a bad fit and at the same time have low p-values for all of your coefficients.
The following combinations are possible:
Good fit-bad $R^2$-high or low p-value: This is possible if the model chosen correctly, but signal to error ratio $\frac{\sigma^2_X}{\sigma^2_e}$ is low. P-value $PV_1$ can be made arbitrarily large or small by changing $n$ if $\hat \beta_1 \neq 0$.
Bad fit-good $R^2$-high or low p-value: This is possible if model is chosen wrongly but $\beta^2_1 \sigma^2_X$ is very large. Again P-value can be made arbitrarily large or small by changing $n$.
Obvious cases are bad fit-bad $R^2$ and good fit-good $R^2$.
To write this answer, I used the formulas listed in this pdf.
|
Significance vs. goodness-of-fit in regression
To add to the answer by @gung let's assume a simpler model of
$$
Y=\beta_0 + \beta_1 X + e
$$
where we are estimating $Y$ using
$$
\hat Y=\hat \beta_0 + \hat \beta_1 X.
$$
we have $n$ data points $
|
41,885
|
Using partial measurements of output variable in modeling
|
Fun question. The key problem as noted by @MartijnWeterings is that the number of trees at phase 2 is only a partial measurement of the total number of trees. If we knew the total number of trees, however, we could solve the problem by building a model of the number of nuts observed at stage 1 given the number of trees at stage 1, and then predict the number of nuts at stage 2 using the number of trees at stage 2. Our strategy in this answer is therefore to first estimate the number of trees at stage 2 and then build a model of nuts given trees at stage 1.
Notation and assumption
In the following, I assume that the sampling of trees and squirrels is random at all stages. Let $n_{1i}$ denote the sum of all nuts collected by squirrel $i$ in phase 1. Let $t_{1i}$ denote the total number of trees squirrel $i$ stored nuts at in phase 1. Let $n_{2j}$ denote the unobserved sum of nuts collected by squirrel $j$ in phase 2 and let $t_{2j}$ denote the number of trees squirrel $j$ stored nuts at in phase 2. Finally let $k_{2j}$ denote the partial number of trees observed, where $k_{2j} \le t_{2j}$,
Number of trees at stage 2
As noted by @MartijnWeterings $k_{2j}$ is always smaller or equal to the total number of trees $t_{2j}$ at phase 2, which is unknown. Our goal thus becomes that of estimating $t_{2j}$ as closely as possible. Fortunately, we have some information on $t_{2j}$. Depending on your sampling design in phase 2, there is a probability $p$ that a squirrel is captured at one of the total $t_{2j}$ trees that it visits. The probability of $k_{2j}$ is thus binomial with parameters $t_{2j}$ and $p$. However, we observe binomial $k_{2j}$; the number of trees $t_{2j}$, however, is not binomial distributed given $k_{2j}$. I was not sure about its exact distribution and therefore I asked a question about it on Mathematics-StackExchange. I received the useful reply that the probability mass function of $t=t_{2j}$ with $k=k_{2j}$ and $p$ is given by
$$P(t; k ,p) = \binom{t-1}{k} p^t (1-p)^{(t-k)}, \quad t \in \{k,...,\infty\}.$$
for all $j$ which has expectation $E(t)=k/p$. Hence if we know $k_{2j}$ and $p$ we could estimate $\hat{t}_{2j}=k_{2j}/p$. As said, probability $p$ depends on your sampling design, but fortunately we can estimate it from the data as
$$\hat{p}=\frac{\sum_{j} k_{2j}}{\sum_{i} t_{1i}}$$ so that $\hat{t}_{2j}=k_{2j}/\hat{p}$.
Estimation under proportionality assumption
Let
$$ \pi = \frac{1}{\#S_1} \sum_{i} \frac{n_{1i}}{t_{1i}}$$
be the average proportion of nuts left by a squirrel at a tree. A first estimate of the total number of nuts of squirrel $j$ is
$$ \hat{n}_{2j} = \pi \hat{t}_{2j}.$$
Estimation using relationship between nuts and trees at phase 1
This may seem unsatisfactory, because it does not take into account that there may be a relationship between $n$ and $t$ other than a simple proportional one. For example we may imagine squirrels having the strange behavior of leaving less nuts per tree the more nuts they have at their disposal. Then the total number of nuts $n$ would not proportionately increase with $t$ and instead flatten off. Hence we could decide to model
$$ n_{1i}= f(t_{1i},\theta) + \epsilon_i$$
where $f$ is a non-linear function with parameters theta and $\epsilon_i$ is a measurement error term. An obvious choice might be
$$ n_{1i} = \theta_0 + \theta_1 \log(t_{1i}) + \epsilon_i$$
with $\epsilon_i$ iid normal with 0 expectation. The model could be fit by non-linear least squares or maximum likelihood. An estimator would then be
$$ \hat{n}_{2j} = \hat{\theta_0} + \hat{\theta_1} \log(\hat{t}_{2j})$$
Of course other functional forms could be used or you could use flexible modeling techniques to approximate the functional relationship, such as random forests (pun intended).
Simulations
Does this work? Let's try it. I simulate data in R according to the following ideas. The probability that a squirrel collects $n+1$ nuts is given by $n \sim \text{Poisson}(20)$. A squirrel then arrives at the first tree and hides $h_1+1$ nuts where $h_1 \sim \text{Poisson}(\lambda)$ and $\lambda \sim \Gamma(60/n,1)$. It continues hiding at $1 + (h_2,...,h_t)$ nuts until it arrives at tree $t$ and is out of nuts. It does so regardless of whether you observe it in phase 1 or 2; however in phase 1 you observe all $h_t$, whereas in phase 2 you observe a sample from $\{h_1,...,h_t\}$. As said I assume you have a simple random sample of trees at phase 2 and so you observe $h_{kj}$ (the k-th tree visited by squirrel j) with probability $p$ (below in the code I call this truncation).
I now sample 1000 squirrels at phase 1. The plot below illustrates the relationship of the total number of trees and total number of nuts collected. It can be seen that there is a decay in that relationship across $t$.
I now sample at stage 2 with $p=0.5$ and consider three estimators. First the estimator under proportionality. Second, I create an estimator which uses the conditional mean of $n_1$ at each observed level of $t_1$ as an estimate for $n_2$ at $\hat{t}_2$. For benchmarking I use again the conditional mean of $n_1$ at each observed level of $t_1$ as an estimate for $n_2$, but now at the true number of trees $t_2$ at phase 2. This estimator is of course not available in practice.
For two samples, one from each of phase 1 and 2, respectively, and the three estimators I arrive at the following biases, respectively: 5.61, -0.19, and 0.24. Furthermore we observe the following root mean square errors: 15.3, 4.07, 3.32. We see that the conditional mean estimator with an adjusted estimate for the number of trees at phase 2 has almost as good performance as the estimator using the unknown true number of trees at phase 2. The remaining error is variance which can perhaps be reduced a bit further by using a better model for $n_1$ given $t_1$ than the non-parametric conditional mean model.
Here is a function creating the data for the simulation I made.
# A squirrel collects nuts
squirrel_set = function(n, trunc= FALSE){
nuts = rpois(n, 20) + 1
nut_seq = list()
for(i in 1:n){
j = 1
nuts_left = nuts[i]
nuts_hidden = numeric()
# squirrel hides nuts at tree j
while(nuts_left>0){
if(j == 1) {lambda = rgamma(1,60/nuts_left,1) }
if(lambda < 1){ lambda = 1}
nuts_hidden[j] = rpois(1, lambda) + 1
if(nuts_left - nuts_hidden[j] <0){
nuts_hidden[j] = nuts_left
nuts_left = 0
}
else{ nuts_left = nuts_left - nuts_hidden[j] }
j = j+1
}
nut_seq[[i]] = nuts_hidden
}
# Truncated sample
# A squirrel is caught with probability .5 at a tree
# (or a random half of the trees are observed and a squirrel is always caught)
if(trunc == TRUE){
trees = sapply(nut_seq , length)
nut_seq_obs = list()
for(i in 1:length(nut_seq)){
caught = rbinom(trees[i],1,.5)
nut_seq_obs[[i]] = nut_seq[[i]][as.logical(caught)]
}
return( list(nut_seq,nut_seq_obs) )
}
else{
return(nut_seq)
}
}
And here the code used in analysis:
set.seed(12345)
n = 1000
# Phase 1
nut_seq1 = squirrel_set(n)
# Phase 2
nut_seq2 = squirrel_set(n, trunc = TRUE)
nut_seq2_true = nut_seq2[[1]]
nut_seq2_trunc = nut_seq2[[2]]
# Trees and nuts at phases 1 and 2
t1 = sapply(nut_seq1,length, simplify = TRUE) # Trees seen at phase 1
k = sapply(nut_seq2_trunc , length) # Trees seen at phase 2
nut_seq2_trunc = nut_seq2_trunc[k>0] # Squirrels with k=0 have avtually not been observed
nut_seq2_true = nut_seq2_true[k>0]
k = k[k>0]
n1 = sapply(nut_seq1,sum, simplify = TRUE) # Trees seen at phase 1
n2 = sapply(nut_seq2_true,sum, simplify = TRUE) # Trees at phase 2 (unobserved)
t2 = sapply(nut_seq2_true,length, simplify = TRUE) # Trees at phase 2 (unobserved)
# Plot
plot( t1, n1, xlab='Trees at phase 1', ylab='Total number of nuts at phase 1')
mnuts = numeric()
for(i in 1:max(t1)){
mnuts[i] = mean(n1[t1 == i])
}
lines( 1:max(t1), mnuts, col=2)
legend("bottomright",lty=1, lwd=2, col='2', legend='Conditional mean')
# Estimators
p = sum(k) / sum(t1) # Estimate of observational probability at phase 2
t2_est = k/p # Estimate of total number of trees for each squirrel at phase 2
n2_prop_est = t2_est * mean(sapply(n1,sum, simplify = TRUE)/t1 ) # proportionality
mnuts = numeric()
for(i in 1:max(t1)){
mnuts[i] = mean(n1[t1 == i]) # Conditional mean at each level of trees at phase 1
}
n2_regest = mnuts[round(t2_est)] # Non-parametric regression estimate of n2
n2_regest_truet2 = mnuts[t2]
# Bias and Variance
mean( n2_prop_est - n2)
sqrt(mean( (n2_prop_est - n2)^2 ))
mean( n2_regest - n2 , na.rm=TRUE)
sqrt(mean( (n2_regest - n2)^2 , na.rm=TRUE))
mean( n2_regest_truet2 - n2 , na.rm=TRUE)
sqrt(mean( (n2_regest_truet2 - n2)^2 , na.rm=TRUE))
|
Using partial measurements of output variable in modeling
|
Fun question. The key problem as noted by @MartijnWeterings is that the number of trees at phase 2 is only a partial measurement of the total number of trees. If we knew the total number of trees, how
|
Using partial measurements of output variable in modeling
Fun question. The key problem as noted by @MartijnWeterings is that the number of trees at phase 2 is only a partial measurement of the total number of trees. If we knew the total number of trees, however, we could solve the problem by building a model of the number of nuts observed at stage 1 given the number of trees at stage 1, and then predict the number of nuts at stage 2 using the number of trees at stage 2. Our strategy in this answer is therefore to first estimate the number of trees at stage 2 and then build a model of nuts given trees at stage 1.
Notation and assumption
In the following, I assume that the sampling of trees and squirrels is random at all stages. Let $n_{1i}$ denote the sum of all nuts collected by squirrel $i$ in phase 1. Let $t_{1i}$ denote the total number of trees squirrel $i$ stored nuts at in phase 1. Let $n_{2j}$ denote the unobserved sum of nuts collected by squirrel $j$ in phase 2 and let $t_{2j}$ denote the number of trees squirrel $j$ stored nuts at in phase 2. Finally let $k_{2j}$ denote the partial number of trees observed, where $k_{2j} \le t_{2j}$,
Number of trees at stage 2
As noted by @MartijnWeterings $k_{2j}$ is always smaller or equal to the total number of trees $t_{2j}$ at phase 2, which is unknown. Our goal thus becomes that of estimating $t_{2j}$ as closely as possible. Fortunately, we have some information on $t_{2j}$. Depending on your sampling design in phase 2, there is a probability $p$ that a squirrel is captured at one of the total $t_{2j}$ trees that it visits. The probability of $k_{2j}$ is thus binomial with parameters $t_{2j}$ and $p$. However, we observe binomial $k_{2j}$; the number of trees $t_{2j}$, however, is not binomial distributed given $k_{2j}$. I was not sure about its exact distribution and therefore I asked a question about it on Mathematics-StackExchange. I received the useful reply that the probability mass function of $t=t_{2j}$ with $k=k_{2j}$ and $p$ is given by
$$P(t; k ,p) = \binom{t-1}{k} p^t (1-p)^{(t-k)}, \quad t \in \{k,...,\infty\}.$$
for all $j$ which has expectation $E(t)=k/p$. Hence if we know $k_{2j}$ and $p$ we could estimate $\hat{t}_{2j}=k_{2j}/p$. As said, probability $p$ depends on your sampling design, but fortunately we can estimate it from the data as
$$\hat{p}=\frac{\sum_{j} k_{2j}}{\sum_{i} t_{1i}}$$ so that $\hat{t}_{2j}=k_{2j}/\hat{p}$.
Estimation under proportionality assumption
Let
$$ \pi = \frac{1}{\#S_1} \sum_{i} \frac{n_{1i}}{t_{1i}}$$
be the average proportion of nuts left by a squirrel at a tree. A first estimate of the total number of nuts of squirrel $j$ is
$$ \hat{n}_{2j} = \pi \hat{t}_{2j}.$$
Estimation using relationship between nuts and trees at phase 1
This may seem unsatisfactory, because it does not take into account that there may be a relationship between $n$ and $t$ other than a simple proportional one. For example we may imagine squirrels having the strange behavior of leaving less nuts per tree the more nuts they have at their disposal. Then the total number of nuts $n$ would not proportionately increase with $t$ and instead flatten off. Hence we could decide to model
$$ n_{1i}= f(t_{1i},\theta) + \epsilon_i$$
where $f$ is a non-linear function with parameters theta and $\epsilon_i$ is a measurement error term. An obvious choice might be
$$ n_{1i} = \theta_0 + \theta_1 \log(t_{1i}) + \epsilon_i$$
with $\epsilon_i$ iid normal with 0 expectation. The model could be fit by non-linear least squares or maximum likelihood. An estimator would then be
$$ \hat{n}_{2j} = \hat{\theta_0} + \hat{\theta_1} \log(\hat{t}_{2j})$$
Of course other functional forms could be used or you could use flexible modeling techniques to approximate the functional relationship, such as random forests (pun intended).
Simulations
Does this work? Let's try it. I simulate data in R according to the following ideas. The probability that a squirrel collects $n+1$ nuts is given by $n \sim \text{Poisson}(20)$. A squirrel then arrives at the first tree and hides $h_1+1$ nuts where $h_1 \sim \text{Poisson}(\lambda)$ and $\lambda \sim \Gamma(60/n,1)$. It continues hiding at $1 + (h_2,...,h_t)$ nuts until it arrives at tree $t$ and is out of nuts. It does so regardless of whether you observe it in phase 1 or 2; however in phase 1 you observe all $h_t$, whereas in phase 2 you observe a sample from $\{h_1,...,h_t\}$. As said I assume you have a simple random sample of trees at phase 2 and so you observe $h_{kj}$ (the k-th tree visited by squirrel j) with probability $p$ (below in the code I call this truncation).
I now sample 1000 squirrels at phase 1. The plot below illustrates the relationship of the total number of trees and total number of nuts collected. It can be seen that there is a decay in that relationship across $t$.
I now sample at stage 2 with $p=0.5$ and consider three estimators. First the estimator under proportionality. Second, I create an estimator which uses the conditional mean of $n_1$ at each observed level of $t_1$ as an estimate for $n_2$ at $\hat{t}_2$. For benchmarking I use again the conditional mean of $n_1$ at each observed level of $t_1$ as an estimate for $n_2$, but now at the true number of trees $t_2$ at phase 2. This estimator is of course not available in practice.
For two samples, one from each of phase 1 and 2, respectively, and the three estimators I arrive at the following biases, respectively: 5.61, -0.19, and 0.24. Furthermore we observe the following root mean square errors: 15.3, 4.07, 3.32. We see that the conditional mean estimator with an adjusted estimate for the number of trees at phase 2 has almost as good performance as the estimator using the unknown true number of trees at phase 2. The remaining error is variance which can perhaps be reduced a bit further by using a better model for $n_1$ given $t_1$ than the non-parametric conditional mean model.
Here is a function creating the data for the simulation I made.
# A squirrel collects nuts
squirrel_set = function(n, trunc= FALSE){
nuts = rpois(n, 20) + 1
nut_seq = list()
for(i in 1:n){
j = 1
nuts_left = nuts[i]
nuts_hidden = numeric()
# squirrel hides nuts at tree j
while(nuts_left>0){
if(j == 1) {lambda = rgamma(1,60/nuts_left,1) }
if(lambda < 1){ lambda = 1}
nuts_hidden[j] = rpois(1, lambda) + 1
if(nuts_left - nuts_hidden[j] <0){
nuts_hidden[j] = nuts_left
nuts_left = 0
}
else{ nuts_left = nuts_left - nuts_hidden[j] }
j = j+1
}
nut_seq[[i]] = nuts_hidden
}
# Truncated sample
# A squirrel is caught with probability .5 at a tree
# (or a random half of the trees are observed and a squirrel is always caught)
if(trunc == TRUE){
trees = sapply(nut_seq , length)
nut_seq_obs = list()
for(i in 1:length(nut_seq)){
caught = rbinom(trees[i],1,.5)
nut_seq_obs[[i]] = nut_seq[[i]][as.logical(caught)]
}
return( list(nut_seq,nut_seq_obs) )
}
else{
return(nut_seq)
}
}
And here the code used in analysis:
set.seed(12345)
n = 1000
# Phase 1
nut_seq1 = squirrel_set(n)
# Phase 2
nut_seq2 = squirrel_set(n, trunc = TRUE)
nut_seq2_true = nut_seq2[[1]]
nut_seq2_trunc = nut_seq2[[2]]
# Trees and nuts at phases 1 and 2
t1 = sapply(nut_seq1,length, simplify = TRUE) # Trees seen at phase 1
k = sapply(nut_seq2_trunc , length) # Trees seen at phase 2
nut_seq2_trunc = nut_seq2_trunc[k>0] # Squirrels with k=0 have avtually not been observed
nut_seq2_true = nut_seq2_true[k>0]
k = k[k>0]
n1 = sapply(nut_seq1,sum, simplify = TRUE) # Trees seen at phase 1
n2 = sapply(nut_seq2_true,sum, simplify = TRUE) # Trees at phase 2 (unobserved)
t2 = sapply(nut_seq2_true,length, simplify = TRUE) # Trees at phase 2 (unobserved)
# Plot
plot( t1, n1, xlab='Trees at phase 1', ylab='Total number of nuts at phase 1')
mnuts = numeric()
for(i in 1:max(t1)){
mnuts[i] = mean(n1[t1 == i])
}
lines( 1:max(t1), mnuts, col=2)
legend("bottomright",lty=1, lwd=2, col='2', legend='Conditional mean')
# Estimators
p = sum(k) / sum(t1) # Estimate of observational probability at phase 2
t2_est = k/p # Estimate of total number of trees for each squirrel at phase 2
n2_prop_est = t2_est * mean(sapply(n1,sum, simplify = TRUE)/t1 ) # proportionality
mnuts = numeric()
for(i in 1:max(t1)){
mnuts[i] = mean(n1[t1 == i]) # Conditional mean at each level of trees at phase 1
}
n2_regest = mnuts[round(t2_est)] # Non-parametric regression estimate of n2
n2_regest_truet2 = mnuts[t2]
# Bias and Variance
mean( n2_prop_est - n2)
sqrt(mean( (n2_prop_est - n2)^2 ))
mean( n2_regest - n2 , na.rm=TRUE)
sqrt(mean( (n2_regest - n2)^2 , na.rm=TRUE))
mean( n2_regest_truet2 - n2 , na.rm=TRUE)
sqrt(mean( (n2_regest_truet2 - n2)^2 , na.rm=TRUE))
|
Using partial measurements of output variable in modeling
Fun question. The key problem as noted by @MartijnWeterings is that the number of trees at phase 2 is only a partial measurement of the total number of trees. If we knew the total number of trees, how
|
41,886
|
Using partial measurements of output variable in modeling
|
In phase 1 you could make a model that relates the behavior of a squirrel to the total number of nuts.
In phase 2 you do not observe the exact same full information as in phase 1. For instance, you do not know how many trees in total are used by a specific squirrel. But you do observe some of the squirel's behavior, namely a sample from the distribution of the number of nuts per tree. From this you can estimate the distribution and the parameters that describe the distribution can be input for the model.
So in phase 1 you make a model that relates the total number of nuts that a squirrel stores with the distribution of the nuts per tree for the squirrel. How exactly to model this is difficult to say.
If you think that you could make some mechanistic model then you could start with some exploratory analysis and prior insights about squirrel behavior to get an idea about a useful model. I lack the data and the biological knowledge to do this in this answer (One obvious direction might be to see whether more nuts per tree will also relate to more nuts in total, and possibly this will have some more complex relationship with the squirrel weight and cheek, and other factors, like high variation in nuts per tree may help to get also an indication about the total number of trees used by a squirrel)
In phase 2 you will make an estimate of the parameters that are needed to make predictions with the model that has been created in phase 1. The parameters that describe the distribution for the number of nuts per tree can be estimated from the sample measured at the subset of trees.
A simple way would be to ignore the tree id's and just use the data per squirrel to estimate the distribution parameters and put them into the model from phase 1.
A more precise
model would treat the tree id's as a random factor such that the behavior
specifically attributed to the squirrel can be better estimated. To
treat the trees as a random factor you will have to know how the
trees can be a random factor. You can make an educated guess for
this, but you could also try to learn this from the data (I'd say with some exploratory analysis first, checking out the correlation between a tree and how many nuts get stored in it per squirrel, and whether this effect is independent or maybe some trees attract specific type of squirrels, before coming up with something quantitative.). In the
phase 1 you do not observe information related to the tree ids but in
phase 2 you do and you can use that data.
So in a nutshell. I think you need some exploratory analysis before you can actually do something quantitative that is more than the simple approach (simple is ignoring the tree ids in phase 2 and using just simple distribution parameters as input for the model whose coefficients are learned in phase 1).
Furthermore, how can we introduce partially measured outputs into the training set?
When you make the model in 1 by using parameters that describe the distribution of the nuts per tree for a specific squirrel you need to take into account that it must be possible to reasonably estimate those numbers in phase 2 and that errors will not effect the model too much. For instance mean and variance (or other simple statistics) could be reasonably estimated from the samples in phase 2 (assuming your sample is not too small) but higher order moments may not.
|
Using partial measurements of output variable in modeling
|
In phase 1 you could make a model that relates the behavior of a squirrel to the total number of nuts.
In phase 2 you do not observe the exact same full information as in phase 1. For instance, you d
|
Using partial measurements of output variable in modeling
In phase 1 you could make a model that relates the behavior of a squirrel to the total number of nuts.
In phase 2 you do not observe the exact same full information as in phase 1. For instance, you do not know how many trees in total are used by a specific squirrel. But you do observe some of the squirel's behavior, namely a sample from the distribution of the number of nuts per tree. From this you can estimate the distribution and the parameters that describe the distribution can be input for the model.
So in phase 1 you make a model that relates the total number of nuts that a squirrel stores with the distribution of the nuts per tree for the squirrel. How exactly to model this is difficult to say.
If you think that you could make some mechanistic model then you could start with some exploratory analysis and prior insights about squirrel behavior to get an idea about a useful model. I lack the data and the biological knowledge to do this in this answer (One obvious direction might be to see whether more nuts per tree will also relate to more nuts in total, and possibly this will have some more complex relationship with the squirrel weight and cheek, and other factors, like high variation in nuts per tree may help to get also an indication about the total number of trees used by a squirrel)
In phase 2 you will make an estimate of the parameters that are needed to make predictions with the model that has been created in phase 1. The parameters that describe the distribution for the number of nuts per tree can be estimated from the sample measured at the subset of trees.
A simple way would be to ignore the tree id's and just use the data per squirrel to estimate the distribution parameters and put them into the model from phase 1.
A more precise
model would treat the tree id's as a random factor such that the behavior
specifically attributed to the squirrel can be better estimated. To
treat the trees as a random factor you will have to know how the
trees can be a random factor. You can make an educated guess for
this, but you could also try to learn this from the data (I'd say with some exploratory analysis first, checking out the correlation between a tree and how many nuts get stored in it per squirrel, and whether this effect is independent or maybe some trees attract specific type of squirrels, before coming up with something quantitative.). In the
phase 1 you do not observe information related to the tree ids but in
phase 2 you do and you can use that data.
So in a nutshell. I think you need some exploratory analysis before you can actually do something quantitative that is more than the simple approach (simple is ignoring the tree ids in phase 2 and using just simple distribution parameters as input for the model whose coefficients are learned in phase 1).
Furthermore, how can we introduce partially measured outputs into the training set?
When you make the model in 1 by using parameters that describe the distribution of the nuts per tree for a specific squirrel you need to take into account that it must be possible to reasonably estimate those numbers in phase 2 and that errors will not effect the model too much. For instance mean and variance (or other simple statistics) could be reasonably estimated from the samples in phase 2 (assuming your sample is not too small) but higher order moments may not.
|
Using partial measurements of output variable in modeling
In phase 1 you could make a model that relates the behavior of a squirrel to the total number of nuts.
In phase 2 you do not observe the exact same full information as in phase 1. For instance, you d
|
41,887
|
Difference between Mean/average accuracy and Overall accuracy
|
What the paper describes
I trust you are referring to the following quote
Each experiment is repeated ten times with a different training set to make the comparison fair, and both the mean accuracies and standard deviation are reported. For the evaluation metrics, overall accuracy (OA) and kappa coefficient (κ) are adopted to quantify the classification performance. The OA is computed by the ratio between the number of the correctly classified test samples and the total test samples.
It appears that the authors were using a single iteration of 10 fold cross validation but avoided using that terminology. The mean accuracy is related to the mean accuracy achieved across ten different training folds. So they build 10 different models using non-overlapping data and test how consistently they perform.
After cross validation an overall model is typically built using all the data from the 10 folds and this is what is used to predict the outcomes in the test set.
Overall accuracy is clearly stated as the accuracy achieved in the test set. Not ideal terminology, the term 'predictive accuracy' is maybe more along the lines of what they done
What it means
In the ideal world mean accuracy of the 10 training experiments would be identical to the overall accuracy. To achieve this would require a perfect match in terms of distribution of samples within each subsampling (mean of the training set folds and the test set) from the parent dataset.
However, each fold has a distinct set of samples so we expect variation in what the population characteristics of each fold will be, therefore what the accuracy will be. This is why standard deviation is calculated alongside mean accuracy for the training set.
This means that when you come to yet another independent set of samples (the test set) you hopefully can guess what range of accuracy you expect to achieve based on your training folds, but you will get a distinct accuracy value for that population. this is what the paper refers to as the 'overall accuracy'
** UPDATE for comments **
The methodology states that the authors tested class sizes of 7,10 and 15 samples per class to determine sensitivity to small sample sizes, the results are presented in Fig 8 and show that the more samples per class the better the overall accuracy, especially in the Indian Pines data set. The table you copy in your updated question states that the training set had 10 samples per class, so the mean accuracy is simply the average accuracy of each class, but this number is pretty meaningless.
To get a number that was more meaningful for comparison to the test set you would need to adjust for expected distribution of class sizes (see table I and II). Table II lists 4 classes with fewer than 150 samples which makes it impossible to sample 10 independent training sets of 15 samples. I therefore now assume the authors mean that the randomisation for selection was independent but the training sets could overlap. Whether (and how) they were able to retain enough test set samples from any of the short fall classes (C1,54,10 and 12) is not clear.
The fact remains that the class accuracy is based on the training set and the overall accuracy is based on the test set so will never agree. To be honest the completely different presentation of the training and test set results makes comparison obscure.
I recommend you read the answers to the following question on CV around the issue of classification accuracy and group imbalance.
Why is accuracy not the best measure for assessing classification models?
see also
https://machinelearningmastery.com/classification-accuracy-is-not-enough-more-performance-measures-you-can-use/
to answer you updated query about sensitivity:
At first I said no but later realised you were right. Class accuracy only considers the actual positives for that class. This means that correct answers are indeed true positives and incorrect answers are false negatives.
** further update **
mean class accuracy is calculated as the mean of the class accuracy across the 10 training sets. So the example in your question is how the class accuracy is calculated in 1 iteration. You would calculate this value for each class for each iteration, then you would calculate its arithmetic mean (and standard deviation).
The paper clearly states that the class accuracy was calculated from 10 training sets while the overall accuracy was calculated from the test set. This means the two should never be perfectly reconcilable. It also means it is very difficult to compare test set performance to training performance. Since selection of samples to training and test sets is not described at all so it is impossible to interpret much from the paper.
|
Difference between Mean/average accuracy and Overall accuracy
|
What the paper describes
I trust you are referring to the following quote
Each experiment is repeated ten times with a different training set to make the comparison fair, and both the mean accuracies
|
Difference between Mean/average accuracy and Overall accuracy
What the paper describes
I trust you are referring to the following quote
Each experiment is repeated ten times with a different training set to make the comparison fair, and both the mean accuracies and standard deviation are reported. For the evaluation metrics, overall accuracy (OA) and kappa coefficient (κ) are adopted to quantify the classification performance. The OA is computed by the ratio between the number of the correctly classified test samples and the total test samples.
It appears that the authors were using a single iteration of 10 fold cross validation but avoided using that terminology. The mean accuracy is related to the mean accuracy achieved across ten different training folds. So they build 10 different models using non-overlapping data and test how consistently they perform.
After cross validation an overall model is typically built using all the data from the 10 folds and this is what is used to predict the outcomes in the test set.
Overall accuracy is clearly stated as the accuracy achieved in the test set. Not ideal terminology, the term 'predictive accuracy' is maybe more along the lines of what they done
What it means
In the ideal world mean accuracy of the 10 training experiments would be identical to the overall accuracy. To achieve this would require a perfect match in terms of distribution of samples within each subsampling (mean of the training set folds and the test set) from the parent dataset.
However, each fold has a distinct set of samples so we expect variation in what the population characteristics of each fold will be, therefore what the accuracy will be. This is why standard deviation is calculated alongside mean accuracy for the training set.
This means that when you come to yet another independent set of samples (the test set) you hopefully can guess what range of accuracy you expect to achieve based on your training folds, but you will get a distinct accuracy value for that population. this is what the paper refers to as the 'overall accuracy'
** UPDATE for comments **
The methodology states that the authors tested class sizes of 7,10 and 15 samples per class to determine sensitivity to small sample sizes, the results are presented in Fig 8 and show that the more samples per class the better the overall accuracy, especially in the Indian Pines data set. The table you copy in your updated question states that the training set had 10 samples per class, so the mean accuracy is simply the average accuracy of each class, but this number is pretty meaningless.
To get a number that was more meaningful for comparison to the test set you would need to adjust for expected distribution of class sizes (see table I and II). Table II lists 4 classes with fewer than 150 samples which makes it impossible to sample 10 independent training sets of 15 samples. I therefore now assume the authors mean that the randomisation for selection was independent but the training sets could overlap. Whether (and how) they were able to retain enough test set samples from any of the short fall classes (C1,54,10 and 12) is not clear.
The fact remains that the class accuracy is based on the training set and the overall accuracy is based on the test set so will never agree. To be honest the completely different presentation of the training and test set results makes comparison obscure.
I recommend you read the answers to the following question on CV around the issue of classification accuracy and group imbalance.
Why is accuracy not the best measure for assessing classification models?
see also
https://machinelearningmastery.com/classification-accuracy-is-not-enough-more-performance-measures-you-can-use/
to answer you updated query about sensitivity:
At first I said no but later realised you were right. Class accuracy only considers the actual positives for that class. This means that correct answers are indeed true positives and incorrect answers are false negatives.
** further update **
mean class accuracy is calculated as the mean of the class accuracy across the 10 training sets. So the example in your question is how the class accuracy is calculated in 1 iteration. You would calculate this value for each class for each iteration, then you would calculate its arithmetic mean (and standard deviation).
The paper clearly states that the class accuracy was calculated from 10 training sets while the overall accuracy was calculated from the test set. This means the two should never be perfectly reconcilable. It also means it is very difficult to compare test set performance to training performance. Since selection of samples to training and test sets is not described at all so it is impossible to interpret much from the paper.
|
Difference between Mean/average accuracy and Overall accuracy
What the paper describes
I trust you are referring to the following quote
Each experiment is repeated ten times with a different training set to make the comparison fair, and both the mean accuracies
|
41,888
|
Difference between Mean/average accuracy and Overall accuracy
|
The mean accuracy and overall accuracy are nearly what you defined. But the mean accuracy is the average across all classes not just 1 like you listed. In fact they can be computed from each other given k target class labels where k >= 2:
avgaccuracy = (2*overallaccuracy + k-2)/k =2(overallaccuracy-1)/k+1
overallaccuracy = (k*avgaccuracy + 2-k)/2 =k(avgaccuracy-1)/2+1
This formula is straight forward to derive by simply reformulating the average accuracy in terms of the overall accuracy. Actually it is quite logical since its merely a ratio between 2-classes and k-classes, and subtracting and adding 1 before and after. Just a very simple re-scaling operation. For your example:
0.9912 = (2 * 0.956 + 8) / 10
So 0.9912 is the mean accuracy.
As the other post mentions, there is also a mean average which can be taken by k-folds cross validation.
In this case it is the k-folds score mean of the mean accuracy. And the k-folds score mean of the overall accuracy. With k-folds there is no way to express an overall accuracy which is not averaged. This type of details is usually implied as most people understand that k-folds has to average scores, and in this context they are the overall and mean accuracy.
|
Difference between Mean/average accuracy and Overall accuracy
|
The mean accuracy and overall accuracy are nearly what you defined. But the mean accuracy is the average across all classes not just 1 like you listed. In fact they can be computed from each other g
|
Difference between Mean/average accuracy and Overall accuracy
The mean accuracy and overall accuracy are nearly what you defined. But the mean accuracy is the average across all classes not just 1 like you listed. In fact they can be computed from each other given k target class labels where k >= 2:
avgaccuracy = (2*overallaccuracy + k-2)/k =2(overallaccuracy-1)/k+1
overallaccuracy = (k*avgaccuracy + 2-k)/2 =k(avgaccuracy-1)/2+1
This formula is straight forward to derive by simply reformulating the average accuracy in terms of the overall accuracy. Actually it is quite logical since its merely a ratio between 2-classes and k-classes, and subtracting and adding 1 before and after. Just a very simple re-scaling operation. For your example:
0.9912 = (2 * 0.956 + 8) / 10
So 0.9912 is the mean accuracy.
As the other post mentions, there is also a mean average which can be taken by k-folds cross validation.
In this case it is the k-folds score mean of the mean accuracy. And the k-folds score mean of the overall accuracy. With k-folds there is no way to express an overall accuracy which is not averaged. This type of details is usually implied as most people understand that k-folds has to average scores, and in this context they are the overall and mean accuracy.
|
Difference between Mean/average accuracy and Overall accuracy
The mean accuracy and overall accuracy are nearly what you defined. But the mean accuracy is the average across all classes not just 1 like you listed. In fact they can be computed from each other g
|
41,889
|
Robust Principal Component Analysis for Anomaly Detection
|
I went through this papers and others, and used Robust PCA for my own needs. Additionaly to Candes et al., you can take a look to the implementation suggested by Lin et al. (2013): https://arxiv.org/pdf/1009.5055.pdf. Besides detecting outliers, one of the problem formulation also allows you to complete missing entries. You can find a nice Python implementation of the Robust PCA problem formulation here.
Question 1:
From what I understand, your 1d time series is a one-day pattern repeated over one complete week, plus noise. Therefore, as you would do using classic PCA, your samples are each day of your time series, and your features are each hours of the days, so you should reshape your data as a 7 x 24 matrix (n_samples x n_features). Indeed, like PCA, your samples (rows) are supposedly strongly correlated with each other, and so you can find a faithful low rank representation of your time series. Robust PCA comes in handy as it is not as strongly affected by outliers as PCA, where strong outliers might influence the main direction of variance.
Before applying Robust PCA to your data, you should also look at preprocessing steps, such as making your time series stationary, center each day, and so on.
Question 2:
The implementation from Lin et al. (2013) apply an adaptative threshold to filter $S$ entries, and keeping only the entries above the threshold. More details in the paper.
This means that the work of detecting outliers is a priori done in the $S$ computation steps. Theoretically, filtering non zero values in $S$ matrix should give you the outliers in your data. However, with noisy or non smooth data, the sparse matrix $S$ may contain too many outliers. If you feel you detect too many outliers, one idea would be to apply a quantile based anomaly detection on the flattened sparse matrix. Let $\sigma = q_{75} - q_{25}$ your inter quartile range, then you could detect all values which distance to zero is more than $3 \times \sigma$.
|
Robust Principal Component Analysis for Anomaly Detection
|
I went through this papers and others, and used Robust PCA for my own needs. Additionaly to Candes et al., you can take a look to the implementation suggested by Lin et al. (2013): https://arxiv.org/p
|
Robust Principal Component Analysis for Anomaly Detection
I went through this papers and others, and used Robust PCA for my own needs. Additionaly to Candes et al., you can take a look to the implementation suggested by Lin et al. (2013): https://arxiv.org/pdf/1009.5055.pdf. Besides detecting outliers, one of the problem formulation also allows you to complete missing entries. You can find a nice Python implementation of the Robust PCA problem formulation here.
Question 1:
From what I understand, your 1d time series is a one-day pattern repeated over one complete week, plus noise. Therefore, as you would do using classic PCA, your samples are each day of your time series, and your features are each hours of the days, so you should reshape your data as a 7 x 24 matrix (n_samples x n_features). Indeed, like PCA, your samples (rows) are supposedly strongly correlated with each other, and so you can find a faithful low rank representation of your time series. Robust PCA comes in handy as it is not as strongly affected by outliers as PCA, where strong outliers might influence the main direction of variance.
Before applying Robust PCA to your data, you should also look at preprocessing steps, such as making your time series stationary, center each day, and so on.
Question 2:
The implementation from Lin et al. (2013) apply an adaptative threshold to filter $S$ entries, and keeping only the entries above the threshold. More details in the paper.
This means that the work of detecting outliers is a priori done in the $S$ computation steps. Theoretically, filtering non zero values in $S$ matrix should give you the outliers in your data. However, with noisy or non smooth data, the sparse matrix $S$ may contain too many outliers. If you feel you detect too many outliers, one idea would be to apply a quantile based anomaly detection on the flattened sparse matrix. Let $\sigma = q_{75} - q_{25}$ your inter quartile range, then you could detect all values which distance to zero is more than $3 \times \sigma$.
|
Robust Principal Component Analysis for Anomaly Detection
I went through this papers and others, and used Robust PCA for my own needs. Additionaly to Candes et al., you can take a look to the implementation suggested by Lin et al. (2013): https://arxiv.org/p
|
41,890
|
How to report: large sample sizes (10000+), significant small difference (1%)
|
Ideally and theoretically, you should decide on the test before seeing any data, and then report only on that test.
In your situation, I would say that you should report the test that makes sense based on what you know about your data generating process. It makes no sense to report on a simple $\chi^2$ test that does not account for covariates you know are relevant. If such covariates exist and are included in the logistic regression, then that is the model you should report.
Of course, this does not hold if the logistic regression was the result of "fishing for significance" by trying different models until something significant came out. But I assume you would not be asking here if you had done that.
And it's a great idea to discuss that your result, while statistically significant, may not be practically meaningful.
|
How to report: large sample sizes (10000+), significant small difference (1%)
|
Ideally and theoretically, you should decide on the test before seeing any data, and then report only on that test.
In your situation, I would say that you should report the test that makes sense base
|
How to report: large sample sizes (10000+), significant small difference (1%)
Ideally and theoretically, you should decide on the test before seeing any data, and then report only on that test.
In your situation, I would say that you should report the test that makes sense based on what you know about your data generating process. It makes no sense to report on a simple $\chi^2$ test that does not account for covariates you know are relevant. If such covariates exist and are included in the logistic regression, then that is the model you should report.
Of course, this does not hold if the logistic regression was the result of "fishing for significance" by trying different models until something significant came out. But I assume you would not be asking here if you had done that.
And it's a great idea to discuss that your result, while statistically significant, may not be practically meaningful.
|
How to report: large sample sizes (10000+), significant small difference (1%)
Ideally and theoretically, you should decide on the test before seeing any data, and then report only on that test.
In your situation, I would say that you should report the test that makes sense base
|
41,891
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
|
I don't think the coursework is intended to be there as busywork in case you prove the Riemann hypothesis on your first day. More likely, the faculty has made the decision that it wants to get all of its graduate students up to some minimal level of mathematical/statistical competence prior to research training, and a substantial program of graduate-level coursework achieves this.
University faculties have a great deal of discretion in deciding on the coursework component (if any) of their PhD program. Some have no coursework, and some have a substantial amount of coursework. In cases where a student comes in well-prepared (e.g., with an existing coursework Masters), the faculty might exempt them from some or all of the coursework. These decisions tend to be made at the level of each faculty, so they depend heavily on the preferences of the Head of School, the Graduate Coordinator, and other senior academics in the faculty.
I can't speak to what is common in the US, but when I did my PhD (Statistics) at ANU (Australia) there was no coursework in the degree; all the entrants had either done a full year of Honours-level courses as undergraduates, or a Masters degree, or they had substantial industry experience, so they came in with a fair bit of solid coursework behind them already. Evidently, in that particular case, the senior staff in the faculty decided they did not need us to have any more coursework before starting research training.
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
|
I don't think the coursework is intended to be there as busywork in case you prove the Riemann hypothesis on your first day. More likely, the faculty has made the decision that it wants to get all of
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
I don't think the coursework is intended to be there as busywork in case you prove the Riemann hypothesis on your first day. More likely, the faculty has made the decision that it wants to get all of its graduate students up to some minimal level of mathematical/statistical competence prior to research training, and a substantial program of graduate-level coursework achieves this.
University faculties have a great deal of discretion in deciding on the coursework component (if any) of their PhD program. Some have no coursework, and some have a substantial amount of coursework. In cases where a student comes in well-prepared (e.g., with an existing coursework Masters), the faculty might exempt them from some or all of the coursework. These decisions tend to be made at the level of each faculty, so they depend heavily on the preferences of the Head of School, the Graduate Coordinator, and other senior academics in the faculty.
I can't speak to what is common in the US, but when I did my PhD (Statistics) at ANU (Australia) there was no coursework in the degree; all the entrants had either done a full year of Honours-level courses as undergraduates, or a Masters degree, or they had substantial industry experience, so they came in with a fair bit of solid coursework behind them already. Evidently, in that particular case, the senior staff in the faculty decided they did not need us to have any more coursework before starting research training.
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
I don't think the coursework is intended to be there as busywork in case you prove the Riemann hypothesis on your first day. More likely, the faculty has made the decision that it wants to get all of
|
41,892
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
|
That's a very country specific thing and I suspect that it did just grow historically. Many other countries are much more focussed on doing research leading to publications and/or a monograph. This mirrors differences that you can also see in undergraduate education (application first vs. "thou shalt not touch a real dataset without deriving measure theory from first axioms").
E.g. for my doctorate in mathematics (mathematics due to the department, but really statistics) in Germany I attended no courses (some universities in Germany have some required courses), but some events at which people (including myself at the start of my research and prior to the viva) presented their research. Instead, I published two papers, wrote a single booklet based on these (and my other results) and defended a viva.
One disadvantage of the solely research focussed approach is that there are few intermediate goals on the way towards your final thesis and viva (thesis defense). Additionally, the duration of the program is often less clear. Arguments I have heard for it is that it teaches independent research and that course work oriented PhD programs are more like more-in-depth master programs.
However, I am not aware of any research/data that really shows that one approach is better than the other in terms of e.g. graduation rate, amount/quality of subsequent research output or success on the job market.
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
|
That's a very country specific thing and I suspect that it did just grow historically. Many other countries are much more focussed on doing research leading to publications and/or a monograph. This mi
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
That's a very country specific thing and I suspect that it did just grow historically. Many other countries are much more focussed on doing research leading to publications and/or a monograph. This mirrors differences that you can also see in undergraduate education (application first vs. "thou shalt not touch a real dataset without deriving measure theory from first axioms").
E.g. for my doctorate in mathematics (mathematics due to the department, but really statistics) in Germany I attended no courses (some universities in Germany have some required courses), but some events at which people (including myself at the start of my research and prior to the viva) presented their research. Instead, I published two papers, wrote a single booklet based on these (and my other results) and defended a viva.
One disadvantage of the solely research focussed approach is that there are few intermediate goals on the way towards your final thesis and viva (thesis defense). Additionally, the duration of the program is often less clear. Arguments I have heard for it is that it teaches independent research and that course work oriented PhD programs are more like more-in-depth master programs.
However, I am not aware of any research/data that really shows that one approach is better than the other in terms of e.g. graduation rate, amount/quality of subsequent research output or success on the job market.
|
Why are PhD programs in statistics coursework heavy relative to PhD programs in the basic sciences?
That's a very country specific thing and I suspect that it did just grow historically. Many other countries are much more focussed on doing research leading to publications and/or a monograph. This mi
|
41,893
|
Does more training data help lower the bias of a high bias model?
|
However, what impact does training data size have on a high bias model? Generally, will more training data lower the bias, will it have no effect, or will it cause a further increase in the bias?
You mean a model with prediction errors due to high bias?
Bias, is defined as $\operatorname{Bias}[\hat{f}(x)]=\mathrm{E}[\hat{f}(x)]-f(x)$ and thus would not be affected by increasing the training set size. If your model predicts vastly different values when the training set changes, i.e., if the error is largely defined by the variance of the predictions, than you can improve the overall loss by more training data, because the model will learn to generalize better, and hence the variance term will go down. To decrease the bias term, you probably need to choose a different model.
|
Does more training data help lower the bias of a high bias model?
|
However, what impact does training data size have on a high bias model? Generally, will more training data lower the bias, will it have no effect, or will it cause a further increase in the bias?
You
|
Does more training data help lower the bias of a high bias model?
However, what impact does training data size have on a high bias model? Generally, will more training data lower the bias, will it have no effect, or will it cause a further increase in the bias?
You mean a model with prediction errors due to high bias?
Bias, is defined as $\operatorname{Bias}[\hat{f}(x)]=\mathrm{E}[\hat{f}(x)]-f(x)$ and thus would not be affected by increasing the training set size. If your model predicts vastly different values when the training set changes, i.e., if the error is largely defined by the variance of the predictions, than you can improve the overall loss by more training data, because the model will learn to generalize better, and hence the variance term will go down. To decrease the bias term, you probably need to choose a different model.
|
Does more training data help lower the bias of a high bias model?
However, what impact does training data size have on a high bias model? Generally, will more training data lower the bias, will it have no effect, or will it cause a further increase in the bias?
You
|
41,894
|
Does more training data help lower the bias of a high bias model?
|
1- Increasing training data size leads to decrease variance.
2- Decrease the variance leads to increase the bias.
so increase the training data size leads to decrease variance and increase variance.
|
Does more training data help lower the bias of a high bias model?
|
1- Increasing training data size leads to decrease variance.
2- Decrease the variance leads to increase the bias.
so increase the training data size leads to decrease variance and increase variance.
|
Does more training data help lower the bias of a high bias model?
1- Increasing training data size leads to decrease variance.
2- Decrease the variance leads to increase the bias.
so increase the training data size leads to decrease variance and increase variance.
|
Does more training data help lower the bias of a high bias model?
1- Increasing training data size leads to decrease variance.
2- Decrease the variance leads to increase the bias.
so increase the training data size leads to decrease variance and increase variance.
|
41,895
|
How to test if the process that generated a time-series has changed over time
|
Structural change can be tested not only with Chow test mentioned by @John Stax Jakobsen.
There are plenty other tests, especially family of fluctuation tests usually works well.
Here you have nice introduction to R package strucchange that computes them. If you're not R user, read just theory, it is well described there.
|
How to test if the process that generated a time-series has changed over time
|
Structural change can be tested not only with Chow test mentioned by @John Stax Jakobsen.
There are plenty other tests, especially family of fluctuation tests usually works well.
Here you have nice in
|
How to test if the process that generated a time-series has changed over time
Structural change can be tested not only with Chow test mentioned by @John Stax Jakobsen.
There are plenty other tests, especially family of fluctuation tests usually works well.
Here you have nice introduction to R package strucchange that computes them. If you're not R user, read just theory, it is well described there.
|
How to test if the process that generated a time-series has changed over time
Structural change can be tested not only with Chow test mentioned by @John Stax Jakobsen.
There are plenty other tests, especially family of fluctuation tests usually works well.
Here you have nice in
|
41,896
|
How to test if the process that generated a time-series has changed over time
|
If it is reasonable to model the relationship with a linear regression, then an easy way to test for a structural break is the chow test.
see the wiki article here
|
How to test if the process that generated a time-series has changed over time
|
If it is reasonable to model the relationship with a linear regression, then an easy way to test for a structural break is the chow test.
see the wiki article here
|
How to test if the process that generated a time-series has changed over time
If it is reasonable to model the relationship with a linear regression, then an easy way to test for a structural break is the chow test.
see the wiki article here
|
How to test if the process that generated a time-series has changed over time
If it is reasonable to model the relationship with a linear regression, then an easy way to test for a structural break is the chow test.
see the wiki article here
|
41,897
|
How to test if the process that generated a time-series has changed over time
|
First, I would just fit some black box models (e.g. GBM or random forest) which directly take into account the time variable $T$, e.g. $Y_t=F(X_t^1, \ldots, X_d^t; T)$. It might be helpful to test various granularity of $T$, such as measured in calendar years (2016, 2018), months passed since 2016, etc. Then, in order to assess the importance of $T$ one could either look at variable importance plots (see e.g. Section “15.3.2 Variable Importance” in Elements of Statistical Learning) or simply drop the $T$ variable, refit the model and compare the model performance.
Alternatively, you could stick to your model (Gaussian process) and compare the 2016 and 2018 residuals. I agree with your intuition that the comparison of distribution of in-sample (2016) and out-of-sample (2018) residuals would get misleading results. However, this can be fixed quickly by partitioning your data as follows: split 2016 data into training subset (used to fit the model) and validation subset (used to assess the quality of your model), also define the second validation dataset using subset of 2018 data. Then, just fit your model using training subset and test the performance (calculate residuals, MSE, etc) on two validation subsets (2016 and 2018). In order to rule out chance (your result might differ just because of bad luck) you might want to repeat the whole exercise (splitting data, fitting model, assessing performance on validation datasets) several times.
Also, as you mentioned, you could fit two different models (one based on 2016 data, another based only on 2018 data). In this case I would also split the data for each year into training and validation subsets and assess the model performance based on the validation subsets. As a measure of similarity you could use: RMSE, QQ-plots, statistical tests you mentioned or calculating the confidence intervals for predictions coming from both models and checking whether the confidence intervals overlap.
|
How to test if the process that generated a time-series has changed over time
|
First, I would just fit some black box models (e.g. GBM or random forest) which directly take into account the time variable $T$, e.g. $Y_t=F(X_t^1, \ldots, X_d^t; T)$. It might be helpful to test var
|
How to test if the process that generated a time-series has changed over time
First, I would just fit some black box models (e.g. GBM or random forest) which directly take into account the time variable $T$, e.g. $Y_t=F(X_t^1, \ldots, X_d^t; T)$. It might be helpful to test various granularity of $T$, such as measured in calendar years (2016, 2018), months passed since 2016, etc. Then, in order to assess the importance of $T$ one could either look at variable importance plots (see e.g. Section “15.3.2 Variable Importance” in Elements of Statistical Learning) or simply drop the $T$ variable, refit the model and compare the model performance.
Alternatively, you could stick to your model (Gaussian process) and compare the 2016 and 2018 residuals. I agree with your intuition that the comparison of distribution of in-sample (2016) and out-of-sample (2018) residuals would get misleading results. However, this can be fixed quickly by partitioning your data as follows: split 2016 data into training subset (used to fit the model) and validation subset (used to assess the quality of your model), also define the second validation dataset using subset of 2018 data. Then, just fit your model using training subset and test the performance (calculate residuals, MSE, etc) on two validation subsets (2016 and 2018). In order to rule out chance (your result might differ just because of bad luck) you might want to repeat the whole exercise (splitting data, fitting model, assessing performance on validation datasets) several times.
Also, as you mentioned, you could fit two different models (one based on 2016 data, another based only on 2018 data). In this case I would also split the data for each year into training and validation subsets and assess the model performance based on the validation subsets. As a measure of similarity you could use: RMSE, QQ-plots, statistical tests you mentioned or calculating the confidence intervals for predictions coming from both models and checking whether the confidence intervals overlap.
|
How to test if the process that generated a time-series has changed over time
First, I would just fit some black box models (e.g. GBM or random forest) which directly take into account the time variable $T$, e.g. $Y_t=F(X_t^1, \ldots, X_d^t; T)$. It might be helpful to test var
|
41,898
|
How to test if the process that generated a time-series has changed over time
|
One of the features that I put into my favorite forecasting package was the CHOW Test to investigate that breakpoint in parameters that was the most significant. Before I did that I had to treat/adjust for pulses/seasonal pulses.
Of course if there are identified level Shifts or Time Trends this test is bypassed.
The CHOW Test premises independent errors with in each group as it is required under the F test that he uses.
My implementation includes the possibility of contemporary and/or lagged user specifed causals within the GLM.
|
How to test if the process that generated a time-series has changed over time
|
One of the features that I put into my favorite forecasting package was the CHOW Test to investigate that breakpoint in parameters that was the most significant. Before I did that I had to treat/adjus
|
How to test if the process that generated a time-series has changed over time
One of the features that I put into my favorite forecasting package was the CHOW Test to investigate that breakpoint in parameters that was the most significant. Before I did that I had to treat/adjust for pulses/seasonal pulses.
Of course if there are identified level Shifts or Time Trends this test is bypassed.
The CHOW Test premises independent errors with in each group as it is required under the F test that he uses.
My implementation includes the possibility of contemporary and/or lagged user specifed causals within the GLM.
|
How to test if the process that generated a time-series has changed over time
One of the features that I put into my favorite forecasting package was the CHOW Test to investigate that breakpoint in parameters that was the most significant. Before I did that I had to treat/adjus
|
41,899
|
When modeling a copula, you need to generate "pseudo observations"? Why? What is a pseudo observation? [closed]
|
Copula models based on pseudo-observation (normalized ranked data), not on the original dataset. That due to the Sklar's theorem (the backbone of the copula model). From Sklar's theorem, copula is a function of uniform margins.
Hence, you need to transform the margins of your dataset to the standard uniform margins, in order to obtain copula data. For RVineCopula, if you simulate your data from RVineSim, then you do not need to transform the margins, however, if your data is a real data, then make sure that you transform it to the uniform distribution using pobs function.
|
When modeling a copula, you need to generate "pseudo observations"? Why? What is a pseudo observatio
|
Copula models based on pseudo-observation (normalized ranked data), not on the original dataset. That due to the Sklar's theorem (the backbone of the copula model). From Sklar's theorem, copula is a f
|
When modeling a copula, you need to generate "pseudo observations"? Why? What is a pseudo observation? [closed]
Copula models based on pseudo-observation (normalized ranked data), not on the original dataset. That due to the Sklar's theorem (the backbone of the copula model). From Sklar's theorem, copula is a function of uniform margins.
Hence, you need to transform the margins of your dataset to the standard uniform margins, in order to obtain copula data. For RVineCopula, if you simulate your data from RVineSim, then you do not need to transform the margins, however, if your data is a real data, then make sure that you transform it to the uniform distribution using pobs function.
|
When modeling a copula, you need to generate "pseudo observations"? Why? What is a pseudo observatio
Copula models based on pseudo-observation (normalized ranked data), not on the original dataset. That due to the Sklar's theorem (the backbone of the copula model). From Sklar's theorem, copula is a f
|
41,900
|
Fitting distributions on censored data
|
A short answer which might be expanded: This is really about how the likelihood function is defined, see for instance How to rigorously define the likelihood?. It doesn't really matter if you use probability densities or probability mass functions to define your likelihood. The likelihood function is always defined with respect to some dominating measure on the sample space of the observations.
If the dominating measure is Lebesgue measure on the real line, we get probability distributions defined via densities. If the dominating measure is counting measure, we get probability mass functions. But there are many other possibilities, an example is modeling daily rainfall, where there might be some positive probability of zero rain, but else a density on positive values. That can be represented as a density (formally: Radon-Nikodym derivative) with respect to a sum of Lebesgue measure on the positive real line, and a probability atom at zero.
In your case, with censoring at the high and low ends, say at $a < b$, your dominating measure is a sum of Lebesgue measure on $(a,b)$ and probability atoms at $a$ and at $b$. In this abstract setting, this is no different than a density with respect to Lebesgue measure or with respect to counting measure. So you have nothing to be preoccupied about! What is important is that the dominating measure is the same for all the possible particular models (whether parametrized or not) that you entertain. And, as far as I know, this framework do not allow for estimating the dominating measure, that has to be known by the modeler.
For information about Radon-Nikodym derivatives and dominating measures, see Interpretation of Radon-Nikodym derivative between probability measures?
|
Fitting distributions on censored data
|
A short answer which might be expanded: This is really about how the likelihood function is defined, see for instance How to rigorously define the likelihood?. It doesn't really matter if you use pr
|
Fitting distributions on censored data
A short answer which might be expanded: This is really about how the likelihood function is defined, see for instance How to rigorously define the likelihood?. It doesn't really matter if you use probability densities or probability mass functions to define your likelihood. The likelihood function is always defined with respect to some dominating measure on the sample space of the observations.
If the dominating measure is Lebesgue measure on the real line, we get probability distributions defined via densities. If the dominating measure is counting measure, we get probability mass functions. But there are many other possibilities, an example is modeling daily rainfall, where there might be some positive probability of zero rain, but else a density on positive values. That can be represented as a density (formally: Radon-Nikodym derivative) with respect to a sum of Lebesgue measure on the positive real line, and a probability atom at zero.
In your case, with censoring at the high and low ends, say at $a < b$, your dominating measure is a sum of Lebesgue measure on $(a,b)$ and probability atoms at $a$ and at $b$. In this abstract setting, this is no different than a density with respect to Lebesgue measure or with respect to counting measure. So you have nothing to be preoccupied about! What is important is that the dominating measure is the same for all the possible particular models (whether parametrized or not) that you entertain. And, as far as I know, this framework do not allow for estimating the dominating measure, that has to be known by the modeler.
For information about Radon-Nikodym derivatives and dominating measures, see Interpretation of Radon-Nikodym derivative between probability measures?
|
Fitting distributions on censored data
A short answer which might be expanded: This is really about how the likelihood function is defined, see for instance How to rigorously define the likelihood?. It doesn't really matter if you use pr
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.