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
42,201
Formula for confidence intervals for small samples and unknown population standard deviation
Here are some good notes on standard deviation and the standard error of the mean here. The Wackerly et al text computes small sample confidence intervals in section 8.8 (page 430) you can see their formula here. Confidence interval: $\bar{Y} \pm t_{\alpha/2} * \frac{S}{\sqrt{n}}$ Where $\bar{y}$ = $\frac{1}{n}$$\sum{\textstyle y_{i}}$ (the sample mean) and $S = \sqrt{\frac{1}{n-1}\sum(y_{i}-\bar{y})^2}$ (the sample standard deviation) t$_{\alpha/2}$ is the critical value for a given value of $\alpha$ (e.g., .1, .05, etc.) and has n-1 degrees of freedom, where n is the sample size, that you'd find in a table. Now if your sample is a large proportion of a known finite population size there is something called a population correction factor, but for basic needs you probably don't have to worry about this.
Formula for confidence intervals for small samples and unknown population standard deviation
Here are some good notes on standard deviation and the standard error of the mean here. The Wackerly et al text computes small sample confidence intervals in section 8.8 (page 430) you can see their f
Formula for confidence intervals for small samples and unknown population standard deviation Here are some good notes on standard deviation and the standard error of the mean here. The Wackerly et al text computes small sample confidence intervals in section 8.8 (page 430) you can see their formula here. Confidence interval: $\bar{Y} \pm t_{\alpha/2} * \frac{S}{\sqrt{n}}$ Where $\bar{y}$ = $\frac{1}{n}$$\sum{\textstyle y_{i}}$ (the sample mean) and $S = \sqrt{\frac{1}{n-1}\sum(y_{i}-\bar{y})^2}$ (the sample standard deviation) t$_{\alpha/2}$ is the critical value for a given value of $\alpha$ (e.g., .1, .05, etc.) and has n-1 degrees of freedom, where n is the sample size, that you'd find in a table. Now if your sample is a large proportion of a known finite population size there is something called a population correction factor, but for basic needs you probably don't have to worry about this.
Formula for confidence intervals for small samples and unknown population standard deviation Here are some good notes on standard deviation and the standard error of the mean here. The Wackerly et al text computes small sample confidence intervals in section 8.8 (page 430) you can see their f
42,202
Moments of Laplace distribution
Here is a quick check using a symbolic algebra package ... Let $X \sim \text{Laplace}(\mu, \sigma)$ with pdf $f(x)$: Then, the first 4 raw moments $E[X^i]$ are given by: where I am using the Expect function from the mathStatica package for Mathematica. It is worth noting that the $3^\text{rd}$ and $4^\text{th}$ raw moments are different to those given in the answer above.
Moments of Laplace distribution
Here is a quick check using a symbolic algebra package ... Let $X \sim \text{Laplace}(\mu, \sigma)$ with pdf $f(x)$: Then, the first 4 raw moments $E[X^i]$ are given by: where I am using the Expect
Moments of Laplace distribution Here is a quick check using a symbolic algebra package ... Let $X \sim \text{Laplace}(\mu, \sigma)$ with pdf $f(x)$: Then, the first 4 raw moments $E[X^i]$ are given by: where I am using the Expect function from the mathStatica package for Mathematica. It is worth noting that the $3^\text{rd}$ and $4^\text{th}$ raw moments are different to those given in the answer above.
Moments of Laplace distribution Here is a quick check using a symbolic algebra package ... Let $X \sim \text{Laplace}(\mu, \sigma)$ with pdf $f(x)$: Then, the first 4 raw moments $E[X^i]$ are given by: where I am using the Expect
42,203
Moments of Laplace distribution
It's been awhile and looks like this hasn't been answered. I'll provide one and hopefully we can mark this as correct. I'll answer in order the questions asked using the parameterization of the wikipedia page $$f(x\mid\mu,b)= \frac{1}{2b} \exp \left( -\frac{|x-\mu|}{b} \right), x\in \mathbb{R}. $$ For the case $\mu=0$, the first four moments are: $$\mathbb{E}(X)=0, \mathbb{E}(X^2)=2b^2 + \mu^2, \mathbb{E}(X^3)=0, and\ \mathbb{E}(X^4) = 24b^4.$$ As whuber indicates in a comment you can related a non-central random variable $Y$ via a binomial expansion of $Y^k=(Xb+\mu)^k$. The value $\mu=0$ is often chosen to simplify the calculation and to build up to the solution. The Laplace have infinite tails like the Cauchy, the support is $x \in (-\infty, \infty)$. For the empirical rule, I'm assuming the OP is using the shorthand for the probability of observations within $\sigma$ of the mean, $\mu$, $2\sigma$ of $\mu$ and $2\sigma$ of $\mu$ respectively. These probabilities are: (0.75688, 0.94089, 0.98563) to 5 significant digits, respectively. A couple of different ways to calculate the expected values are: a. Direct integration (usually split the integral at the point $\mu$ where the sign changes. b. Differentiate the moment generating function $m$ times and set $t=0$ to get the $m$th moment. c. Formulate the Laplace random variable (r.v.) as a scale mixture of Normal and Exponential random variable. Then use conditional expectations. Note approach (c) is only easier than (a) if you know the moments of Normal and Exponential random variables-or can calculate them easier than directly calculating the moments of the Laplace distribution
Moments of Laplace distribution
It's been awhile and looks like this hasn't been answered. I'll provide one and hopefully we can mark this as correct. I'll answer in order the questions asked using the parameterization of the wikipe
Moments of Laplace distribution It's been awhile and looks like this hasn't been answered. I'll provide one and hopefully we can mark this as correct. I'll answer in order the questions asked using the parameterization of the wikipedia page $$f(x\mid\mu,b)= \frac{1}{2b} \exp \left( -\frac{|x-\mu|}{b} \right), x\in \mathbb{R}. $$ For the case $\mu=0$, the first four moments are: $$\mathbb{E}(X)=0, \mathbb{E}(X^2)=2b^2 + \mu^2, \mathbb{E}(X^3)=0, and\ \mathbb{E}(X^4) = 24b^4.$$ As whuber indicates in a comment you can related a non-central random variable $Y$ via a binomial expansion of $Y^k=(Xb+\mu)^k$. The value $\mu=0$ is often chosen to simplify the calculation and to build up to the solution. The Laplace have infinite tails like the Cauchy, the support is $x \in (-\infty, \infty)$. For the empirical rule, I'm assuming the OP is using the shorthand for the probability of observations within $\sigma$ of the mean, $\mu$, $2\sigma$ of $\mu$ and $2\sigma$ of $\mu$ respectively. These probabilities are: (0.75688, 0.94089, 0.98563) to 5 significant digits, respectively. A couple of different ways to calculate the expected values are: a. Direct integration (usually split the integral at the point $\mu$ where the sign changes. b. Differentiate the moment generating function $m$ times and set $t=0$ to get the $m$th moment. c. Formulate the Laplace random variable (r.v.) as a scale mixture of Normal and Exponential random variable. Then use conditional expectations. Note approach (c) is only easier than (a) if you know the moments of Normal and Exponential random variables-or can calculate them easier than directly calculating the moments of the Laplace distribution
Moments of Laplace distribution It's been awhile and looks like this hasn't been answered. I'll provide one and hopefully we can mark this as correct. I'll answer in order the questions asked using the parameterization of the wikipe
42,204
What to do with almost-continuous variable in regression?
I'd say interact continuous age with a dummy "continuous age is available", and categorical age with a dummy "continuous age is not available". That way you'll be using as much of the information you have as possible. Of course if the effect of age is something you'd like to be able to summarize with just one point estimate, you'll have to think a bit more (though the coefficient on continuous age should be a pretty good approximation for that).
What to do with almost-continuous variable in regression?
I'd say interact continuous age with a dummy "continuous age is available", and categorical age with a dummy "continuous age is not available". That way you'll be using as much of the information you
What to do with almost-continuous variable in regression? I'd say interact continuous age with a dummy "continuous age is available", and categorical age with a dummy "continuous age is not available". That way you'll be using as much of the information you have as possible. Of course if the effect of age is something you'd like to be able to summarize with just one point estimate, you'll have to think a bit more (though the coefficient on continuous age should be a pretty good approximation for that).
What to do with almost-continuous variable in regression? I'd say interact continuous age with a dummy "continuous age is available", and categorical age with a dummy "continuous age is not available". That way you'll be using as much of the information you
42,205
What to do with almost-continuous variable in regression?
You can incorporate this in the Bayesian framework by specifying a prior distribution for the age variable. And for the posterior, you have: $$p(\theta|DI)\propto p(\theta|I)p(D|\theta I)$$ Now you simply take $D\equiv (18+)$ for example. This is no more difficult "in-principle" compared to when you actually do know the ages. The difference is that your likelihood function must be a cumulative distribution function instead of a density. As an example, suppose age is the only regressor you have (denoted $x_i$), and you are fitting a OLS model. This is for my benefit - but the generalisation is just details, rather than conceptual. If you have observed the ages exactly the likelihood function is: $$p(y_1\dots y_N|x_1\dots x_N\alpha\beta\sigma I)=(2\pi\sigma^2)^{-\frac{N}{2}}\exp\left(-\frac{1}{2\sigma^2}\sum_{i=1}^{N}(y_i-\alpha-\beta x_i)^2\right)$$ But now suppose that the $(N+1)$th observation, you only observe that $L<x_{N+1}<U$. Lets call this piece of information $Z$. Now we can use the brilliant trick of introducing a nuisance parameter and then integrating it out again (via the sum rule). The nuisance parameter we introduce is $x_{N+1}$ (the actual unobserved age), and we have: $$p(y_1\dots y_N y_{N+1}|x_1\dots x_N Z\alpha\beta\sigma I)=\int_{L}^{U} p(y_1\dots y_N y_{N+1}x_{N+1}|x_1\dots x_N Z\alpha\beta\sigma I)dx_{N+1}$$ Now we can split the integrand by using the product rule $P(AB|C)=P(A|C)P(B|AC)$ and we get: $$p(x_{N+1}|x_1\dots x_N Z\alpha\beta\sigma I)p(y_1\dots y_N y_{N+1}|x_1\dots x_N x_{N+1}Z\alpha\beta\sigma I)$$ Note that in the second density, the information $Z\equiv L<x_{N+1}<U$ is redundant because we are already conditioning on the true value $x_{N+1}$. So we can remove it. Note that this second term could be called the "clean" data. The first term is basically a statement of how likely the unobserved age is given $L<x_{N+1}<U$, in addition to the position of the "true line" $(\alpha,\beta)$, the noise level $\sigma$, and the values of all other ages $(x_1\dots x_N)$. And so you have an integrated likelihood (sometimes called quasi-likelihood): $$p(Y|XZ\alpha\beta\sigma I)=(2\pi\sigma^2)^{-\frac{N+1}{2}}\exp\left(-\frac{1}{2\sigma^2}\sum_{i=1}^{N}(y_i-\alpha-\beta x_i)^2\right)$$ $$\times\int_{L}^{U}p(x_{N+1}|X\alpha\beta\sigma I)\exp\left(-\frac{(y_{N+1}-\alpha-\beta x_{N+1})^2}{2\sigma^2}\right)dx_{N+1}$$ Now for every "messy" data, you will have a similar integral. You can take the above integral as multi-dimensional (with appropriate matrix sum of squares in the exponential). I have heard something like this called the "Missing information Principle". You basically create a "nice" dataset from your "messy" one (i.e. the data set you wish you had), and then average out the "nice" inferences. You give more weight to certain nice data sets according to what your "messy" information is.
What to do with almost-continuous variable in regression?
You can incorporate this in the Bayesian framework by specifying a prior distribution for the age variable. And for the posterior, you have: $$p(\theta|DI)\propto p(\theta|I)p(D|\theta I)$$ Now you s
What to do with almost-continuous variable in regression? You can incorporate this in the Bayesian framework by specifying a prior distribution for the age variable. And for the posterior, you have: $$p(\theta|DI)\propto p(\theta|I)p(D|\theta I)$$ Now you simply take $D\equiv (18+)$ for example. This is no more difficult "in-principle" compared to when you actually do know the ages. The difference is that your likelihood function must be a cumulative distribution function instead of a density. As an example, suppose age is the only regressor you have (denoted $x_i$), and you are fitting a OLS model. This is for my benefit - but the generalisation is just details, rather than conceptual. If you have observed the ages exactly the likelihood function is: $$p(y_1\dots y_N|x_1\dots x_N\alpha\beta\sigma I)=(2\pi\sigma^2)^{-\frac{N}{2}}\exp\left(-\frac{1}{2\sigma^2}\sum_{i=1}^{N}(y_i-\alpha-\beta x_i)^2\right)$$ But now suppose that the $(N+1)$th observation, you only observe that $L<x_{N+1}<U$. Lets call this piece of information $Z$. Now we can use the brilliant trick of introducing a nuisance parameter and then integrating it out again (via the sum rule). The nuisance parameter we introduce is $x_{N+1}$ (the actual unobserved age), and we have: $$p(y_1\dots y_N y_{N+1}|x_1\dots x_N Z\alpha\beta\sigma I)=\int_{L}^{U} p(y_1\dots y_N y_{N+1}x_{N+1}|x_1\dots x_N Z\alpha\beta\sigma I)dx_{N+1}$$ Now we can split the integrand by using the product rule $P(AB|C)=P(A|C)P(B|AC)$ and we get: $$p(x_{N+1}|x_1\dots x_N Z\alpha\beta\sigma I)p(y_1\dots y_N y_{N+1}|x_1\dots x_N x_{N+1}Z\alpha\beta\sigma I)$$ Note that in the second density, the information $Z\equiv L<x_{N+1}<U$ is redundant because we are already conditioning on the true value $x_{N+1}$. So we can remove it. Note that this second term could be called the "clean" data. The first term is basically a statement of how likely the unobserved age is given $L<x_{N+1}<U$, in addition to the position of the "true line" $(\alpha,\beta)$, the noise level $\sigma$, and the values of all other ages $(x_1\dots x_N)$. And so you have an integrated likelihood (sometimes called quasi-likelihood): $$p(Y|XZ\alpha\beta\sigma I)=(2\pi\sigma^2)^{-\frac{N+1}{2}}\exp\left(-\frac{1}{2\sigma^2}\sum_{i=1}^{N}(y_i-\alpha-\beta x_i)^2\right)$$ $$\times\int_{L}^{U}p(x_{N+1}|X\alpha\beta\sigma I)\exp\left(-\frac{(y_{N+1}-\alpha-\beta x_{N+1})^2}{2\sigma^2}\right)dx_{N+1}$$ Now for every "messy" data, you will have a similar integral. You can take the above integral as multi-dimensional (with appropriate matrix sum of squares in the exponential). I have heard something like this called the "Missing information Principle". You basically create a "nice" dataset from your "messy" one (i.e. the data set you wish you had), and then average out the "nice" inferences. You give more weight to certain nice data sets according to what your "messy" information is.
What to do with almost-continuous variable in regression? You can incorporate this in the Bayesian framework by specifying a prior distribution for the age variable. And for the posterior, you have: $$p(\theta|DI)\propto p(\theta|I)p(D|\theta I)$$ Now you s
42,206
What to do with almost-continuous variable in regression?
You can treat age as an interval censored variable. Some survival routines do this in a straight forward way for the response variable, if age is a predictor then I don't know if there are ready made tools available. But you could still do it using maximum liklihood.
What to do with almost-continuous variable in regression?
You can treat age as an interval censored variable. Some survival routines do this in a straight forward way for the response variable, if age is a predictor then I don't know if there are ready made
What to do with almost-continuous variable in regression? You can treat age as an interval censored variable. Some survival routines do this in a straight forward way for the response variable, if age is a predictor then I don't know if there are ready made tools available. But you could still do it using maximum liklihood.
What to do with almost-continuous variable in regression? You can treat age as an interval censored variable. Some survival routines do this in a straight forward way for the response variable, if age is a predictor then I don't know if there are ready made
42,207
Probability for finding a double-as-likely event
Partition the outcomes by the frequency of occurrences $x$ of the "double outcome", $0 \le x \le t$. Conditional on this number, the distribution of the remaining $t-x$ outcomes is multinomial across $n-1$ equiprobable bins. Let $p(t-x, n-1, x)$ be the chance that no bin out of $n-1$ equally likely ones receives more than $x$ outcomes. The sought-for probability therefore equals $$\sum_{x=0}^{t} \binom{t}{x}\left(\frac{2}{n+1}\right)^x \left(\frac{n-1}{n+1}\right)^{t-x} p(t-x,n-1,x).$$ In Exact Tail Probabilities and Percentiles of the Multinomial Maximum, Anirban DasGupta points out (after correcting typographical errors) that $p(n,K,x)K^n/n!$ equals the coefficient of $\lambda^n$ in the expansion of $\left(\sum_{j=0}^{x}\lambda^j/j!\right)^K$ (using his notation). For the values of $t$ and $n$ involved here, this coefficient can be computed in at most a few seconds (making sure to discard all $O(\lambda^{n+1})$ terms while performing the successive convolutions needed to obtain the $K^{\text{th}}$ power). (I checked the timing and corrected the typos by reproducing DasGupta's Table 4, which displays the complementary probabilities $1 - p(n,K,x)$, and extending it to values where $n$ and $K$ are both in the hundreds.) Quoting a theorem of Kolchin et al., DasGupta provides an approximation for the computationally intensive case where $t$ is substantially larger than $n$. Between the exact computation and the approximation, it looks like all possibilities are covered.
Probability for finding a double-as-likely event
Partition the outcomes by the frequency of occurrences $x$ of the "double outcome", $0 \le x \le t$. Conditional on this number, the distribution of the remaining $t-x$ outcomes is multinomial across
Probability for finding a double-as-likely event Partition the outcomes by the frequency of occurrences $x$ of the "double outcome", $0 \le x \le t$. Conditional on this number, the distribution of the remaining $t-x$ outcomes is multinomial across $n-1$ equiprobable bins. Let $p(t-x, n-1, x)$ be the chance that no bin out of $n-1$ equally likely ones receives more than $x$ outcomes. The sought-for probability therefore equals $$\sum_{x=0}^{t} \binom{t}{x}\left(\frac{2}{n+1}\right)^x \left(\frac{n-1}{n+1}\right)^{t-x} p(t-x,n-1,x).$$ In Exact Tail Probabilities and Percentiles of the Multinomial Maximum, Anirban DasGupta points out (after correcting typographical errors) that $p(n,K,x)K^n/n!$ equals the coefficient of $\lambda^n$ in the expansion of $\left(\sum_{j=0}^{x}\lambda^j/j!\right)^K$ (using his notation). For the values of $t$ and $n$ involved here, this coefficient can be computed in at most a few seconds (making sure to discard all $O(\lambda^{n+1})$ terms while performing the successive convolutions needed to obtain the $K^{\text{th}}$ power). (I checked the timing and corrected the typos by reproducing DasGupta's Table 4, which displays the complementary probabilities $1 - p(n,K,x)$, and extending it to values where $n$ and $K$ are both in the hundreds.) Quoting a theorem of Kolchin et al., DasGupta provides an approximation for the computationally intensive case where $t$ is substantially larger than $n$. Between the exact computation and the approximation, it looks like all possibilities are covered.
Probability for finding a double-as-likely event Partition the outcomes by the frequency of occurrences $x$ of the "double outcome", $0 \le x \le t$. Conditional on this number, the distribution of the remaining $t-x$ outcomes is multinomial across
42,208
Probability for finding a double-as-likely event
I agree with some comments, in that the Poisson approximation sounds nice here (not a 'crude' approximation). It should be asympotically exact, and it seems the most reasonable thing to do, as an exact analytic solutions seems difficult. As an intermediate alternative, (if you really need it) I suggest I fisrt order correction to the Poisson approximation, in the following way (I've done something similar some time ago, and it worked). As suggested by a comment, your model is (not approximately but exactly) Poisson if we condition on the sum. That is: Let $X_t$ ($t$ is a parameter here) be a vector of $n$ independent Poisson variables, the first one with $\lambda = 2t/(n+1)$, the others with $\lambda = t/(n+1)$. Let $s=\sum x$, so $E(s)=t$. It is clear that $X_t$ is not equivalent to other model (because our model is restricted to $s=t$), but it is a good approximation. Further, the distribution of $X_t | s$ is equivalent to our model. Indeed, we can write $ \displaystyle P(X_t) = \sum_s P(X_t | s) P(s)$ This can also be writen for the event in consideration (that $x_1 $ is the maximum). We know to compute the LHS, and $P(s)$, but we are interested in the other term. Our first order Poisson approximation comes from assuming that $P(s)$ concentrates about the mean so that it can be assimilated to a delta, and then $ P(X_t) \approx P(X_t | s=t) $ To refine the aprroximation, we can see the above as a convolution of two functions: our unknown $P(X_t | s)$, which we assume smooth around $s=t$, and a quasi delta function, say a gaussian with small variance. Now, we have our first order approximation (for continuous variables) : $h(x) = g(x) * N(x_0,\sigma^2)$ (convolution) $h(x_0) \approx g(x_0) + g(x_0)''\sigma^2/2$ $g(x_0) \approx h(x_0) - h''(x_0)''\sigma^2/2$ Applying this to the previous equation can lead to a refined approximation to our desired probability.
Probability for finding a double-as-likely event
I agree with some comments, in that the Poisson approximation sounds nice here (not a 'crude' approximation). It should be asympotically exact, and it seems the most reasonable thing to do, as an exac
Probability for finding a double-as-likely event I agree with some comments, in that the Poisson approximation sounds nice here (not a 'crude' approximation). It should be asympotically exact, and it seems the most reasonable thing to do, as an exact analytic solutions seems difficult. As an intermediate alternative, (if you really need it) I suggest I fisrt order correction to the Poisson approximation, in the following way (I've done something similar some time ago, and it worked). As suggested by a comment, your model is (not approximately but exactly) Poisson if we condition on the sum. That is: Let $X_t$ ($t$ is a parameter here) be a vector of $n$ independent Poisson variables, the first one with $\lambda = 2t/(n+1)$, the others with $\lambda = t/(n+1)$. Let $s=\sum x$, so $E(s)=t$. It is clear that $X_t$ is not equivalent to other model (because our model is restricted to $s=t$), but it is a good approximation. Further, the distribution of $X_t | s$ is equivalent to our model. Indeed, we can write $ \displaystyle P(X_t) = \sum_s P(X_t | s) P(s)$ This can also be writen for the event in consideration (that $x_1 $ is the maximum). We know to compute the LHS, and $P(s)$, but we are interested in the other term. Our first order Poisson approximation comes from assuming that $P(s)$ concentrates about the mean so that it can be assimilated to a delta, and then $ P(X_t) \approx P(X_t | s=t) $ To refine the aprroximation, we can see the above as a convolution of two functions: our unknown $P(X_t | s)$, which we assume smooth around $s=t$, and a quasi delta function, say a gaussian with small variance. Now, we have our first order approximation (for continuous variables) : $h(x) = g(x) * N(x_0,\sigma^2)$ (convolution) $h(x_0) \approx g(x_0) + g(x_0)''\sigma^2/2$ $g(x_0) \approx h(x_0) - h''(x_0)''\sigma^2/2$ Applying this to the previous equation can lead to a refined approximation to our desired probability.
Probability for finding a double-as-likely event I agree with some comments, in that the Poisson approximation sounds nice here (not a 'crude' approximation). It should be asympotically exact, and it seems the most reasonable thing to do, as an exac
42,209
Probability for finding a double-as-likely event
Just a word of explanation: Part out of curiosity, part for lack of a better more theoretical method, i approached the problem in a completely empirical/inductive way. I'm aware that there is the risk of getting stuck in a dead end without gaining much insight, but i thought, i'll just present what i got so far anyway, in case it is useful to someone. Starting by computing the exact probabilities for $n,t\in\{1,...,8\}$ we get Due to the underlying multinomial distribution, multiplying the entries in the table by $(n+1)^t$ leaves us with a purely integer table: Now we find that there is a polynomial in $n$ for every column which acts as the sequence function for that column: Dividing the sequence functions by $(n+1)^t$ gives us sequence functions for the original probabilities for the first $t$'s. These rational polynomials can be simplified by decomposing them into partial fractions and substituting $x$ for $1/(n+1)$, leaving us with: or as coefficient table Starting with the $x^2$ column there are sequence functions for these coefficients again: That's how far i got. There are definitely exploitable patterns here that allow sequence functions to occur, but i'm not sure if there is a nice closed form solution for these sequence functions.
Probability for finding a double-as-likely event
Just a word of explanation: Part out of curiosity, part for lack of a better more theoretical method, i approached the problem in a completely empirical/inductive way. I'm aware that there is the risk
Probability for finding a double-as-likely event Just a word of explanation: Part out of curiosity, part for lack of a better more theoretical method, i approached the problem in a completely empirical/inductive way. I'm aware that there is the risk of getting stuck in a dead end without gaining much insight, but i thought, i'll just present what i got so far anyway, in case it is useful to someone. Starting by computing the exact probabilities for $n,t\in\{1,...,8\}$ we get Due to the underlying multinomial distribution, multiplying the entries in the table by $(n+1)^t$ leaves us with a purely integer table: Now we find that there is a polynomial in $n$ for every column which acts as the sequence function for that column: Dividing the sequence functions by $(n+1)^t$ gives us sequence functions for the original probabilities for the first $t$'s. These rational polynomials can be simplified by decomposing them into partial fractions and substituting $x$ for $1/(n+1)$, leaving us with: or as coefficient table Starting with the $x^2$ column there are sequence functions for these coefficients again: That's how far i got. There are definitely exploitable patterns here that allow sequence functions to occur, but i'm not sure if there is a nice closed form solution for these sequence functions.
Probability for finding a double-as-likely event Just a word of explanation: Part out of curiosity, part for lack of a better more theoretical method, i approached the problem in a completely empirical/inductive way. I'm aware that there is the risk
42,210
Improving accuracy of a binary classification when the target is unbalanced
The problem is more with the choice of the accuracy scoring rule. Make sure that the ultimate goal is classification as opposed to prediction. The proportion classified correctly is a discontinuous improper scoring rule. An improper scoring rule is one that is optimized by a bogus model. With an improper scoring rule such things as addition of a highly important predictor making the model less accurate can happen. The use of log likelihood (or deviance) or the Brier quadratic scoring rule will help. The concordance index C (which happens to equal the ROC area, making ROCs appear more useful than they really are) is a useful measure of predictive discrimination once the model is finalized.
Improving accuracy of a binary classification when the target is unbalanced
The problem is more with the choice of the accuracy scoring rule. Make sure that the ultimate goal is classification as opposed to prediction. The proportion classified correctly is a discontinuous
Improving accuracy of a binary classification when the target is unbalanced The problem is more with the choice of the accuracy scoring rule. Make sure that the ultimate goal is classification as opposed to prediction. The proportion classified correctly is a discontinuous improper scoring rule. An improper scoring rule is one that is optimized by a bogus model. With an improper scoring rule such things as addition of a highly important predictor making the model less accurate can happen. The use of log likelihood (or deviance) or the Brier quadratic scoring rule will help. The concordance index C (which happens to equal the ROC area, making ROCs appear more useful than they really are) is a useful measure of predictive discrimination once the model is finalized.
Improving accuracy of a binary classification when the target is unbalanced The problem is more with the choice of the accuracy scoring rule. Make sure that the ultimate goal is classification as opposed to prediction. The proportion classified correctly is a discontinuous
42,211
Improving accuracy of a binary classification when the target is unbalanced
Regarding decision trees, I would suggest the following. Assume that you have 10 training examples from class $C_1$ and 90 training examples from class $C_2$. You can use an ensemble of $N$ decision trees, where each tree is trained on 10 examples from $C_1$ and 10 randomly chosen examples from $C_2$. The decision of the ensemble may be the majority vote. You can play with different $N$ to see how it works.
Improving accuracy of a binary classification when the target is unbalanced
Regarding decision trees, I would suggest the following. Assume that you have 10 training examples from class $C_1$ and 90 training examples from class $C_2$. You can use an ensemble of $N$ decision t
Improving accuracy of a binary classification when the target is unbalanced Regarding decision trees, I would suggest the following. Assume that you have 10 training examples from class $C_1$ and 90 training examples from class $C_2$. You can use an ensemble of $N$ decision trees, where each tree is trained on 10 examples from $C_1$ and 10 randomly chosen examples from $C_2$. The decision of the ensemble may be the majority vote. You can play with different $N$ to see how it works.
Improving accuracy of a binary classification when the target is unbalanced Regarding decision trees, I would suggest the following. Assume that you have 10 training examples from class $C_1$ and 90 training examples from class $C_2$. You can use an ensemble of $N$ decision t
42,212
Improving accuracy of a binary classification when the target is unbalanced
Based on the output you shared, Maximum # of branches from a node is set at 2. It's possible that raising that limit would give you more options for branches, especially if SAS can take continuous variables and break them up into categories. It's data dredgy, but that's the game we're in, and as long as you crossvalidate you're on solid moral ground :-)
Improving accuracy of a binary classification when the target is unbalanced
Based on the output you shared, Maximum # of branches from a node is set at 2. It's possible that raising that limit would give you more options for branches, especially if SAS can take continuous va
Improving accuracy of a binary classification when the target is unbalanced Based on the output you shared, Maximum # of branches from a node is set at 2. It's possible that raising that limit would give you more options for branches, especially if SAS can take continuous variables and break them up into categories. It's data dredgy, but that's the game we're in, and as long as you crossvalidate you're on solid moral ground :-)
Improving accuracy of a binary classification when the target is unbalanced Based on the output you shared, Maximum # of branches from a node is set at 2. It's possible that raising that limit would give you more options for branches, especially if SAS can take continuous va
42,213
Improving accuracy of a binary classification when the target is unbalanced
If you are using tree-based methods, you can play around with the splitting criterion. For example, at each step, choose the split that gives the highest weighted accuracy (the average of the two classes' accuracies). This can be used as the basis for a random forest too, which should give you a good classifier. I once used a similar process to boost precision while sacrificing recall. It worked very well (better than thresholding the scores from the classification algorithm which were very noisy anyway).
Improving accuracy of a binary classification when the target is unbalanced
If you are using tree-based methods, you can play around with the splitting criterion. For example, at each step, choose the split that gives the highest weighted accuracy (the average of the two clas
Improving accuracy of a binary classification when the target is unbalanced If you are using tree-based methods, you can play around with the splitting criterion. For example, at each step, choose the split that gives the highest weighted accuracy (the average of the two classes' accuracies). This can be used as the basis for a random forest too, which should give you a good classifier. I once used a similar process to boost precision while sacrificing recall. It worked very well (better than thresholding the scores from the classification algorithm which were very noisy anyway).
Improving accuracy of a binary classification when the target is unbalanced If you are using tree-based methods, you can play around with the splitting criterion. For example, at each step, choose the split that gives the highest weighted accuracy (the average of the two clas
42,214
Effect size of Cochran's Q
I have found two measures of effect size in the literature for Cochran's $Q$ test of $b$ blocks (subjects) and $k$ treatments (groups): Serlin, Carr and Marascuillo's (2007) maximum-corrected measure of effect size ($\eta^{2}_{Q}$), which is given by: $$\eta^{2}_{Q} = \frac{Q}{b(k-1)},$$ where $0\le\eta^{2}_{Q}\le 1$. Berry, Johnston and Mielke (2007) offer a chance-corrected measure of effect size ($\mathcal{R}$), which is given by: $$\mathcal{R} = 1 - \frac{\delta}{\mu_{\delta}},$$ where: $$\delta = \left[k {b\choose 2}\right]^{-1}\sum_{i=1}^{k}\sum_{j=1}^{b-1}\sum_{l=j+1}^{b}{\left|x_{ji}-x_{li}\right|}$$ for observations $x$ in data matrix $\mathbf{X}$, $$\mu_{\delta} = \frac{2}{b\left(b-1\right)}\left[\left(\sum_{i=1}^{b}{p_{i}}\right)\left(b-\sum_{i=1}^{b}{p_{i}}\right)-\sum_{i=1}^{n}{p_{i}\left(1-p_{i}\right)}\right],$$ and $p_{i}$ is the proportions of successes across all treatments in the $i^{\text{th}}$ block. Update: From personal correspondence with Berry, the published Equation [7] contains a typographical error, and the $2/[k(k-1)]$ term in the equation for $\mu_{\delta}$ should be replaced with $2/[b(b-1)]$ as I have represented above. Berry &Co. also make a critique of $\eta^{2}_{Q}$ versus $\mathcal{R}$, writing (I substitute the symbols $b$ and $k$ for the symbols $n$ and $c$ appearing in their paper): Chance-corrected measures of effect size, such as $\mathcal{R}$, possess distinct advantages in interpretation over maximum-corrected measures of effect size, such as $\eta^{2}_{Q}$. The problem lies in the manner in which $\eta^{2}_{Q}$ is maximized. The denominator of $\eta^{2}_{Q}$, $Q_{\max}=b(k-1)$, standardizes the observed value of $Q$ for the sample size and the number of treatments. Unfortunately, $b(k-1)$ does not standardize $Q$ for the data on which $Q$ is based but rather standardizes $Q$ on another unobserved hypothetical set of data. A little farther, they sell the merits of $\mathcal{R}$ over those of $\eta^{2}_{Q}$: $\mathcal{R}$ is completely data dependent, whereas $\eta^{2}_{Q}$ relies on an unobserved, idealized data set for its maximum value. Thus, $\mathcal{R}$ can achieve an effect size of unity for the observed data, while this is usually impossible for $\eta^{2}_{Q}$. Second, $\mathcal{R}$ is a chance-corrected measure of effect size. Furthermore, $\mathcal{R}$ is zero under chance conditions, unity when agreement among the $b$ subjects is perfect, and negative under conditions of disagreement. Therefore, $\mathcal{R}$ has a clear interpretation corresponding to Cohen's coefficient of agreement (1960) and other chance-corrected measures that is familiar to most researchers. On the other hand, $\eta^{2}_{Q}$ possesses no meaningful interpretation except for values of 0 and 1. Although takes the form of a correlation ratio, it cannot be interpreted as a correlation coefficient unless the marginal frequency totals are identical I have implemented both of these effect size measures in Stata in the cochranq package, which can be accessed within Stata by typing net describe cochranq, from(https://alexisdinno.com/stata). The nonpar package for R on CRAN contains the cochrans.q program, which will give the classical *Q test, but does not offer the more recent and precise non-asymptomatic tests statistic, or effect size calculations, or adjustments for multiple comparisons. References Berry, K. J., Johnston, J. E., and Paul W. Mielke, J. (2007). An alternative measure of effect size for Cochran’s $Q$ test for related proportions. Perceptual and Motor Skills, 104:1236–1242. Serlin, R. C., Carr, J., and Marascuillo, L. A. (1982). A measure of association for selected nonparametric procedures. Psychological Bulletin, 92:786–790.
Effect size of Cochran's Q
I have found two measures of effect size in the literature for Cochran's $Q$ test of $b$ blocks (subjects) and $k$ treatments (groups): Serlin, Carr and Marascuillo's (2007) maximum-corrected measure
Effect size of Cochran's Q I have found two measures of effect size in the literature for Cochran's $Q$ test of $b$ blocks (subjects) and $k$ treatments (groups): Serlin, Carr and Marascuillo's (2007) maximum-corrected measure of effect size ($\eta^{2}_{Q}$), which is given by: $$\eta^{2}_{Q} = \frac{Q}{b(k-1)},$$ where $0\le\eta^{2}_{Q}\le 1$. Berry, Johnston and Mielke (2007) offer a chance-corrected measure of effect size ($\mathcal{R}$), which is given by: $$\mathcal{R} = 1 - \frac{\delta}{\mu_{\delta}},$$ where: $$\delta = \left[k {b\choose 2}\right]^{-1}\sum_{i=1}^{k}\sum_{j=1}^{b-1}\sum_{l=j+1}^{b}{\left|x_{ji}-x_{li}\right|}$$ for observations $x$ in data matrix $\mathbf{X}$, $$\mu_{\delta} = \frac{2}{b\left(b-1\right)}\left[\left(\sum_{i=1}^{b}{p_{i}}\right)\left(b-\sum_{i=1}^{b}{p_{i}}\right)-\sum_{i=1}^{n}{p_{i}\left(1-p_{i}\right)}\right],$$ and $p_{i}$ is the proportions of successes across all treatments in the $i^{\text{th}}$ block. Update: From personal correspondence with Berry, the published Equation [7] contains a typographical error, and the $2/[k(k-1)]$ term in the equation for $\mu_{\delta}$ should be replaced with $2/[b(b-1)]$ as I have represented above. Berry &Co. also make a critique of $\eta^{2}_{Q}$ versus $\mathcal{R}$, writing (I substitute the symbols $b$ and $k$ for the symbols $n$ and $c$ appearing in their paper): Chance-corrected measures of effect size, such as $\mathcal{R}$, possess distinct advantages in interpretation over maximum-corrected measures of effect size, such as $\eta^{2}_{Q}$. The problem lies in the manner in which $\eta^{2}_{Q}$ is maximized. The denominator of $\eta^{2}_{Q}$, $Q_{\max}=b(k-1)$, standardizes the observed value of $Q$ for the sample size and the number of treatments. Unfortunately, $b(k-1)$ does not standardize $Q$ for the data on which $Q$ is based but rather standardizes $Q$ on another unobserved hypothetical set of data. A little farther, they sell the merits of $\mathcal{R}$ over those of $\eta^{2}_{Q}$: $\mathcal{R}$ is completely data dependent, whereas $\eta^{2}_{Q}$ relies on an unobserved, idealized data set for its maximum value. Thus, $\mathcal{R}$ can achieve an effect size of unity for the observed data, while this is usually impossible for $\eta^{2}_{Q}$. Second, $\mathcal{R}$ is a chance-corrected measure of effect size. Furthermore, $\mathcal{R}$ is zero under chance conditions, unity when agreement among the $b$ subjects is perfect, and negative under conditions of disagreement. Therefore, $\mathcal{R}$ has a clear interpretation corresponding to Cohen's coefficient of agreement (1960) and other chance-corrected measures that is familiar to most researchers. On the other hand, $\eta^{2}_{Q}$ possesses no meaningful interpretation except for values of 0 and 1. Although takes the form of a correlation ratio, it cannot be interpreted as a correlation coefficient unless the marginal frequency totals are identical I have implemented both of these effect size measures in Stata in the cochranq package, which can be accessed within Stata by typing net describe cochranq, from(https://alexisdinno.com/stata). The nonpar package for R on CRAN contains the cochrans.q program, which will give the classical *Q test, but does not offer the more recent and precise non-asymptomatic tests statistic, or effect size calculations, or adjustments for multiple comparisons. References Berry, K. J., Johnston, J. E., and Paul W. Mielke, J. (2007). An alternative measure of effect size for Cochran’s $Q$ test for related proportions. Perceptual and Motor Skills, 104:1236–1242. Serlin, R. C., Carr, J., and Marascuillo, L. A. (1982). A measure of association for selected nonparametric procedures. Psychological Bulletin, 92:786–790.
Effect size of Cochran's Q I have found two measures of effect size in the literature for Cochran's $Q$ test of $b$ blocks (subjects) and $k$ treatments (groups): Serlin, Carr and Marascuillo's (2007) maximum-corrected measure
42,215
Effect size of Cochran's Q
I found this paper with Google but I cannot access it, so I don't really know what it is about really: Berry KJ, Johnston JE, Mielke PW Jr. An alternative measure of effect size for Cochran's Q test for related proportions. Percept Mot Skills. 2007 Jun;104(3 Pt 2):1236-42. I initially thought that using pairwise multiple comparisons with Cochran or McNemar test* (if the overall test is significant) would give you further indication of where the differences lie, while reporting simple difference for your binary outcome would help asserting the magnitude of the observed difference. * I found an online tutorial with R.
Effect size of Cochran's Q
I found this paper with Google but I cannot access it, so I don't really know what it is about really: Berry KJ, Johnston JE, Mielke PW Jr. An alternative measure of effect size for Cochran's Q t
Effect size of Cochran's Q I found this paper with Google but I cannot access it, so I don't really know what it is about really: Berry KJ, Johnston JE, Mielke PW Jr. An alternative measure of effect size for Cochran's Q test for related proportions. Percept Mot Skills. 2007 Jun;104(3 Pt 2):1236-42. I initially thought that using pairwise multiple comparisons with Cochran or McNemar test* (if the overall test is significant) would give you further indication of where the differences lie, while reporting simple difference for your binary outcome would help asserting the magnitude of the observed difference. * I found an online tutorial with R.
Effect size of Cochran's Q I found this paper with Google but I cannot access it, so I don't really know what it is about really: Berry KJ, Johnston JE, Mielke PW Jr. An alternative measure of effect size for Cochran's Q t
42,216
Binomial data analysis with all 0 responses for some treatment groups
The problem with zeroes, is that the data do not rule out arbitrarily small proportions. So your prior information must be assessed more carefully, because in this case it still matters. Details which are irrelevant when the prior information is "swamped" by the data can be important. In this type of problem, the population size $N$ becomes important, but a binomial assumes $N\to\infty$, which gives absurd results, if this limit is applied too soon in the calculations (as your standard errors indicates). In this case, there is relatively straight-forward approximation, you just replace $\frac{0}{25}$ with $\frac{1}{27}$, which is a Bayesian estimate based on a uniform prior for the true fraction of "positive infections". Given that you are using GLIMMIX - doing anything more sophisticated will likely wreck your SAS program. To be consistent, it may be worthwhile to replace all proportions $\frac{r}{n}$ with $\frac{r+1}{n+2}$ - however it shouldn't influence your results too much.
Binomial data analysis with all 0 responses for some treatment groups
The problem with zeroes, is that the data do not rule out arbitrarily small proportions. So your prior information must be assessed more carefully, because in this case it still matters. Details whi
Binomial data analysis with all 0 responses for some treatment groups The problem with zeroes, is that the data do not rule out arbitrarily small proportions. So your prior information must be assessed more carefully, because in this case it still matters. Details which are irrelevant when the prior information is "swamped" by the data can be important. In this type of problem, the population size $N$ becomes important, but a binomial assumes $N\to\infty$, which gives absurd results, if this limit is applied too soon in the calculations (as your standard errors indicates). In this case, there is relatively straight-forward approximation, you just replace $\frac{0}{25}$ with $\frac{1}{27}$, which is a Bayesian estimate based on a uniform prior for the true fraction of "positive infections". Given that you are using GLIMMIX - doing anything more sophisticated will likely wreck your SAS program. To be consistent, it may be worthwhile to replace all proportions $\frac{r}{n}$ with $\frac{r+1}{n+2}$ - however it shouldn't influence your results too much.
Binomial data analysis with all 0 responses for some treatment groups The problem with zeroes, is that the data do not rule out arbitrarily small proportions. So your prior information must be assessed more carefully, because in this case it still matters. Details whi
42,217
Binomial data analysis with all 0 responses for some treatment groups
I believe that this is an experiment where it is safe to assume a monotone relationship: for a longer exposition time the infection probability can not be smaller. So you can run monotone/isotonic regression. You can even incorporate into your model that the infection probability at time=0 is 0.
Binomial data analysis with all 0 responses for some treatment groups
I believe that this is an experiment where it is safe to assume a monotone relationship: for a longer exposition time the infection probability can not be smaller. So you can run monotone/isotonic reg
Binomial data analysis with all 0 responses for some treatment groups I believe that this is an experiment where it is safe to assume a monotone relationship: for a longer exposition time the infection probability can not be smaller. So you can run monotone/isotonic regression. You can even incorporate into your model that the infection probability at time=0 is 0.
Binomial data analysis with all 0 responses for some treatment groups I believe that this is an experiment where it is safe to assume a monotone relationship: for a longer exposition time the infection probability can not be smaller. So you can run monotone/isotonic reg
42,218
Binomial data analysis with all 0 responses for some treatment groups
You could try exact logistic regression with proc logistic, but then you cannot specify random effects somewhere in your model which you probably do now as you're using proc mixed. You'd have to switch to fixed effects but you could keep the binomial error distribution.
Binomial data analysis with all 0 responses for some treatment groups
You could try exact logistic regression with proc logistic, but then you cannot specify random effects somewhere in your model which you probably do now as you're using proc mixed. You'd have to switc
Binomial data analysis with all 0 responses for some treatment groups You could try exact logistic regression with proc logistic, but then you cannot specify random effects somewhere in your model which you probably do now as you're using proc mixed. You'd have to switch to fixed effects but you could keep the binomial error distribution.
Binomial data analysis with all 0 responses for some treatment groups You could try exact logistic regression with proc logistic, but then you cannot specify random effects somewhere in your model which you probably do now as you're using proc mixed. You'd have to switc
42,219
Remeasuring "bad" values
If the probability of a bad measurement is small than the probability of having two bad measurements out of three will be very small, thus neglecting the outlying one among the three will usually leave you with two valid measurements. I would, however, record all the values measured, even other measurements on the same subject/sample. On the strength of a data collection of valid and bad measurements you could study the distributions of bad and valid measurements. You might also see that bad values depend on the true value (and thus carry information) and both bad and valid values may depend on other measurements of the same subject/sample. When you possess the (conditional) distributions of bad and valid measurements, and the proportion of bad measurements then for each specific measurement you will be able to calculate the probability that it is bad (comes from an other distribution), and to calculate best estimates and established confidence intervals. I believe that your protocol (keep the two if CV is low, otherwise use the lowest CV pair of three) may be good to start with, but I would revise it after collecting enough data to know more about bad measurements. However, whether a protocol is acceptable also depends on the probability of a bad measurement, how bad a bad measurement is, and how critical is a bad best value in its application. I assume that you are talking about CV because you analysed some of your existing data and you found CV to be stable. This suggests that measurement error is proportional to the value, thus measurement error SD is constant on the logarithmic scale. If so, taking the geometric mean (not the arithmetic mean) may be more accurate.
Remeasuring "bad" values
If the probability of a bad measurement is small than the probability of having two bad measurements out of three will be very small, thus neglecting the outlying one among the three will usually leav
Remeasuring "bad" values If the probability of a bad measurement is small than the probability of having two bad measurements out of three will be very small, thus neglecting the outlying one among the three will usually leave you with two valid measurements. I would, however, record all the values measured, even other measurements on the same subject/sample. On the strength of a data collection of valid and bad measurements you could study the distributions of bad and valid measurements. You might also see that bad values depend on the true value (and thus carry information) and both bad and valid values may depend on other measurements of the same subject/sample. When you possess the (conditional) distributions of bad and valid measurements, and the proportion of bad measurements then for each specific measurement you will be able to calculate the probability that it is bad (comes from an other distribution), and to calculate best estimates and established confidence intervals. I believe that your protocol (keep the two if CV is low, otherwise use the lowest CV pair of three) may be good to start with, but I would revise it after collecting enough data to know more about bad measurements. However, whether a protocol is acceptable also depends on the probability of a bad measurement, how bad a bad measurement is, and how critical is a bad best value in its application. I assume that you are talking about CV because you analysed some of your existing data and you found CV to be stable. This suggests that measurement error is proportional to the value, thus measurement error SD is constant on the logarithmic scale. If so, taking the geometric mean (not the arithmetic mean) may be more accurate.
Remeasuring "bad" values If the probability of a bad measurement is small than the probability of having two bad measurements out of three will be very small, thus neglecting the outlying one among the three will usually leav
42,220
Is there a method to find what is a good sample size for a VAR-model?
The usual way of estimating VAR(p) model for $n$-dimensional vector $X_t=(X_{1t},...,X_{nt})$ is using OLS for each equation: \begin{align} X_{it}=\theta_{0i}+\sum_{s=1}^p\sum_{j=1}^n\theta_{sj}X_{j,t-s}+\varepsilon_{it} \end{align} So the answer is yes. For each equation you will need to estimate $np+1$ parameters, so the sample size is chosen as in usual regression with $np+1$ independent variables. Things you will need to take into account is whether additional exogenous variables are included and what type of covariance matrix for $\varepsilon_t=(\varepsilon_{t1},...,\varepsilon_{tn})$ you intend to postulate. This will increase the number of parameters to be estimated.
Is there a method to find what is a good sample size for a VAR-model?
The usual way of estimating VAR(p) model for $n$-dimensional vector $X_t=(X_{1t},...,X_{nt})$ is using OLS for each equation: \begin{align} X_{it}=\theta_{0i}+\sum_{s=1}^p\sum_{j=1}^n\theta_{sj}X_{j,t
Is there a method to find what is a good sample size for a VAR-model? The usual way of estimating VAR(p) model for $n$-dimensional vector $X_t=(X_{1t},...,X_{nt})$ is using OLS for each equation: \begin{align} X_{it}=\theta_{0i}+\sum_{s=1}^p\sum_{j=1}^n\theta_{sj}X_{j,t-s}+\varepsilon_{it} \end{align} So the answer is yes. For each equation you will need to estimate $np+1$ parameters, so the sample size is chosen as in usual regression with $np+1$ independent variables. Things you will need to take into account is whether additional exogenous variables are included and what type of covariance matrix for $\varepsilon_t=(\varepsilon_{t1},...,\varepsilon_{tn})$ you intend to postulate. This will increase the number of parameters to be estimated.
Is there a method to find what is a good sample size for a VAR-model? The usual way of estimating VAR(p) model for $n$-dimensional vector $X_t=(X_{1t},...,X_{nt})$ is using OLS for each equation: \begin{align} X_{it}=\theta_{0i}+\sum_{s=1}^p\sum_{j=1}^n\theta_{sj}X_{j,t
42,221
Limiting distribution of a squared sum of random variables
If $X_i$ and $Y_j$ are dependent for $i=j$, but independent for $i\neq j$ we have an iid sample from bivariate distribution $Z_i=(X_i,Y_i)$. Then central limit theorem gives us \begin{align} \sqrt{n}\left(\frac{1}{n}\sum_{i=1}^nZ_i -EZ_1\right)\xrightarrow{D}N(0,\Sigma) \end{align} with $\Sigma=cov(Z_1)$ and $\xrightarrow{D}$ indicating convergence in distribution. Note that $$(S_n,T_n)=\frac{1}{n}\sum_{i=1}^nZ_i.$$ Now we can use delta method, which states that if $r_n(U_n-\theta)\xrightarrow{D}U$ for numbers $r_n\to\infty$, then $r_n(\phi(U_n)-\phi(\theta))\xrightarrow{D}\phi'_\theta(U)$. This statement can be found here. Delta method is also described here. In our case now we have $r_n=\sqrt{n}$, $\phi(x,y)=x^2-y^2$, $U_n=(S_n,T_n)$ and $\theta=(EX_1,EY_1)$. We have $$\phi_{\theta}'=(2EX_1,-2EY_1)$$ and $$U=(U_1,U_2)\sim N(0,\Sigma)$$ Finally we get \begin{align} \sqrt{n}\left(S_n^2-T_n^2-(EX_1)^2+(EY_1)^2\right)\xrightarrow{D} 2U_1EX_1-2U_2EY_1:=V \end{align} Since we know that $(U_1,U_2)\sim N(0,\Sigma)$ we get that $$V\sim N(0,4(EX_1,EY_1)\Sigma(EX_1,EY_1)').$$ Note that I basically redid the example after the theorem in the link. The final answer then depends on $\Sigma=cov((X_1,Y_1))$, but this should be known to original poster.
Limiting distribution of a squared sum of random variables
If $X_i$ and $Y_j$ are dependent for $i=j$, but independent for $i\neq j$ we have an iid sample from bivariate distribution $Z_i=(X_i,Y_i)$. Then central limit theorem gives us \begin{align} \sqrt{n}
Limiting distribution of a squared sum of random variables If $X_i$ and $Y_j$ are dependent for $i=j$, but independent for $i\neq j$ we have an iid sample from bivariate distribution $Z_i=(X_i,Y_i)$. Then central limit theorem gives us \begin{align} \sqrt{n}\left(\frac{1}{n}\sum_{i=1}^nZ_i -EZ_1\right)\xrightarrow{D}N(0,\Sigma) \end{align} with $\Sigma=cov(Z_1)$ and $\xrightarrow{D}$ indicating convergence in distribution. Note that $$(S_n,T_n)=\frac{1}{n}\sum_{i=1}^nZ_i.$$ Now we can use delta method, which states that if $r_n(U_n-\theta)\xrightarrow{D}U$ for numbers $r_n\to\infty$, then $r_n(\phi(U_n)-\phi(\theta))\xrightarrow{D}\phi'_\theta(U)$. This statement can be found here. Delta method is also described here. In our case now we have $r_n=\sqrt{n}$, $\phi(x,y)=x^2-y^2$, $U_n=(S_n,T_n)$ and $\theta=(EX_1,EY_1)$. We have $$\phi_{\theta}'=(2EX_1,-2EY_1)$$ and $$U=(U_1,U_2)\sim N(0,\Sigma)$$ Finally we get \begin{align} \sqrt{n}\left(S_n^2-T_n^2-(EX_1)^2+(EY_1)^2\right)\xrightarrow{D} 2U_1EX_1-2U_2EY_1:=V \end{align} Since we know that $(U_1,U_2)\sim N(0,\Sigma)$ we get that $$V\sim N(0,4(EX_1,EY_1)\Sigma(EX_1,EY_1)').$$ Note that I basically redid the example after the theorem in the link. The final answer then depends on $\Sigma=cov((X_1,Y_1))$, but this should be known to original poster.
Limiting distribution of a squared sum of random variables If $X_i$ and $Y_j$ are dependent for $i=j$, but independent for $i\neq j$ we have an iid sample from bivariate distribution $Z_i=(X_i,Y_i)$. Then central limit theorem gives us \begin{align} \sqrt{n}
42,222
How can I make a continuous distribution out of simulation results in R?
It sounds like what you're describing is a bootstrap simulation in order to estimate the distribution of a statistic (the relative frequencies). The package I'd suggest you to look into is the boot package: functions and datasets for bootstrapping from the book "Bootstrap Methods and Their Applications" by A. C. Davison and D. V. Hinkley (1997, CUP). It should hold many functions needed for what (it seems to me) that you are trying to do. Here are some tutorials on the boot package. Best, Tal
How can I make a continuous distribution out of simulation results in R?
It sounds like what you're describing is a bootstrap simulation in order to estimate the distribution of a statistic (the relative frequencies). The package I'd suggest you to look into is the boot pa
How can I make a continuous distribution out of simulation results in R? It sounds like what you're describing is a bootstrap simulation in order to estimate the distribution of a statistic (the relative frequencies). The package I'd suggest you to look into is the boot package: functions and datasets for bootstrapping from the book "Bootstrap Methods and Their Applications" by A. C. Davison and D. V. Hinkley (1997, CUP). It should hold many functions needed for what (it seems to me) that you are trying to do. Here are some tutorials on the boot package. Best, Tal
How can I make a continuous distribution out of simulation results in R? It sounds like what you're describing is a bootstrap simulation in order to estimate the distribution of a statistic (the relative frequencies). The package I'd suggest you to look into is the boot pa
42,223
How can I make a continuous distribution out of simulation results in R?
Sounds like you want something like a Kernel Density Estimate of the distribution. In R I think you want density function.
How can I make a continuous distribution out of simulation results in R?
Sounds like you want something like a Kernel Density Estimate of the distribution. In R I think you want density function.
How can I make a continuous distribution out of simulation results in R? Sounds like you want something like a Kernel Density Estimate of the distribution. In R I think you want density function.
How can I make a continuous distribution out of simulation results in R? Sounds like you want something like a Kernel Density Estimate of the distribution. In R I think you want density function.
42,224
What options are there to combine different distance functions?
I can think of three: Combine them in a linear manner ($d=d_1+\alpha d_2$) and find best $\alpha$ by some optimization, let's say minimizing CV error for kNN or minimizing silhouette for clustering. Train separate classifiers / cluster the data few times based on both distances and then blend the results. This may not work too well because you have only 2 base methods. For classification only, you may use "klNN" -- get $k$ neighbors based on first metric and $l$ based on the second.
What options are there to combine different distance functions?
I can think of three: Combine them in a linear manner ($d=d_1+\alpha d_2$) and find best $\alpha$ by some optimization, let's say minimizing CV error for kNN or minimizing silhouette for clustering.
What options are there to combine different distance functions? I can think of three: Combine them in a linear manner ($d=d_1+\alpha d_2$) and find best $\alpha$ by some optimization, let's say minimizing CV error for kNN or minimizing silhouette for clustering. Train separate classifiers / cluster the data few times based on both distances and then blend the results. This may not work too well because you have only 2 base methods. For classification only, you may use "klNN" -- get $k$ neighbors based on first metric and $l$ based on the second.
What options are there to combine different distance functions? I can think of three: Combine them in a linear manner ($d=d_1+\alpha d_2$) and find best $\alpha$ by some optimization, let's say minimizing CV error for kNN or minimizing silhouette for clustering.
42,225
Assessing linearity in a mixed effects model
Not really an answer, but I was interested in trying it out... I assume that the pattern is not easily recognisable just by plotting? So I tried to make up some data that might behave this way: set.seed(69) id<- rep(1:20, each=6) x<-rep(1:6, 20) y<-jitter(x+id/5, factor=5) + jitter(sin(x), factor=5) df1<-data.frame(id, x, y) plot(y~x) xyplot(y~x|id, data=df1, type="l") For me, if I had this data without knowing how it was made, I think I would have trouble picking out the overlaid signal and perhaps assume it was linear. Resid vs fitted of lmer1 (below) doesn't show much, but the resid vs x is more suggestive. lmer1<-lmer(y~x+(1|id), data=df1, REML=F) xyplot(resid(lmer1)~fitted(lmer1), type=c("p", "smooth")) xyplot(resid(lmer1)~x, type=c("p", "smooth")) Using your suggestion of conducting an ANOVA on the residuals gives a significant effect, indicating perhaps some kind of systematic difference: lmer2<-lmer(resid(lmer1)~factor(x)+(1|id), data=df1, REML=F) #sd attributed to id is 0 anova(lmer2) So perhaps this method may be useful to determine whether you need to include higher order terms by using, maybe, increasing order polynomials: lmer3.1 <- lmer(y~poly(x,2)+(1|id), data=df1, REML=F) lmer3.2 <- lmer(y~poly(x,3)+(1|id), data=df1, REML=F) lmer3.3 <- lmer(y~poly(x,4)+(1|id), data=df1, REML=F) anova(lmer1, lmer3.1, lmer3.2, lmer3.3) In this method the cubic function 'wins' and might be a useful approximation of what's going on and comes quite close to the generated model: lmer4<-lmer(y~x+sin(x)+(1|id), data=df1) anova(lmer3.2, lmer4) I don't really know if this helps or not, but hopefully this simulated data mirrors your problem and somebody can use this to give a more exact answer to your question. I'm not sure about the binomial part of your question.
Assessing linearity in a mixed effects model
Not really an answer, but I was interested in trying it out... I assume that the pattern is not easily recognisable just by plotting? So I tried to make up some data that might behave this way: set.se
Assessing linearity in a mixed effects model Not really an answer, but I was interested in trying it out... I assume that the pattern is not easily recognisable just by plotting? So I tried to make up some data that might behave this way: set.seed(69) id<- rep(1:20, each=6) x<-rep(1:6, 20) y<-jitter(x+id/5, factor=5) + jitter(sin(x), factor=5) df1<-data.frame(id, x, y) plot(y~x) xyplot(y~x|id, data=df1, type="l") For me, if I had this data without knowing how it was made, I think I would have trouble picking out the overlaid signal and perhaps assume it was linear. Resid vs fitted of lmer1 (below) doesn't show much, but the resid vs x is more suggestive. lmer1<-lmer(y~x+(1|id), data=df1, REML=F) xyplot(resid(lmer1)~fitted(lmer1), type=c("p", "smooth")) xyplot(resid(lmer1)~x, type=c("p", "smooth")) Using your suggestion of conducting an ANOVA on the residuals gives a significant effect, indicating perhaps some kind of systematic difference: lmer2<-lmer(resid(lmer1)~factor(x)+(1|id), data=df1, REML=F) #sd attributed to id is 0 anova(lmer2) So perhaps this method may be useful to determine whether you need to include higher order terms by using, maybe, increasing order polynomials: lmer3.1 <- lmer(y~poly(x,2)+(1|id), data=df1, REML=F) lmer3.2 <- lmer(y~poly(x,3)+(1|id), data=df1, REML=F) lmer3.3 <- lmer(y~poly(x,4)+(1|id), data=df1, REML=F) anova(lmer1, lmer3.1, lmer3.2, lmer3.3) In this method the cubic function 'wins' and might be a useful approximation of what's going on and comes quite close to the generated model: lmer4<-lmer(y~x+sin(x)+(1|id), data=df1) anova(lmer3.2, lmer4) I don't really know if this helps or not, but hopefully this simulated data mirrors your problem and somebody can use this to give a more exact answer to your question. I'm not sure about the binomial part of your question.
Assessing linearity in a mixed effects model Not really an answer, but I was interested in trying it out... I assume that the pattern is not easily recognisable just by plotting? So I tried to make up some data that might behave this way: set.se
42,226
A measure to describe the distribution of a dendrogram
See this SO question: https://stackoverflow.com/questions/2218395/how-do-you-compare-the-similarity-between-two-dendrograms-in-r
A measure to describe the distribution of a dendrogram
See this SO question: https://stackoverflow.com/questions/2218395/how-do-you-compare-the-similarity-between-two-dendrograms-in-r
A measure to describe the distribution of a dendrogram See this SO question: https://stackoverflow.com/questions/2218395/how-do-you-compare-the-similarity-between-two-dendrograms-in-r
A measure to describe the distribution of a dendrogram See this SO question: https://stackoverflow.com/questions/2218395/how-do-you-compare-the-similarity-between-two-dendrograms-in-r
42,227
Model suggestion
Not easy at all. This starts to sound like the sort of thing that Jamie Robins and colleagues have done a lot of work on. To quote the start of the abstract of one of their papers: "In observational studies with exposures or treatments that vary over time, standard approaches for adjustment of confounding are biased when there exist time-dependent confounders that are also affected by previous treatment." (Robins JM, Hernán MA, Brumback B. Marginal Structural Models and Causal Inference in Epidemiology. Epidemiology 2000;11:550-560. http://www.jstor.org/stable/3703997) In their example, low CD4 count means you're more likely to get anti-HIV drugs, which (hopefully) increase your CD4 count. Sounds very much like your setting. There's been a lot of work in this area recently (i.e. more recently than that paper), and it's not easy to get to grips with from the journal papers. Hernán & Robins are writing a book, which should help a lot -- it's not finished yet, but there's a draft of the first 10 chapters available.
Model suggestion
Not easy at all. This starts to sound like the sort of thing that Jamie Robins and colleagues have done a lot of work on. To quote the start of the abstract of one of their papers: "In observational s
Model suggestion Not easy at all. This starts to sound like the sort of thing that Jamie Robins and colleagues have done a lot of work on. To quote the start of the abstract of one of their papers: "In observational studies with exposures or treatments that vary over time, standard approaches for adjustment of confounding are biased when there exist time-dependent confounders that are also affected by previous treatment." (Robins JM, Hernán MA, Brumback B. Marginal Structural Models and Causal Inference in Epidemiology. Epidemiology 2000;11:550-560. http://www.jstor.org/stable/3703997) In their example, low CD4 count means you're more likely to get anti-HIV drugs, which (hopefully) increase your CD4 count. Sounds very much like your setting. There's been a lot of work in this area recently (i.e. more recently than that paper), and it's not easy to get to grips with from the journal papers. Hernán & Robins are writing a book, which should help a lot -- it's not finished yet, but there's a draft of the first 10 chapters available.
Model suggestion Not easy at all. This starts to sound like the sort of thing that Jamie Robins and colleagues have done a lot of work on. To quote the start of the abstract of one of their papers: "In observational s
42,228
Model suggestion
You have clearly stated a part of your model: C depends on B, in that values of B above a threshold will change C. The change in C will furthermore reduce B in the next measurement. By "next measurement" I understand you mean next in time. Let's index time as $t = 0, 1, 2, \ldots$. Then the dependence of C on B sounds like a contemporaneous one. If we adopt a simple linear model (which can readily be expanded to incorporate covariates and variable but predetermined thresholds) and let $u$ be a constant threshold, $$C(t) = \beta_1 I_{B(t) \gt u} + \epsilon$$ with random deviations $\epsilon$ (which I won't bother to index; you know the drill). Here, $I$ is the indicator function. Also, $$B(t+1) = B(t) - \beta_2 (C(t) - C(t-1)) + \delta$$ and again $\delta$ represents random (independent) deviations. I'm stuck here because you haven't specified more precisely just how B changes in response to a change in C; I have merely provided one possible interpretation. Finally, $$A(t) = \beta_3 B(t) + \beta_4 C(t) + \beta_5 + \gamma$$ with independent random deviations $\gamma$. The presence of that indicator function in the first formula is problematic: it makes this a nonlinear problem. However, this seems to be an essential feature of the situation; I would be loth to ignore it in the name of simplicity or ease of calculation (although both are important considerations). The lags $B(t+1) - B(t)$ and $C(t) - C(t-1)$ also point towards autoregressive models, another complication. Because of these issues, the most tractable approach might be with Bayesian techniques: parameterize the distributions of $\epsilon$, $\delta$, and $\gamma$, provide priors for those parameters and the $\beta$s, and let the machinery (e.g., WinBUGS or RBUGS) roll.
Model suggestion
You have clearly stated a part of your model: C depends on B, in that values of B above a threshold will change C. The change in C will furthermore reduce B in the next measurement. By "next measure
Model suggestion You have clearly stated a part of your model: C depends on B, in that values of B above a threshold will change C. The change in C will furthermore reduce B in the next measurement. By "next measurement" I understand you mean next in time. Let's index time as $t = 0, 1, 2, \ldots$. Then the dependence of C on B sounds like a contemporaneous one. If we adopt a simple linear model (which can readily be expanded to incorporate covariates and variable but predetermined thresholds) and let $u$ be a constant threshold, $$C(t) = \beta_1 I_{B(t) \gt u} + \epsilon$$ with random deviations $\epsilon$ (which I won't bother to index; you know the drill). Here, $I$ is the indicator function. Also, $$B(t+1) = B(t) - \beta_2 (C(t) - C(t-1)) + \delta$$ and again $\delta$ represents random (independent) deviations. I'm stuck here because you haven't specified more precisely just how B changes in response to a change in C; I have merely provided one possible interpretation. Finally, $$A(t) = \beta_3 B(t) + \beta_4 C(t) + \beta_5 + \gamma$$ with independent random deviations $\gamma$. The presence of that indicator function in the first formula is problematic: it makes this a nonlinear problem. However, this seems to be an essential feature of the situation; I would be loth to ignore it in the name of simplicity or ease of calculation (although both are important considerations). The lags $B(t+1) - B(t)$ and $C(t) - C(t-1)$ also point towards autoregressive models, another complication. Because of these issues, the most tractable approach might be with Bayesian techniques: parameterize the distributions of $\epsilon$, $\delta$, and $\gamma$, provide priors for those parameters and the $\beta$s, and let the machinery (e.g., WinBUGS or RBUGS) roll.
Model suggestion You have clearly stated a part of your model: C depends on B, in that values of B above a threshold will change C. The change in C will furthermore reduce B in the next measurement. By "next measure
42,229
Model suggestion
Your problem is one of multi-collinear regressors (since B and C are correlated). I would suggest that you look at the answers to the question: Dealing with correlated regressors. The following paper may also be relevant in your context: Using principal components for estimating logistic regression with high-dimensional multicollinear data
Model suggestion
Your problem is one of multi-collinear regressors (since B and C are correlated). I would suggest that you look at the answers to the question: Dealing with correlated regressors. The following paper
Model suggestion Your problem is one of multi-collinear regressors (since B and C are correlated). I would suggest that you look at the answers to the question: Dealing with correlated regressors. The following paper may also be relevant in your context: Using principal components for estimating logistic regression with high-dimensional multicollinear data
Model suggestion Your problem is one of multi-collinear regressors (since B and C are correlated). I would suggest that you look at the answers to the question: Dealing with correlated regressors. The following paper
42,230
Bootstrapped regression with total data or bootstrap with matched data?
There is a wrinkle that you need to worry about. In the case of matching, you are throwing away observations (i.e., those that aren't matched and don't make it into your analysis) and some might be replicated. These decisions aren't random; they are a function of covariates. As a result, creating confidence intervals in this context are a bit complicated. To calculate the appropriate standard errors, see Large Sample Properties of (Matching Estimators for Average Treatment Effects by Abadie and Imbens. Additionally, Abadie also has a paper on On the Failure of the Bootstrap for Matching Estimators. To implement Abadie-Imbens standard errors, see the Matching package in R by Jas Sekhon. On the question of which estimator to believe, it depends on how well you think that matching is correctly controlling for confounders, I'd be inclined to believe that approach. It seems that your first set of analyses doesn't control for those factors in any way? If you think that they are important, then you probably wouldn't be inclined to believe those results.
Bootstrapped regression with total data or bootstrap with matched data?
There is a wrinkle that you need to worry about. In the case of matching, you are throwing away observations (i.e., those that aren't matched and don't make it into your analysis) and some might be re
Bootstrapped regression with total data or bootstrap with matched data? There is a wrinkle that you need to worry about. In the case of matching, you are throwing away observations (i.e., those that aren't matched and don't make it into your analysis) and some might be replicated. These decisions aren't random; they are a function of covariates. As a result, creating confidence intervals in this context are a bit complicated. To calculate the appropriate standard errors, see Large Sample Properties of (Matching Estimators for Average Treatment Effects by Abadie and Imbens. Additionally, Abadie also has a paper on On the Failure of the Bootstrap for Matching Estimators. To implement Abadie-Imbens standard errors, see the Matching package in R by Jas Sekhon. On the question of which estimator to believe, it depends on how well you think that matching is correctly controlling for confounders, I'd be inclined to believe that approach. It seems that your first set of analyses doesn't control for those factors in any way? If you think that they are important, then you probably wouldn't be inclined to believe those results.
Bootstrapped regression with total data or bootstrap with matched data? There is a wrinkle that you need to worry about. In the case of matching, you are throwing away observations (i.e., those that aren't matched and don't make it into your analysis) and some might be re
42,231
How can I work around "lumpiness" in simulated maximum likelihood estimation?
It sounds like you need to use a more robust optimization algorithm that can handle local minima. Particle swarm methods work quite well in this case. Or you could try other evolutionary optimization methods or simulated annealing.
How can I work around "lumpiness" in simulated maximum likelihood estimation?
It sounds like you need to use a more robust optimization algorithm that can handle local minima. Particle swarm methods work quite well in this case. Or you could try other evolutionary optimization
How can I work around "lumpiness" in simulated maximum likelihood estimation? It sounds like you need to use a more robust optimization algorithm that can handle local minima. Particle swarm methods work quite well in this case. Or you could try other evolutionary optimization methods or simulated annealing.
How can I work around "lumpiness" in simulated maximum likelihood estimation? It sounds like you need to use a more robust optimization algorithm that can handle local minima. Particle swarm methods work quite well in this case. Or you could try other evolutionary optimization
42,232
How can I work around "lumpiness" in simulated maximum likelihood estimation?
Your likelihood function is non-concave (i.e. the Hessian matrix of your likelihood function is not SDN). From this it follows that You will only find a local maximae to your likelihood function (no garantuee of global optimality) This maxima will always depend on your choice of starting point. Your maximization procedure will always be an iterative one. Without directly solving the issues aboves, one way to handle them would be thru Monte carlo optimization (a review is here) which is basically a recasting of Rob's suggestion inside the frame of statistics.
How can I work around "lumpiness" in simulated maximum likelihood estimation?
Your likelihood function is non-concave (i.e. the Hessian matrix of your likelihood function is not SDN). From this it follows that You will only find a local maximae to your likelihood function (no
How can I work around "lumpiness" in simulated maximum likelihood estimation? Your likelihood function is non-concave (i.e. the Hessian matrix of your likelihood function is not SDN). From this it follows that You will only find a local maximae to your likelihood function (no garantuee of global optimality) This maxima will always depend on your choice of starting point. Your maximization procedure will always be an iterative one. Without directly solving the issues aboves, one way to handle them would be thru Monte carlo optimization (a review is here) which is basically a recasting of Rob's suggestion inside the frame of statistics.
How can I work around "lumpiness" in simulated maximum likelihood estimation? Your likelihood function is non-concave (i.e. the Hessian matrix of your likelihood function is not SDN). From this it follows that You will only find a local maximae to your likelihood function (no
42,233
How can I work around "lumpiness" in simulated maximum likelihood estimation?
You could avoid the problem altogether by simply estimating W = alphaH * H + alphaM * M + alphaL * L + X * beta using 2sls. The fact that H,M, and L are discrete doesn't violate any of the assumptions of 2sls. Of course, using maximum likelihood will produce more efficient estimates, but it relies on more assumptions. If nothing else, the 2sls estimates should provide good starting values for you maximization algorithm. For maximizing the likelihood,you should try changing your simulation method to make the likelihood function smooth. I think a slight variant of the Geweke-Hajivassiliou-Keane (often just GHK) simulator would work.
How can I work around "lumpiness" in simulated maximum likelihood estimation?
You could avoid the problem altogether by simply estimating W = alphaH * H + alphaM * M + alphaL * L + X * beta using 2sls. The fact that H,M, and L are discrete doesn't violate any of the assumptions
How can I work around "lumpiness" in simulated maximum likelihood estimation? You could avoid the problem altogether by simply estimating W = alphaH * H + alphaM * M + alphaL * L + X * beta using 2sls. The fact that H,M, and L are discrete doesn't violate any of the assumptions of 2sls. Of course, using maximum likelihood will produce more efficient estimates, but it relies on more assumptions. If nothing else, the 2sls estimates should provide good starting values for you maximization algorithm. For maximizing the likelihood,you should try changing your simulation method to make the likelihood function smooth. I think a slight variant of the Geweke-Hajivassiliou-Keane (often just GHK) simulator would work.
How can I work around "lumpiness" in simulated maximum likelihood estimation? You could avoid the problem altogether by simply estimating W = alphaH * H + alphaM * M + alphaL * L + X * beta using 2sls. The fact that H,M, and L are discrete doesn't violate any of the assumptions
42,234
Using bootstrap for glm coefficients variance estimation (in R)
Have you thought about using simulate in the arm package? Gelman & Hill have some nice chapters on this in their book.
Using bootstrap for glm coefficients variance estimation (in R)
Have you thought about using simulate in the arm package? Gelman & Hill have some nice chapters on this in their book.
Using bootstrap for glm coefficients variance estimation (in R) Have you thought about using simulate in the arm package? Gelman & Hill have some nice chapters on this in their book.
Using bootstrap for glm coefficients variance estimation (in R) Have you thought about using simulate in the arm package? Gelman & Hill have some nice chapters on this in their book.
42,235
Using bootstrap for glm coefficients variance estimation (in R)
Yes, you are right. What boot does is that it just generates new training sets by drawing with replacement from the original set. So about 2/3 of the original objects are present in each of the new sets, still the size is the same, so it does not influence model building.
Using bootstrap for glm coefficients variance estimation (in R)
Yes, you are right. What boot does is that it just generates new training sets by drawing with replacement from the original set. So about 2/3 of the original objects are present in each of the new se
Using bootstrap for glm coefficients variance estimation (in R) Yes, you are right. What boot does is that it just generates new training sets by drawing with replacement from the original set. So about 2/3 of the original objects are present in each of the new sets, still the size is the same, so it does not influence model building.
Using bootstrap for glm coefficients variance estimation (in R) Yes, you are right. What boot does is that it just generates new training sets by drawing with replacement from the original set. So about 2/3 of the original objects are present in each of the new se
42,236
Appropriate link function for 2AFC data?
It doesn't just seem like it will have consequences, it will have large consequences. Fit that second function to the data you put in your last question on this. It goes dramatically negative as it approaches 0.5. Perhaps more importantly, you also need to consider what the different equations mean for how one interprets the functioning of the mind. There is no known function that is just best for all 2AFC*. Such a function would be tantamount to proving a universal law of the operations of the mind. You have to model your data if you want the very best fit. *OK, some models like splines will just fit most anything but you'd have to justify why you have all the extra parameters theoretically. (ASIDE: you were opposed to clipping when difficulty achieved maximum (or minimum). Consider, if you were modelling a robotic arm at the maximum point of travel you would just clip the results at the maximum point of travel (something your first equation does). Just because you didn't know what that point was before you found it doesn't mean anything. You found it when performance reached chance.)
Appropriate link function for 2AFC data?
It doesn't just seem like it will have consequences, it will have large consequences. Fit that second function to the data you put in your last question on this. It goes dramatically negative as it
Appropriate link function for 2AFC data? It doesn't just seem like it will have consequences, it will have large consequences. Fit that second function to the data you put in your last question on this. It goes dramatically negative as it approaches 0.5. Perhaps more importantly, you also need to consider what the different equations mean for how one interprets the functioning of the mind. There is no known function that is just best for all 2AFC*. Such a function would be tantamount to proving a universal law of the operations of the mind. You have to model your data if you want the very best fit. *OK, some models like splines will just fit most anything but you'd have to justify why you have all the extra parameters theoretically. (ASIDE: you were opposed to clipping when difficulty achieved maximum (or minimum). Consider, if you were modelling a robotic arm at the maximum point of travel you would just clip the results at the maximum point of travel (something your first equation does). Just because you didn't know what that point was before you found it doesn't mean anything. You found it when performance reached chance.)
Appropriate link function for 2AFC data? It doesn't just seem like it will have consequences, it will have large consequences. Fit that second function to the data you put in your last question on this. It goes dramatically negative as it
42,237
Donut-like Distribution in Cartesian Coordinates
Converting a 2D density $f_{r,\theta}$ from polar coordinates $(r,\theta)$ to Cartesian coordinates $(x,y)$ where $r(x,y)^2 = x^2+y^2$ and $\tan{\theta(x,y)}=y/x$ turns out to be simple, because the reference (Lebesgue) measure merely changes from $r\,\mathrm dr\,\mathrm d\theta$ to $\mathrm dx\,\mathrm dy.$ Therefore the probability element can be re-expressed as $$f_{r,\theta}(r,\theta)\mathrm dr\,\mathrm d\theta = \frac{f_{r,\theta}(r,\theta)}{r} r\,\mathrm dr\,\mathrm d\theta = \frac{f_{r,\theta}(r(x,y),\theta(x,y))}{r(x,y)}\mathrm dx\,\mathrm dy.\tag{*}$$ This formula says to Divide the density by $r$ and then Express $r$ and $\theta$ in Cartesian coordinates. The function f below implements this formula for general radial densities $f_{r,\theta}.$ In the question the density is the product of the chi-squared$(k)$ density for $r$ and the Uniform$(0,2\pi)$ density for $\theta,$ giving $$f_{r,\theta}(r,\theta) = \frac{1}{2^{k/2}\Gamma(k/2)} r^{k-1}e^{-r/2}\times\frac{1}{2\pi}$$ and plugging that into $(*)$ produces $$f_{x,y}(x,y) = \frac{1}{\pi\,2^{k/2+1}\,\Gamma(k/2)} r^{k-2}e^{-r/2} = \frac{ \left(x^2+y^2\right)^{k/2-1}e^{-\sqrt{x^2+y^2}/2}}{\pi\,2^{k/2+1}\,\Gamma(k/2)}.$$ As an example (with $k=20$), I used R to generate 100,000 values of $(r,\theta),$ converted those to $(x,y),$ and computed a kernel density estimate. library(MASS) # Generate (r, theta). k <- 20 n <- 1e5 r <- rchisq(n, k) theta <- runif(n, 0, 2*pi) # Convert to (x, y). x <- r * cos(theta) y <- r * sin(theta) # Compute and plot a density (omitting some outliers). q <- qchisq(sqrt(0.99), k) den <- kde2d(x, y, lims = q * c(-1, 1, -1, 1), n = 50) image(den, asp = 1, bty = "n") Here's an image showing your "hole:" This R function performs steps (1) and (2) with an arbitrary density function df for the radial density (and a uniform density for the angle): f <- function(x, y, df, ...) { r <- outer(x, y, \(x,y) sqrt(x^2 + y^2)) # Step 2: r(x,y) df(r, ...) / r * 1 / (2 * pi) # Step 1: Formula (*) } Its inputs are vectors x and y. Its output is a matrix of densities at all ordered pairs from x and y. Using this function, let's compare the empirical density (shown in the image) to the calculated density using $(*)$ (implemented as dc): z.hat <- with(den, f(x, y, dc, k = k)) A <- with(den, mean(diff(x)) * mean(diff(y))) with(den, plot(sqrt(z.hat), sqrt(z), col = gray(0, .25), ylab = "Root Empirical Density", xlab = "Root Calculated Density")) abline(0:1, col = "Red", lwd = 2) The agreement is excellent. (I use root scales to achieve a heteroscedastic response, making the variation around the 1:1 reference line the same at all locations.)
Donut-like Distribution in Cartesian Coordinates
Converting a 2D density $f_{r,\theta}$ from polar coordinates $(r,\theta)$ to Cartesian coordinates $(x,y)$ where $r(x,y)^2 = x^2+y^2$ and $\tan{\theta(x,y)}=y/x$ turns out to be simple, because the r
Donut-like Distribution in Cartesian Coordinates Converting a 2D density $f_{r,\theta}$ from polar coordinates $(r,\theta)$ to Cartesian coordinates $(x,y)$ where $r(x,y)^2 = x^2+y^2$ and $\tan{\theta(x,y)}=y/x$ turns out to be simple, because the reference (Lebesgue) measure merely changes from $r\,\mathrm dr\,\mathrm d\theta$ to $\mathrm dx\,\mathrm dy.$ Therefore the probability element can be re-expressed as $$f_{r,\theta}(r,\theta)\mathrm dr\,\mathrm d\theta = \frac{f_{r,\theta}(r,\theta)}{r} r\,\mathrm dr\,\mathrm d\theta = \frac{f_{r,\theta}(r(x,y),\theta(x,y))}{r(x,y)}\mathrm dx\,\mathrm dy.\tag{*}$$ This formula says to Divide the density by $r$ and then Express $r$ and $\theta$ in Cartesian coordinates. The function f below implements this formula for general radial densities $f_{r,\theta}.$ In the question the density is the product of the chi-squared$(k)$ density for $r$ and the Uniform$(0,2\pi)$ density for $\theta,$ giving $$f_{r,\theta}(r,\theta) = \frac{1}{2^{k/2}\Gamma(k/2)} r^{k-1}e^{-r/2}\times\frac{1}{2\pi}$$ and plugging that into $(*)$ produces $$f_{x,y}(x,y) = \frac{1}{\pi\,2^{k/2+1}\,\Gamma(k/2)} r^{k-2}e^{-r/2} = \frac{ \left(x^2+y^2\right)^{k/2-1}e^{-\sqrt{x^2+y^2}/2}}{\pi\,2^{k/2+1}\,\Gamma(k/2)}.$$ As an example (with $k=20$), I used R to generate 100,000 values of $(r,\theta),$ converted those to $(x,y),$ and computed a kernel density estimate. library(MASS) # Generate (r, theta). k <- 20 n <- 1e5 r <- rchisq(n, k) theta <- runif(n, 0, 2*pi) # Convert to (x, y). x <- r * cos(theta) y <- r * sin(theta) # Compute and plot a density (omitting some outliers). q <- qchisq(sqrt(0.99), k) den <- kde2d(x, y, lims = q * c(-1, 1, -1, 1), n = 50) image(den, asp = 1, bty = "n") Here's an image showing your "hole:" This R function performs steps (1) and (2) with an arbitrary density function df for the radial density (and a uniform density for the angle): f <- function(x, y, df, ...) { r <- outer(x, y, \(x,y) sqrt(x^2 + y^2)) # Step 2: r(x,y) df(r, ...) / r * 1 / (2 * pi) # Step 1: Formula (*) } Its inputs are vectors x and y. Its output is a matrix of densities at all ordered pairs from x and y. Using this function, let's compare the empirical density (shown in the image) to the calculated density using $(*)$ (implemented as dc): z.hat <- with(den, f(x, y, dc, k = k)) A <- with(den, mean(diff(x)) * mean(diff(y))) with(den, plot(sqrt(z.hat), sqrt(z), col = gray(0, .25), ylab = "Root Empirical Density", xlab = "Root Calculated Density")) abline(0:1, col = "Red", lwd = 2) The agreement is excellent. (I use root scales to achieve a heteroscedastic response, making the variation around the 1:1 reference line the same at all locations.)
Donut-like Distribution in Cartesian Coordinates Converting a 2D density $f_{r,\theta}$ from polar coordinates $(r,\theta)$ to Cartesian coordinates $(x,y)$ where $r(x,y)^2 = x^2+y^2$ and $\tan{\theta(x,y)}=y/x$ turns out to be simple, because the r
42,238
Flipping an unfair coin until there are more heads
Consolidation of my comments: You stop the first time you have one more Heads than Tails, so you are correct that the probability you stop after an even number of flips is $0$. So let's consider the probability of stopping after $2k+1$ flips. After $2k$ flips you want the same number of Heads and Tails, without ever having had more Heads than Tails, and then finally have an extra Heads. The number of ways of doing this is the number of Dyck words, the Catalan number $\frac{1}{k+1} \binom{2k}k$. If the probability of Heads is $p$ and Tails is $1-p$, since you need $k+1$ Heads and $k$ Tails, the probability of this is $$\mathbb P(X=2k+1)= \frac1{k+1}{2k \choose k}p^{k+1}(1-p)^k$$ If $p \ge \frac12$ then the probability of ever stopping is $\sum\limits_{k=0}^\infty\frac1{k+1}{2k \choose k}p^{k+1}(1-p)^k = 1$, so the expected number of flips need to finish is $$\mathbb E[X]=\sum\limits_{k=0}^\infty\frac{2k+1}{k+1}{2k \choose k}p^{k+1}(1-p)^k = \frac{1}{2p-1}$$ With $p=\frac35$ this gives $\mathbb E[X]=5$, as suggested by the simulations. With $p=\frac12$ this gives $\mathbb E[X]=+\infty$, so you almost surely finish in finite time but with an infinite expected time. With $p<\frac12$ then the probability of ever stopping is $\frac p{1-p} <1$ and the probability of never stopping is $\frac{1-2p}{1-p}>0$, so there is no expectation. Curiously, if you condition on stopping in finite time, the conditional expectation is $\mathbb E[X \mid X < \infty]=\frac{1}{|2p-1|}$, similar to the result when $p > \frac12$. For example with $p=\frac25$, the probability of ever stopping is $\frac23$ and the expectation of the number of flips conditioned on stopping is again $5$.
Flipping an unfair coin until there are more heads
Consolidation of my comments: You stop the first time you have one more Heads than Tails, so you are correct that the probability you stop after an even number of flips is $0$. So let's consider the
Flipping an unfair coin until there are more heads Consolidation of my comments: You stop the first time you have one more Heads than Tails, so you are correct that the probability you stop after an even number of flips is $0$. So let's consider the probability of stopping after $2k+1$ flips. After $2k$ flips you want the same number of Heads and Tails, without ever having had more Heads than Tails, and then finally have an extra Heads. The number of ways of doing this is the number of Dyck words, the Catalan number $\frac{1}{k+1} \binom{2k}k$. If the probability of Heads is $p$ and Tails is $1-p$, since you need $k+1$ Heads and $k$ Tails, the probability of this is $$\mathbb P(X=2k+1)= \frac1{k+1}{2k \choose k}p^{k+1}(1-p)^k$$ If $p \ge \frac12$ then the probability of ever stopping is $\sum\limits_{k=0}^\infty\frac1{k+1}{2k \choose k}p^{k+1}(1-p)^k = 1$, so the expected number of flips need to finish is $$\mathbb E[X]=\sum\limits_{k=0}^\infty\frac{2k+1}{k+1}{2k \choose k}p^{k+1}(1-p)^k = \frac{1}{2p-1}$$ With $p=\frac35$ this gives $\mathbb E[X]=5$, as suggested by the simulations. With $p=\frac12$ this gives $\mathbb E[X]=+\infty$, so you almost surely finish in finite time but with an infinite expected time. With $p<\frac12$ then the probability of ever stopping is $\frac p{1-p} <1$ and the probability of never stopping is $\frac{1-2p}{1-p}>0$, so there is no expectation. Curiously, if you condition on stopping in finite time, the conditional expectation is $\mathbb E[X \mid X < \infty]=\frac{1}{|2p-1|}$, similar to the result when $p > \frac12$. For example with $p=\frac25$, the probability of ever stopping is $\frac23$ and the expectation of the number of flips conditioned on stopping is again $5$.
Flipping an unfair coin until there are more heads Consolidation of my comments: You stop the first time you have one more Heads than Tails, so you are correct that the probability you stop after an even number of flips is $0$. So let's consider the
42,239
Flipping an unfair coin until there are more heads
I found another solution on Quora which ingeniously avoids the labour of finding out the PMF. $\displaystyle \mathbb E[X] = p\cdot \mathbb E[H|X] + (1-p)\cdot \mathbb E[T|X] \tag{1}\label 1$ where, $\mathbb E[T|X]$ denotes the expected number of flips given that the first flip has been a tail. $\mathbb E[H|X]$ denotes the expected number of flips given that the first flip has been a heads. In case the first flip is a heads, heads is already leading, so $\mathbb E[H|X]=1.$ Think about the case where the first flip is a tail. $$\begin{cases}F_1(T)&= 1 \\ F_1(H)&=0\end{cases}$$ where $F_i$ represents the $i^{\texttt{th}}$ cumulative frequency. Further $\mathbb E[X]$ flips, it is expected that it'll add $n$ heads and $n+1$ tails. $$\begin{cases}F_{\mathbb E[X]+1}(T) &=1+n \\ F_{\mathbb E[X]+1}(H) &=0+(n+1)\end{cases}$$ Now that, heads and tails are at par, it's expected that flipping further $\mathbb E[X]$ times more, heads will finally lead! (Say this time, it adds $m$ tails and $m+1$ heads) $$\begin{cases}F_{2\mathbb E[X]+1}(T) &=1+n+m \\ \\ F_{2\mathbb E[X]+1}(H) &=0+(n+1)+(m+1)\end{cases}$$ Thus, we have: $$\mathbb E[T|X]=2\mathbb E[X]+1.$$ Substituting these results in $\eqref 1$, $$\mathbb E[X]=p+(1-p)(2\mathbb E[X]+1)\\ \implies \boxed{\mathbb E[X] = \frac{1}{2p-1}}$$ This makes sense only if $1\geqslant p>1/2$.
Flipping an unfair coin until there are more heads
I found another solution on Quora which ingeniously avoids the labour of finding out the PMF. $\displaystyle \mathbb E[X] = p\cdot \mathbb E[H|X] + (1-p)\cdot \mathbb E[T|X] \tag{1}\label 1$ where, $
Flipping an unfair coin until there are more heads I found another solution on Quora which ingeniously avoids the labour of finding out the PMF. $\displaystyle \mathbb E[X] = p\cdot \mathbb E[H|X] + (1-p)\cdot \mathbb E[T|X] \tag{1}\label 1$ where, $\mathbb E[T|X]$ denotes the expected number of flips given that the first flip has been a tail. $\mathbb E[H|X]$ denotes the expected number of flips given that the first flip has been a heads. In case the first flip is a heads, heads is already leading, so $\mathbb E[H|X]=1.$ Think about the case where the first flip is a tail. $$\begin{cases}F_1(T)&= 1 \\ F_1(H)&=0\end{cases}$$ where $F_i$ represents the $i^{\texttt{th}}$ cumulative frequency. Further $\mathbb E[X]$ flips, it is expected that it'll add $n$ heads and $n+1$ tails. $$\begin{cases}F_{\mathbb E[X]+1}(T) &=1+n \\ F_{\mathbb E[X]+1}(H) &=0+(n+1)\end{cases}$$ Now that, heads and tails are at par, it's expected that flipping further $\mathbb E[X]$ times more, heads will finally lead! (Say this time, it adds $m$ tails and $m+1$ heads) $$\begin{cases}F_{2\mathbb E[X]+1}(T) &=1+n+m \\ \\ F_{2\mathbb E[X]+1}(H) &=0+(n+1)+(m+1)\end{cases}$$ Thus, we have: $$\mathbb E[T|X]=2\mathbb E[X]+1.$$ Substituting these results in $\eqref 1$, $$\mathbb E[X]=p+(1-p)(2\mathbb E[X]+1)\\ \implies \boxed{\mathbb E[X] = \frac{1}{2p-1}}$$ This makes sense only if $1\geqslant p>1/2$.
Flipping an unfair coin until there are more heads I found another solution on Quora which ingeniously avoids the labour of finding out the PMF. $\displaystyle \mathbb E[X] = p\cdot \mathbb E[H|X] + (1-p)\cdot \mathbb E[T|X] \tag{1}\label 1$ where, $
42,240
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)?
Brier Score decomposition relies on a foundational concept in statistics called the partition of sums of squares. The basic idea is that we have a sums of squares over any series, we can break that series into arbitrary groups, calculate the sums of squares within each group, calculate the sums of squares between each group using only group means, and then the total sums of squares is equal to the sums of squares of each group plus the sums of squares between the group means. $$ \text{Total SS} = \text{Group SS} + \text{Residual SS} \tag{1} $$ Wikipedia has a proof of this theorem. There's a neat little cancelation that occurs that makes everything very neat. This cancelation only occurs for sums of squares in particular. Conceptually, it's related to the fact that when we add independent and normally distributed random variables together, the variance of the sum is equal to the sum of variances. Although this theorem is often applied to variance and discussed in the context of linear regression, the theorem itself is simple algebra and can be used in a wide variety of contexts. Also, we have total freedom as to how we break the series into groups. For example, for a clustering algorithm I might want to talk about "Within Group Variance" and "Between Group Variance". For ANOVA I might want to talk about the "proportion of variance explained." In each case, we simply decompose the sums of squares into a group level contribution and an overall contribution and assign interpretations to each part. The trick is to break the series into meaningful groups so that a meaningful interpretation can be assigned to each group. For Brier scores, it's assumed that we've broken our forecasts into groups so that we only have a small number of distinct forecasts. In practice this is almost always done with a bucketing strategy. For example, I might divide my forecasts into 5 groups: everything between 0 and 0.2 is treated as 0.1, everything between 0.2 and 0.4 is treated as 0.3, and so on. The number of buckets you can get away with depends on how much data you have, but in practice 5 is usually OK when sample sizes are small, and 10 is usually more than enough to calculate the calibration metrics. You can see scikit-learn's calibration_curve() for a practical example. In fact, one interpretation of the calibration/reliability component of a Brier score decomposition is that it's simply the MSE of a calibration curve. Once you've divided your forecasts up into a finite number of buckets, you can calculate the Brier score and its components: $$ \underbrace{\frac{1}{N}\sum\limits _{t=1}^{N}\sum\limits _{i=1}^{R}(f_{ti}-o_{ti})^2 \,\!}_{\text{Brier Score}} = \underbrace{\frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(f_{k}-\bar{o}_{k})}^{2}}_{\text{Calibration/Reliability}} \underbrace{ - \underbrace{\frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(\bar{o}_{k}-\bar{o})}^{2}}_{\text{Resolution}} + \underbrace{\bar{o}\left({1-\bar{o}}\right)}_{\text{Uncertainty}} }_{\text{Refinement}} \tag{2} $$ We start by breaking the Brier score into two components: calibration and refinement: The first term, called calibration, calibration error, or reliability, indicates how close the assigned probabilities are to the actual probability in each bucket. For example, for a bucket where the forecasted probability is 10%, we would want about 10% of the examples in that bucket to be positives. If 50% are positive, or only 2%, then our prediction was poorly calibrated. The second term, refinement, indicates how good the predictions are after controlling for poor calibration. In this way, it's similar to AUC in that a model with a high predictive power will still get a low (lower is better) refinement score regardless of how poorly calibrated it is. Sometimes it's useful to further decompose the refinement into two separate terms - resolution and uncertainty. Resolution indicates the forecasters ability to go out on a limb and make non-trivial predictions. If every forecast is exactly equal to the prevalence - if the model is basically just spitting out the same constant value for every example - then resolution will be low. Only if the forecaster goes out on a limb and actually tries to adjust their forecast up or down based on knowledge will they get a good resolution score. Uncertainty is the only term which does not include the forecast probability at all. This represents the uncertainty of the actual outcome. If outcomes are balanced and the overall prevalence is 50%, then uncertainty will be a maximum of 0.25. If there an imbalance between positives and negatives, uncertainty will be lower. For example, if only 10% of outcomes are positives, then uncertainty will be $0.1 (1 - 0.1) = 0.09$. You might notice this is exactly the same formula as the variance of Bernoulli trial. The point of Brier score decomposition is to diagnose some of the common ways that a model or a forecaster can go wrong. If they're just straight up terrible, they'll get a low Brier score. If they're pretty good overall but tend to be too conservative or aggressive, or if they incorrectly believe events that only happen 95% of the time are a "sure thing" or that events that happen 5% of the time "can never happen," or if they never put out a score less than 10% because "you never know" even though the actual rate for the bottom bucket is 1%, then they'll be poorly calibrated. If they play it safe and always make a forecast exactly at or near the overall prevalence, then they'll get a poor resolution score. If you have a model which you believe to be poorly calibrated, you can sometimes do a post hoc correction to recalibrate the output. This is useful for models like neural networks which do not claim to emit a probability, or models like naïve Bayes which are known to crash high or low when their assumptions are violated. You should be careful with this though, as you could simply be papering over a fundamental mismatch between your model and the actual data.
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)?
Brier Score decomposition relies on a foundational concept in statistics called the partition of sums of squares. The basic idea is that we have a sums of squares over any series, we can break that se
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)? Brier Score decomposition relies on a foundational concept in statistics called the partition of sums of squares. The basic idea is that we have a sums of squares over any series, we can break that series into arbitrary groups, calculate the sums of squares within each group, calculate the sums of squares between each group using only group means, and then the total sums of squares is equal to the sums of squares of each group plus the sums of squares between the group means. $$ \text{Total SS} = \text{Group SS} + \text{Residual SS} \tag{1} $$ Wikipedia has a proof of this theorem. There's a neat little cancelation that occurs that makes everything very neat. This cancelation only occurs for sums of squares in particular. Conceptually, it's related to the fact that when we add independent and normally distributed random variables together, the variance of the sum is equal to the sum of variances. Although this theorem is often applied to variance and discussed in the context of linear regression, the theorem itself is simple algebra and can be used in a wide variety of contexts. Also, we have total freedom as to how we break the series into groups. For example, for a clustering algorithm I might want to talk about "Within Group Variance" and "Between Group Variance". For ANOVA I might want to talk about the "proportion of variance explained." In each case, we simply decompose the sums of squares into a group level contribution and an overall contribution and assign interpretations to each part. The trick is to break the series into meaningful groups so that a meaningful interpretation can be assigned to each group. For Brier scores, it's assumed that we've broken our forecasts into groups so that we only have a small number of distinct forecasts. In practice this is almost always done with a bucketing strategy. For example, I might divide my forecasts into 5 groups: everything between 0 and 0.2 is treated as 0.1, everything between 0.2 and 0.4 is treated as 0.3, and so on. The number of buckets you can get away with depends on how much data you have, but in practice 5 is usually OK when sample sizes are small, and 10 is usually more than enough to calculate the calibration metrics. You can see scikit-learn's calibration_curve() for a practical example. In fact, one interpretation of the calibration/reliability component of a Brier score decomposition is that it's simply the MSE of a calibration curve. Once you've divided your forecasts up into a finite number of buckets, you can calculate the Brier score and its components: $$ \underbrace{\frac{1}{N}\sum\limits _{t=1}^{N}\sum\limits _{i=1}^{R}(f_{ti}-o_{ti})^2 \,\!}_{\text{Brier Score}} = \underbrace{\frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(f_{k}-\bar{o}_{k})}^{2}}_{\text{Calibration/Reliability}} \underbrace{ - \underbrace{\frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(\bar{o}_{k}-\bar{o})}^{2}}_{\text{Resolution}} + \underbrace{\bar{o}\left({1-\bar{o}}\right)}_{\text{Uncertainty}} }_{\text{Refinement}} \tag{2} $$ We start by breaking the Brier score into two components: calibration and refinement: The first term, called calibration, calibration error, or reliability, indicates how close the assigned probabilities are to the actual probability in each bucket. For example, for a bucket where the forecasted probability is 10%, we would want about 10% of the examples in that bucket to be positives. If 50% are positive, or only 2%, then our prediction was poorly calibrated. The second term, refinement, indicates how good the predictions are after controlling for poor calibration. In this way, it's similar to AUC in that a model with a high predictive power will still get a low (lower is better) refinement score regardless of how poorly calibrated it is. Sometimes it's useful to further decompose the refinement into two separate terms - resolution and uncertainty. Resolution indicates the forecasters ability to go out on a limb and make non-trivial predictions. If every forecast is exactly equal to the prevalence - if the model is basically just spitting out the same constant value for every example - then resolution will be low. Only if the forecaster goes out on a limb and actually tries to adjust their forecast up or down based on knowledge will they get a good resolution score. Uncertainty is the only term which does not include the forecast probability at all. This represents the uncertainty of the actual outcome. If outcomes are balanced and the overall prevalence is 50%, then uncertainty will be a maximum of 0.25. If there an imbalance between positives and negatives, uncertainty will be lower. For example, if only 10% of outcomes are positives, then uncertainty will be $0.1 (1 - 0.1) = 0.09$. You might notice this is exactly the same formula as the variance of Bernoulli trial. The point of Brier score decomposition is to diagnose some of the common ways that a model or a forecaster can go wrong. If they're just straight up terrible, they'll get a low Brier score. If they're pretty good overall but tend to be too conservative or aggressive, or if they incorrectly believe events that only happen 95% of the time are a "sure thing" or that events that happen 5% of the time "can never happen," or if they never put out a score less than 10% because "you never know" even though the actual rate for the bottom bucket is 1%, then they'll be poorly calibrated. If they play it safe and always make a forecast exactly at or near the overall prevalence, then they'll get a poor resolution score. If you have a model which you believe to be poorly calibrated, you can sometimes do a post hoc correction to recalibrate the output. This is useful for models like neural networks which do not claim to emit a probability, or models like naïve Bayes which are known to crash high or low when their assumptions are violated. You should be careful with this though, as you could simply be papering over a fundamental mismatch between your model and the actual data.
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)? Brier Score decomposition relies on a foundational concept in statistics called the partition of sums of squares. The basic idea is that we have a sums of squares over any series, we can break that se
42,241
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)?
The Brier score (BS) is a measure of the accuracy of probabilistic predictions. It is calculated by taking the mean squared error between the predicted probabilities and the true outcomes. The first equation you provided is the general form of the Brier score, which takes into account all of the predicted probabilities for all of the individual predictions that have been made. The second equation you provided decomposes the Brier score into three components: the reliability (REL), the resolution (RES), and the uncertainty (UNC). These three components provide insight into the different factors that contribute to the overall Brier score, and allow you to analyze the performance of a probabilistic prediction system in more detail. The two equations are equivalent. The relative accuracy measures how close the predicted probabilities are to the observed frequencies. The resolution measures how well the predictions can distinguish between events with different frequencies. And the uncertainty measures the average predicted probability. The second equation is obtained from the first one by introducing these three components and rearranging the terms. In particular, the relative accuracy is defined as: $$ REL = \frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(\mathbf{f_{k}}-\mathbf{\bar{o}}_{\mathbf{k}})}^{2} $$ The resolution is defined as: $$ RES = -\frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(\mathbf{\bar{o}_{k}}-\bar{\mathbf{o}})}^{2} $$ And the uncertainty is defined as: $$ UNC = \mathbf{\bar{o}}\left({1-\mathbf{\bar{o}}}\right) $$ The Brier score is then obtained by adding these three components: $$ BS = REL + RES + UNC $$ I hope this helps clarify the relationship between the two equations you provided.
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)?
The Brier score (BS) is a measure of the accuracy of probabilistic predictions. It is calculated by taking the mean squared error between the predicted probabilities and the true outcomes. The first e
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)? The Brier score (BS) is a measure of the accuracy of probabilistic predictions. It is calculated by taking the mean squared error between the predicted probabilities and the true outcomes. The first equation you provided is the general form of the Brier score, which takes into account all of the predicted probabilities for all of the individual predictions that have been made. The second equation you provided decomposes the Brier score into three components: the reliability (REL), the resolution (RES), and the uncertainty (UNC). These three components provide insight into the different factors that contribute to the overall Brier score, and allow you to analyze the performance of a probabilistic prediction system in more detail. The two equations are equivalent. The relative accuracy measures how close the predicted probabilities are to the observed frequencies. The resolution measures how well the predictions can distinguish between events with different frequencies. And the uncertainty measures the average predicted probability. The second equation is obtained from the first one by introducing these three components and rearranging the terms. In particular, the relative accuracy is defined as: $$ REL = \frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(\mathbf{f_{k}}-\mathbf{\bar{o}}_{\mathbf{k}})}^{2} $$ The resolution is defined as: $$ RES = -\frac{1}{N}\sum\limits _{k=1}^{K}{n_{k}(\mathbf{\bar{o}_{k}}-\bar{\mathbf{o}})}^{2} $$ And the uncertainty is defined as: $$ UNC = \mathbf{\bar{o}}\left({1-\mathbf{\bar{o}}}\right) $$ The Brier score is then obtained by adding these three components: $$ BS = REL + RES + UNC $$ I hope this helps clarify the relationship between the two equations you provided.
How does the Brier Score break down to (Reliability - Resolution + Uncertainty)? The Brier score (BS) is a measure of the accuracy of probabilistic predictions. It is calculated by taking the mean squared error between the predicted probabilities and the true outcomes. The first e
42,242
What is the statistical model for a multi-label problem?
Let's generalise your example by supposing that we have $K$ types of animal/object. As you correctly point out, if we are dealing with observations where these types are mutually exclusive then we would have $K$ possible outcomes and so we would use some kind of multinomial model with $K$ categories. However, if these animals/objects are not mutually exclusive then we would now have $2^K$ possible outcomes so we could now use some kind of multinomial model with $2^K$ categories. In principle this latter case is not really all that different from the former case, and the same types of models can be used. In your example of a dog/cat/horse model, you have $K=3$ so there would be $2^K=8$ possible outcomes. Note that this type of model does not impose any assumed structure on the combinations of animals/objects in the outcome variable; it is appropriate if $K$ is not too large. If $K$ is large enough that $2^K$ is too large to deal with effectively then we would probably impose more structure on the model to specify some kind of parametric relationship between the animals/objects occurring in an outcome. At that point the two forms of model would become different.
What is the statistical model for a multi-label problem?
Let's generalise your example by supposing that we have $K$ types of animal/object. As you correctly point out, if we are dealing with observations where these types are mutually exclusive then we wo
What is the statistical model for a multi-label problem? Let's generalise your example by supposing that we have $K$ types of animal/object. As you correctly point out, if we are dealing with observations where these types are mutually exclusive then we would have $K$ possible outcomes and so we would use some kind of multinomial model with $K$ categories. However, if these animals/objects are not mutually exclusive then we would now have $2^K$ possible outcomes so we could now use some kind of multinomial model with $2^K$ categories. In principle this latter case is not really all that different from the former case, and the same types of models can be used. In your example of a dog/cat/horse model, you have $K=3$ so there would be $2^K=8$ possible outcomes. Note that this type of model does not impose any assumed structure on the combinations of animals/objects in the outcome variable; it is appropriate if $K$ is not too large. If $K$ is large enough that $2^K$ is too large to deal with effectively then we would probably impose more structure on the model to specify some kind of parametric relationship between the animals/objects occurring in an outcome. At that point the two forms of model would become different.
What is the statistical model for a multi-label problem? Let's generalise your example by supposing that we have $K$ types of animal/object. As you correctly point out, if we are dealing with observations where these types are mutually exclusive then we wo
42,243
What is the statistical model for a multi-label problem?
You can think of the multinomial (aka multinoulli) distribution used in multinomial classification as a multivariate discrete distribution obtained in two steps: assign a Bernoulli marginal distribution to each of the labels; use a very specific copula function to model the dependence between the marginals; the copula is such that the Bernoullis are perfectly dependent (if one of them takes value 1, all the others take value 0). In a multi-label problem, you change the copula because you drop the assumption of perfect dependence (two or more Bernoullis are allowed to simultaneously take value 1). The problem is that you need to decide which copula to use. For example, you could use the product copula (all the Bernoullis are independent), similarly to what is done in naive Bayes models. There are several obstacles to choosing / specifying an appropriate copula function: if the number of labels ($K$) is large, you incur in the curse of dimensionality; roughly speaking, you need to model $K^2$ correlations between the Bernoullis, as mentioned in Ben's answer; there are infinitely many possible dependence structures you could choose; it's unclear whether the dependence structure needs to be parametrized separately (before training the model) or estimated while training the model; the copula of a discrete random vector is not fully identifiable, which can cause serious inconsistencies. That said, I think that the easier way to go is to use the product copula (make the Bernoullis independent), which is equivalent to training $K$ separate binomial classification models (one for each label), but with parameter sharing in all the layers but the last one.
What is the statistical model for a multi-label problem?
You can think of the multinomial (aka multinoulli) distribution used in multinomial classification as a multivariate discrete distribution obtained in two steps: assign a Bernoulli marginal distribut
What is the statistical model for a multi-label problem? You can think of the multinomial (aka multinoulli) distribution used in multinomial classification as a multivariate discrete distribution obtained in two steps: assign a Bernoulli marginal distribution to each of the labels; use a very specific copula function to model the dependence between the marginals; the copula is such that the Bernoullis are perfectly dependent (if one of them takes value 1, all the others take value 0). In a multi-label problem, you change the copula because you drop the assumption of perfect dependence (two or more Bernoullis are allowed to simultaneously take value 1). The problem is that you need to decide which copula to use. For example, you could use the product copula (all the Bernoullis are independent), similarly to what is done in naive Bayes models. There are several obstacles to choosing / specifying an appropriate copula function: if the number of labels ($K$) is large, you incur in the curse of dimensionality; roughly speaking, you need to model $K^2$ correlations between the Bernoullis, as mentioned in Ben's answer; there are infinitely many possible dependence structures you could choose; it's unclear whether the dependence structure needs to be parametrized separately (before training the model) or estimated while training the model; the copula of a discrete random vector is not fully identifiable, which can cause serious inconsistencies. That said, I think that the easier way to go is to use the product copula (make the Bernoullis independent), which is equivalent to training $K$ separate binomial classification models (one for each label), but with parameter sharing in all the layers but the last one.
What is the statistical model for a multi-label problem? You can think of the multinomial (aka multinoulli) distribution used in multinomial classification as a multivariate discrete distribution obtained in two steps: assign a Bernoulli marginal distribut
42,244
A Kinder Egg Problem
You could potentially approach this as an inference from an occupancy problem, depending on the sampling method. For simplicity, let's assume that there are $N$ types of toys and your sampling method gives you an IID sample of $n$ toys that are equiprobable over the different types. Let $K_n$ denote the number of disinct toys in your sample. Given the values $N$ and $n$ this =random variable follows the classical occupancy distribution (see e.g., O'Neill 2019), with probability mass function: $$\mathbb{P}(K_n = k) = \text{Occ}(k|n,N) = \frac{(N)_k \cdot S(n,k)}{N^n} \quad \quad \quad \text{for all } 1 \leqslant k \leqslant \min(n,N).$$ Observing the occupancy value $K_n=k$ gives you the log-likelihood function: $$\ell_k(N) = \sum_{i=1}^k \log (N-i+1) - n \log(N) \quad \quad \quad \quad \quad \text{for all } N \geqslant k.$$ You can find the details for computing the MLE and MoM estimators for $N$ in this related question. If you can specify the number of toys you've collected and the number of distinct toys you got I can complete the estimation. (I'm impressed that you have an embarrassing amount of data on Kinder egg toys; if you'd be interested in sharing that data, it would make a nice example for inferences in occupancy problems.)
A Kinder Egg Problem
You could potentially approach this as an inference from an occupancy problem, depending on the sampling method. For simplicity, let's assume that there are $N$ types of toys and your sampling method
A Kinder Egg Problem You could potentially approach this as an inference from an occupancy problem, depending on the sampling method. For simplicity, let's assume that there are $N$ types of toys and your sampling method gives you an IID sample of $n$ toys that are equiprobable over the different types. Let $K_n$ denote the number of disinct toys in your sample. Given the values $N$ and $n$ this =random variable follows the classical occupancy distribution (see e.g., O'Neill 2019), with probability mass function: $$\mathbb{P}(K_n = k) = \text{Occ}(k|n,N) = \frac{(N)_k \cdot S(n,k)}{N^n} \quad \quad \quad \text{for all } 1 \leqslant k \leqslant \min(n,N).$$ Observing the occupancy value $K_n=k$ gives you the log-likelihood function: $$\ell_k(N) = \sum_{i=1}^k \log (N-i+1) - n \log(N) \quad \quad \quad \quad \quad \text{for all } N \geqslant k.$$ You can find the details for computing the MLE and MoM estimators for $N$ in this related question. If you can specify the number of toys you've collected and the number of distinct toys you got I can complete the estimation. (I'm impressed that you have an embarrassing amount of data on Kinder egg toys; if you'd be interested in sharing that data, it would make a nice example for inferences in occupancy problems.)
A Kinder Egg Problem You could potentially approach this as an inference from an occupancy problem, depending on the sampling method. For simplicity, let's assume that there are $N$ types of toys and your sampling method
42,245
Are $U=\frac{2X_1^2}{(X_2+X_3)^2}$ and $V=\frac{2(X_2-X_3)^2}{2X_1^2+(X_2+X_3)^2}$ independent?
Let $X=X_1,$ $Y=(X_2+X_3)/\sqrt2,$ and $Z=(X_2-X_3)/\sqrt2.$ As in your question, it is apparent that these are iid standard Normal. Moreover, $$U = \frac{X^2}{Y^2}\ \text{ and }\ V = 2\frac{Z^2}{X^2 + Y^2}.$$ Consider, then, how $X/Y$ and $X^2+Y^2$ are related. The latter is the squared distance from the origin while the former is the cotangent of the angle $\Theta$ made by $(X,Y)$ to the $X$-axis. Because iid Normal variables are spherical, the angle and the distance are independent. Recall that any (measurable) functions of independent variables are independent. Call these functions $f$ and $g.$ Beginning with the variables $\Theta$ and $(R, Z) = (\sqrt{X^2+Y^2}, Z),$ we have just seen $(\Theta,R,Z)$ are independent. Observing that we may express $V = 2Z^2/R^2 = g(R,Z)$ and $U = \cot^2(\Theta) = f(\Theta),$ we immediately see $(U,V)$ are independent. In retrospect, it is evident $(\Theta, R, Z)$ is a cylindrical coordinate system for the original Cartesian coordinates $(X_1,X_2,X_3).$ Thus, if you prefer an explicitly rigorous, Calculus-based derivation, consider computing the joint distribution function in these cylindrical coordinates: it should separate into a term for $\theta$ and a term for $(r,z).$ BTW, this is a challenge for those of us who like to draw inspiration from simulations: both $U$ and $V$ have infinite means and, in even fairly large simulations, the $(U,V)$ scatterplot can look decidedly dependent. Here, for instance, is a log-log plot for 4,000 random $(U,V)$ pairs. The lack of many extreme values of $U$ makes it look like $V$ tends to be high when $U$ is extreme. Here's the R simulation code. n <- 4e3 x <- rnorm(n) y <- rnorm(n) z <- rnorm(n) u <- 2*x^2 / (y+z)^2 v <- 2*(y-z)^2 / (2*z^2 + (y+z)^2) plot(u,v, log="xy", col=gray(0, alpha=0.1), asp=1)
Are $U=\frac{2X_1^2}{(X_2+X_3)^2}$ and $V=\frac{2(X_2-X_3)^2}{2X_1^2+(X_2+X_3)^2}$ independent?
Let $X=X_1,$ $Y=(X_2+X_3)/\sqrt2,$ and $Z=(X_2-X_3)/\sqrt2.$ As in your question, it is apparent that these are iid standard Normal. Moreover, $$U = \frac{X^2}{Y^2}\ \text{ and }\ V = 2\frac{Z^2}{X^2
Are $U=\frac{2X_1^2}{(X_2+X_3)^2}$ and $V=\frac{2(X_2-X_3)^2}{2X_1^2+(X_2+X_3)^2}$ independent? Let $X=X_1,$ $Y=(X_2+X_3)/\sqrt2,$ and $Z=(X_2-X_3)/\sqrt2.$ As in your question, it is apparent that these are iid standard Normal. Moreover, $$U = \frac{X^2}{Y^2}\ \text{ and }\ V = 2\frac{Z^2}{X^2 + Y^2}.$$ Consider, then, how $X/Y$ and $X^2+Y^2$ are related. The latter is the squared distance from the origin while the former is the cotangent of the angle $\Theta$ made by $(X,Y)$ to the $X$-axis. Because iid Normal variables are spherical, the angle and the distance are independent. Recall that any (measurable) functions of independent variables are independent. Call these functions $f$ and $g.$ Beginning with the variables $\Theta$ and $(R, Z) = (\sqrt{X^2+Y^2}, Z),$ we have just seen $(\Theta,R,Z)$ are independent. Observing that we may express $V = 2Z^2/R^2 = g(R,Z)$ and $U = \cot^2(\Theta) = f(\Theta),$ we immediately see $(U,V)$ are independent. In retrospect, it is evident $(\Theta, R, Z)$ is a cylindrical coordinate system for the original Cartesian coordinates $(X_1,X_2,X_3).$ Thus, if you prefer an explicitly rigorous, Calculus-based derivation, consider computing the joint distribution function in these cylindrical coordinates: it should separate into a term for $\theta$ and a term for $(r,z).$ BTW, this is a challenge for those of us who like to draw inspiration from simulations: both $U$ and $V$ have infinite means and, in even fairly large simulations, the $(U,V)$ scatterplot can look decidedly dependent. Here, for instance, is a log-log plot for 4,000 random $(U,V)$ pairs. The lack of many extreme values of $U$ makes it look like $V$ tends to be high when $U$ is extreme. Here's the R simulation code. n <- 4e3 x <- rnorm(n) y <- rnorm(n) z <- rnorm(n) u <- 2*x^2 / (y+z)^2 v <- 2*(y-z)^2 / (2*z^2 + (y+z)^2) plot(u,v, log="xy", col=gray(0, alpha=0.1), asp=1)
Are $U=\frac{2X_1^2}{(X_2+X_3)^2}$ and $V=\frac{2(X_2-X_3)^2}{2X_1^2+(X_2+X_3)^2}$ independent? Let $X=X_1,$ $Y=(X_2+X_3)/\sqrt2,$ and $Z=(X_2-X_3)/\sqrt2.$ As in your question, it is apparent that these are iid standard Normal. Moreover, $$U = \frac{X^2}{Y^2}\ \text{ and }\ V = 2\frac{Z^2}{X^2
42,246
Calculate $E [ Z_{t-1}| X_{t-1}]$ in an ARMA process
For the Gaussian ARMA model we can derive the conditional mean and variance using standard results for conditional moments for the multivariate normal distribution. This requires use of the auto-correlation function for the ARMA model. You can find details of how to compute the autocorrelation function for an ARMA model in Section 3.3 of Brockwell and Davis (1991). Details of how to compute the conditional distribution and moments can be found in O'Neill (2021), which describes the functions in the ts.extend package. First we derive the autocorrelation function $\gamma$ at the relevant lag values (zero and one in this case): $$\gamma(k) \equiv \mathbb{Corr}(X_t,X_{t-k}).$$ Using these values we can then write the conditional expectation of interest as: $$\mathbb{E}(X_t | X_{t-1} = x) = \mu + \gamma(1) (x - \mu).$$ (In this equation I have included a mean term $\mu$ for the Gaussian ARMA model, even though this mean is zero in your question.) The conditional expectation of interest to you can be computed using the functions in the ts.extend package. Here is an example using the parameters $\mu = 0$, $\phi = 0.8$ and $\theta = -0.3$. #Set model parameters mu <- 0 phi <- 0.8 theta <- -0.3 #Compute autocorrelation AUTOCORR <- ts.extend::ARMA.autocov(n = 2, ar = phi, ma = theta, corr = TRUE) CORR.LAG1 <- AUTOCORR[2] #Compute and plot conditional expectation x <- (-30:30)/10 E <- mu + CORR.LAG1*(x - mu) plot(x, E, type = 'l', xlim = c(-3, 3), ylim = c(-3, 3), main = 'Conditional Expectation in Gaussian ARMA Model', xlab = 'X[t-1]', ylab = 'E(X[t] | X[t-1])')
Calculate $E [ Z_{t-1}| X_{t-1}]$ in an ARMA process
For the Gaussian ARMA model we can derive the conditional mean and variance using standard results for conditional moments for the multivariate normal distribution. This requires use of the auto-corr
Calculate $E [ Z_{t-1}| X_{t-1}]$ in an ARMA process For the Gaussian ARMA model we can derive the conditional mean and variance using standard results for conditional moments for the multivariate normal distribution. This requires use of the auto-correlation function for the ARMA model. You can find details of how to compute the autocorrelation function for an ARMA model in Section 3.3 of Brockwell and Davis (1991). Details of how to compute the conditional distribution and moments can be found in O'Neill (2021), which describes the functions in the ts.extend package. First we derive the autocorrelation function $\gamma$ at the relevant lag values (zero and one in this case): $$\gamma(k) \equiv \mathbb{Corr}(X_t,X_{t-k}).$$ Using these values we can then write the conditional expectation of interest as: $$\mathbb{E}(X_t | X_{t-1} = x) = \mu + \gamma(1) (x - \mu).$$ (In this equation I have included a mean term $\mu$ for the Gaussian ARMA model, even though this mean is zero in your question.) The conditional expectation of interest to you can be computed using the functions in the ts.extend package. Here is an example using the parameters $\mu = 0$, $\phi = 0.8$ and $\theta = -0.3$. #Set model parameters mu <- 0 phi <- 0.8 theta <- -0.3 #Compute autocorrelation AUTOCORR <- ts.extend::ARMA.autocov(n = 2, ar = phi, ma = theta, corr = TRUE) CORR.LAG1 <- AUTOCORR[2] #Compute and plot conditional expectation x <- (-30:30)/10 E <- mu + CORR.LAG1*(x - mu) plot(x, E, type = 'l', xlim = c(-3, 3), ylim = c(-3, 3), main = 'Conditional Expectation in Gaussian ARMA Model', xlab = 'X[t-1]', ylab = 'E(X[t] | X[t-1])')
Calculate $E [ Z_{t-1}| X_{t-1}]$ in an ARMA process For the Gaussian ARMA model we can derive the conditional mean and variance using standard results for conditional moments for the multivariate normal distribution. This requires use of the auto-corr
42,247
Why do most ML papers totally ignore the variance of the validation error?
The current trend in machine learning research is to train huge models. Let me quote one article At OpenAI, an important machine-learning think tank, researchers recently designed and trained a much-lauded deep-learning language system called GPT-3 at the cost of more than $4 million. Even though they made a mistake when they implemented the system, they didn't fix it, explaining simply in a supplement to their scholarly publication that "due to the cost of training, it wasn't feasible to retrain the model." If a model is to expensive to train to fix a bug, certainly nobody is going to bother with $k$-fold cross-validation. Moreover, if you have a huge dataset and subsample it, the subsample would be still huge enough to drive the variance low. Of course assuming that re-training would be deterministic, what is not true as there are known examples of non-reproducible results in machine learning, or getting different results with different random seeds.
Why do most ML papers totally ignore the variance of the validation error?
The current trend in machine learning research is to train huge models. Let me quote one article At OpenAI, an important machine-learning think tank, researchers recently designed and trained a much-
Why do most ML papers totally ignore the variance of the validation error? The current trend in machine learning research is to train huge models. Let me quote one article At OpenAI, an important machine-learning think tank, researchers recently designed and trained a much-lauded deep-learning language system called GPT-3 at the cost of more than $4 million. Even though they made a mistake when they implemented the system, they didn't fix it, explaining simply in a supplement to their scholarly publication that "due to the cost of training, it wasn't feasible to retrain the model." If a model is to expensive to train to fix a bug, certainly nobody is going to bother with $k$-fold cross-validation. Moreover, if you have a huge dataset and subsample it, the subsample would be still huge enough to drive the variance low. Of course assuming that re-training would be deterministic, what is not true as there are known examples of non-reproducible results in machine learning, or getting different results with different random seeds.
Why do most ML papers totally ignore the variance of the validation error? The current trend in machine learning research is to train huge models. Let me quote one article At OpenAI, an important machine-learning think tank, researchers recently designed and trained a much-
42,248
Confused: Why is lme4 changing techniques from Wald F tests to Wald Chisquare?
It's not Anova(conflictcon1, type = 3, Test = 'F') but rather Anova(conflictcon1, type = 3, test.statistic = 'F')
Confused: Why is lme4 changing techniques from Wald F tests to Wald Chisquare?
It's not Anova(conflictcon1, type = 3, Test = 'F') but rather Anova(conflictcon1, type = 3, test.statistic = 'F')
Confused: Why is lme4 changing techniques from Wald F tests to Wald Chisquare? It's not Anova(conflictcon1, type = 3, Test = 'F') but rather Anova(conflictcon1, type = 3, test.statistic = 'F')
Confused: Why is lme4 changing techniques from Wald F tests to Wald Chisquare? It's not Anova(conflictcon1, type = 3, Test = 'F') but rather Anova(conflictcon1, type = 3, test.statistic = 'F')
42,249
How to get rid of background noise in time series data?
This is an example of change-point analysis, for which tools are described for example here and, in the context of loess (a standard approach for smoothing), here. The changepoint package in R provides some potentially useful tools. Note the both the mean and the variance in depth readings change dramatically during a dive, so the tools in that package for evaluating change-points on those bases might help. (I don't have much practical experience with that, however.) In this case, as a simple approach, you might consider working with the differences between successive depth readings. It looks like those differences are small while the bird is on the surface, but then undergo a biphasic large-magnitude positive/negative change during a dive. The threshold for calling a dive could then be based on the magnitudes of those biphasic changes, with dive depth determined by going back to the original undifferenced data for each dive. That said, your solution of using a rolling window of 30 is fine if it reliably does what you want. It nicely incorporates your knowledge of the subject matter, as that size of a window seems large enough to smooth out individual dives without being too aggressive in smoothing.
How to get rid of background noise in time series data?
This is an example of change-point analysis, for which tools are described for example here and, in the context of loess (a standard approach for smoothing), here. The changepoint package in R provide
How to get rid of background noise in time series data? This is an example of change-point analysis, for which tools are described for example here and, in the context of loess (a standard approach for smoothing), here. The changepoint package in R provides some potentially useful tools. Note the both the mean and the variance in depth readings change dramatically during a dive, so the tools in that package for evaluating change-points on those bases might help. (I don't have much practical experience with that, however.) In this case, as a simple approach, you might consider working with the differences between successive depth readings. It looks like those differences are small while the bird is on the surface, but then undergo a biphasic large-magnitude positive/negative change during a dive. The threshold for calling a dive could then be based on the magnitudes of those biphasic changes, with dive depth determined by going back to the original undifferenced data for each dive. That said, your solution of using a rolling window of 30 is fine if it reliably does what you want. It nicely incorporates your knowledge of the subject matter, as that size of a window seems large enough to smooth out individual dives without being too aggressive in smoothing.
How to get rid of background noise in time series data? This is an example of change-point analysis, for which tools are described for example here and, in the context of loess (a standard approach for smoothing), here. The changepoint package in R provide
42,250
How to get rid of background noise in time series data?
Your question will likely get better answers at https://dsp.stackexchange.com/. What you are describing in your update is very close to a median filter. The median filter is part of a larger class of filters called order-statistic filters. Another order-statistic filter you may be interested in is the LULU filter. From a quick Google search, I found the smooth function, which may be applicable.
How to get rid of background noise in time series data?
Your question will likely get better answers at https://dsp.stackexchange.com/. What you are describing in your update is very close to a median filter. The median filter is part of a larger class of
How to get rid of background noise in time series data? Your question will likely get better answers at https://dsp.stackexchange.com/. What you are describing in your update is very close to a median filter. The median filter is part of a larger class of filters called order-statistic filters. Another order-statistic filter you may be interested in is the LULU filter. From a quick Google search, I found the smooth function, which may be applicable.
How to get rid of background noise in time series data? Your question will likely get better answers at https://dsp.stackexchange.com/. What you are describing in your update is very close to a median filter. The median filter is part of a larger class of
42,251
What to do when your training and testing data have different distributions
Collect data from the population you want to predict, and use that data to train your model. This is the best approach. Alternatively, think long and deep about how you can possibly post-process your predictions (from a model trained on a sample from population A) to apply to population B. How you do this will depend on your subject matter. The simplest way, based on the information you give, would be to apply an affine linear transformation to your predictions, to map the interval $[40,1500]$ to $[400,600]$. Given that you already have your model, a simple approach like this will likely be cheaper and faster than collecting new data from the new population, so it may make sense to try it and to think about whether you can realistically hope that a new model will be sufficiently better to justify the added expense of new data collection.
What to do when your training and testing data have different distributions
Collect data from the population you want to predict, and use that data to train your model. This is the best approach. Alternatively, think long and deep about how you can possibly post-process your
What to do when your training and testing data have different distributions Collect data from the population you want to predict, and use that data to train your model. This is the best approach. Alternatively, think long and deep about how you can possibly post-process your predictions (from a model trained on a sample from population A) to apply to population B. How you do this will depend on your subject matter. The simplest way, based on the information you give, would be to apply an affine linear transformation to your predictions, to map the interval $[40,1500]$ to $[400,600]$. Given that you already have your model, a simple approach like this will likely be cheaper and faster than collecting new data from the new population, so it may make sense to try it and to think about whether you can realistically hope that a new model will be sufficiently better to justify the added expense of new data collection.
What to do when your training and testing data have different distributions Collect data from the population you want to predict, and use that data to train your model. This is the best approach. Alternatively, think long and deep about how you can possibly post-process your
42,252
What to do when your training and testing data have different distributions
Like I said in my comment, I don't necessarily see how a change in the range of the response is an issue. In particular, in your case, I think it is a red herring. First, it's important to ask, should the test set have the same range of responses as the train set? In many cases it is not the case and I don't know why that would be problematic necessarily. If the goal was to predict daily high temperature, it's easy to imagine a dataset where a range of temperatures from 0-100F is observed in a multi-year train set while only temperatures in the range of 40-60F are observed in a test set which corresponds to a single month. If we created a model that acurately predicted temperature, we should still expect it to perform well on this test set assuming we have a good model in the first place. Some exceptions include If the relationship between the predictors and the response changes (concept drift). If the domain of the data shifts away from the domain of the training data (applicability domain). In this case, your model has to extrapolate to a region it has never seen before. (See Applied Predictive Modeling pg 535) In this example, we don't know anything about the range of the predictors, but the range of the response for the test set is clearly within the range of the response we see in the train set. If the goal is to estimate how well the model will perform when applied, it makes sense to split the train and test sets based on time and evaluate performance on future months. If there are minor performance losses related to shifts in the distribution of the response, then that is normal and part of what you want to estimate. That being said, it would be better to evaluate the model over a longer period, or over multiple one month periods using time series cross-validation (See Forecasting: Principles and Practice, Section 3.4). That is, unless you're only concerned with how it will perform in Februay, sepcifically. If I had to guess, the reason you are not getting acceptable performance has nothing to do with the range of the response. One, more likely, cuplrit is omitted variable bias. In particular, the effects of covid are very likely at play and should somehow be accounted for (see the comment by @Sycorax). Additionally, without knowing anything else, I might imagine the quanitity of 'applications' to have some seasonality. Both of these factors will complicate the analysis, especially when you do not have much data.
What to do when your training and testing data have different distributions
Like I said in my comment, I don't necessarily see how a change in the range of the response is an issue. In particular, in your case, I think it is a red herring. First, it's important to ask, should
What to do when your training and testing data have different distributions Like I said in my comment, I don't necessarily see how a change in the range of the response is an issue. In particular, in your case, I think it is a red herring. First, it's important to ask, should the test set have the same range of responses as the train set? In many cases it is not the case and I don't know why that would be problematic necessarily. If the goal was to predict daily high temperature, it's easy to imagine a dataset where a range of temperatures from 0-100F is observed in a multi-year train set while only temperatures in the range of 40-60F are observed in a test set which corresponds to a single month. If we created a model that acurately predicted temperature, we should still expect it to perform well on this test set assuming we have a good model in the first place. Some exceptions include If the relationship between the predictors and the response changes (concept drift). If the domain of the data shifts away from the domain of the training data (applicability domain). In this case, your model has to extrapolate to a region it has never seen before. (See Applied Predictive Modeling pg 535) In this example, we don't know anything about the range of the predictors, but the range of the response for the test set is clearly within the range of the response we see in the train set. If the goal is to estimate how well the model will perform when applied, it makes sense to split the train and test sets based on time and evaluate performance on future months. If there are minor performance losses related to shifts in the distribution of the response, then that is normal and part of what you want to estimate. That being said, it would be better to evaluate the model over a longer period, or over multiple one month periods using time series cross-validation (See Forecasting: Principles and Practice, Section 3.4). That is, unless you're only concerned with how it will perform in Februay, sepcifically. If I had to guess, the reason you are not getting acceptable performance has nothing to do with the range of the response. One, more likely, cuplrit is omitted variable bias. In particular, the effects of covid are very likely at play and should somehow be accounted for (see the comment by @Sycorax). Additionally, without knowing anything else, I might imagine the quanitity of 'applications' to have some seasonality. Both of these factors will complicate the analysis, especially when you do not have much data.
What to do when your training and testing data have different distributions Like I said in my comment, I don't necessarily see how a change in the range of the response is an issue. In particular, in your case, I think it is a red herring. First, it's important to ask, should
42,253
Is there a name for the increase in variance upon remeasurement after subsetting with a cut-off value?
This is a kind of regression toward the mean applied, in this specific case, to the variance or standard deviation. Regression toward the mean is observed when selecting subjects based on a very high or very low value and observing that subsequent measurements will be closer to the average. Regression toward the mean can be observed, for instance, if you compare the best students in a class and check their trajectories over a period of time (there is many other scenarios possible!). At T1, you choose the best students based on a measure Y1, like, for instance, indx <- Y1 > 1, then at T2, we should see a trend toward the population parameters (in this example : $\mu = 0$, $\sigma =\sqrt{1.25} $) set.seed(1) N <- 1000 Y0 <- rnorm(N,mean=0,sd=1) Y1 <- Y0 + rnorm(N,mean=0,sd=0.5) Y2 <- Y0 + rnorm(N,mean=0,sd=0.5) indx <- Y1 > 1 mean(Y1[indx]) #1.685 sd(Y1[indx]) #0.6007802 mean(Y2[indx]) #1.357769 # a decrease toward the population mean = 0 sd(Y2[indx]) #0.8145581 # an increase toward the population standard deviation = sqrt(1.25) As expected. To make the matter more obvious, we could use the best students at T1 and T2 for a third measure T3, like Y3 <- Y0 + rnorm(N,mean=0,sd=0.5) indx2 <- Y2[indx]>1 mean(Y3[indx2]) #-0.02015669 sd(Y3[indx2]) #1.123317 which are even closer to the population parameters. I don't have a specific references for the regression toward the mean in the context of effect sizes, but this phenomenon is covered extensively in many ressources. I do not see why regression toward the mean would be different in the context of effect sizes. The Wikipedia page can be very helpful and has many references. Stigler (2002) has an interesting and very accessible to most readers chapter on the topic. Stigler, S. M. (2002). Statistics on the table. The theory of statistical concepts and methods. Harvard University Press.
Is there a name for the increase in variance upon remeasurement after subsetting with a cut-off valu
This is a kind of regression toward the mean applied, in this specific case, to the variance or standard deviation. Regression toward the mean is observed when selecting subjects based on a very high
Is there a name for the increase in variance upon remeasurement after subsetting with a cut-off value? This is a kind of regression toward the mean applied, in this specific case, to the variance or standard deviation. Regression toward the mean is observed when selecting subjects based on a very high or very low value and observing that subsequent measurements will be closer to the average. Regression toward the mean can be observed, for instance, if you compare the best students in a class and check their trajectories over a period of time (there is many other scenarios possible!). At T1, you choose the best students based on a measure Y1, like, for instance, indx <- Y1 > 1, then at T2, we should see a trend toward the population parameters (in this example : $\mu = 0$, $\sigma =\sqrt{1.25} $) set.seed(1) N <- 1000 Y0 <- rnorm(N,mean=0,sd=1) Y1 <- Y0 + rnorm(N,mean=0,sd=0.5) Y2 <- Y0 + rnorm(N,mean=0,sd=0.5) indx <- Y1 > 1 mean(Y1[indx]) #1.685 sd(Y1[indx]) #0.6007802 mean(Y2[indx]) #1.357769 # a decrease toward the population mean = 0 sd(Y2[indx]) #0.8145581 # an increase toward the population standard deviation = sqrt(1.25) As expected. To make the matter more obvious, we could use the best students at T1 and T2 for a third measure T3, like Y3 <- Y0 + rnorm(N,mean=0,sd=0.5) indx2 <- Y2[indx]>1 mean(Y3[indx2]) #-0.02015669 sd(Y3[indx2]) #1.123317 which are even closer to the population parameters. I don't have a specific references for the regression toward the mean in the context of effect sizes, but this phenomenon is covered extensively in many ressources. I do not see why regression toward the mean would be different in the context of effect sizes. The Wikipedia page can be very helpful and has many references. Stigler (2002) has an interesting and very accessible to most readers chapter on the topic. Stigler, S. M. (2002). Statistics on the table. The theory of statistical concepts and methods. Harvard University Press.
Is there a name for the increase in variance upon remeasurement after subsetting with a cut-off valu This is a kind of regression toward the mean applied, in this specific case, to the variance or standard deviation. Regression toward the mean is observed when selecting subjects based on a very high
42,254
Serial correlation AR(1) model for residuals: how to generalize to irregular times
The Ornstein-Uhlenbeck (OU) process can be considered as it is a natural extension of the (V)AR(1). I here skip the mathematical derivation. I first present the multivariate version, which I worked with. The OU process can be specified as follows: $Y(0)\sim N(\mu, \Omega)$, $Y(t+\Delta t)|Y(t) \sim N(\mu + e^{-\Gamma \Delta t}\left(Y(t)-\mu\right), \Omega-e^{-\Gamma \Delta t}\Omega e^{-\Gamma^T \Delta t}),$ where $\mu, \Omega, \Gamma$ are the parameters satisfying the following constraints: The real part of each eigenvalue of $\Gamma$ is positive. $\Gamma\Omega+\Omega\Gamma^T$ is a covariance matrix, $\Omega$ is a covariance matrix. You can see now that if we reduce to one response: $Y(0)\sim N(\mu, \omega^2)$, $Y(t+\Delta t)|Y(t) \sim N(\mu + e^{-\gamma \Delta t}\left(Y(t)-\mu\right), \omega^2\times (1-e^{-2\gamma \Delta t}).$ Now we consider equidistant time points, the process is reduced to AR(1): $Y(0)\sim N(\mu, \omega^2)$, $Y(t+1)|Y(t) \sim N(\mu + e^{-\gamma}\left(Y(t)-\mu\right), \omega^2\times (1-e^{-2\gamma}).$ Finally, if we set $\mu$ equal to 0, then we have: $Y(0)\sim N(0, \omega^2)$, $Y(t+1)|Y(t) \sim N(e^{-\gamma}Y(t), \omega^2\times (1-e^{-2\gamma}).$
Serial correlation AR(1) model for residuals: how to generalize to irregular times
The Ornstein-Uhlenbeck (OU) process can be considered as it is a natural extension of the (V)AR(1). I here skip the mathematical derivation. I first present the multivariate version, which I worked wi
Serial correlation AR(1) model for residuals: how to generalize to irregular times The Ornstein-Uhlenbeck (OU) process can be considered as it is a natural extension of the (V)AR(1). I here skip the mathematical derivation. I first present the multivariate version, which I worked with. The OU process can be specified as follows: $Y(0)\sim N(\mu, \Omega)$, $Y(t+\Delta t)|Y(t) \sim N(\mu + e^{-\Gamma \Delta t}\left(Y(t)-\mu\right), \Omega-e^{-\Gamma \Delta t}\Omega e^{-\Gamma^T \Delta t}),$ where $\mu, \Omega, \Gamma$ are the parameters satisfying the following constraints: The real part of each eigenvalue of $\Gamma$ is positive. $\Gamma\Omega+\Omega\Gamma^T$ is a covariance matrix, $\Omega$ is a covariance matrix. You can see now that if we reduce to one response: $Y(0)\sim N(\mu, \omega^2)$, $Y(t+\Delta t)|Y(t) \sim N(\mu + e^{-\gamma \Delta t}\left(Y(t)-\mu\right), \omega^2\times (1-e^{-2\gamma \Delta t}).$ Now we consider equidistant time points, the process is reduced to AR(1): $Y(0)\sim N(\mu, \omega^2)$, $Y(t+1)|Y(t) \sim N(\mu + e^{-\gamma}\left(Y(t)-\mu\right), \omega^2\times (1-e^{-2\gamma}).$ Finally, if we set $\mu$ equal to 0, then we have: $Y(0)\sim N(0, \omega^2)$, $Y(t+1)|Y(t) \sim N(e^{-\gamma}Y(t), \omega^2\times (1-e^{-2\gamma}).$
Serial correlation AR(1) model for residuals: how to generalize to irregular times The Ornstein-Uhlenbeck (OU) process can be considered as it is a natural extension of the (V)AR(1). I here skip the mathematical derivation. I first present the multivariate version, which I worked wi
42,255
Serial correlation AR(1) model for residuals: how to generalize to irregular times
Assuming the data to be at irregular intervals with different number of measurements for each subject: $y_{t_{11}},y_{t_{12}},\ldots,y_{t_{1K_1}}$ $y_{t_{21}},y_{t_{22}},\ldots,y_{t_{2K_2}}$ $\vdots$ $y_{t_{N1}},y_{t_{N2}},\ldots,y_{t_{NK_N}}$ For sake of simplicity, I am writing the equations for linear models instead of a proportional odds model which can be modeled using a logit link function. We could model the first measurement for the ith subject as: $$y_{t_{i1}} = \beta_0 +\beta_1t_{i1}+\boldsymbol{\beta X}+\gamma_i+\epsilon_{i1}$$ The second measurement should be autocorrelated with the first measurement. The correlation should be 1 when $t_{i2} = t_{i1}$ and 0 when they are too far away. One choice is to choose the correlation to be inversely proportional to the time interval. $$corr(t1,t2) = \frac{\rho}{\rho+f(t_{i2}-t_{i1})} $$ where $f$ can be chosen depending on the decay needed. If $f$ is chosen as the identity function, it means that we have a correlation of 0.5 at a time interval of $\rho$ (which is flexible and $\rho$ can be estimated accordingly) The second measurement then becomes: $$y_{t_{i2}} = \beta_0 +\beta_1t_{i2}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\gamma_i+\epsilon_{i2}$$ Similarly, $$y_{t_{i3}} = \beta_0 +\beta_1t_{i3}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i3}-t_{i1})}\gamma_i+\epsilon_{i3}$$ $$\vdots$$ $$y_{t_{iK_i}} = \beta_0 +\beta_1t_{iK_i}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{iK_i}-t_{i1})}\gamma_i+\epsilon_{iK_i}$$ This correlation structure seems simple and natural, however, (I think) as we go to the measurements at the end, like the correlation between the last observation and last but one observation is small compared to the first and second observation even if they are equally separated in time. To remedy this an alternative specification of the random effects to preserve autocorrelation between measurements is: $$y_{t_{i2}} = \beta_0 +\beta_1t_{i2}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\gamma_i+\epsilon_{i2}$$ Similarly, $$y_{t_{i3}} = \beta_0 +\beta_1t_{i3}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\frac{\rho}{\rho+(t_{i3}-t_{i2})}\gamma_i+\epsilon_{i3}$$ $$\vdots$$ $$y_{t_{iK_i}} = \beta_0 +\beta_1t_{iK_i}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\frac{\rho}{\rho+(t_{i3}-t_{i2})} \ldots \frac{\rho}{\rho+(t_{iK_i}-t_{iK_{i-1}})}\gamma_i+\epsilon_{iK_i}$$ There may be some attenuation in correlation here too, but probably much less than the previous specification. This model could be estimated with a Bayesian hierarchical model with appropriate priors on the random effects and beta coefficients without any non-identifiability issues. I just wrote down my thoughts, I am not an expert in the field. Please let me know if I missed any major concept or if am wrong somewhere.
Serial correlation AR(1) model for residuals: how to generalize to irregular times
Assuming the data to be at irregular intervals with different number of measurements for each subject: $y_{t_{11}},y_{t_{12}},\ldots,y_{t_{1K_1}}$ $y_{t_{21}},y_{t_{22}},\ldots,y_{t_{2K_2}}$ $\vdots$
Serial correlation AR(1) model for residuals: how to generalize to irregular times Assuming the data to be at irregular intervals with different number of measurements for each subject: $y_{t_{11}},y_{t_{12}},\ldots,y_{t_{1K_1}}$ $y_{t_{21}},y_{t_{22}},\ldots,y_{t_{2K_2}}$ $\vdots$ $y_{t_{N1}},y_{t_{N2}},\ldots,y_{t_{NK_N}}$ For sake of simplicity, I am writing the equations for linear models instead of a proportional odds model which can be modeled using a logit link function. We could model the first measurement for the ith subject as: $$y_{t_{i1}} = \beta_0 +\beta_1t_{i1}+\boldsymbol{\beta X}+\gamma_i+\epsilon_{i1}$$ The second measurement should be autocorrelated with the first measurement. The correlation should be 1 when $t_{i2} = t_{i1}$ and 0 when they are too far away. One choice is to choose the correlation to be inversely proportional to the time interval. $$corr(t1,t2) = \frac{\rho}{\rho+f(t_{i2}-t_{i1})} $$ where $f$ can be chosen depending on the decay needed. If $f$ is chosen as the identity function, it means that we have a correlation of 0.5 at a time interval of $\rho$ (which is flexible and $\rho$ can be estimated accordingly) The second measurement then becomes: $$y_{t_{i2}} = \beta_0 +\beta_1t_{i2}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\gamma_i+\epsilon_{i2}$$ Similarly, $$y_{t_{i3}} = \beta_0 +\beta_1t_{i3}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i3}-t_{i1})}\gamma_i+\epsilon_{i3}$$ $$\vdots$$ $$y_{t_{iK_i}} = \beta_0 +\beta_1t_{iK_i}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{iK_i}-t_{i1})}\gamma_i+\epsilon_{iK_i}$$ This correlation structure seems simple and natural, however, (I think) as we go to the measurements at the end, like the correlation between the last observation and last but one observation is small compared to the first and second observation even if they are equally separated in time. To remedy this an alternative specification of the random effects to preserve autocorrelation between measurements is: $$y_{t_{i2}} = \beta_0 +\beta_1t_{i2}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\gamma_i+\epsilon_{i2}$$ Similarly, $$y_{t_{i3}} = \beta_0 +\beta_1t_{i3}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\frac{\rho}{\rho+(t_{i3}-t_{i2})}\gamma_i+\epsilon_{i3}$$ $$\vdots$$ $$y_{t_{iK_i}} = \beta_0 +\beta_1t_{iK_i}+\boldsymbol{\beta X}+\frac{\rho}{\rho+(t_{i2}-t_{i1})}\frac{\rho}{\rho+(t_{i3}-t_{i2})} \ldots \frac{\rho}{\rho+(t_{iK_i}-t_{iK_{i-1}})}\gamma_i+\epsilon_{iK_i}$$ There may be some attenuation in correlation here too, but probably much less than the previous specification. This model could be estimated with a Bayesian hierarchical model with appropriate priors on the random effects and beta coefficients without any non-identifiability issues. I just wrote down my thoughts, I am not an expert in the field. Please let me know if I missed any major concept or if am wrong somewhere.
Serial correlation AR(1) model for residuals: how to generalize to irregular times Assuming the data to be at irregular intervals with different number of measurements for each subject: $y_{t_{11}},y_{t_{12}},\ldots,y_{t_{1K_1}}$ $y_{t_{21}},y_{t_{22}},\ldots,y_{t_{2K_2}}$ $\vdots$
42,256
Serial correlation AR(1) model for residuals: how to generalize to irregular times
When you generalize to a continuous time form, you only need the random effects relevant to your specific observations, because the covariance with earlier random effects will be conditioned on the time interval. This paper describes a continuous-time Rasch model https://psycnet.apa.org/record/2019-22131-001 , using the ctsem software https://cran.r-project.org/web/packages/ctsem/index.html for R (I am the author) . The software is designed to handle this sort of structure, though only limited development (and more limited documentation) have gone into the non-continuous data side of things and once multivariate situations are encountered, the sampling is very slow. Here is R code that generates and fits what I believe to be the sort of structure you're talking about, using the much faster extended kalman filter approximation, as well as the more rigorous full sampling approach via Stan's HMC: #install software # source(file = 'https://github.com/cdriveraus/ctsem/raw/master/installctsem.R') invlogit=function (x) exp(x)/(1 + exp(x)) n.manifest=7 #generate data gm <- ctModel(DRIFT=-.3, DIFFUSION=.3, CINT=.1, #dynamic system pars TRAITVAR=diag(.3,1), #old approach to allow individual variation LAMBDA= matrix(rep(1,each=n.manifest)), #factor loading TDpredNames = 'intervention', TDPREDMEANS = matrix(c(rep(0,10),1,rep(0,9))), TDPREDEFFECT = 1, #intervention timing / effect Tpoints=20, MANIFESTMEANS=c(0,rep(c(.5,-.5),each=(n.manifest-1)/2)), #measurement offset T0MEANS=-.3, #initial latent state T0VAR=.5 #initial latent variance ) d=ctGenerate(gm,n.subjects = 50,logdtsd=.2) #generate continuous data #convert to binary d[,gm$manifestNames] <- rbinom(nrow(d)*gm$n.manifest,size=1,prob=invlogit(d[,gm$manifestNames])) #model to fit m <- ctModel( manifestNames = gm$manifestNames, #observation variables TDpredNames = 'intervention', latentNames='eta1', MANIFESTMEANS = c(0,paste0('m',2:n.manifest,'|param|FALSE')), #set prior to N(0,1), disable individual variation LAMBDA = rep(1,n.manifest), #factor loading T0MEANS='t0m|param|TRUE|.1', CINT = 'b|param|TRUE|1', #use standard normal for mean prior, individual variation = TRUE (default), default scale for sd type = "stanct" ) # ctModelLatex(m) #shows general SDE / measurement structure but assuming continuous observation type m$manifesttype[]=1 #set observation type to binary cores=6 #fit with integration (faster, linearised approximation) ro <- ctStanFit( datalong = d, ctstanmodel = m,cores=cores, plot=10,verbose=0, intoverstates = T,nopriors=F, optimize=T,intoverpop=T)#,optimcontrol=list(stochastic=F)) so=summary(ro) # so ctKalman(ro,plot=T,kalmanvec='etasmooth',subjects=1:3) #latent performance, conditioned on parameters and all data ctKalman(ro,plot=T,kalmanvec='etaprior')#conditioned only on pars and previous data ctKalman(ro,plot=T,kalmanvec='yprior') #observation predictions ctKalman(ro,plot=T,kalmanvec='ysmooth') #fit without kalman filter integration (much slower, using Stan's HMC sampler) r <- ctStanFit( datalong = d, #fit=FALSE, #set this to skip fitting and just get the standata and stanmodel objects ctstanmodel = m, iter = 200,verbose=0, control=list(max_treedepth=4), nopriors=FALSE, chains = cores,plot=F, intoverstates = FALSE, optimize=FALSE,intoverpop=F) s=summary(r) # s
Serial correlation AR(1) model for residuals: how to generalize to irregular times
When you generalize to a continuous time form, you only need the random effects relevant to your specific observations, because the covariance with earlier random effects will be conditioned on the ti
Serial correlation AR(1) model for residuals: how to generalize to irregular times When you generalize to a continuous time form, you only need the random effects relevant to your specific observations, because the covariance with earlier random effects will be conditioned on the time interval. This paper describes a continuous-time Rasch model https://psycnet.apa.org/record/2019-22131-001 , using the ctsem software https://cran.r-project.org/web/packages/ctsem/index.html for R (I am the author) . The software is designed to handle this sort of structure, though only limited development (and more limited documentation) have gone into the non-continuous data side of things and once multivariate situations are encountered, the sampling is very slow. Here is R code that generates and fits what I believe to be the sort of structure you're talking about, using the much faster extended kalman filter approximation, as well as the more rigorous full sampling approach via Stan's HMC: #install software # source(file = 'https://github.com/cdriveraus/ctsem/raw/master/installctsem.R') invlogit=function (x) exp(x)/(1 + exp(x)) n.manifest=7 #generate data gm <- ctModel(DRIFT=-.3, DIFFUSION=.3, CINT=.1, #dynamic system pars TRAITVAR=diag(.3,1), #old approach to allow individual variation LAMBDA= matrix(rep(1,each=n.manifest)), #factor loading TDpredNames = 'intervention', TDPREDMEANS = matrix(c(rep(0,10),1,rep(0,9))), TDPREDEFFECT = 1, #intervention timing / effect Tpoints=20, MANIFESTMEANS=c(0,rep(c(.5,-.5),each=(n.manifest-1)/2)), #measurement offset T0MEANS=-.3, #initial latent state T0VAR=.5 #initial latent variance ) d=ctGenerate(gm,n.subjects = 50,logdtsd=.2) #generate continuous data #convert to binary d[,gm$manifestNames] <- rbinom(nrow(d)*gm$n.manifest,size=1,prob=invlogit(d[,gm$manifestNames])) #model to fit m <- ctModel( manifestNames = gm$manifestNames, #observation variables TDpredNames = 'intervention', latentNames='eta1', MANIFESTMEANS = c(0,paste0('m',2:n.manifest,'|param|FALSE')), #set prior to N(0,1), disable individual variation LAMBDA = rep(1,n.manifest), #factor loading T0MEANS='t0m|param|TRUE|.1', CINT = 'b|param|TRUE|1', #use standard normal for mean prior, individual variation = TRUE (default), default scale for sd type = "stanct" ) # ctModelLatex(m) #shows general SDE / measurement structure but assuming continuous observation type m$manifesttype[]=1 #set observation type to binary cores=6 #fit with integration (faster, linearised approximation) ro <- ctStanFit( datalong = d, ctstanmodel = m,cores=cores, plot=10,verbose=0, intoverstates = T,nopriors=F, optimize=T,intoverpop=T)#,optimcontrol=list(stochastic=F)) so=summary(ro) # so ctKalman(ro,plot=T,kalmanvec='etasmooth',subjects=1:3) #latent performance, conditioned on parameters and all data ctKalman(ro,plot=T,kalmanvec='etaprior')#conditioned only on pars and previous data ctKalman(ro,plot=T,kalmanvec='yprior') #observation predictions ctKalman(ro,plot=T,kalmanvec='ysmooth') #fit without kalman filter integration (much slower, using Stan's HMC sampler) r <- ctStanFit( datalong = d, #fit=FALSE, #set this to skip fitting and just get the standata and stanmodel objects ctstanmodel = m, iter = 200,verbose=0, control=list(max_treedepth=4), nopriors=FALSE, chains = cores,plot=F, intoverstates = FALSE, optimize=FALSE,intoverpop=F) s=summary(r) # s
Serial correlation AR(1) model for residuals: how to generalize to irregular times When you generalize to a continuous time form, you only need the random effects relevant to your specific observations, because the covariance with earlier random effects will be conditioned on the ti
42,257
Two sample test for exponential distribution with only two observations
Consider a likelihood ratio test. Since the likelihood maximizing $\hat\lambda_0$, $\hat\lambda_1$, $\hat\lambda_2$, are respectively $1/\bar{x}=2/(x_1+x_2)$, $1/x_1$, and $1/x_2$, the likelihood ratio $\Lambda$ is $$ \begin{align} \Lambda &= \frac{f_{\hat\lambda_0}(x_1,x_2)}{f_{\hat \lambda_1}(x_1)f_{\hat \lambda_2}(x_2)} \\ &= \frac{\hat\lambda_0^2 e^{-\hat\lambda_0(x_1+x_2)}}{\hat\lambda_1 e^{-\hat\lambda_1x_1} \hat\lambda_2 e^{-\hat\lambda_2x_2}} \\ &= \frac{\hat\lambda_0^2}{\hat\lambda_1 \hat\lambda_2}e^{-\hat\lambda_0(x_1+x_2)+\hat\lambda_1x_1+\hat\lambda_2x_2} \\ &= \frac{x_1x_2}{\bar x^2}e^{-2+1+1} \\ &= \left(\frac{\tilde x}{\bar x}\right)^2 \end{align} $$ where $\tilde x$ is the geometric mean of $x_1$ and $x_2$. That gives the rule for the first hypothesis test to reject $H_0$ when $\tilde x/\bar x<c$ an appropriate $c$. The same rule works for the second test but needs the accompanying condition that $x_1>x_2$. The ratio of geometric to algebraic mean makes intuitive sense since the geometric is always less and only equals the algebraic mean with $x_1=x_2$. If the two observations are close, then the null hypothesis looks reasonable and the likelihood ratio will be high. If $x_1$ and $x_2$ are very different then the geometric mean will be a good deal less than the algebraic mean and the likelihood ratio will be low, indicating that the null hypothesis should be rejected.
Two sample test for exponential distribution with only two observations
Consider a likelihood ratio test. Since the likelihood maximizing $\hat\lambda_0$, $\hat\lambda_1$, $\hat\lambda_2$, are respectively $1/\bar{x}=2/(x_1+x_2)$, $1/x_1$, and $1/x_2$, the likelihood rat
Two sample test for exponential distribution with only two observations Consider a likelihood ratio test. Since the likelihood maximizing $\hat\lambda_0$, $\hat\lambda_1$, $\hat\lambda_2$, are respectively $1/\bar{x}=2/(x_1+x_2)$, $1/x_1$, and $1/x_2$, the likelihood ratio $\Lambda$ is $$ \begin{align} \Lambda &= \frac{f_{\hat\lambda_0}(x_1,x_2)}{f_{\hat \lambda_1}(x_1)f_{\hat \lambda_2}(x_2)} \\ &= \frac{\hat\lambda_0^2 e^{-\hat\lambda_0(x_1+x_2)}}{\hat\lambda_1 e^{-\hat\lambda_1x_1} \hat\lambda_2 e^{-\hat\lambda_2x_2}} \\ &= \frac{\hat\lambda_0^2}{\hat\lambda_1 \hat\lambda_2}e^{-\hat\lambda_0(x_1+x_2)+\hat\lambda_1x_1+\hat\lambda_2x_2} \\ &= \frac{x_1x_2}{\bar x^2}e^{-2+1+1} \\ &= \left(\frac{\tilde x}{\bar x}\right)^2 \end{align} $$ where $\tilde x$ is the geometric mean of $x_1$ and $x_2$. That gives the rule for the first hypothesis test to reject $H_0$ when $\tilde x/\bar x<c$ an appropriate $c$. The same rule works for the second test but needs the accompanying condition that $x_1>x_2$. The ratio of geometric to algebraic mean makes intuitive sense since the geometric is always less and only equals the algebraic mean with $x_1=x_2$. If the two observations are close, then the null hypothesis looks reasonable and the likelihood ratio will be high. If $x_1$ and $x_2$ are very different then the geometric mean will be a good deal less than the algebraic mean and the likelihood ratio will be low, indicating that the null hypothesis should be rejected.
Two sample test for exponential distribution with only two observations Consider a likelihood ratio test. Since the likelihood maximizing $\hat\lambda_0$, $\hat\lambda_1$, $\hat\lambda_2$, are respectively $1/\bar{x}=2/(x_1+x_2)$, $1/x_1$, and $1/x_2$, the likelihood rat
42,258
Two sample test for exponential distribution with only two observations
This question relates to the more general question Find the distribution of the statistic and the critical region of the generalized test at level $\alpha$ for two sample test, which asks the same question but with samples of potentially different sizes than one. An answer to that question uses a statistic that follows Fisher's z-distribution. When we apply the same approach to this problem, then that answer simplifies to the use of the statistic $\log(X_1/X_2)$ which follows a logistic distribution with scale $s=1$ and location $\mu = \log(\lambda_1/\lambda_2)$. So the tests for the hypothesis $\lambda_1/\lambda_2=1$ can be tested with the statistic $\log(X_1/X_2)$. And the p-values can be computed based on that statistic following a logistic distribution given the null hypothesis. The difference between the first and second case is whether you use a one-tailed or two-tailed test, and changes the p-value by a factor two.
Two sample test for exponential distribution with only two observations
This question relates to the more general question Find the distribution of the statistic and the critical region of the generalized test at level $\alpha$ for two sample test, which asks the same que
Two sample test for exponential distribution with only two observations This question relates to the more general question Find the distribution of the statistic and the critical region of the generalized test at level $\alpha$ for two sample test, which asks the same question but with samples of potentially different sizes than one. An answer to that question uses a statistic that follows Fisher's z-distribution. When we apply the same approach to this problem, then that answer simplifies to the use of the statistic $\log(X_1/X_2)$ which follows a logistic distribution with scale $s=1$ and location $\mu = \log(\lambda_1/\lambda_2)$. So the tests for the hypothesis $\lambda_1/\lambda_2=1$ can be tested with the statistic $\log(X_1/X_2)$. And the p-values can be computed based on that statistic following a logistic distribution given the null hypothesis. The difference between the first and second case is whether you use a one-tailed or two-tailed test, and changes the p-value by a factor two.
Two sample test for exponential distribution with only two observations This question relates to the more general question Find the distribution of the statistic and the critical region of the generalized test at level $\alpha$ for two sample test, which asks the same que
42,259
MDP and Sate Value Finding?
For action $a$, we have $Q(A, d) = 0.1 V(B) + 0.9 V(A)$. For action $b$, we have $Q(A, b) = 0.8 V(B) + 0.2 V(A)$. Then, we have $V(A) = -0.1 + \max(Q(A, a), Q(A, b))$. We also have $V(B) = 1$. That is all you need to solve the problem. The easiest way might be by fixing the policy. I.e. assuming $Q(A, a) > Q(A, b)$ and working out what $V(A)$ would be; then doing the same for $Q(A, b) > Q(A, a)$, and checking which one gives a consistent result. This is called "policy iteration": fix the policy, work out $V^{\pi}(A), Q^{\pi}(A, a), Q^{\pi}(A, b)$, improve the policy if necessary, until convergence. For this particular problem there are only 2 policies we need to consider, so this will lead to a small number of calculations. Let's first calculate $V^{\pi}(A)$, where $\pi(A)=a$. We get $Q^{\pi}(A,a)=0.1V(B)+0.9V^{\pi}(A)$, $Q^{\pi}(A,d)=0.8V(B)+0.2V^{\pi}(A)$, and $V^{\pi}(A)=−0.1+Q^{\pi}(A,d)$. Fill in $V(B)=1$ and combine the above to get $Q^{\pi}(A,a)=0.1+0.9(−0.1+Q^{\pi}(A,a))=0.01+0.9Q^{\pi}(A,a)$. This gives us $Q^{\pi}(A,a)=0.1$. Now do the same for $Q^{\pi}(A,b)$, and you should get a higher value; that means we need to change ${\pi}$. Change $\pi$, and repeat the calculations.
MDP and Sate Value Finding?
For action $a$, we have $Q(A, d) = 0.1 V(B) + 0.9 V(A)$. For action $b$, we have $Q(A, b) = 0.8 V(B) + 0.2 V(A)$. Then, we have $V(A) = -0.1 + \max(Q(A, a), Q(A, b))$. We also have $V(B) = 1$. That is
MDP and Sate Value Finding? For action $a$, we have $Q(A, d) = 0.1 V(B) + 0.9 V(A)$. For action $b$, we have $Q(A, b) = 0.8 V(B) + 0.2 V(A)$. Then, we have $V(A) = -0.1 + \max(Q(A, a), Q(A, b))$. We also have $V(B) = 1$. That is all you need to solve the problem. The easiest way might be by fixing the policy. I.e. assuming $Q(A, a) > Q(A, b)$ and working out what $V(A)$ would be; then doing the same for $Q(A, b) > Q(A, a)$, and checking which one gives a consistent result. This is called "policy iteration": fix the policy, work out $V^{\pi}(A), Q^{\pi}(A, a), Q^{\pi}(A, b)$, improve the policy if necessary, until convergence. For this particular problem there are only 2 policies we need to consider, so this will lead to a small number of calculations. Let's first calculate $V^{\pi}(A)$, where $\pi(A)=a$. We get $Q^{\pi}(A,a)=0.1V(B)+0.9V^{\pi}(A)$, $Q^{\pi}(A,d)=0.8V(B)+0.2V^{\pi}(A)$, and $V^{\pi}(A)=−0.1+Q^{\pi}(A,d)$. Fill in $V(B)=1$ and combine the above to get $Q^{\pi}(A,a)=0.1+0.9(−0.1+Q^{\pi}(A,a))=0.01+0.9Q^{\pi}(A,a)$. This gives us $Q^{\pi}(A,a)=0.1$. Now do the same for $Q^{\pi}(A,b)$, and you should get a higher value; that means we need to change ${\pi}$. Change $\pi$, and repeat the calculations.
MDP and Sate Value Finding? For action $a$, we have $Q(A, d) = 0.1 V(B) + 0.9 V(A)$. For action $b$, we have $Q(A, b) = 0.8 V(B) + 0.2 V(A)$. Then, we have $V(A) = -0.1 + \max(Q(A, a), Q(A, b))$. We also have $V(B) = 1$. That is
42,260
How to prove positive (semi-)definitness in matrix notation without numbers
Note that $X$ is generally not square, unless you have as many regressors as observations. In that case - see the derivation at the end of my answer - OLS and GLS are equally efficient. Notice also a mistake in the above expression in that the correct variance of GLS is $$ \sigma^2(X'\Omega^{-1} X)^{-1} $$ A standard result in matrix algebra tells out that $$ A\geq B\Leftrightarrow B^{-1}-A^{-1}\geq0$$ (much like $3>2$ and $1/2>1/3$). Hence, we may also establish that ($\sigma^2$ is just a scale factor which cancels out of the comparison) $$ X'\Omega^{-1} X-X'X(X'\Omega X)^{-1}X'X\geq 0 $$ Rearrange the lhs to $$ X'(\Omega^{-1}-X(X'\Omega X)^{-1}X')X $$ or, with $\Omega^{1/2}$ a symmetric matrix square root of $\Omega$ and $\Omega^{-1/2}$ its inverse, $$ X'(\Omega^{-1/2}\Omega^{-1/2}-\Omega^{-1/2}\Omega^{1/2}X(X'\Omega X)^{-1}X'\Omega^{1/2}\Omega^{-1/2})X $$ or $$ X'\Omega^{-1/2}(I-\Omega^{1/2}X(X'\Omega X)^{-1}X'\Omega^{1/2})\Omega^{-1/2}X $$ or $$ X'\Omega^{-1/2}(I-\Omega^{1/2}X(X'\Omega^{1/2}\Omega^{1/2} X)^{-1}X'\Omega^{1/2})\Omega^{-1/2}X $$ Now let $C:=\Omega^{-1/2}X$ and $D:=\Omega^{1/2}X$ so that we may write $$ C'(I-D(D'D)^{-1}D')C $$ Now, $M_D:=I-D(D'D)^{-1}D'$ is a residual-maker, hence, symmetric and idempotent projection matrix. Let $c:=Ce$ for some nonzero vector $e$. Then, for $f:=M_Dc$, $$ c'M_Dc=c'M_D'M_Dc\equiv f'f\geq0, $$ as $f'f=\sum_if_i^2$ is a sum of squares. Now, if $X$ actually were square (and invertible), we would have $$ X'X(X'\Omega X)^{-1}X'X=X'XX^{-1}\Omega^{-1}(X')^{-1}X'X=X'\Omega^{-1} X $$ so that OLS and GLS would be equally efficient! In fact, they would be numerically identical, as $$ (X'\Omega^{-1} X)^{-1}X'\Omega^{-1}y=X^{-1}\Omega X'^{-1}X'\Omega^{-1}y=X^{-1}y=X^{-1}X'^{-1}X'y=(X'X)^{-1}X'y $$
How to prove positive (semi-)definitness in matrix notation without numbers
Note that $X$ is generally not square, unless you have as many regressors as observations. In that case - see the derivation at the end of my answer - OLS and GLS are equally efficient. Notice also a
How to prove positive (semi-)definitness in matrix notation without numbers Note that $X$ is generally not square, unless you have as many regressors as observations. In that case - see the derivation at the end of my answer - OLS and GLS are equally efficient. Notice also a mistake in the above expression in that the correct variance of GLS is $$ \sigma^2(X'\Omega^{-1} X)^{-1} $$ A standard result in matrix algebra tells out that $$ A\geq B\Leftrightarrow B^{-1}-A^{-1}\geq0$$ (much like $3>2$ and $1/2>1/3$). Hence, we may also establish that ($\sigma^2$ is just a scale factor which cancels out of the comparison) $$ X'\Omega^{-1} X-X'X(X'\Omega X)^{-1}X'X\geq 0 $$ Rearrange the lhs to $$ X'(\Omega^{-1}-X(X'\Omega X)^{-1}X')X $$ or, with $\Omega^{1/2}$ a symmetric matrix square root of $\Omega$ and $\Omega^{-1/2}$ its inverse, $$ X'(\Omega^{-1/2}\Omega^{-1/2}-\Omega^{-1/2}\Omega^{1/2}X(X'\Omega X)^{-1}X'\Omega^{1/2}\Omega^{-1/2})X $$ or $$ X'\Omega^{-1/2}(I-\Omega^{1/2}X(X'\Omega X)^{-1}X'\Omega^{1/2})\Omega^{-1/2}X $$ or $$ X'\Omega^{-1/2}(I-\Omega^{1/2}X(X'\Omega^{1/2}\Omega^{1/2} X)^{-1}X'\Omega^{1/2})\Omega^{-1/2}X $$ Now let $C:=\Omega^{-1/2}X$ and $D:=\Omega^{1/2}X$ so that we may write $$ C'(I-D(D'D)^{-1}D')C $$ Now, $M_D:=I-D(D'D)^{-1}D'$ is a residual-maker, hence, symmetric and idempotent projection matrix. Let $c:=Ce$ for some nonzero vector $e$. Then, for $f:=M_Dc$, $$ c'M_Dc=c'M_D'M_Dc\equiv f'f\geq0, $$ as $f'f=\sum_if_i^2$ is a sum of squares. Now, if $X$ actually were square (and invertible), we would have $$ X'X(X'\Omega X)^{-1}X'X=X'XX^{-1}\Omega^{-1}(X')^{-1}X'X=X'\Omega^{-1} X $$ so that OLS and GLS would be equally efficient! In fact, they would be numerically identical, as $$ (X'\Omega^{-1} X)^{-1}X'\Omega^{-1}y=X^{-1}\Omega X'^{-1}X'\Omega^{-1}y=X^{-1}y=X^{-1}X'^{-1}X'y=(X'X)^{-1}X'y $$
How to prove positive (semi-)definitness in matrix notation without numbers Note that $X$ is generally not square, unless you have as many regressors as observations. In that case - see the derivation at the end of my answer - OLS and GLS are equally efficient. Notice also a
42,261
How to calculate 95% CI of vaccine with 90% efficacy?
One way to do it is to fit a Poisson model (a very close approximation to the binomial with such low rates), and compare the estimated risks: library("emmeans") dat <- data.frame( group = c("placebo", "vaccine"), infected = c(86, 8), N = c(86, 8) + c(21683, 21761)) mod <- glm(infected ~ group + offset(log(N)), data = dat, family = "poisson") Using emmeans::emmeans, we can obtain estimates of the rates per 1000: risk <- emmeans(mod, "group", at = list(N = 1000), type = "response") risk ## group rate SE df asymp.LCL asymp.UCL ## placebo 3.951 0.426 Inf 3.198 4.880 ## vaccine 0.367 0.130 Inf 0.184 0.735 ## ## Confidence level used: 0.95 ## Intervals are back-transformed from the log scale These estimates match those we compute manually: with(dat, 1000*infected / N) ## [1] 3.9505719 0.3674951 Now, just do the paired comparison. With `type = "response", this is converted to a ratio -- the infection risk ratio: irr <- pairs(risk, reverse = TRUE) confint(irr) ## contrast ratio SE df asymp.LCL asymp.UCL ## vaccine / placebo 0.093 0.0344 Inf 0.0451 0.192 ## ## Confidence level used: 0.95 ## Intervals are back-transformed from the log scale The efficacy is thus 1 - 0.093 = 90.7%, with a 95% CI of 80.8% to 95.49%. Created on 2020-11-30 by the reprex package (v0.3.0)
How to calculate 95% CI of vaccine with 90% efficacy?
One way to do it is to fit a Poisson model (a very close approximation to the binomial with such low rates), and compare the estimated risks: library("emmeans") dat <- data.frame( group = c("plac
How to calculate 95% CI of vaccine with 90% efficacy? One way to do it is to fit a Poisson model (a very close approximation to the binomial with such low rates), and compare the estimated risks: library("emmeans") dat <- data.frame( group = c("placebo", "vaccine"), infected = c(86, 8), N = c(86, 8) + c(21683, 21761)) mod <- glm(infected ~ group + offset(log(N)), data = dat, family = "poisson") Using emmeans::emmeans, we can obtain estimates of the rates per 1000: risk <- emmeans(mod, "group", at = list(N = 1000), type = "response") risk ## group rate SE df asymp.LCL asymp.UCL ## placebo 3.951 0.426 Inf 3.198 4.880 ## vaccine 0.367 0.130 Inf 0.184 0.735 ## ## Confidence level used: 0.95 ## Intervals are back-transformed from the log scale These estimates match those we compute manually: with(dat, 1000*infected / N) ## [1] 3.9505719 0.3674951 Now, just do the paired comparison. With `type = "response", this is converted to a ratio -- the infection risk ratio: irr <- pairs(risk, reverse = TRUE) confint(irr) ## contrast ratio SE df asymp.LCL asymp.UCL ## vaccine / placebo 0.093 0.0344 Inf 0.0451 0.192 ## ## Confidence level used: 0.95 ## Intervals are back-transformed from the log scale The efficacy is thus 1 - 0.093 = 90.7%, with a 95% CI of 80.8% to 95.49%. Created on 2020-11-30 by the reprex package (v0.3.0)
How to calculate 95% CI of vaccine with 90% efficacy? One way to do it is to fit a Poisson model (a very close approximation to the binomial with such low rates), and compare the estimated risks: library("emmeans") dat <- data.frame( group = c("plac
42,262
How to calculate 95% CI of vaccine with 90% efficacy?
Use the online calculator. The relative risk (RR), its standard error and 95% confidence interval are calculated according to Altman, 1991.
How to calculate 95% CI of vaccine with 90% efficacy?
Use the online calculator. The relative risk (RR), its standard error and 95% confidence interval are calculated according to Altman, 1991.
How to calculate 95% CI of vaccine with 90% efficacy? Use the online calculator. The relative risk (RR), its standard error and 95% confidence interval are calculated according to Altman, 1991.
How to calculate 95% CI of vaccine with 90% efficacy? Use the online calculator. The relative risk (RR), its standard error and 95% confidence interval are calculated according to Altman, 1991.
42,263
How to calculate and interpret a marginal treatment effect (local instrumental variable)? (Intuition through simple example.)
I think this is a good way to explain the details. I got it from Counterfactuals and Causal Inference by Morgan and Winship, which is a wonderful book. Let's say we are interested in the effect on wages from attending college ($D$). I am not a huge fan of distance, so imagine we had an instrumental variable $Z$ that is a lottery where winners get a voucher worth 25K. Let's assume that 10% of students win and everyone is auto-enrolled in the lottery to simplify things. The LATE estimated by the Wald estimator is the ATE for folks who go to school when they win 25K and don't go to school when they lose (the compliers). There's an intuitive derivation of this here, along with the familiar formula. So far this is pretty standard. Now suppose we have a fancier lottery. Instead of 10% getting an identical 25K voucher, the winners get something random that is uniformly distributed between \$1 and tuition at Harvey Mudd College.$^*$ Now $Z$ is continuous, and let's assume it still satisfies (relevance, monotonicity, and random assignment). An LIV is the limiting case of a component binary IV drawn from $Z$ in which $z′′$ approaches $z′$ for any two values of $Z$ such that $z′′ > z′$. Each LIV then defines a marginal treatment effect, which is the limiting form of a LATE, in which the IV is an LIV. What does this mean? You could make some LIVs from $Z$ by stratifying the data by the values of $Z$ and then doing the Wald on adjacent strata (zero to one, one to two, etc). Assuming enough data, LIVs could be constructed for each dollar increase in the voucher. Each LIV could then be used to estimate its own LATE, and these LIV-identified LATEs are the MTEs. LATEs and many other average treatment effects can be seen as weighted averages of the fundamental marginal treatment effects. $^*$I did this in dollar increments, but you could also imagine doing this in pennies or something even more infinitesimal instead. Harvey Mudd was the most expensive college in the US last year in terms of sticker price.
How to calculate and interpret a marginal treatment effect (local instrumental variable)? (Intuition
I think this is a good way to explain the details. I got it from Counterfactuals and Causal Inference by Morgan and Winship, which is a wonderful book. Let's say we are interested in the effect on wag
How to calculate and interpret a marginal treatment effect (local instrumental variable)? (Intuition through simple example.) I think this is a good way to explain the details. I got it from Counterfactuals and Causal Inference by Morgan and Winship, which is a wonderful book. Let's say we are interested in the effect on wages from attending college ($D$). I am not a huge fan of distance, so imagine we had an instrumental variable $Z$ that is a lottery where winners get a voucher worth 25K. Let's assume that 10% of students win and everyone is auto-enrolled in the lottery to simplify things. The LATE estimated by the Wald estimator is the ATE for folks who go to school when they win 25K and don't go to school when they lose (the compliers). There's an intuitive derivation of this here, along with the familiar formula. So far this is pretty standard. Now suppose we have a fancier lottery. Instead of 10% getting an identical 25K voucher, the winners get something random that is uniformly distributed between \$1 and tuition at Harvey Mudd College.$^*$ Now $Z$ is continuous, and let's assume it still satisfies (relevance, monotonicity, and random assignment). An LIV is the limiting case of a component binary IV drawn from $Z$ in which $z′′$ approaches $z′$ for any two values of $Z$ such that $z′′ > z′$. Each LIV then defines a marginal treatment effect, which is the limiting form of a LATE, in which the IV is an LIV. What does this mean? You could make some LIVs from $Z$ by stratifying the data by the values of $Z$ and then doing the Wald on adjacent strata (zero to one, one to two, etc). Assuming enough data, LIVs could be constructed for each dollar increase in the voucher. Each LIV could then be used to estimate its own LATE, and these LIV-identified LATEs are the MTEs. LATEs and many other average treatment effects can be seen as weighted averages of the fundamental marginal treatment effects. $^*$I did this in dollar increments, but you could also imagine doing this in pennies or something even more infinitesimal instead. Harvey Mudd was the most expensive college in the US last year in terms of sticker price.
How to calculate and interpret a marginal treatment effect (local instrumental variable)? (Intuition I think this is a good way to explain the details. I got it from Counterfactuals and Causal Inference by Morgan and Winship, which is a wonderful book. Let's say we are interested in the effect on wag
42,264
Evaluating (Uniform) Expectations over Non-simple Region
Let's solve the more general problem and then apply it to the specific setting as an illustration. Suppose $g:\mathcal{X}\to\mathbb{R}$ is a measurable function. Let $\{\mathcal{A}_i\}\subset \mathscr{P}(\mathcal{X})$ be a finite or countable collection of subsets of $\mathcal X,$ each with finite positive measure $p_i = \int_{\mathcal{A}_i}\mathrm{d}x.$ Associated with each $\mathcal A_i$ is its indicator function $\mathscr{I}_i.$ Then for any sequence of numbers $(\omega_i)$ -- essentially by construction of the integral -- we have that $$\int_\mathcal{X} \sum_i g(x)\omega_i\mathscr{I}_i(x)\,\mathrm{d}x = \sum_i \omega_i \int_{\mathcal{A}_i} g(x)\,\mathrm{d}x = \sum_i \omega_i p_i \int_{\mathcal{A}_i} g(x)\,\frac{\mathrm{d}x}{|p_i|}$$ When the $\omega_i$ are positive and the sum of $\omega_i p_i$ is unity, the right hand side is the expectation of $g(X)$ where the distribution of $X$ is a mixture of the uniform distributions on the $\mathcal{A}_i$ with mixture weights $\omega_i p_i.$ I will continue to use this imagery and this language even when some of the $\omega_i$ are negative. Think of this as a "generalized mixture" if you like. Provided the left hand integrand is never negative and is positive on some set of positive area, we may normalize it to produce a genuine distribution. Evidently its density function is $$f(x;(\mathcal{A}_i), (\omega_i)) = \frac{1}{\sum_i \omega_i p_i} \sum_i \omega_i g(x) \mathscr{I}_i(x).\tag{*}$$ The first formula therefore gives the expectation $E[g(Z)]$ when $Z$ has this mixture distribution. The right hand side of the formula shows that this expectation is a linear combination of the expectations of the mixture components. To apply this observation to the example in the question, let $\mathcal X =\mathbb{R}^2$ (with its usual Borel measure) and $g(x,y) = xy.$ Let's begin by getting all the calculations out of the way. They amount to integrating $g$ over various rectangles $[a,b]\times[c,d].$ It is elementary to compute that The area of a rectangle $[a,b]\times[c,d]$ is $p(a,b,c,d)=(b-a)(d-c).$ $$G(a,b,c,d)=\iint_{[a,b]\times[c,d]}xy\,\mathrm{d}x\mathrm{d}y = \frac{1}{4}(b^2-a^2)(d^2-c^2) = p(a,b,c,d)(a+b)(c+d)/4.$$ The problem can be expressed in terms of six rectangles: the two big ones (which therefore receive weights $\omega_i=1$) from which the four little ones have been removed (by applying weights $\omega_i=-1$). Here is a table of their properties, computed using $(1)$ and $(2)$ above. $$ \begin{array}[llrrrl] & i & [a,b]& [c,d] & p & G & \omega \\ \hline 1 & [0,1]& [0,1] & 1 & 1/4 & 1 \\ 2 & [1,2]& [1,2] & 1 & 9/4 & 1 \\ 3 & [1/5,2/5] & [1/5,2/5] & 1/25 & 9/100 & -1 \\ 4 & [3/5,4/5] & [1/5,2/5] & 1/25 & 21/100 & -1\\ 5 & [1/5,2/5] & [3/5,4/5] & 1/25 & 21/100 & -1\\ 6 & [3/5,4/5] & [3/5,4/5] & 1/25 & 49/100 & -1 \end{array} $$ The denominator in $(*)$ is $$\sum_{i=1}^6 \omega_i p_i = 1 + 1 - \frac{1}{25} - \cdots - \frac{1}{25} = \frac{46}{25}.$$ Writing $Z=(X,Y),$ the answer to the question is $$E[XY] = E[g(Z)] = \frac{25}{46}\left(\frac{1}{4} + \frac{9}{4} - \frac{9}{2500} - \frac{21}{2500} - \frac{21}{2500} - \frac{49}{2500}\right)=\frac{123}{92}.$$
Evaluating (Uniform) Expectations over Non-simple Region
Let's solve the more general problem and then apply it to the specific setting as an illustration. Suppose $g:\mathcal{X}\to\mathbb{R}$ is a measurable function. Let $\{\mathcal{A}_i\}\subset \mathsc
Evaluating (Uniform) Expectations over Non-simple Region Let's solve the more general problem and then apply it to the specific setting as an illustration. Suppose $g:\mathcal{X}\to\mathbb{R}$ is a measurable function. Let $\{\mathcal{A}_i\}\subset \mathscr{P}(\mathcal{X})$ be a finite or countable collection of subsets of $\mathcal X,$ each with finite positive measure $p_i = \int_{\mathcal{A}_i}\mathrm{d}x.$ Associated with each $\mathcal A_i$ is its indicator function $\mathscr{I}_i.$ Then for any sequence of numbers $(\omega_i)$ -- essentially by construction of the integral -- we have that $$\int_\mathcal{X} \sum_i g(x)\omega_i\mathscr{I}_i(x)\,\mathrm{d}x = \sum_i \omega_i \int_{\mathcal{A}_i} g(x)\,\mathrm{d}x = \sum_i \omega_i p_i \int_{\mathcal{A}_i} g(x)\,\frac{\mathrm{d}x}{|p_i|}$$ When the $\omega_i$ are positive and the sum of $\omega_i p_i$ is unity, the right hand side is the expectation of $g(X)$ where the distribution of $X$ is a mixture of the uniform distributions on the $\mathcal{A}_i$ with mixture weights $\omega_i p_i.$ I will continue to use this imagery and this language even when some of the $\omega_i$ are negative. Think of this as a "generalized mixture" if you like. Provided the left hand integrand is never negative and is positive on some set of positive area, we may normalize it to produce a genuine distribution. Evidently its density function is $$f(x;(\mathcal{A}_i), (\omega_i)) = \frac{1}{\sum_i \omega_i p_i} \sum_i \omega_i g(x) \mathscr{I}_i(x).\tag{*}$$ The first formula therefore gives the expectation $E[g(Z)]$ when $Z$ has this mixture distribution. The right hand side of the formula shows that this expectation is a linear combination of the expectations of the mixture components. To apply this observation to the example in the question, let $\mathcal X =\mathbb{R}^2$ (with its usual Borel measure) and $g(x,y) = xy.$ Let's begin by getting all the calculations out of the way. They amount to integrating $g$ over various rectangles $[a,b]\times[c,d].$ It is elementary to compute that The area of a rectangle $[a,b]\times[c,d]$ is $p(a,b,c,d)=(b-a)(d-c).$ $$G(a,b,c,d)=\iint_{[a,b]\times[c,d]}xy\,\mathrm{d}x\mathrm{d}y = \frac{1}{4}(b^2-a^2)(d^2-c^2) = p(a,b,c,d)(a+b)(c+d)/4.$$ The problem can be expressed in terms of six rectangles: the two big ones (which therefore receive weights $\omega_i=1$) from which the four little ones have been removed (by applying weights $\omega_i=-1$). Here is a table of their properties, computed using $(1)$ and $(2)$ above. $$ \begin{array}[llrrrl] & i & [a,b]& [c,d] & p & G & \omega \\ \hline 1 & [0,1]& [0,1] & 1 & 1/4 & 1 \\ 2 & [1,2]& [1,2] & 1 & 9/4 & 1 \\ 3 & [1/5,2/5] & [1/5,2/5] & 1/25 & 9/100 & -1 \\ 4 & [3/5,4/5] & [1/5,2/5] & 1/25 & 21/100 & -1\\ 5 & [1/5,2/5] & [3/5,4/5] & 1/25 & 21/100 & -1\\ 6 & [3/5,4/5] & [3/5,4/5] & 1/25 & 49/100 & -1 \end{array} $$ The denominator in $(*)$ is $$\sum_{i=1}^6 \omega_i p_i = 1 + 1 - \frac{1}{25} - \cdots - \frac{1}{25} = \frac{46}{25}.$$ Writing $Z=(X,Y),$ the answer to the question is $$E[XY] = E[g(Z)] = \frac{25}{46}\left(\frac{1}{4} + \frac{9}{4} - \frac{9}{2500} - \frac{21}{2500} - \frac{21}{2500} - \frac{49}{2500}\right)=\frac{123}{92}.$$
Evaluating (Uniform) Expectations over Non-simple Region Let's solve the more general problem and then apply it to the specific setting as an illustration. Suppose $g:\mathcal{X}\to\mathbb{R}$ is a measurable function. Let $\{\mathcal{A}_i\}\subset \mathsc
42,265
Should reconstruction loss be computed as sum or average over input for variational autoencoders?
To go directly to the answer, the loss does have a precise derivation (but that doesn't mean you can't necessarily change it). It's important to remember that Variational Auto-encoders are at their core a method for doing variational inference over some latent variables we assume to be generating the data. In this framework we aim to minimise the KL-divergence between some approximate posterior over the latent variables and the true posterior, which we can alternatively do my maximising the evidence lower bound (ELBO), details in the VAE paper. This gives us the objective in VAEs: $$ \mathcal{L}(\theta,\phi) = \underbrace{\mathbb{E}_{q_\phi}[\log p_\theta(x|z)]}_{\text{Reconstruction Loss}} - \underbrace{D_{KL}(q_\phi(z)||p(z))}_{\text{KL Regulariser}} $$ Now the reconstruction loss is the expected log-likelihood of the data given the latent variables. For an image which is made up of a number of pixels the total log-likelihood will be the sum of the log-likelihood of all of the pixels (assuming independence), not the average log-likelihood of each individual pixel which is why it's the case in the example. The question of whether you can add an extra parameter is an interesting one. DeepMind for example have introduced the $\beta$-VAE, which does exactly this, albeit for a slightly different purpose - they show that this extra parameter can lead to a more disentangled latent-space that allows for more interpretable variables. How principled this change in objective is is up for debate, but it does work. That being said it is very easy to change the KL regulariser term in a principled way by simply changing your prior ($p(z)$) on the latent variables, the original prior is a very boring standard normal distribution so just swapping in something else will change the loss function. You might even be able, though I haven't checked this myself, to specify a new prior ($p'(z)$) such that: $$ D_{KL}(q_\phi(z)||p'(z)) = \lambda * D_{KL}(q_\phi(z)||p(z)), $$ which will do exactly what you want. So basically the answer is yes - feel free to change the loss function if it helps you do the task you want just be aware of how what you're doing is different to the original case so you don't make any claims you shouldn't.
Should reconstruction loss be computed as sum or average over input for variational autoencoders?
To go directly to the answer, the loss does have a precise derivation (but that doesn't mean you can't necessarily change it). It's important to remember that Variational Auto-encoders are at their co
Should reconstruction loss be computed as sum or average over input for variational autoencoders? To go directly to the answer, the loss does have a precise derivation (but that doesn't mean you can't necessarily change it). It's important to remember that Variational Auto-encoders are at their core a method for doing variational inference over some latent variables we assume to be generating the data. In this framework we aim to minimise the KL-divergence between some approximate posterior over the latent variables and the true posterior, which we can alternatively do my maximising the evidence lower bound (ELBO), details in the VAE paper. This gives us the objective in VAEs: $$ \mathcal{L}(\theta,\phi) = \underbrace{\mathbb{E}_{q_\phi}[\log p_\theta(x|z)]}_{\text{Reconstruction Loss}} - \underbrace{D_{KL}(q_\phi(z)||p(z))}_{\text{KL Regulariser}} $$ Now the reconstruction loss is the expected log-likelihood of the data given the latent variables. For an image which is made up of a number of pixels the total log-likelihood will be the sum of the log-likelihood of all of the pixels (assuming independence), not the average log-likelihood of each individual pixel which is why it's the case in the example. The question of whether you can add an extra parameter is an interesting one. DeepMind for example have introduced the $\beta$-VAE, which does exactly this, albeit for a slightly different purpose - they show that this extra parameter can lead to a more disentangled latent-space that allows for more interpretable variables. How principled this change in objective is is up for debate, but it does work. That being said it is very easy to change the KL regulariser term in a principled way by simply changing your prior ($p(z)$) on the latent variables, the original prior is a very boring standard normal distribution so just swapping in something else will change the loss function. You might even be able, though I haven't checked this myself, to specify a new prior ($p'(z)$) such that: $$ D_{KL}(q_\phi(z)||p'(z)) = \lambda * D_{KL}(q_\phi(z)||p(z)), $$ which will do exactly what you want. So basically the answer is yes - feel free to change the loss function if it helps you do the task you want just be aware of how what you're doing is different to the original case so you don't make any claims you shouldn't.
Should reconstruction loss be computed as sum or average over input for variational autoencoders? To go directly to the answer, the loss does have a precise derivation (but that doesn't mean you can't necessarily change it). It's important to remember that Variational Auto-encoders are at their co
42,266
Should reconstruction loss be computed as sum or average over input for variational autoencoders?
As I understand how VAE works, the KL loss can be considered as the regulariser and reconstruction loss is one that drives the model weighs to produce the correct output. To answer your specific question: "Can I use a lambda parameter to capture the tradeoff between kl divergence and reconstruction"; yes you can use a parameter rather a multiplayer such that $reconstruction_loss + \lambda \times kl_loss$. However, $\lambda$ would have to assume a smaller value ($1/28^2$). I found this paper useful to grasp the concepts in VAE in general. https://arxiv.org/abs/1606.05908
Should reconstruction loss be computed as sum or average over input for variational autoencoders?
As I understand how VAE works, the KL loss can be considered as the regulariser and reconstruction loss is one that drives the model weighs to produce the correct output. To answer your specific quest
Should reconstruction loss be computed as sum or average over input for variational autoencoders? As I understand how VAE works, the KL loss can be considered as the regulariser and reconstruction loss is one that drives the model weighs to produce the correct output. To answer your specific question: "Can I use a lambda parameter to capture the tradeoff between kl divergence and reconstruction"; yes you can use a parameter rather a multiplayer such that $reconstruction_loss + \lambda \times kl_loss$. However, $\lambda$ would have to assume a smaller value ($1/28^2$). I found this paper useful to grasp the concepts in VAE in general. https://arxiv.org/abs/1606.05908
Should reconstruction loss be computed as sum or average over input for variational autoencoders? As I understand how VAE works, the KL loss can be considered as the regulariser and reconstruction loss is one that drives the model weighs to produce the correct output. To answer your specific quest
42,267
In mgcv::gam(), what is the difference between s(x, by=cat) and s(x, cat, bs='fs')?
Q3 The by smooth variant has a separate smoothness parameter for each level of cat. In one sense you can think of these smooths as creating entirely separate smooth functions (they're aren't quite, they share the same basis for example), hence you have nlevels(cat) entries in the summary() output. fs smooths share a single smoothness parameter, and in that sense are a bit closer to the smooth equivalent of random slopes; all the smooths are being pulled towards 0 (null function), with the smooths for some levels of cat pulled more towards 0 than others. Q1 You should just treat the fs smooth summary as some measure of overall importance of the set of smooth functions. If the fs smooth is the only one in the model where x is a covariate then you could say interpret this as a test of the amount of variation in the response that can be explained by smooth functions of x, against a null of no effect. It's like an omnibus test in the sense that it is over the set of smooths. Put another way, it is a bit like a test for a variance term of random slopes in a mixed effects model; this would be on a single variance parameter and you get a single test over the entire "effect" even though it represents $m$ slopes. Q2 Typically, one would use fs where there where nlevels(cat) was large and you aren't particularly interested in the specific levels, just like you might work with random effects in a mixed effects model. As there could feasibly be a separate line for the many levels of the factor but we think of this as a single "smooth" you get a single plot with each smooth superimposed to get some idea of the variation within and between individual functions. It would get very messy it if also showed confidence bands for each smooth. In the by case, because you conditioned on the observed set of levels (sensu fixed effects in a mixed model) it makes sense to view these are being of individual interest, hence a separate plot per level of cat. Also note that this is just the default plot to get a quick look at the fitted functions.
In mgcv::gam(), what is the difference between s(x, by=cat) and s(x, cat, bs='fs')?
Q3 The by smooth variant has a separate smoothness parameter for each level of cat. In one sense you can think of these smooths as creating entirely separate smooth functions (they're aren't quite, th
In mgcv::gam(), what is the difference between s(x, by=cat) and s(x, cat, bs='fs')? Q3 The by smooth variant has a separate smoothness parameter for each level of cat. In one sense you can think of these smooths as creating entirely separate smooth functions (they're aren't quite, they share the same basis for example), hence you have nlevels(cat) entries in the summary() output. fs smooths share a single smoothness parameter, and in that sense are a bit closer to the smooth equivalent of random slopes; all the smooths are being pulled towards 0 (null function), with the smooths for some levels of cat pulled more towards 0 than others. Q1 You should just treat the fs smooth summary as some measure of overall importance of the set of smooth functions. If the fs smooth is the only one in the model where x is a covariate then you could say interpret this as a test of the amount of variation in the response that can be explained by smooth functions of x, against a null of no effect. It's like an omnibus test in the sense that it is over the set of smooths. Put another way, it is a bit like a test for a variance term of random slopes in a mixed effects model; this would be on a single variance parameter and you get a single test over the entire "effect" even though it represents $m$ slopes. Q2 Typically, one would use fs where there where nlevels(cat) was large and you aren't particularly interested in the specific levels, just like you might work with random effects in a mixed effects model. As there could feasibly be a separate line for the many levels of the factor but we think of this as a single "smooth" you get a single plot with each smooth superimposed to get some idea of the variation within and between individual functions. It would get very messy it if also showed confidence bands for each smooth. In the by case, because you conditioned on the observed set of levels (sensu fixed effects in a mixed model) it makes sense to view these are being of individual interest, hence a separate plot per level of cat. Also note that this is just the default plot to get a quick look at the fitted functions.
In mgcv::gam(), what is the difference between s(x, by=cat) and s(x, cat, bs='fs')? Q3 The by smooth variant has a separate smoothness parameter for each level of cat. In one sense you can think of these smooths as creating entirely separate smooth functions (they're aren't quite, th
42,268
Linear Changepoint Model with LASSO
Nice question. I have more to say tomorrow, but for now the main point here is that your predictor matrix, changepoints is just a weighted matrix of piecewise linear basis functions, where the weights are set to fit the 25 equally-spaced points in your data. It is common enough to use lasso to penalise regression splines, although other methods are more popular. If you haven't already read it, chapter 5 of Elements of Statistical Learning covers this. Let $X$ be standard matrix of basis functions (middle panel), $w$ be the weights applied to each basis (right panel), and $X_w$ be the weighted basis matrix (left panel). If you were to use OLS instead of lasso, it wouldn't matter if you used the $X$ or $X_w$, since the regression weights could capture the difference: $\hat y = X_w \times \beta = X \times \beta_w$, where $\beta_w = w \times \beta$. With lasso, however, you end up with a slightly different solution, since penalising $\beta$ isn't the same as penalising $\beta_w$. I need to do a little more poking around to be sure, but using $X_w$, which is already tailored to the data, should just lead to a tighter fit to the data for a given L1 penalty term (alpha), and as a result there exists some penalty, $\alpha > 10,000$, that gives exactly the same solution when using $X$. Note: I've skipped over some details on centring the basis functions and subtracting the linear trend. Code: def plot_weights(weights, colour=True): n = weights.shape[0] if colour: for i in range(n): plt.plot([i, i], [0, weights[i]]) else: plt.vlines(x=np.arange(n), ymin=0, ymax=weights) plt.hlines(0, 0, n, linestyle='dashed') plt.ylabel('Weight') slope = changepoints[:, 0] weighted_bases = changepoints[:, 1:] - slope.reshape(-1, 1) ix_argmax = np.abs(weighted_bases).argmax(0) basis_weights = np.array([weighted_bases[ix, i] for i, ix in enumerate(ix_argmax)]) raw_bases = weighted_bases / basis_weights fig, axes = plt.subplots(1, 4, figsize=(14, 2)) plt.sca(axes[0]) plt.plot(changepoints) plt.title('Changepoint Matrix =') plt.sca(axes[1]) plt.plot(slope) plt.title('Slope +') plt.sca(axes[2]) plt.plot(bases) plt.title('(Basis functions') plt.sca(axes[3]) plot_weights(basis_weights) plt.title('× Weights)') plt.tight_layout()
Linear Changepoint Model with LASSO
Nice question. I have more to say tomorrow, but for now the main point here is that your predictor matrix, changepoints is just a weighted matrix of piecewise linear basis functions, where the weights
Linear Changepoint Model with LASSO Nice question. I have more to say tomorrow, but for now the main point here is that your predictor matrix, changepoints is just a weighted matrix of piecewise linear basis functions, where the weights are set to fit the 25 equally-spaced points in your data. It is common enough to use lasso to penalise regression splines, although other methods are more popular. If you haven't already read it, chapter 5 of Elements of Statistical Learning covers this. Let $X$ be standard matrix of basis functions (middle panel), $w$ be the weights applied to each basis (right panel), and $X_w$ be the weighted basis matrix (left panel). If you were to use OLS instead of lasso, it wouldn't matter if you used the $X$ or $X_w$, since the regression weights could capture the difference: $\hat y = X_w \times \beta = X \times \beta_w$, where $\beta_w = w \times \beta$. With lasso, however, you end up with a slightly different solution, since penalising $\beta$ isn't the same as penalising $\beta_w$. I need to do a little more poking around to be sure, but using $X_w$, which is already tailored to the data, should just lead to a tighter fit to the data for a given L1 penalty term (alpha), and as a result there exists some penalty, $\alpha > 10,000$, that gives exactly the same solution when using $X$. Note: I've skipped over some details on centring the basis functions and subtracting the linear trend. Code: def plot_weights(weights, colour=True): n = weights.shape[0] if colour: for i in range(n): plt.plot([i, i], [0, weights[i]]) else: plt.vlines(x=np.arange(n), ymin=0, ymax=weights) plt.hlines(0, 0, n, linestyle='dashed') plt.ylabel('Weight') slope = changepoints[:, 0] weighted_bases = changepoints[:, 1:] - slope.reshape(-1, 1) ix_argmax = np.abs(weighted_bases).argmax(0) basis_weights = np.array([weighted_bases[ix, i] for i, ix in enumerate(ix_argmax)]) raw_bases = weighted_bases / basis_weights fig, axes = plt.subplots(1, 4, figsize=(14, 2)) plt.sca(axes[0]) plt.plot(changepoints) plt.title('Changepoint Matrix =') plt.sca(axes[1]) plt.plot(slope) plt.title('Slope +') plt.sca(axes[2]) plt.plot(bases) plt.title('(Basis functions') plt.sca(axes[3]) plot_weights(basis_weights) plt.title('× Weights)') plt.tight_layout()
Linear Changepoint Model with LASSO Nice question. I have more to say tomorrow, but for now the main point here is that your predictor matrix, changepoints is just a weighted matrix of piecewise linear basis functions, where the weights
42,269
Nonparametric theory textbook(s)?
I would recommend A Distribution-Free Theory of Nonparametric Regression by Györfi, Kohler, Krzyżak and Walk. It looks like what you are looking for: proofs use sigma fields as needed, there is plenty of use of dominated convergence and Fatou's Lemma, and it hits topics like kernels and k-nearest neighbors. The online notes from László Györfi seem like a smaller (i.e. much less complete) version of what you are looking for: there are sigma fields, dominated convergence proofs, etc. Maybe take a peek at that to see if you want to investigate the larger book by him and coauthors.
Nonparametric theory textbook(s)?
I would recommend A Distribution-Free Theory of Nonparametric Regression by Györfi, Kohler, Krzyżak and Walk. It looks like what you are looking for: proofs use sigma fields as needed, there is plenty
Nonparametric theory textbook(s)? I would recommend A Distribution-Free Theory of Nonparametric Regression by Györfi, Kohler, Krzyżak and Walk. It looks like what you are looking for: proofs use sigma fields as needed, there is plenty of use of dominated convergence and Fatou's Lemma, and it hits topics like kernels and k-nearest neighbors. The online notes from László Györfi seem like a smaller (i.e. much less complete) version of what you are looking for: there are sigma fields, dominated convergence proofs, etc. Maybe take a peek at that to see if you want to investigate the larger book by him and coauthors.
Nonparametric theory textbook(s)? I would recommend A Distribution-Free Theory of Nonparametric Regression by Györfi, Kohler, Krzyżak and Walk. It looks like what you are looking for: proofs use sigma fields as needed, there is plenty
42,270
Nonparametric theory textbook(s)?
There's a chapter in this book on nonparametric statistics: "Modern Statistical Methods for Astronomy With R Applications", Feigelson and Babu https://www.cambridge.org/us/academic/subjects/physics/astronomy-general/modern-statistical-methods-astronomy-r-applications?format=HB&isbn=9780521767279
Nonparametric theory textbook(s)?
There's a chapter in this book on nonparametric statistics: "Modern Statistical Methods for Astronomy With R Applications", Feigelson and Babu https://www.cambridge.org/us/academic/subjects/physics/as
Nonparametric theory textbook(s)? There's a chapter in this book on nonparametric statistics: "Modern Statistical Methods for Astronomy With R Applications", Feigelson and Babu https://www.cambridge.org/us/academic/subjects/physics/astronomy-general/modern-statistical-methods-astronomy-r-applications?format=HB&isbn=9780521767279
Nonparametric theory textbook(s)? There's a chapter in this book on nonparametric statistics: "Modern Statistical Methods for Astronomy With R Applications", Feigelson and Babu https://www.cambridge.org/us/academic/subjects/physics/as
42,271
Meaning of Gaussian mixture weights?
The simple answer is that the weights estimated by GMM seek to estimate the true weights of the GMM. Sticking the the one-dimensional case, a GMM has $K$ components, where each component is a different normal distribution. A classic example is to consider heights of humans: if you look at the density, it looks like it has two peaks (bimodal), but if you restrict to each gender, they looks like normal distributions. So you could think of the height of a human to be an indicator for gender, and then conditinoal on that indicator, height follows a normal distribution. That's exactly what a GMM models, and you can think of the weights as the probability of belonging to one of the $K$ components of the model. So in our example, the weights would just be the probability of being male and female. Now with GMM, you may not have access to who belongs to what gender, and so you need to use your data to, in some sense, simultaneously learn about the two distributions and also learn about which distribution an observation belongs to. This is typically done through expectation maximization (EM), where you start by assuming that the weights are uniform, so they are all $1/K$ (or $1/2$ in our example). Then, you proceed with the EM steps and in theory, the weights converge to the true weights. Intuitively, what you're doing is figuring out for each observation $i$ and component $k$ , you estimate the probability of observation $i$ belonging to component $k$. Denote this $p_{ik}$. Then the weight for $k$ is defined as $\frac{1}{n}\sum_{i=1}^n p_{ik}$,which can be thought of as the sample probability of a random observation belonging to component $k$, which is exactly what the weight is basically defining. Intuition of assignment of weights (and more generally, of EM procedure) To answer your comment (and updated post), the weights are the estimated probability of a draw belonging to each respective normal distribution (don't know the ordering, but that means that a random draw from your sample has a 48.6% chance of being in one of them, and a 51.3% chance of being in the other... note that they sum up to one!). As for how that is calculated, it's hard to provide much more than either intuition or the full blown calculations for the EM procedure, which you can easily find googling, but I'll give it a shot. Let's focus on your example. You start by specifying 2 distributions, and the EM process starts by assuming that each normal is equally likely to be assigned, and the variances of both normals are the same and equal to the variance of the entire sample. Then you randomly assign one observation to be the component mean for one of the two components, and another (distinct!) observation to the other component. So in your example, let's call the dark blue one component 1, and the turquoise one component 2. Since the true means are different, and since you randomly choose different observations for the mean estimate for each component, by definition one of two mean estimates will be closer to one of the two unknown true means. Then given those specifications, you calculate the probability of each observation belonging to each of the two components. For example, looking at your plot, for a point super far to the right, it will be more likely to belong to the component with initial mean further to the right than to the other one. Then based on these probabilities and the values, you update the weights, means, and variances of both components. Note that component two will quickly have a higher variance, since all those spread out values to the far right will all go to it. It may not yet pick up the far left ones, but as you keep doing this iterative procedure, eventually the variance of component one will get smaller, while the variance of component two will get larger. At a certain point, the variance of component 2 will be so great that the points to the way left will no longer be assigned to component 1, since although they are closer in terms of mean, they are not consistent with the spread of component one, which has a tighter variance, so they will start favoring component 2. I'm just talking about means and variances to illustrate, but you're also heavily abusing that the distributions are normal for this assignment process and figuring things out. Doing this over and over will slowly assign points to the correct components, and as you do that, the probability weights will also update accordingly. You basically do this until things dont change anymore, and the iterative process is done.
Meaning of Gaussian mixture weights?
The simple answer is that the weights estimated by GMM seek to estimate the true weights of the GMM. Sticking the the one-dimensional case, a GMM has $K$ components, where each component is a differen
Meaning of Gaussian mixture weights? The simple answer is that the weights estimated by GMM seek to estimate the true weights of the GMM. Sticking the the one-dimensional case, a GMM has $K$ components, where each component is a different normal distribution. A classic example is to consider heights of humans: if you look at the density, it looks like it has two peaks (bimodal), but if you restrict to each gender, they looks like normal distributions. So you could think of the height of a human to be an indicator for gender, and then conditinoal on that indicator, height follows a normal distribution. That's exactly what a GMM models, and you can think of the weights as the probability of belonging to one of the $K$ components of the model. So in our example, the weights would just be the probability of being male and female. Now with GMM, you may not have access to who belongs to what gender, and so you need to use your data to, in some sense, simultaneously learn about the two distributions and also learn about which distribution an observation belongs to. This is typically done through expectation maximization (EM), where you start by assuming that the weights are uniform, so they are all $1/K$ (or $1/2$ in our example). Then, you proceed with the EM steps and in theory, the weights converge to the true weights. Intuitively, what you're doing is figuring out for each observation $i$ and component $k$ , you estimate the probability of observation $i$ belonging to component $k$. Denote this $p_{ik}$. Then the weight for $k$ is defined as $\frac{1}{n}\sum_{i=1}^n p_{ik}$,which can be thought of as the sample probability of a random observation belonging to component $k$, which is exactly what the weight is basically defining. Intuition of assignment of weights (and more generally, of EM procedure) To answer your comment (and updated post), the weights are the estimated probability of a draw belonging to each respective normal distribution (don't know the ordering, but that means that a random draw from your sample has a 48.6% chance of being in one of them, and a 51.3% chance of being in the other... note that they sum up to one!). As for how that is calculated, it's hard to provide much more than either intuition or the full blown calculations for the EM procedure, which you can easily find googling, but I'll give it a shot. Let's focus on your example. You start by specifying 2 distributions, and the EM process starts by assuming that each normal is equally likely to be assigned, and the variances of both normals are the same and equal to the variance of the entire sample. Then you randomly assign one observation to be the component mean for one of the two components, and another (distinct!) observation to the other component. So in your example, let's call the dark blue one component 1, and the turquoise one component 2. Since the true means are different, and since you randomly choose different observations for the mean estimate for each component, by definition one of two mean estimates will be closer to one of the two unknown true means. Then given those specifications, you calculate the probability of each observation belonging to each of the two components. For example, looking at your plot, for a point super far to the right, it will be more likely to belong to the component with initial mean further to the right than to the other one. Then based on these probabilities and the values, you update the weights, means, and variances of both components. Note that component two will quickly have a higher variance, since all those spread out values to the far right will all go to it. It may not yet pick up the far left ones, but as you keep doing this iterative procedure, eventually the variance of component one will get smaller, while the variance of component two will get larger. At a certain point, the variance of component 2 will be so great that the points to the way left will no longer be assigned to component 1, since although they are closer in terms of mean, they are not consistent with the spread of component one, which has a tighter variance, so they will start favoring component 2. I'm just talking about means and variances to illustrate, but you're also heavily abusing that the distributions are normal for this assignment process and figuring things out. Doing this over and over will slowly assign points to the correct components, and as you do that, the probability weights will also update accordingly. You basically do this until things dont change anymore, and the iterative process is done.
Meaning of Gaussian mixture weights? The simple answer is that the weights estimated by GMM seek to estimate the true weights of the GMM. Sticking the the one-dimensional case, a GMM has $K$ components, where each component is a differen
42,272
Is power law distribution for extreme event special like normal distribution?
With respect to the first question, whether there is a convergence theorem leading to power-law distributions, the Extremal Types Theorem should be mentioned (Fisher and Tippett, 1928, Gnedenko 1934), leading to the three max-stable Extreme Value Distributions (Type I to III, also known as Gumbel, Fréchet and Weibull distributions). The Fréchet distribution or the Generalised Extreme Value (GEV) distribution with shape parameter $\xi>0$ is characterised by a fat tail. Maxima of long (asymptotically) sequences of e.g. the Cauchy, Student, or Pareto (power-law) distribution are Fréchet distributed, and it can also be shown that the Fréchet distribution is the so-called Penultimate distribution for maxima of the Gaussian distribution, even though the latter are asymptotically Gumbel (light tailed) distributed. So there is a general theorem related to the power-law distribution. With respect to the second question, I can point you to the book of Prof. Didier Sornette, "Critical Phenomena in Natural Sciences", where he provides extensive motivation from statistical physics for fat-tailed natural phenomena. PS: This is my first answer on a StackExchange site, in case you have tips or criticism, I'm happy for feedback!
Is power law distribution for extreme event special like normal distribution?
With respect to the first question, whether there is a convergence theorem leading to power-law distributions, the Extremal Types Theorem should be mentioned (Fisher and Tippett, 1928, Gnedenko 1934),
Is power law distribution for extreme event special like normal distribution? With respect to the first question, whether there is a convergence theorem leading to power-law distributions, the Extremal Types Theorem should be mentioned (Fisher and Tippett, 1928, Gnedenko 1934), leading to the three max-stable Extreme Value Distributions (Type I to III, also known as Gumbel, Fréchet and Weibull distributions). The Fréchet distribution or the Generalised Extreme Value (GEV) distribution with shape parameter $\xi>0$ is characterised by a fat tail. Maxima of long (asymptotically) sequences of e.g. the Cauchy, Student, or Pareto (power-law) distribution are Fréchet distributed, and it can also be shown that the Fréchet distribution is the so-called Penultimate distribution for maxima of the Gaussian distribution, even though the latter are asymptotically Gumbel (light tailed) distributed. So there is a general theorem related to the power-law distribution. With respect to the second question, I can point you to the book of Prof. Didier Sornette, "Critical Phenomena in Natural Sciences", where he provides extensive motivation from statistical physics for fat-tailed natural phenomena. PS: This is my first answer on a StackExchange site, in case you have tips or criticism, I'm happy for feedback!
Is power law distribution for extreme event special like normal distribution? With respect to the first question, whether there is a convergence theorem leading to power-law distributions, the Extremal Types Theorem should be mentioned (Fisher and Tippett, 1928, Gnedenko 1934),
42,273
Is power law distribution for extreme event special like normal distribution?
$\bullet$ First, heavy-tailed/Pareto distributions (aka power laws) frequently occur outside of finance and economy. They are used to describe the size/height/magnitude/severity distribution of countless natural phenomena. A few examples are ocean waves, volcanic eruptions, asteroid impacts (a well-known example is the size of the craters on the moon), tornadoes, forest fires, streamflow and floods, solar flares, landslides, rainfall... Other interesting human-related examples are the size of human settlements, size of files transferred on the web, Google's PageRank numbers of webpages... This is closely related to the field of extreme value analysis (hundred-year floods, rogue waves...) - see the answer by Joel listing some famous extreme value distributions. It is also to be noted that the empirical distributions (histograms, KDEs) of the phenomena above are heavy-tailed. In other words, we already observe the power-law naturally emerging in these phenomena. So yes, we do use parametric models to approximate the naturally occurring distributions, simulate values, etc., but I don't think we can say that it is artificial. (The paper Clauset et al. 2009 linked to by Sycorax in the comments above seems to be a good reference here.) $\bullet$ Second, as far as your question, while power-law distributions are frequently observed, the underlying physical processes by which they arise are still mostly unknown. Indeed, natural phenomena are complex. E.g., floods are produced by the interplay between meteorological and hydrological processes, but are also influenced by infrastructure (e.g., dams) and human activities (e.g., land use). Nevertheless, there are many underlying processes that are believed to generate fat tails in the distributions of natural and other human-related phenomena, such as: multiplicative processes (El Adlouni et al. 2008, Mitzenmacher 2004). random walks, the Yule process, self-organized criticality, inverses of quantities (Newman 2005). References Newman, Mark EJ. "Power laws, Pareto distributions and Zipf's law." Contemporary physics 46.5 (2005): 323-351. El Adlouni, S., B. Bobée, and T. B. M. J. Ouarda. "On the tails of extreme event distributions in hydrology." Journal of Hydrology 355.1-4 (2008): 16-33. Mitzenmacher, Michael. "A brief history of generative models for power law and lognormal distributions." Internet mathematics 1.2 (2004): 226-251. Clauset, Aaron, Cosma Rohilla Shalizi, and Mark EJ Newman. "Power-law distributions in empirical data." SIAM review 51.4 (2009): 661-703.
Is power law distribution for extreme event special like normal distribution?
$\bullet$ First, heavy-tailed/Pareto distributions (aka power laws) frequently occur outside of finance and economy. They are used to describe the size/height/magnitude/severity distribution of countl
Is power law distribution for extreme event special like normal distribution? $\bullet$ First, heavy-tailed/Pareto distributions (aka power laws) frequently occur outside of finance and economy. They are used to describe the size/height/magnitude/severity distribution of countless natural phenomena. A few examples are ocean waves, volcanic eruptions, asteroid impacts (a well-known example is the size of the craters on the moon), tornadoes, forest fires, streamflow and floods, solar flares, landslides, rainfall... Other interesting human-related examples are the size of human settlements, size of files transferred on the web, Google's PageRank numbers of webpages... This is closely related to the field of extreme value analysis (hundred-year floods, rogue waves...) - see the answer by Joel listing some famous extreme value distributions. It is also to be noted that the empirical distributions (histograms, KDEs) of the phenomena above are heavy-tailed. In other words, we already observe the power-law naturally emerging in these phenomena. So yes, we do use parametric models to approximate the naturally occurring distributions, simulate values, etc., but I don't think we can say that it is artificial. (The paper Clauset et al. 2009 linked to by Sycorax in the comments above seems to be a good reference here.) $\bullet$ Second, as far as your question, while power-law distributions are frequently observed, the underlying physical processes by which they arise are still mostly unknown. Indeed, natural phenomena are complex. E.g., floods are produced by the interplay between meteorological and hydrological processes, but are also influenced by infrastructure (e.g., dams) and human activities (e.g., land use). Nevertheless, there are many underlying processes that are believed to generate fat tails in the distributions of natural and other human-related phenomena, such as: multiplicative processes (El Adlouni et al. 2008, Mitzenmacher 2004). random walks, the Yule process, self-organized criticality, inverses of quantities (Newman 2005). References Newman, Mark EJ. "Power laws, Pareto distributions and Zipf's law." Contemporary physics 46.5 (2005): 323-351. El Adlouni, S., B. Bobée, and T. B. M. J. Ouarda. "On the tails of extreme event distributions in hydrology." Journal of Hydrology 355.1-4 (2008): 16-33. Mitzenmacher, Michael. "A brief history of generative models for power law and lognormal distributions." Internet mathematics 1.2 (2004): 226-251. Clauset, Aaron, Cosma Rohilla Shalizi, and Mark EJ Newman. "Power-law distributions in empirical data." SIAM review 51.4 (2009): 661-703.
Is power law distribution for extreme event special like normal distribution? $\bullet$ First, heavy-tailed/Pareto distributions (aka power laws) frequently occur outside of finance and economy. They are used to describe the size/height/magnitude/severity distribution of countl
42,274
Correlation between normal and log-normal variables
As is often the case, precisely formulating the question helped me work out the answer. My approach makes use of the marginal expectation of the bivariate normal: $$E_X(y) = E(X|Y=y) = \mu_x + \rho\frac{\sigma_x}{\sigma_y}(y-\mu_y)$$ Returning to my notation from the question above, this gives us: $$\begin{split}E(X_1Y_2) & = \int_{-\infty}^\infty \int_{-\infty}^\infty f(x,y)\cdot x \cdot e^y\:\mathrm{d}x\:\mathrm{d}y = \int_{-\infty}^\infty e^y \left(\int_{-\infty}^\infty x \cdot f(x,y) \:\mathrm{d}x\right)\mathrm{d}y\\ &= \int_{-\infty}^\infty e^y \cdot h(y) \cdot E_X(y)\:\mathrm{d}y \:=\,\int_{-\infty}^\infty e^y \cdot h(y) \cdot \left[\mu_1 + \rho\frac{\sigma_1}{\sigma_2}(y-\mu_2)\right]\:\mathrm{d}y\\ &= \mu_1\int_{-\infty}^\infty e^y \cdot h(y)\:\mathrm{d}y + \rho\frac{\sigma_1}{\sigma_2}\int_{-\infty}^\infty y \cdot e^y \cdot h(y)\:\mathrm{d}y - \mu_2\rho\frac{\sigma_1}{\sigma_2}\int_{-\infty}^\infty e^y \cdot h(y)\:\mathrm{d}y\\ &= \mu_1E(Y_2) + \rho\frac{\sigma_1}{\sigma_2}E(X_2Y_2) - \mu_2\rho\frac{\sigma_1}{\sigma_2}E(Y_2) \end{split}$$ The answer to a previous question gives us $E(X_2Y_2) = (\mu_2 + \sigma_2^2) \cdot E(Y_2)$, which gives us: $$\begin{split}E(X_1Y_2) & = \left[\mu_1 + \rho\frac{\sigma_1}{\sigma_2}(\mu_2 + \sigma_2^2) - \mu_2\rho\frac{\sigma_1}{\sigma_2}\right] \cdot E(Y_2) \\ &= \left[\mu_1 + \mu_2\rho\frac{\sigma_1}{\sigma_2} + \rho\sigma_1\sigma_2 - \mu_2\rho\frac{\sigma_1}{\sigma_2}\right] \cdot E(Y_2) \\ &= \left[\mu_1 + \rho\sigma_1\sigma_2\right] \cdot E(Y_2) \end{split}$$ where $h(x)$ is the marginal PDF of $X_2 \sim N(\mu_2,\sigma_2)$. This then gives us $$\begin{split}\mathrm{Cov}(X_1,Y_2) & = E(X_1Y_2) - E(X_1)E(Y_2) \\ &= \left[\mu_1 + \rho\sigma_1\sigma_2\right] \cdot E(Y_2) - \mu_1 \cdot E(Y_2)\\ &= \rho\sigma_1\sigma_2 \cdot E(Y_2) \end{split}$$ And hence $$\begin{split}\mathrm{Corr}(X_1,Y_2) & = \frac{\mathrm{Cov}(X_1,Y_2)}{\mathrm{sd}(X_1)\cdot\mathrm{sd}(Y_2)} = \frac{\rho\sigma_1\sigma_2 \cdot E(Y_2)}{\sigma_1\cdot\mathrm{sd}(Y_2)} = \boldsymbol{\rho\sigma_2\frac{E(Y_2)}{\mathrm{sd}(Y_2)}} \end{split}$$ The formulae for $E(Y_2)$ and $\mathrm{sd}(Y_2)$ can be found here.
Correlation between normal and log-normal variables
As is often the case, precisely formulating the question helped me work out the answer. My approach makes use of the marginal expectation of the bivariate normal: $$E_X(y) = E(X|Y=y) = \mu_x + \rho\fr
Correlation between normal and log-normal variables As is often the case, precisely formulating the question helped me work out the answer. My approach makes use of the marginal expectation of the bivariate normal: $$E_X(y) = E(X|Y=y) = \mu_x + \rho\frac{\sigma_x}{\sigma_y}(y-\mu_y)$$ Returning to my notation from the question above, this gives us: $$\begin{split}E(X_1Y_2) & = \int_{-\infty}^\infty \int_{-\infty}^\infty f(x,y)\cdot x \cdot e^y\:\mathrm{d}x\:\mathrm{d}y = \int_{-\infty}^\infty e^y \left(\int_{-\infty}^\infty x \cdot f(x,y) \:\mathrm{d}x\right)\mathrm{d}y\\ &= \int_{-\infty}^\infty e^y \cdot h(y) \cdot E_X(y)\:\mathrm{d}y \:=\,\int_{-\infty}^\infty e^y \cdot h(y) \cdot \left[\mu_1 + \rho\frac{\sigma_1}{\sigma_2}(y-\mu_2)\right]\:\mathrm{d}y\\ &= \mu_1\int_{-\infty}^\infty e^y \cdot h(y)\:\mathrm{d}y + \rho\frac{\sigma_1}{\sigma_2}\int_{-\infty}^\infty y \cdot e^y \cdot h(y)\:\mathrm{d}y - \mu_2\rho\frac{\sigma_1}{\sigma_2}\int_{-\infty}^\infty e^y \cdot h(y)\:\mathrm{d}y\\ &= \mu_1E(Y_2) + \rho\frac{\sigma_1}{\sigma_2}E(X_2Y_2) - \mu_2\rho\frac{\sigma_1}{\sigma_2}E(Y_2) \end{split}$$ The answer to a previous question gives us $E(X_2Y_2) = (\mu_2 + \sigma_2^2) \cdot E(Y_2)$, which gives us: $$\begin{split}E(X_1Y_2) & = \left[\mu_1 + \rho\frac{\sigma_1}{\sigma_2}(\mu_2 + \sigma_2^2) - \mu_2\rho\frac{\sigma_1}{\sigma_2}\right] \cdot E(Y_2) \\ &= \left[\mu_1 + \mu_2\rho\frac{\sigma_1}{\sigma_2} + \rho\sigma_1\sigma_2 - \mu_2\rho\frac{\sigma_1}{\sigma_2}\right] \cdot E(Y_2) \\ &= \left[\mu_1 + \rho\sigma_1\sigma_2\right] \cdot E(Y_2) \end{split}$$ where $h(x)$ is the marginal PDF of $X_2 \sim N(\mu_2,\sigma_2)$. This then gives us $$\begin{split}\mathrm{Cov}(X_1,Y_2) & = E(X_1Y_2) - E(X_1)E(Y_2) \\ &= \left[\mu_1 + \rho\sigma_1\sigma_2\right] \cdot E(Y_2) - \mu_1 \cdot E(Y_2)\\ &= \rho\sigma_1\sigma_2 \cdot E(Y_2) \end{split}$$ And hence $$\begin{split}\mathrm{Corr}(X_1,Y_2) & = \frac{\mathrm{Cov}(X_1,Y_2)}{\mathrm{sd}(X_1)\cdot\mathrm{sd}(Y_2)} = \frac{\rho\sigma_1\sigma_2 \cdot E(Y_2)}{\sigma_1\cdot\mathrm{sd}(Y_2)} = \boldsymbol{\rho\sigma_2\frac{E(Y_2)}{\mathrm{sd}(Y_2)}} \end{split}$$ The formulae for $E(Y_2)$ and $\mathrm{sd}(Y_2)$ can be found here.
Correlation between normal and log-normal variables As is often the case, precisely formulating the question helped me work out the answer. My approach makes use of the marginal expectation of the bivariate normal: $$E_X(y) = E(X|Y=y) = \mu_x + \rho\fr
42,275
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to use the Kruskal-Wallis test?
I think these are very valid questions. Sequential testing leads to the problem of multiple testing. For this problem, plenty of corrections are easily available (Bonferroni being the simplest and probably most popular). The real problem with sequential applying the Mann-Whitney-U-Test is that it can lead to inconsistent test decisions like the following: A < B < C < A. You can apply Kruskal-Wallis test and afterwards Dunn's test to avoid this lack of transitivity. However the actual issue cannot be solved, since the inherent problem is in the null hypothesis of these types of tests (see my point 3). Since you have only few data available, you won't be able to show that your data nicely follows a normal distribution. However, due to the same reason, you will not be able to show that it does probably not follow a normal distribution. Hence, just assuming it is not normal is usually considered as acceptable. This is a commong misunderstanding in the context of Mann-Whitney test which can be found in almost all commercial statistical software programs and in many introductory textbooks. The Mann-Whitney test is not a test for medians and it does not assume the distributions to have identical shapes. Under very strict assumptions, which particularly is identical shape of distributions, its results can be interpreted as a test for median, but it is usually impossible to reliably check these assumptions. The Mann-Whitney test is a test for stochastical equality of distributions. More precisely, it tests the null hypothesis that the probability of one randomly selected individual being greater than a randomly selected individual from the other group is equal to 50%. The same applies to the Kruskal-Wallis test. A great resource for this and much more information is: George W. Divine, H. James Norton, Anna E. Barón & Elizabeth Juarez-Colunga (2018) The Wilcoxon–Mann–Whitney Procedure Fails as a Test of Medians, The American Statistician, 72:3, 278-286, DOI: 10.1080/00031305.2017.1305291 But regarding your data: you have time-to-event data. That is a particular kind of data, that requires particular statistical modelling, depending on the discipline these may be known as survival, time-to-event or failure analysis. You may read into that. In general, with such small datasets I would prefer do rely more on descriptive statistics (i.e. visualization, e.g. via Kaplan-Meier curves) than on inferential statistics (i.e. p-values based on complex statistical models).
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to u
I think these are very valid questions. Sequential testing leads to the problem of multiple testing. For this problem, plenty of corrections are easily available (Bonferroni being the simplest and pr
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to use the Kruskal-Wallis test? I think these are very valid questions. Sequential testing leads to the problem of multiple testing. For this problem, plenty of corrections are easily available (Bonferroni being the simplest and probably most popular). The real problem with sequential applying the Mann-Whitney-U-Test is that it can lead to inconsistent test decisions like the following: A < B < C < A. You can apply Kruskal-Wallis test and afterwards Dunn's test to avoid this lack of transitivity. However the actual issue cannot be solved, since the inherent problem is in the null hypothesis of these types of tests (see my point 3). Since you have only few data available, you won't be able to show that your data nicely follows a normal distribution. However, due to the same reason, you will not be able to show that it does probably not follow a normal distribution. Hence, just assuming it is not normal is usually considered as acceptable. This is a commong misunderstanding in the context of Mann-Whitney test which can be found in almost all commercial statistical software programs and in many introductory textbooks. The Mann-Whitney test is not a test for medians and it does not assume the distributions to have identical shapes. Under very strict assumptions, which particularly is identical shape of distributions, its results can be interpreted as a test for median, but it is usually impossible to reliably check these assumptions. The Mann-Whitney test is a test for stochastical equality of distributions. More precisely, it tests the null hypothesis that the probability of one randomly selected individual being greater than a randomly selected individual from the other group is equal to 50%. The same applies to the Kruskal-Wallis test. A great resource for this and much more information is: George W. Divine, H. James Norton, Anna E. Barón & Elizabeth Juarez-Colunga (2018) The Wilcoxon–Mann–Whitney Procedure Fails as a Test of Medians, The American Statistician, 72:3, 278-286, DOI: 10.1080/00031305.2017.1305291 But regarding your data: you have time-to-event data. That is a particular kind of data, that requires particular statistical modelling, depending on the discipline these may be known as survival, time-to-event or failure analysis. You may read into that. In general, with such small datasets I would prefer do rely more on descriptive statistics (i.e. visualization, e.g. via Kaplan-Meier curves) than on inferential statistics (i.e. p-values based on complex statistical models).
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to u I think these are very valid questions. Sequential testing leads to the problem of multiple testing. For this problem, plenty of corrections are easily available (Bonferroni being the simplest and pr
42,276
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to use the Kruskal-Wallis test?
Point by point answers: You should do Kruskall-Wallis test. The problem with multiple Mann-Whitney tests, or broadly speaking multiple pairwise comparisons has a name - Multiple Comparisons Problem. The wikipedia article linked is a good start but you'll find several explanations if you google "multiple comparisons problem". No, Kruskall-wallis does not assume data to be normally distributed. It does require that data from different factors have similar shape. More information on assumptions made by Kruskall-wallis tests are here, here, and here. You can info on relevant R function here. Be particularly aware of the "shape" of data assumption as discussed here. You can look into Welch's anova which makes fewer assumptions. Hope this helps.
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to u
Point by point answers: You should do Kruskall-Wallis test. The problem with multiple Mann-Whitney tests, or broadly speaking multiple pairwise comparisons has a name - Multiple Comparisons Problem.
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to use the Kruskal-Wallis test? Point by point answers: You should do Kruskall-Wallis test. The problem with multiple Mann-Whitney tests, or broadly speaking multiple pairwise comparisons has a name - Multiple Comparisons Problem. The wikipedia article linked is a good start but you'll find several explanations if you google "multiple comparisons problem". No, Kruskall-wallis does not assume data to be normally distributed. It does require that data from different factors have similar shape. More information on assumptions made by Kruskall-wallis tests are here, here, and here. You can info on relevant R function here. Be particularly aware of the "shape" of data assumption as discussed here. You can look into Welch's anova which makes fewer assumptions. Hope this helps.
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to u Point by point answers: You should do Kruskall-Wallis test. The problem with multiple Mann-Whitney tests, or broadly speaking multiple pairwise comparisons has a name - Multiple Comparisons Problem.
42,277
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to use the Kruskal-Wallis test?
Before employing non-parametric sample test, as you are, in effect, doing a failure analysis, perhaps explore the underlying data from the perspective of Reliability Theory. In particular, compute an empirical hazard function (see this lecture). Note, the exponential distribution is characterized by a constant instantaneous failure rate, and further, it is the most common failure density observed in reliability work. If you can make a data-based argument on the failure law, no need for a less powerful non-parametric approach. However, if pursuing a non-parametric analysis, to quote Wikipedia on a test you cited: The Kruskal–Wallis test by ranks, Kruskal–Wallis H test[1] (named after William Kruskal and W. Allen Wallis), or one-way ANOVA on ranks[1] is a non-parametric method for testing whether samples originate from the same distribution.[2][3][4] It is used for comparing two or more independent samples of equal or different sample sizes. It extends the Mann–Whitney U test, which is used for comparing only two groups. The parametric equivalent of the Kruskal–Wallis test is the one-way analysis of variance (ANOVA). So, it appears to be a valid choice.
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to u
Before employing non-parametric sample test, as you are, in effect, doing a failure analysis, perhaps explore the underlying data from the perspective of Reliability Theory. In particular, compute an
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to use the Kruskal-Wallis test? Before employing non-parametric sample test, as you are, in effect, doing a failure analysis, perhaps explore the underlying data from the perspective of Reliability Theory. In particular, compute an empirical hazard function (see this lecture). Note, the exponential distribution is characterized by a constant instantaneous failure rate, and further, it is the most common failure density observed in reliability work. If you can make a data-based argument on the failure law, no need for a less powerful non-parametric approach. However, if pursuing a non-parametric analysis, to quote Wikipedia on a test you cited: The Kruskal–Wallis test by ranks, Kruskal–Wallis H test[1] (named after William Kruskal and W. Allen Wallis), or one-way ANOVA on ranks[1] is a non-parametric method for testing whether samples originate from the same distribution.[2][3][4] It is used for comparing two or more independent samples of equal or different sample sizes. It extends the Mann–Whitney U test, which is used for comparing only two groups. The parametric equivalent of the Kruskal–Wallis test is the one-way analysis of variance (ANOVA). So, it appears to be a valid choice.
Can I use the Mann-Whitney U test sequentially (pairwise) when I have three groups or do I need to u Before employing non-parametric sample test, as you are, in effect, doing a failure analysis, perhaps explore the underlying data from the perspective of Reliability Theory. In particular, compute an
42,278
Markov chain as sum of iid random variables
I think you are somehow mixing independence and conditional independence. The idea is not that $X_{n+1}$ is independent from $X_0 ... X_{n-1}$, but that it is conditionally independent given $X_n$. This simply means that, once you know the value of $X_n$, the previous values $X_0...X_{n-1}$ are irrelevant for the distribution of $X_{n+1}$. Taking your example, let us assume that $X_n = 5$. Now, when we want to predict the value of $X_{n+1}$, knowing the values of $X_0...X_{n-1},Z_0...Z_{n-1}$ is completely irrelevant. Nothing changes in your prediction if $X_{n-1}=4$ or $X_{n-1}=5$, once you know that $X_n = 5$. Now: $$\mathbb{P}(X_{n+1}=x_{n+1}|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( \sum_0^{n+1}Z_i =x_{n+1}|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( X_n + Z_{n+1} =x_{n+1}|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( Z_{n+1} =x_{n+1}-x_n|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( Z_{n+1} =x_{n+1}-x_n|X_n=x_n)$$ $$\mathbb{P}( X_{n+1} =x_{n+1}|X_n=x_n)$$ We were able to remove the conditioning on all $X_i$ for i smaller than $n$ because our probability is only a function of $Z_{n+1}$ (which is independent from them as a consequence of its independence from all $Z_i$), and of $x_n$ which is a given value. This gives you a Markov Chain with infinite states, where every state has a transition probability of $p$ to the next state (+1) and $1-p$ to itself. The same reasoning applies to $\Pi_n$. This will instead only have two states ${0,1}$. State $0$ is an attractor, so it has transition probability $p=1$ to itself, while from state $1$ has probability $p$ of transition to itself, and probability $1-p$ of going to state $0$. Now, (3) is NOT a Markov chain. $$\mathbb{P}(X_{n+1}=x_{n+1}|X_0=x_0...X_n=x_n)$$ $$\mathbb{P}(X_n + S_n+Z_{n+1}|X_0=x_0 ... X_n=x_n)$$ Here, however, we have no way of knowing the value of $S_n$ just by $X_n$. Knowing for example that $X_n=10$ would simply mean that $\sum_0^nS_i=10$, but we cannot infer the value of $S_n$ without peeking at the previous "history". Therefore, the markovian property does not hold. (4), on the other hand, is a Markov Chain (I will use $(x,y)$ notation since now $X$ is multivariate). $$\mathbb{P}(X_{n+1}=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ $$\mathbb{P}((S_{n+1},\sum_0^{n+1}S_i)=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ $$\mathbb{P}((S_{n}+Z_{n+1},\sum_0^{n}S_i+S_{n}+Z_{n+1})=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ $$\mathbb{P}((x_{n}+Z_{n+1},y_n+x_{n}+Z_{n+1})=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ Again, this is only a function of $Z_{n+1}$ (which is independent of previous $S_i$) and of $(x_n,y_n)$, and we can therefore remove conditioning on previous values as they are redundant. $$\mathbb{P}((x_{n}+Z_{n+1},y_n+x_{n}+Z_{n+1})=(x_{n+1},y_{n+1})|X_n=(x_{n},y_{n}))$$ $$\mathbb{P}(X_{n+1}=(x_{n+1},y_{n+1})|X_n=(x_{n},y_{n}))$$ Which makes it Markovian. I hope the logical passages are clear enough, otherwise let me know!
Markov chain as sum of iid random variables
I think you are somehow mixing independence and conditional independence. The idea is not that $X_{n+1}$ is independent from $X_0 ... X_{n-1}$, but that it is conditionally independent given $X_n$.
Markov chain as sum of iid random variables I think you are somehow mixing independence and conditional independence. The idea is not that $X_{n+1}$ is independent from $X_0 ... X_{n-1}$, but that it is conditionally independent given $X_n$. This simply means that, once you know the value of $X_n$, the previous values $X_0...X_{n-1}$ are irrelevant for the distribution of $X_{n+1}$. Taking your example, let us assume that $X_n = 5$. Now, when we want to predict the value of $X_{n+1}$, knowing the values of $X_0...X_{n-1},Z_0...Z_{n-1}$ is completely irrelevant. Nothing changes in your prediction if $X_{n-1}=4$ or $X_{n-1}=5$, once you know that $X_n = 5$. Now: $$\mathbb{P}(X_{n+1}=x_{n+1}|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( \sum_0^{n+1}Z_i =x_{n+1}|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( X_n + Z_{n+1} =x_{n+1}|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( Z_{n+1} =x_{n+1}-x_n|X_0=x_0,...,X_n=x_n)$$ $$\mathbb{P}( Z_{n+1} =x_{n+1}-x_n|X_n=x_n)$$ $$\mathbb{P}( X_{n+1} =x_{n+1}|X_n=x_n)$$ We were able to remove the conditioning on all $X_i$ for i smaller than $n$ because our probability is only a function of $Z_{n+1}$ (which is independent from them as a consequence of its independence from all $Z_i$), and of $x_n$ which is a given value. This gives you a Markov Chain with infinite states, where every state has a transition probability of $p$ to the next state (+1) and $1-p$ to itself. The same reasoning applies to $\Pi_n$. This will instead only have two states ${0,1}$. State $0$ is an attractor, so it has transition probability $p=1$ to itself, while from state $1$ has probability $p$ of transition to itself, and probability $1-p$ of going to state $0$. Now, (3) is NOT a Markov chain. $$\mathbb{P}(X_{n+1}=x_{n+1}|X_0=x_0...X_n=x_n)$$ $$\mathbb{P}(X_n + S_n+Z_{n+1}|X_0=x_0 ... X_n=x_n)$$ Here, however, we have no way of knowing the value of $S_n$ just by $X_n$. Knowing for example that $X_n=10$ would simply mean that $\sum_0^nS_i=10$, but we cannot infer the value of $S_n$ without peeking at the previous "history". Therefore, the markovian property does not hold. (4), on the other hand, is a Markov Chain (I will use $(x,y)$ notation since now $X$ is multivariate). $$\mathbb{P}(X_{n+1}=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ $$\mathbb{P}((S_{n+1},\sum_0^{n+1}S_i)=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ $$\mathbb{P}((S_{n}+Z_{n+1},\sum_0^{n}S_i+S_{n}+Z_{n+1})=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ $$\mathbb{P}((x_{n}+Z_{n+1},y_n+x_{n}+Z_{n+1})=(x_{n+1},y_{n+1})|X_0=(x_{0},y_{0})...X_n=(x_{n},y_{n}))$$ Again, this is only a function of $Z_{n+1}$ (which is independent of previous $S_i$) and of $(x_n,y_n)$, and we can therefore remove conditioning on previous values as they are redundant. $$\mathbb{P}((x_{n}+Z_{n+1},y_n+x_{n}+Z_{n+1})=(x_{n+1},y_{n+1})|X_n=(x_{n},y_{n}))$$ $$\mathbb{P}(X_{n+1}=(x_{n+1},y_{n+1})|X_n=(x_{n},y_{n}))$$ Which makes it Markovian. I hope the logical passages are clear enough, otherwise let me know!
Markov chain as sum of iid random variables I think you are somehow mixing independence and conditional independence. The idea is not that $X_{n+1}$ is independent from $X_0 ... X_{n-1}$, but that it is conditionally independent given $X_n$.
42,279
Question about Casella and Berger's proof of MLE invariance
The occurrences of suprema (instead of maxima, which might not exist) are troublesome. Let us therefore isolate the basic underlying idea and rigorously establish it. Definitions Suppose $f:\Theta\to\mathbb{R}$ is any real-valued function on a set $\Theta.$ By definition, its supremum is the least upper bound of the values of $f:$ $$\sup_{\theta\in\Theta} f(\theta) = \operatorname{lub}\, \{f(\theta)\mid \theta\in\Theta\}.$$ As a shorthand, I will write $f^{*}_\Theta$ for this supremum. The least upper bound of a set of real numbers $\mathcal A,$ written $\operatorname{lub}\,\mathcal A,$ is a number $x\in \mathbb{R}\cup \{\pm\infty\}$ (having the obvious ordering relation) with two defining properties (which, according to the axioms of Real numbers, make it unique): For all $a\in\mathcal A,$ $a \le x.$ If $y$ is any number in $\mathbb{R}\cup \{\pm\infty\}$ satisfying (1), then $y \ge x.$ The Underlying Idea Let $\Theta= \bigcup_{\mathcal A \in \mathbf{A}} \mathcal A$ be a union of sets. For each such $\mathcal A$ let $f_{\mathcal A}$ be the restriction of $f$ to $\mathcal A.$ The claim is $$\sup_{\mathcal A \in \mathbf{A}} f^{*}_{\mathcal A} = f^{*}_\Theta.$$ This is demonstrated in two steps. First, when we assemble a bunch of suprema of $f$ over subsets of $\Theta,$ they cannot exceed the supremum of $f$ on $\Theta.$ Indeed, consider a set $\mathcal A\in \mathbf A.$ Because $\mathcal A$ is a subset of $\Theta,$ none of its elements exceed $f^{*}_\Theta.$ Consequently (by part (2) of the definition) $f^{*}_{\mathcal A} \le f^{*}_\Theta.$ A fortiori, $f^{*}_\Theta$ is an upper bound of all the $f^{*}_{\mathcal A},$ proving that $$\sup_{\mathcal A \in \mathbf{A}} f^{*}_{\mathcal A} \le f^{*}_\Theta.\tag{*}$$ Second, let $y$ be an upper bound for all the $f^{*}_{\mathcal A}$ and let $\theta\in\Theta.$ Because $\Theta= \bigcup \mathcal A,$ there exists an $\mathcal A$ for which $\theta\in\mathcal A.$ Because $y \ge f^{*}_{\mathcal A},$ $y \ge \theta.$ Therefore (by part (2) of the definition), $y \ge f^{*}_\Theta.$ Because all upper bounds of the $f^{*}_{\mathcal A}$ exceed $f^{*}_\Theta,$ $$\sup_{\mathcal A \in \mathbf{A}} f^{*}_{\mathcal A} \ge f^{*}_\Theta.\tag{**}$$ The statements $(*)$ and $(**)$ prove the claim. Application to Maximizing Likelihoods The likelihood $\mathcal L$ is a function on a set $\Theta$ of distributions. (I drop the reference to the data $X$ because $X$ will never change during this discussion.) Given another function $g$ on this set, $\Theta$ can be expressed as the union of its level sets, $$\Theta = \bigcup_{\eta\in\mathbb R} g^{-1}(\eta) = \bigcup_{\mathcal A \in \mathbf A} \mathcal A$$ where $\mathbf A$ is this collection of level sets. In terms of the notation used in the question, our previously proven claim is the middle equality in $$\sup_{\eta\in\mathbb R} \mathcal L^{*}(\eta) =\sup_{\eta\in\mathbb R} \mathcal L^{*}_{g^{-1}(\eta)} = \mathcal L^{*}_\Theta = \sup_{\theta\in\Theta}\mathcal{L}(\theta),$$ precisely as stated in the question. Conclusions This relationship between the "induced likelihood" and likelihood has nothing whatsoever to do with properties of likelihood, random variables, or anything else statistical: it is purely a statement about upper bounds of values attained by a function on a set. The least upper bound can be defined with respect to the entire set $(\mathcal{L}^{*}_\Theta)$ or it can be found in stages by first taking the least upper bounds of subsets of the set $(\mathcal{L}^{*}_{g^{-1}(\eta)})$ and then finding the least upper bound of those upper bounds.
Question about Casella and Berger's proof of MLE invariance
The occurrences of suprema (instead of maxima, which might not exist) are troublesome. Let us therefore isolate the basic underlying idea and rigorously establish it. Definitions Suppose $f:\Theta\to
Question about Casella and Berger's proof of MLE invariance The occurrences of suprema (instead of maxima, which might not exist) are troublesome. Let us therefore isolate the basic underlying idea and rigorously establish it. Definitions Suppose $f:\Theta\to\mathbb{R}$ is any real-valued function on a set $\Theta.$ By definition, its supremum is the least upper bound of the values of $f:$ $$\sup_{\theta\in\Theta} f(\theta) = \operatorname{lub}\, \{f(\theta)\mid \theta\in\Theta\}.$$ As a shorthand, I will write $f^{*}_\Theta$ for this supremum. The least upper bound of a set of real numbers $\mathcal A,$ written $\operatorname{lub}\,\mathcal A,$ is a number $x\in \mathbb{R}\cup \{\pm\infty\}$ (having the obvious ordering relation) with two defining properties (which, according to the axioms of Real numbers, make it unique): For all $a\in\mathcal A,$ $a \le x.$ If $y$ is any number in $\mathbb{R}\cup \{\pm\infty\}$ satisfying (1), then $y \ge x.$ The Underlying Idea Let $\Theta= \bigcup_{\mathcal A \in \mathbf{A}} \mathcal A$ be a union of sets. For each such $\mathcal A$ let $f_{\mathcal A}$ be the restriction of $f$ to $\mathcal A.$ The claim is $$\sup_{\mathcal A \in \mathbf{A}} f^{*}_{\mathcal A} = f^{*}_\Theta.$$ This is demonstrated in two steps. First, when we assemble a bunch of suprema of $f$ over subsets of $\Theta,$ they cannot exceed the supremum of $f$ on $\Theta.$ Indeed, consider a set $\mathcal A\in \mathbf A.$ Because $\mathcal A$ is a subset of $\Theta,$ none of its elements exceed $f^{*}_\Theta.$ Consequently (by part (2) of the definition) $f^{*}_{\mathcal A} \le f^{*}_\Theta.$ A fortiori, $f^{*}_\Theta$ is an upper bound of all the $f^{*}_{\mathcal A},$ proving that $$\sup_{\mathcal A \in \mathbf{A}} f^{*}_{\mathcal A} \le f^{*}_\Theta.\tag{*}$$ Second, let $y$ be an upper bound for all the $f^{*}_{\mathcal A}$ and let $\theta\in\Theta.$ Because $\Theta= \bigcup \mathcal A,$ there exists an $\mathcal A$ for which $\theta\in\mathcal A.$ Because $y \ge f^{*}_{\mathcal A},$ $y \ge \theta.$ Therefore (by part (2) of the definition), $y \ge f^{*}_\Theta.$ Because all upper bounds of the $f^{*}_{\mathcal A}$ exceed $f^{*}_\Theta,$ $$\sup_{\mathcal A \in \mathbf{A}} f^{*}_{\mathcal A} \ge f^{*}_\Theta.\tag{**}$$ The statements $(*)$ and $(**)$ prove the claim. Application to Maximizing Likelihoods The likelihood $\mathcal L$ is a function on a set $\Theta$ of distributions. (I drop the reference to the data $X$ because $X$ will never change during this discussion.) Given another function $g$ on this set, $\Theta$ can be expressed as the union of its level sets, $$\Theta = \bigcup_{\eta\in\mathbb R} g^{-1}(\eta) = \bigcup_{\mathcal A \in \mathbf A} \mathcal A$$ where $\mathbf A$ is this collection of level sets. In terms of the notation used in the question, our previously proven claim is the middle equality in $$\sup_{\eta\in\mathbb R} \mathcal L^{*}(\eta) =\sup_{\eta\in\mathbb R} \mathcal L^{*}_{g^{-1}(\eta)} = \mathcal L^{*}_\Theta = \sup_{\theta\in\Theta}\mathcal{L}(\theta),$$ precisely as stated in the question. Conclusions This relationship between the "induced likelihood" and likelihood has nothing whatsoever to do with properties of likelihood, random variables, or anything else statistical: it is purely a statement about upper bounds of values attained by a function on a set. The least upper bound can be defined with respect to the entire set $(\mathcal{L}^{*}_\Theta)$ or it can be found in stages by first taking the least upper bounds of subsets of the set $(\mathcal{L}^{*}_{g^{-1}(\eta)})$ and then finding the least upper bound of those upper bounds.
Question about Casella and Berger's proof of MLE invariance The occurrences of suprema (instead of maxima, which might not exist) are troublesome. Let us therefore isolate the basic underlying idea and rigorously establish it. Definitions Suppose $f:\Theta\to
42,280
Akaike Information Criterion (AIC) derivation
Consider scalar parameters $\theta_0$ and the corresponding scalar estimate $\hat \theta$ for simplicity. I will answer Q1 and Q3 which are essentially asking why is the mean of the score function $\Bbb{E}_{\theta}(s(\theta)) =0 $. This is a widely known result.. To put it simply, Notice that score function $s(\theta)$ depends of the random observations $X$. We can take its expectation as follows: \begin{align} \Bbb{E}_{\theta}(s) & = \int_x f(x;\theta) \frac{\partial \log f(x;\theta)}{\partial \theta} dx \\ &=\int_x \frac{\partial f(x;\theta)}{\partial \theta} dx = 0 \qquad \text{(exchanging integral and derivative)} \end{align} Now, notice that $S_n$ is nothing but averaged-sum of score functions based on independent observations. Hence, its expectation will also be zero. For Q2) the motivation is to find study the asymptotic properties of our estimator wrt to the true parameter. Let $\hat{\theta}$ be the maximizer of $L_{n}(\theta)=\frac{1}{n} \sum_{i=1}^{n} \log f\left(X_{i} | \theta\right)$. Now, by meanvalue theorem \begin{align} 0=L_{n}^{\prime}(\hat{\theta}) & =L_{n}^{\prime}\left(\theta_{0}\right)+L_{n}^{\prime \prime}\left(\hat{\theta}_{1}\right)\left(\hat{\theta}-\theta_{0}\right) \quad \text{(for some $\theta_1 \in [\hat\theta,\theta_0]$)}\\ \implies & \left(\hat{\theta}-\theta_{0}\right) = \frac{L_{n}^{\prime}\left(\theta_{0}\right)}{L_{n}^{\prime \prime}\left(\hat{\theta}_{1}\right)} \end{align} Consider the numerator: \begin{align} \sqrt{n}\left(\frac{1}{n} \sum_{i=1}^{n} l^{\prime}\left(X_{i} | \theta_{0}\right)-\mathbb{E}_{\theta_{0}} l^{\prime}\left(X_{1} | \theta_{0}\right)\right) & = \sqrt{n}(S_n - \Bbb{E}(S_n)) \\ & \rightarrow N\left(0, \operatorname{Var}_{\theta_{0}}\left(l^{\prime}\left(X_{1} | \theta_{0}\right)\right)\right) = N(0,V) \end{align} Now, the denominator $L^{''}_n$ coverges to the Fisher's information $(J)$ by LLN. Therefore, for the scalar paramters case, we can see that $$\sqrt{n}(\hat \theta - \theta_0) \rightarrow N(0,\frac{V}{J^2})$$
Akaike Information Criterion (AIC) derivation
Consider scalar parameters $\theta_0$ and the corresponding scalar estimate $\hat \theta$ for simplicity. I will answer Q1 and Q3 which are essentially asking why is the mean of the score function $\
Akaike Information Criterion (AIC) derivation Consider scalar parameters $\theta_0$ and the corresponding scalar estimate $\hat \theta$ for simplicity. I will answer Q1 and Q3 which are essentially asking why is the mean of the score function $\Bbb{E}_{\theta}(s(\theta)) =0 $. This is a widely known result.. To put it simply, Notice that score function $s(\theta)$ depends of the random observations $X$. We can take its expectation as follows: \begin{align} \Bbb{E}_{\theta}(s) & = \int_x f(x;\theta) \frac{\partial \log f(x;\theta)}{\partial \theta} dx \\ &=\int_x \frac{\partial f(x;\theta)}{\partial \theta} dx = 0 \qquad \text{(exchanging integral and derivative)} \end{align} Now, notice that $S_n$ is nothing but averaged-sum of score functions based on independent observations. Hence, its expectation will also be zero. For Q2) the motivation is to find study the asymptotic properties of our estimator wrt to the true parameter. Let $\hat{\theta}$ be the maximizer of $L_{n}(\theta)=\frac{1}{n} \sum_{i=1}^{n} \log f\left(X_{i} | \theta\right)$. Now, by meanvalue theorem \begin{align} 0=L_{n}^{\prime}(\hat{\theta}) & =L_{n}^{\prime}\left(\theta_{0}\right)+L_{n}^{\prime \prime}\left(\hat{\theta}_{1}\right)\left(\hat{\theta}-\theta_{0}\right) \quad \text{(for some $\theta_1 \in [\hat\theta,\theta_0]$)}\\ \implies & \left(\hat{\theta}-\theta_{0}\right) = \frac{L_{n}^{\prime}\left(\theta_{0}\right)}{L_{n}^{\prime \prime}\left(\hat{\theta}_{1}\right)} \end{align} Consider the numerator: \begin{align} \sqrt{n}\left(\frac{1}{n} \sum_{i=1}^{n} l^{\prime}\left(X_{i} | \theta_{0}\right)-\mathbb{E}_{\theta_{0}} l^{\prime}\left(X_{1} | \theta_{0}\right)\right) & = \sqrt{n}(S_n - \Bbb{E}(S_n)) \\ & \rightarrow N\left(0, \operatorname{Var}_{\theta_{0}}\left(l^{\prime}\left(X_{1} | \theta_{0}\right)\right)\right) = N(0,V) \end{align} Now, the denominator $L^{''}_n$ coverges to the Fisher's information $(J)$ by LLN. Therefore, for the scalar paramters case, we can see that $$\sqrt{n}(\hat \theta - \theta_0) \rightarrow N(0,\frac{V}{J^2})$$
Akaike Information Criterion (AIC) derivation Consider scalar parameters $\theta_0$ and the corresponding scalar estimate $\hat \theta$ for simplicity. I will answer Q1 and Q3 which are essentially asking why is the mean of the score function $\
42,281
What is the quantile covariance?
Setup We'll assume that the feature covariance $\mathrm{var}(X) \in \mathbb{R}^{p \times p}$ is full rank. As you have in the original post, define $$(\hat{\alpha}, \hat{\beta}) = \arg\min_{\alpha, \beta} \mathbb{E} \left[ \left(Y - \left\{ \alpha + \beta^T \Sigma_{XX}^{-1} (X - \mu_X) \right\} \right)^2 \right]$$ and $$(\tilde{\alpha}, \tilde{\beta}) = \arg\min_{\alpha, \beta} \mathbb{E} \left[ \rho_\tau \left(Y - \left\{ \alpha + \beta^T \Sigma_{XX}^{-1} (X - \mu_X) \right\} \right) \right],$$ where e.g. $\mu_Y = \mathbb{E}[Y]$, $\Sigma_{XX} = \mathrm{cov}(X, X) = \mathrm{var}(X)$, and $\Sigma_{YX} = \mathrm{cov}(Y,X)$. Recall that the covariance $\Sigma_{XY} = \left(\Sigma_{YX}\right)^T$ and that the covariance $\Sigma_{XY}$ is itself just a vector whose $j^{\mathrm{th}}$ entry is the (scalar) covariance between $X_j$ and $Y$. Review of OLS Write that $$(\hat{u}, \hat{v}) = \arg\min_{u, v} \mathbb{E} \left[ \left(Y - \left\{ u + v^T (X - \mu_X) \right\} \right)^2 \right],$$ where $\hat{u} \in \mathbb{R}$ is the population-level OLS intercept and $\hat{v} \in \mathbb{R}^p$ is the population-level OLS slope, and so $\hat{u} + \hat{v}^T (X - \mu_X)$ is the population-level OLS line-of-best-fit. Connection between OLS and covariance Using matrix algebra, we could derive that $\hat{u} = \mu_Y$ and $$\hat{v}^T = \Sigma_{YX}\Sigma_{XX}^{-1}. \tag{*}$$ In terms of your first displayed equation, we see that $\hat{u} = \hat{\alpha}$ and $\hat{v} = \Sigma_{XX}^{-1}\,\hat{\beta}$; that is, $$\hat{\beta} = \Sigma_{XX} \, \hat{v} = \Sigma_{XX} \left( \Sigma_{XX}^{-1}\,\Sigma_{XY} \right) = \Sigma_{XY},$$ the covariance. Quantile covariance In order to define the "quantile covariance" $\Sigma_{YX}^{\mathrm{QUANTILE}}$, the authors continue to treat $(*)$ as true while switching away from a squared error loss function. Specifically, they could consider $$(\tilde{u}, \tilde{v}) = \arg\min_{u, v} \mathbb{E} \left[ \rho_\tau \left(Y - \left\{ u + v^T (X - \mathbb{E}[X]) \right\} \right) \right],$$ which is analogous to the population-level OLS fit earlier except now with quantile loss instead of squared loss. At this point, the goal is to connect the population-level quantile slope $\tilde{v}$ to a "quantile covariance". To do this, we could define that $$\tilde{v}^T =: \Sigma_{YX}^{\mathrm{QUANTILE}}\,\Sigma_{XX}^{-1}, \tag{**}$$ so that $\Sigma_{YX}^{\mathrm{QUANTILE}}$ is recovered through $\beta$ in your second displayed equation, i.e. $\tilde{\beta} = \Sigma_{XY}^{\mathrm{QUANTILE}}$.
What is the quantile covariance?
Setup We'll assume that the feature covariance $\mathrm{var}(X) \in \mathbb{R}^{p \times p}$ is full rank. As you have in the original post, define $$(\hat{\alpha}, \hat{\beta}) = \arg\min_{\alpha, \b
What is the quantile covariance? Setup We'll assume that the feature covariance $\mathrm{var}(X) \in \mathbb{R}^{p \times p}$ is full rank. As you have in the original post, define $$(\hat{\alpha}, \hat{\beta}) = \arg\min_{\alpha, \beta} \mathbb{E} \left[ \left(Y - \left\{ \alpha + \beta^T \Sigma_{XX}^{-1} (X - \mu_X) \right\} \right)^2 \right]$$ and $$(\tilde{\alpha}, \tilde{\beta}) = \arg\min_{\alpha, \beta} \mathbb{E} \left[ \rho_\tau \left(Y - \left\{ \alpha + \beta^T \Sigma_{XX}^{-1} (X - \mu_X) \right\} \right) \right],$$ where e.g. $\mu_Y = \mathbb{E}[Y]$, $\Sigma_{XX} = \mathrm{cov}(X, X) = \mathrm{var}(X)$, and $\Sigma_{YX} = \mathrm{cov}(Y,X)$. Recall that the covariance $\Sigma_{XY} = \left(\Sigma_{YX}\right)^T$ and that the covariance $\Sigma_{XY}$ is itself just a vector whose $j^{\mathrm{th}}$ entry is the (scalar) covariance between $X_j$ and $Y$. Review of OLS Write that $$(\hat{u}, \hat{v}) = \arg\min_{u, v} \mathbb{E} \left[ \left(Y - \left\{ u + v^T (X - \mu_X) \right\} \right)^2 \right],$$ where $\hat{u} \in \mathbb{R}$ is the population-level OLS intercept and $\hat{v} \in \mathbb{R}^p$ is the population-level OLS slope, and so $\hat{u} + \hat{v}^T (X - \mu_X)$ is the population-level OLS line-of-best-fit. Connection between OLS and covariance Using matrix algebra, we could derive that $\hat{u} = \mu_Y$ and $$\hat{v}^T = \Sigma_{YX}\Sigma_{XX}^{-1}. \tag{*}$$ In terms of your first displayed equation, we see that $\hat{u} = \hat{\alpha}$ and $\hat{v} = \Sigma_{XX}^{-1}\,\hat{\beta}$; that is, $$\hat{\beta} = \Sigma_{XX} \, \hat{v} = \Sigma_{XX} \left( \Sigma_{XX}^{-1}\,\Sigma_{XY} \right) = \Sigma_{XY},$$ the covariance. Quantile covariance In order to define the "quantile covariance" $\Sigma_{YX}^{\mathrm{QUANTILE}}$, the authors continue to treat $(*)$ as true while switching away from a squared error loss function. Specifically, they could consider $$(\tilde{u}, \tilde{v}) = \arg\min_{u, v} \mathbb{E} \left[ \rho_\tau \left(Y - \left\{ u + v^T (X - \mathbb{E}[X]) \right\} \right) \right],$$ which is analogous to the population-level OLS fit earlier except now with quantile loss instead of squared loss. At this point, the goal is to connect the population-level quantile slope $\tilde{v}$ to a "quantile covariance". To do this, we could define that $$\tilde{v}^T =: \Sigma_{YX}^{\mathrm{QUANTILE}}\,\Sigma_{XX}^{-1}, \tag{**}$$ so that $\Sigma_{YX}^{\mathrm{QUANTILE}}$ is recovered through $\beta$ in your second displayed equation, i.e. $\tilde{\beta} = \Sigma_{XY}^{\mathrm{QUANTILE}}$.
What is the quantile covariance? Setup We'll assume that the feature covariance $\mathrm{var}(X) \in \mathbb{R}^{p \times p}$ is full rank. As you have in the original post, define $$(\hat{\alpha}, \hat{\beta}) = \arg\min_{\alpha, \b
42,282
Understanding the reproducing property of RKHS
You're overthinking this: the result with $M$ is just a restatement of the reproducing property. Using wikipedia's notation, we have that the reproducing property is defined as having an element $k_x \in \mathcal H$ for each $x\in\mathcal X$, the domain, such that $$ \langle f, k_x\rangle = f(x) $$ for each $f\in\mathcal H$. Writing out the inner product as an integral w.r.t. a measure $\mu$ (I'm using Lebesgue integrals so this applies to both sums and the usual integrals) we have $$ f(x) = \langle f, k_x\rangle = \int_{\mathcal X} f(x')k_x(x')\,\text d\mu(x') \\ = \int_{\mathcal X} f(x')k(x,x')\,\text d\mu(x') $$ so plugging in $M=f$ exactly gives what they state.
Understanding the reproducing property of RKHS
You're overthinking this: the result with $M$ is just a restatement of the reproducing property. Using wikipedia's notation, we have that the reproducing property is defined as having an element $k_x
Understanding the reproducing property of RKHS You're overthinking this: the result with $M$ is just a restatement of the reproducing property. Using wikipedia's notation, we have that the reproducing property is defined as having an element $k_x \in \mathcal H$ for each $x\in\mathcal X$, the domain, such that $$ \langle f, k_x\rangle = f(x) $$ for each $f\in\mathcal H$. Writing out the inner product as an integral w.r.t. a measure $\mu$ (I'm using Lebesgue integrals so this applies to both sums and the usual integrals) we have $$ f(x) = \langle f, k_x\rangle = \int_{\mathcal X} f(x')k_x(x')\,\text d\mu(x') \\ = \int_{\mathcal X} f(x')k(x,x')\,\text d\mu(x') $$ so plugging in $M=f$ exactly gives what they state.
Understanding the reproducing property of RKHS You're overthinking this: the result with $M$ is just a restatement of the reproducing property. Using wikipedia's notation, we have that the reproducing property is defined as having an element $k_x
42,283
Are loss functions necessarily additive in observations?
Loss functions are not always additive in observations: A loss function is function of an estimator (or predictor) and the thing it is estimating (predicting). The loss function is often, but not always, a distance function. Moreover, the estimator (predictor) sometimes, but not always, involves a sum of terms involving a single observation. Generally speaking, the loss function does not always have a form that is additive with respect to the observations. For prediction problems, deviation from this form occurs because of the form of the loss function. For estimation problems, it occurs either because of the form of the loss function, or because of the form of the estimator appearing in the loss function. To see the generality of the loss form for a prediction problem, consider the general case where we have an observed data $\mathbf{y} = (y_1,...,y_n)$ and we want to predict the observable vector $\mathbf{y}_* = (y_{n+1},...,y_{n+k})$ using the predictor $\hat{\mathbf{y}}_* = \mathbf{H}(\mathbf{y})$. We can write the loss for this prediction problem as: $$L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = L(\mathbf{H}(\mathbf{y}), \mathbf{y}_*).$$ The loss function in your question is the Euclidean distance between the prediction vector and the observed data vector, which is $L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = ||\hat{\mathbf{y}}_* - \mathbf{y}_*||^2 = \sum_i (\hat{y}_{*i} - y_{*i})^2$. That particular form is composed of a sum of terms involving the observed values being predicted, and so the additivity property holds in that case. However, there are many other examples of loss functions that give rise to a form that does not have this additivity property. A simple example of two loss functions that are not additive in the observations are when the loss is equal to the prediction error either from the best prediction, or from the worst prediction. In the case of "loss from best prediction" we have the loss function $L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = \min_i |\hat{y}_{*i} - y_{*i}|$, and in "loss from worse prediction" we have the loss function $L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = \max_i |\hat{y}_{*i} - y_{*i}|$. In either case, the loss function is not additive for the individual terms.
Are loss functions necessarily additive in observations?
Loss functions are not always additive in observations: A loss function is function of an estimator (or predictor) and the thing it is estimating (predicting). The loss function is often, but not alw
Are loss functions necessarily additive in observations? Loss functions are not always additive in observations: A loss function is function of an estimator (or predictor) and the thing it is estimating (predicting). The loss function is often, but not always, a distance function. Moreover, the estimator (predictor) sometimes, but not always, involves a sum of terms involving a single observation. Generally speaking, the loss function does not always have a form that is additive with respect to the observations. For prediction problems, deviation from this form occurs because of the form of the loss function. For estimation problems, it occurs either because of the form of the loss function, or because of the form of the estimator appearing in the loss function. To see the generality of the loss form for a prediction problem, consider the general case where we have an observed data $\mathbf{y} = (y_1,...,y_n)$ and we want to predict the observable vector $\mathbf{y}_* = (y_{n+1},...,y_{n+k})$ using the predictor $\hat{\mathbf{y}}_* = \mathbf{H}(\mathbf{y})$. We can write the loss for this prediction problem as: $$L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = L(\mathbf{H}(\mathbf{y}), \mathbf{y}_*).$$ The loss function in your question is the Euclidean distance between the prediction vector and the observed data vector, which is $L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = ||\hat{\mathbf{y}}_* - \mathbf{y}_*||^2 = \sum_i (\hat{y}_{*i} - y_{*i})^2$. That particular form is composed of a sum of terms involving the observed values being predicted, and so the additivity property holds in that case. However, there are many other examples of loss functions that give rise to a form that does not have this additivity property. A simple example of two loss functions that are not additive in the observations are when the loss is equal to the prediction error either from the best prediction, or from the worst prediction. In the case of "loss from best prediction" we have the loss function $L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = \min_i |\hat{y}_{*i} - y_{*i}|$, and in "loss from worse prediction" we have the loss function $L(\hat{\mathbf{y}}_*, \mathbf{y}_*) = \max_i |\hat{y}_{*i} - y_{*i}|$. In either case, the loss function is not additive for the individual terms.
Are loss functions necessarily additive in observations? Loss functions are not always additive in observations: A loss function is function of an estimator (or predictor) and the thing it is estimating (predicting). The loss function is often, but not alw
42,284
Are loss functions necessarily additive in observations?
There are two most common causes for loss function being a sum/average. First, you may simply define your loss as average of some metric. It's related to concept of risk minimization. Second reason is that you use Maximum Likelihood or something related, like Maximum A Posteriori. Additivity comes from the fact that Maximum Likelihood solves $$\arg\max_{\theta} P_{\theta}(Dataset) = \arg\max_{\theta} \prod_{x \in Dataset} P_{\theta}(x)$$ which is equal to $$\arg\min_{\theta} \sum_{x \in Dataset} -log(P_{\theta}(x)).$$ For example, if $P_{\theta}$ is Gaussian you'll get exactly mean squared error.
Are loss functions necessarily additive in observations?
There are two most common causes for loss function being a sum/average. First, you may simply define your loss as average of some metric. It's related to concept of risk minimization. Second reason is
Are loss functions necessarily additive in observations? There are two most common causes for loss function being a sum/average. First, you may simply define your loss as average of some metric. It's related to concept of risk minimization. Second reason is that you use Maximum Likelihood or something related, like Maximum A Posteriori. Additivity comes from the fact that Maximum Likelihood solves $$\arg\max_{\theta} P_{\theta}(Dataset) = \arg\max_{\theta} \prod_{x \in Dataset} P_{\theta}(x)$$ which is equal to $$\arg\min_{\theta} \sum_{x \in Dataset} -log(P_{\theta}(x)).$$ For example, if $P_{\theta}$ is Gaussian you'll get exactly mean squared error.
Are loss functions necessarily additive in observations? There are two most common causes for loss function being a sum/average. First, you may simply define your loss as average of some metric. It's related to concept of risk minimization. Second reason is
42,285
Chi Square vs F Tests for GLM Model Comparisons
Basically, yes. $F$ is used when the dispersion parameter is estimated rather than assumed to be fixed to some known value. $F$ is also often used for quasi-likelihood models where a somewhat ad hoc overdispersion parameter is estimated (see e.g. Venables and Ripley Modern Applied Statistics with S). For a Tweedie distribution you're estimating a dispersion parameter and (possibly) a shape parameter. If you estimate the shape parameter rather than fixing it some a priori value, you'll probably be underestimating the uncertainty unless you do something fancy (e.g. bootstrapping).
Chi Square vs F Tests for GLM Model Comparisons
Basically, yes. $F$ is used when the dispersion parameter is estimated rather than assumed to be fixed to some known value. $F$ is also often used for quasi-likelihood models where a somewhat ad hoc o
Chi Square vs F Tests for GLM Model Comparisons Basically, yes. $F$ is used when the dispersion parameter is estimated rather than assumed to be fixed to some known value. $F$ is also often used for quasi-likelihood models where a somewhat ad hoc overdispersion parameter is estimated (see e.g. Venables and Ripley Modern Applied Statistics with S). For a Tweedie distribution you're estimating a dispersion parameter and (possibly) a shape parameter. If you estimate the shape parameter rather than fixing it some a priori value, you'll probably be underestimating the uncertainty unless you do something fancy (e.g. bootstrapping).
Chi Square vs F Tests for GLM Model Comparisons Basically, yes. $F$ is used when the dispersion parameter is estimated rather than assumed to be fixed to some known value. $F$ is also often used for quasi-likelihood models where a somewhat ad hoc o
42,286
Can I judge skewness from a scatterplot with bivariate data in R?
Is it safe to say that the data is left or negatively skewed? No, it is not safe: Firstly, the appearance of the plot is of positive (right) skew, not negative (left) skew. Regardless, you need to be careful here because there is over-plotting, which means that you can't actually see what is going on in that big red mass in the middle. Although it is unlikely, it is possible that this red mass of points is hiding concentrations of points that would detract from positive skewness of one or both variables (or it might even induce negative skewness). To get a better assessment of the skewness of the two variables I would recommend constructing kernel density plots of the variables of interest and calculating the sample skewness of these variables (R code for this below). library(moments); #Make sure you have installed this package first DATA <- filterdacsom5; #Check skewness of median income skewness(DATA$Median_Income); plot(density(DATA$Median_Income)); #Check skewness of population skewness(DATA$Total_Population); plot(density(DATA$Total_Population)); Note that the scatterplot gives you information about the joint distribution of the variables, which you won't get from individual density plots. If you would like to see a better representation of the variables in the scatterplot, I would recommend you adjust it to deal with over-plotting --- e.g., use alpha-transparency or a contour plot.
Can I judge skewness from a scatterplot with bivariate data in R?
Is it safe to say that the data is left or negatively skewed? No, it is not safe: Firstly, the appearance of the plot is of positive (right) skew, not negative (left) skew. Regardless, you need to b
Can I judge skewness from a scatterplot with bivariate data in R? Is it safe to say that the data is left or negatively skewed? No, it is not safe: Firstly, the appearance of the plot is of positive (right) skew, not negative (left) skew. Regardless, you need to be careful here because there is over-plotting, which means that you can't actually see what is going on in that big red mass in the middle. Although it is unlikely, it is possible that this red mass of points is hiding concentrations of points that would detract from positive skewness of one or both variables (or it might even induce negative skewness). To get a better assessment of the skewness of the two variables I would recommend constructing kernel density plots of the variables of interest and calculating the sample skewness of these variables (R code for this below). library(moments); #Make sure you have installed this package first DATA <- filterdacsom5; #Check skewness of median income skewness(DATA$Median_Income); plot(density(DATA$Median_Income)); #Check skewness of population skewness(DATA$Total_Population); plot(density(DATA$Total_Population)); Note that the scatterplot gives you information about the joint distribution of the variables, which you won't get from individual density plots. If you would like to see a better representation of the variables in the scatterplot, I would recommend you adjust it to deal with over-plotting --- e.g., use alpha-transparency or a contour plot.
Can I judge skewness from a scatterplot with bivariate data in R? Is it safe to say that the data is left or negatively skewed? No, it is not safe: Firstly, the appearance of the plot is of positive (right) skew, not negative (left) skew. Regardless, you need to b
42,287
Can I judge skewness from a scatterplot with bivariate data in R?
This approad may be missleading and this is why. The scatterplot can tell you something about the distribution of each variable. But the scatterplot also tells you something about the relationsship between two variables, which can lead to problems if one is making an interpretation about one of the variables alone, e.g. interpreting the skewness. Let's assume some data with heteroscedasticity where y doesn't have negative values (like in your example). The resulting plot could be like this: The resulting plot looks relatively close to the provided plot and the plot suggests that x is skewed although this is actually not the case since x has an uniform distribution (see code for data generation below) as the histogram for x shows: Thus, the relationship between the variables can result in an missleading scatter plot in terms of interpreting the distribution of one variable. The code I used for the plot: set.seed(568) x = rep(1:10000,2) a <- 20000 b = -2 sigma2 = x^2 eps = rnorm(x,mean=0,sd= rev(sqrt(sigma2))) # heteroscedasticity y = a + b*x + eps y[y<0] <- -y[y<0] # no negative values in y plot(x, y) EDIT: I agree with Ben that the transparency and overplotting are important in this case and this is why I choose such a big sample size for my example. Using transparency fot the same data is less missleading. plot(x, y, col = alpha("black", 0.05))
Can I judge skewness from a scatterplot with bivariate data in R?
This approad may be missleading and this is why. The scatterplot can tell you something about the distribution of each variable. But the scatterplot also tells you something about the relationsship be
Can I judge skewness from a scatterplot with bivariate data in R? This approad may be missleading and this is why. The scatterplot can tell you something about the distribution of each variable. But the scatterplot also tells you something about the relationsship between two variables, which can lead to problems if one is making an interpretation about one of the variables alone, e.g. interpreting the skewness. Let's assume some data with heteroscedasticity where y doesn't have negative values (like in your example). The resulting plot could be like this: The resulting plot looks relatively close to the provided plot and the plot suggests that x is skewed although this is actually not the case since x has an uniform distribution (see code for data generation below) as the histogram for x shows: Thus, the relationship between the variables can result in an missleading scatter plot in terms of interpreting the distribution of one variable. The code I used for the plot: set.seed(568) x = rep(1:10000,2) a <- 20000 b = -2 sigma2 = x^2 eps = rnorm(x,mean=0,sd= rev(sqrt(sigma2))) # heteroscedasticity y = a + b*x + eps y[y<0] <- -y[y<0] # no negative values in y plot(x, y) EDIT: I agree with Ben that the transparency and overplotting are important in this case and this is why I choose such a big sample size for my example. Using transparency fot the same data is less missleading. plot(x, y, col = alpha("black", 0.05))
Can I judge skewness from a scatterplot with bivariate data in R? This approad may be missleading and this is why. The scatterplot can tell you something about the distribution of each variable. But the scatterplot also tells you something about the relationsship be
42,288
Use and misuse of Winsorization
When winsorizing the data, the $\alpha\%$ winsorization is defined as replacing the $(100\%-\alpha)/2$ smallest values with value above them, and $(100\%-\alpha)/2$ largest values with the value below them (with $\alpha\in[0\%, 100\%]$), for example, a 90% winsorization would see all data below the 5th percentile set to the 5th percentile, and data above the 95th percentile set to the 95th percentile. then you apply regular statistical methods to such data, e.g. compute arithmetic mean. With winsorized mean, you replace the smallest and largest values as above and then compute arithmetic mean. So both approaches are exactly the same, since winsorized mean is defined in terms of winsorizing the data and then taking regular mean. In the first case, you apply function $f$ to the data, and then pass the output through $g$, while in second case, you apply $h(x) = g(f(x))$, so they are mathematically equivalent. You are right that we can often choose between using "mechanistic" approaches to dealing with outliers (like winsorizing, dropping, or downweighting them), or using end-to-end models that accounts for such data. However, this is not really the case of winsorized mean, since of the reasons outlined above. Example of such end-to-end model would be regression assuming long-tailed distribution for likelihood function, where the model assumes that the data was generated from "outlier"-prone distribution. Notice also that in many cases in statistics estimators don't depend only on the data, e.g. when using regularization, or priors in Bayesian approach. Even if you use very basic statistical tools, like choosing between empirical mean and median to measure central tendency, while not deciding to ignore the extreme data points, you choose to pay much less attention to them. What I am trying to say, is that the fact that you didn't explicitly transform the data, does not have to mean that you are "letting the data to speak for itself", or that the approach is more "pure" in any sense.
Use and misuse of Winsorization
When winsorizing the data, the $\alpha\%$ winsorization is defined as replacing the $(100\%-\alpha)/2$ smallest values with value above them, and $(100\%-\alpha)/2$ largest values with the value below
Use and misuse of Winsorization When winsorizing the data, the $\alpha\%$ winsorization is defined as replacing the $(100\%-\alpha)/2$ smallest values with value above them, and $(100\%-\alpha)/2$ largest values with the value below them (with $\alpha\in[0\%, 100\%]$), for example, a 90% winsorization would see all data below the 5th percentile set to the 5th percentile, and data above the 95th percentile set to the 95th percentile. then you apply regular statistical methods to such data, e.g. compute arithmetic mean. With winsorized mean, you replace the smallest and largest values as above and then compute arithmetic mean. So both approaches are exactly the same, since winsorized mean is defined in terms of winsorizing the data and then taking regular mean. In the first case, you apply function $f$ to the data, and then pass the output through $g$, while in second case, you apply $h(x) = g(f(x))$, so they are mathematically equivalent. You are right that we can often choose between using "mechanistic" approaches to dealing with outliers (like winsorizing, dropping, or downweighting them), or using end-to-end models that accounts for such data. However, this is not really the case of winsorized mean, since of the reasons outlined above. Example of such end-to-end model would be regression assuming long-tailed distribution for likelihood function, where the model assumes that the data was generated from "outlier"-prone distribution. Notice also that in many cases in statistics estimators don't depend only on the data, e.g. when using regularization, or priors in Bayesian approach. Even if you use very basic statistical tools, like choosing between empirical mean and median to measure central tendency, while not deciding to ignore the extreme data points, you choose to pay much less attention to them. What I am trying to say, is that the fact that you didn't explicitly transform the data, does not have to mean that you are "letting the data to speak for itself", or that the approach is more "pure" in any sense.
Use and misuse of Winsorization When winsorizing the data, the $\alpha\%$ winsorization is defined as replacing the $(100\%-\alpha)/2$ smallest values with value above them, and $(100\%-\alpha)/2$ largest values with the value below
42,289
How to interpret a two-way interaction in a 3-way interaction model
My question is, is there a significant ab interaction? If I trust model A, then I would say no, but if I trust model B, then I would say yes. Which model is more correct, or does it depend on details of the model? Why does adding a 3-way interaction make an originally non-significant two-way interaction (model A) significant (model B)? Neither model is "correct". They are different models. It is absolutely OK to find a meaningful interaction in the first model, but the same interaction may not be meaningful in the second. In the second model, the a:b interaction itself is involved in an interaction with c. This means that the intepretation of the a:b interaction in the second model is conditional on c being zero (or at it's reference level if it is categorical). It is then necessary to intepret the a:b:c interation, which will tell you how the a:b interaction changes with c. So from this it is easy to see there is no reason to expect the a:b to have a similar magnitude (or statistial significance) in the two models.
How to interpret a two-way interaction in a 3-way interaction model
My question is, is there a significant ab interaction? If I trust model A, then I would say no, but if I trust model B, then I would say yes. Which model is more correct, or does it depend on details
How to interpret a two-way interaction in a 3-way interaction model My question is, is there a significant ab interaction? If I trust model A, then I would say no, but if I trust model B, then I would say yes. Which model is more correct, or does it depend on details of the model? Why does adding a 3-way interaction make an originally non-significant two-way interaction (model A) significant (model B)? Neither model is "correct". They are different models. It is absolutely OK to find a meaningful interaction in the first model, but the same interaction may not be meaningful in the second. In the second model, the a:b interaction itself is involved in an interaction with c. This means that the intepretation of the a:b interaction in the second model is conditional on c being zero (or at it's reference level if it is categorical). It is then necessary to intepret the a:b:c interation, which will tell you how the a:b interaction changes with c. So from this it is easy to see there is no reason to expect the a:b to have a similar magnitude (or statistial significance) in the two models.
How to interpret a two-way interaction in a 3-way interaction model My question is, is there a significant ab interaction? If I trust model A, then I would say no, but if I trust model B, then I would say yes. Which model is more correct, or does it depend on details
42,290
Does sampling from a large dataset lead to correct inferences?
If you have the whole population, you are not really doing any inference of a variable, that only happens when you are taking a sample. Let's say you are using a model that predicts weight based on height, so it's $$w = a\cdot h + \epsilon$$ Where $\epsilon$ is some error. Somehow you have collected data on the whole population of the planet. Or even better, any person that ever lived. But then, what's a person? Already, you have some interesting questions here. But let's stick to the plan. For the whole population, you estimate an 'a'. Then we sample down to 1 million people. If it's a random sample, you can establish limits on how far your inference on this sample lies from the true value. In frequentist statistics, you assume a 'true' value of $a$, which is going to be superclose to the inference on the whole population, and its going to be very close to the inference on the smaller population as well. Under assumptions on the error, the variance of an estimator will be proportional to 1 over the square of 1 million for the sample, and 1 over the square of whatever the size of the whole population for that original inference. This follows from the Central Limit Theorem. So both are close to the 'true' value and they are going to be close to each other as well. I mentioned frequentist, so now I have to mention some other viewpoint as well, but the inference in Bayesian statistics is going to be pretty much equal as well, allthough perhaps you are not really assuming a 'true' value for $a$, but rather updating your belief after measuring all those people. But the math still holds pretty much and if you do it with the sample it will be extremely close to the inference on the whole population. Regardless of the estimator variance, a more interesting point here is that the model is clearly not the truth. There is no true value for $a$, it's just a simplification that you may trust to use for your usecase. This holds for any model, however sophisticated it may appear. Another thought, if you have big data it is often the case that you have a lot of data relative to the number of variables that you are estimating. At that scale, using the Central Limit Theorem for deriving estimator variances is sometimes missing the larger point, as in the previous paragraph, your model is wrong and you already know it. For example if you use a simple linear regression such as above, with a population of 1m people, your estimator variance is in the order of 1 over square root of 1 million, that's 0.001. So your report is going to be, "$a$ is contained in the interval $[1.234, 1.235]$. The significance is through the roof.". But at that point, a better question may be, how well does this model actually predict weight from height? And you apply cross-validation and things like that, and it's going to look like machine learning more.
Does sampling from a large dataset lead to correct inferences?
If you have the whole population, you are not really doing any inference of a variable, that only happens when you are taking a sample. Let's say you are using a model that predicts weight based on he
Does sampling from a large dataset lead to correct inferences? If you have the whole population, you are not really doing any inference of a variable, that only happens when you are taking a sample. Let's say you are using a model that predicts weight based on height, so it's $$w = a\cdot h + \epsilon$$ Where $\epsilon$ is some error. Somehow you have collected data on the whole population of the planet. Or even better, any person that ever lived. But then, what's a person? Already, you have some interesting questions here. But let's stick to the plan. For the whole population, you estimate an 'a'. Then we sample down to 1 million people. If it's a random sample, you can establish limits on how far your inference on this sample lies from the true value. In frequentist statistics, you assume a 'true' value of $a$, which is going to be superclose to the inference on the whole population, and its going to be very close to the inference on the smaller population as well. Under assumptions on the error, the variance of an estimator will be proportional to 1 over the square of 1 million for the sample, and 1 over the square of whatever the size of the whole population for that original inference. This follows from the Central Limit Theorem. So both are close to the 'true' value and they are going to be close to each other as well. I mentioned frequentist, so now I have to mention some other viewpoint as well, but the inference in Bayesian statistics is going to be pretty much equal as well, allthough perhaps you are not really assuming a 'true' value for $a$, but rather updating your belief after measuring all those people. But the math still holds pretty much and if you do it with the sample it will be extremely close to the inference on the whole population. Regardless of the estimator variance, a more interesting point here is that the model is clearly not the truth. There is no true value for $a$, it's just a simplification that you may trust to use for your usecase. This holds for any model, however sophisticated it may appear. Another thought, if you have big data it is often the case that you have a lot of data relative to the number of variables that you are estimating. At that scale, using the Central Limit Theorem for deriving estimator variances is sometimes missing the larger point, as in the previous paragraph, your model is wrong and you already know it. For example if you use a simple linear regression such as above, with a population of 1m people, your estimator variance is in the order of 1 over square root of 1 million, that's 0.001. So your report is going to be, "$a$ is contained in the interval $[1.234, 1.235]$. The significance is through the roof.". But at that point, a better question may be, how well does this model actually predict weight from height? And you apply cross-validation and things like that, and it's going to look like machine learning more.
Does sampling from a large dataset lead to correct inferences? If you have the whole population, you are not really doing any inference of a variable, that only happens when you are taking a sample. Let's say you are using a model that predicts weight based on he
42,291
Does sampling from a large dataset lead to correct inferences?
Yes, this works. All data is a sample population. If you have enough to achieve some level of performance on some metric, than you have achieved your goal. There will generally be a point of diminishing returns on the size of the data. Thus, more data will make little difference. As long as you have enough to make an appropriate generalization on test data, then you are good. Additionally, you can used unsampled instances from the larger datset for testing.
Does sampling from a large dataset lead to correct inferences?
Yes, this works. All data is a sample population. If you have enough to achieve some level of performance on some metric, than you have achieved your goal. There will generally be a point of diminishi
Does sampling from a large dataset lead to correct inferences? Yes, this works. All data is a sample population. If you have enough to achieve some level of performance on some metric, than you have achieved your goal. There will generally be a point of diminishing returns on the size of the data. Thus, more data will make little difference. As long as you have enough to make an appropriate generalization on test data, then you are good. Additionally, you can used unsampled instances from the larger datset for testing.
Does sampling from a large dataset lead to correct inferences? Yes, this works. All data is a sample population. If you have enough to achieve some level of performance on some metric, than you have achieved your goal. There will generally be a point of diminishi
42,292
Does sampling from a large dataset lead to correct inferences?
I imagine it depends on what kind of inferences you're trying to make about the population. In general you could be making any kind of inference, including inferences about the estimators used to learn population parameters. This question immediately made me think of the bootstrap and jackknife resampling techniques, which are often used to make inferences about the variance of estimators. These methods fail in at least some circumstances: the jackknife fails to estimate the variance of the sample median. So although it probably works in some circumstances, it does not work for all subsampling techniques, over all classes of inferences.
Does sampling from a large dataset lead to correct inferences?
I imagine it depends on what kind of inferences you're trying to make about the population. In general you could be making any kind of inference, including inferences about the estimators used to lear
Does sampling from a large dataset lead to correct inferences? I imagine it depends on what kind of inferences you're trying to make about the population. In general you could be making any kind of inference, including inferences about the estimators used to learn population parameters. This question immediately made me think of the bootstrap and jackknife resampling techniques, which are often used to make inferences about the variance of estimators. These methods fail in at least some circumstances: the jackknife fails to estimate the variance of the sample median. So although it probably works in some circumstances, it does not work for all subsampling techniques, over all classes of inferences.
Does sampling from a large dataset lead to correct inferences? I imagine it depends on what kind of inferences you're trying to make about the population. In general you could be making any kind of inference, including inferences about the estimators used to lear
42,293
Does sampling from a large dataset lead to correct inferences?
This is certainly the case in the infinite population setting, but IRL that's rarely the case at least as far as big data are concerned. For instance, if I run an insurance company and manage claims, I can do statistical analyses of all claims or even just a large subset. There's a challenge here. If I do a simple random sample (SRS) of n/N > 0.3 (30% or more) of my claims, then the normal approach to calculating CIs and p-values will not replicate. Because if the study were done again, I would be very likely to sample exactly one of the same n's I pulled in the first iteration, and in the second, and so on, meaning that my estimate of the SE will be too large (if the data are truly independent) or possibly too small (if there is dependence). Finite sample corrections can be used under the independent data assumption. Correctly identifying correlation structures is a requirement to estimate the correcting sampling distribution of statistics.
Does sampling from a large dataset lead to correct inferences?
This is certainly the case in the infinite population setting, but IRL that's rarely the case at least as far as big data are concerned. For instance, if I run an insurance company and manage claims,
Does sampling from a large dataset lead to correct inferences? This is certainly the case in the infinite population setting, but IRL that's rarely the case at least as far as big data are concerned. For instance, if I run an insurance company and manage claims, I can do statistical analyses of all claims or even just a large subset. There's a challenge here. If I do a simple random sample (SRS) of n/N > 0.3 (30% or more) of my claims, then the normal approach to calculating CIs and p-values will not replicate. Because if the study were done again, I would be very likely to sample exactly one of the same n's I pulled in the first iteration, and in the second, and so on, meaning that my estimate of the SE will be too large (if the data are truly independent) or possibly too small (if there is dependence). Finite sample corrections can be used under the independent data assumption. Correctly identifying correlation structures is a requirement to estimate the correcting sampling distribution of statistics.
Does sampling from a large dataset lead to correct inferences? This is certainly the case in the infinite population setting, but IRL that's rarely the case at least as far as big data are concerned. For instance, if I run an insurance company and manage claims,
42,294
Why increasing the batch size has the same effect as decaying the learning rate?
I think it may be a confusion about the different meanings of stability -- stable as in numerically stable / weights don't go to infinity, versus stable as in the loss steadily monotonically decreases and you eventually converge to some good solution. L2 regularization accomplishes the first, but doesn't necessarily help with the second. Small batch size isn't necessarily stable in the first sense and is unstable in the second sense. Large batch size also isn't necessarily stable in the first sense but is stable in the second sense. In terms of selecting batch size / learning rate for large scale training, we're concerned more about the second sense of stability. One way to see it is that if you take $B$ steps with batch size 1 and learning rate $\eta$, it should be pretty close to taking a single step with batch size $B$ and learning rate $B\eta$, assuming the gradient is roughly constant with mean $\mu$ over these $B$ steps and our minibatch gradient estimate has variance $\frac{\sigma^2}{B}$.
Why increasing the batch size has the same effect as decaying the learning rate?
I think it may be a confusion about the different meanings of stability -- stable as in numerically stable / weights don't go to infinity, versus stable as in the loss steadily monotonically decreases
Why increasing the batch size has the same effect as decaying the learning rate? I think it may be a confusion about the different meanings of stability -- stable as in numerically stable / weights don't go to infinity, versus stable as in the loss steadily monotonically decreases and you eventually converge to some good solution. L2 regularization accomplishes the first, but doesn't necessarily help with the second. Small batch size isn't necessarily stable in the first sense and is unstable in the second sense. Large batch size also isn't necessarily stable in the first sense but is stable in the second sense. In terms of selecting batch size / learning rate for large scale training, we're concerned more about the second sense of stability. One way to see it is that if you take $B$ steps with batch size 1 and learning rate $\eta$, it should be pretty close to taking a single step with batch size $B$ and learning rate $B\eta$, assuming the gradient is roughly constant with mean $\mu$ over these $B$ steps and our minibatch gradient estimate has variance $\frac{\sigma^2}{B}$.
Why increasing the batch size has the same effect as decaying the learning rate? I think it may be a confusion about the different meanings of stability -- stable as in numerically stable / weights don't go to infinity, versus stable as in the loss steadily monotonically decreases
42,295
Random Forest Regression - R^2 score or MSE for Comparison
There is no real difference in discrimination between the mean squared error and the R-squared, when it is used on a test dataset as the R-Squared is just the MSE divided by the MSE of the prediction of the mean, which is a constant. So MSE and R-Squared are proportional to each other and the ranking will never be different between these two measures. This is not the case if the measures are averaged across different test dataset, as then the denominators of the R-Squared between the test sets are different. In this case, e.g. in 5-fold cross-validation, I would rather use the MSE. On the other hand, if the test datasets are not commensurable I would rather use the R-Squared, because it is rather comparable between inherently different datasets. I would also look at ranking measures like Spearman rho and Kendalls tau, as they are more robust against outliers than MSE and R-squared. Or at the median absolute error, or the median squared error.
Random Forest Regression - R^2 score or MSE for Comparison
There is no real difference in discrimination between the mean squared error and the R-squared, when it is used on a test dataset as the R-Squared is just the MSE divided by the MSE of the prediction
Random Forest Regression - R^2 score or MSE for Comparison There is no real difference in discrimination between the mean squared error and the R-squared, when it is used on a test dataset as the R-Squared is just the MSE divided by the MSE of the prediction of the mean, which is a constant. So MSE and R-Squared are proportional to each other and the ranking will never be different between these two measures. This is not the case if the measures are averaged across different test dataset, as then the denominators of the R-Squared between the test sets are different. In this case, e.g. in 5-fold cross-validation, I would rather use the MSE. On the other hand, if the test datasets are not commensurable I would rather use the R-Squared, because it is rather comparable between inherently different datasets. I would also look at ranking measures like Spearman rho and Kendalls tau, as they are more robust against outliers than MSE and R-squared. Or at the median absolute error, or the median squared error.
Random Forest Regression - R^2 score or MSE for Comparison There is no real difference in discrimination between the mean squared error and the R-squared, when it is used on a test dataset as the R-Squared is just the MSE divided by the MSE of the prediction
42,296
Random Forest Regression - R^2 score or MSE for Comparison
The r2_score is a statistical description of how your samples fit along a linear model. It only works well if there is a linear relationship between features and outcome (with few outliers). Instead you should calculate the mean-absolute-error or mean-squared-error using labeled samples from the testset, that your model did not see during training.
Random Forest Regression - R^2 score or MSE for Comparison
The r2_score is a statistical description of how your samples fit along a linear model. It only works well if there is a linear relationship between features and outcome (with few outliers). Instead
Random Forest Regression - R^2 score or MSE for Comparison The r2_score is a statistical description of how your samples fit along a linear model. It only works well if there is a linear relationship between features and outcome (with few outliers). Instead you should calculate the mean-absolute-error or mean-squared-error using labeled samples from the testset, that your model did not see during training.
Random Forest Regression - R^2 score or MSE for Comparison The r2_score is a statistical description of how your samples fit along a linear model. It only works well if there is a linear relationship between features and outcome (with few outliers). Instead
42,297
Correlation between an observation and its rank in a random sample
I will give a hint. The key concept is exchangeability, meaning that the random vector $(X_1, \dotsc, X_n)$ has the same distribution as $(X_{\pi 1}, \dotsc, X_{\pi n})$ for all permutations $\pi$ of $(1,2,\dotsc, n)$. Then you can check that the vector of ranks $(R_1, \dotsc, R_n)$ also will be exchangeable. Exchangeability is a generalization of iid, so will generalize your eventual result. We need something more: even the distribution of the $n$ pairs $$ \left( (\begin{smallmatrix} X_1\\R_1\end{smallmatrix}), \dotsc, (\begin{smallmatrix} X_n\\R_n\end{smallmatrix}) \right) $$ is exchangeable. (Then of course we need to assume first exist). Now calculate: (for some $j$ between 1 and $n$) \begin{align} \DeclareMathOperator{\E}{\mathbb{E}} & \sum_\pi \E X_{\pi j} R_{\pi j} \\ = {} & \E \sum_\pi X_{\pi j} R_{\pi j} \\ = {} & \E \sum_{r=1}^n \sum_{\pi\colon R_{\pi j=r}} X_{\pi j} R_{\pi j} \\ = {} & (n-1)! \sum_{r=1}^n \E X_{\pi j} r \\ = {} & (n-1)! \mu \frac{n (n+1)}{2} \end{align} where $\mu$ is the common expectation of the $X_i$. You should be able to conclude.
Correlation between an observation and its rank in a random sample
I will give a hint. The key concept is exchangeability, meaning that the random vector $(X_1, \dotsc, X_n)$ has the same distribution as $(X_{\pi 1}, \dotsc, X_{\pi n})$ for all permutations $\pi$ of
Correlation between an observation and its rank in a random sample I will give a hint. The key concept is exchangeability, meaning that the random vector $(X_1, \dotsc, X_n)$ has the same distribution as $(X_{\pi 1}, \dotsc, X_{\pi n})$ for all permutations $\pi$ of $(1,2,\dotsc, n)$. Then you can check that the vector of ranks $(R_1, \dotsc, R_n)$ also will be exchangeable. Exchangeability is a generalization of iid, so will generalize your eventual result. We need something more: even the distribution of the $n$ pairs $$ \left( (\begin{smallmatrix} X_1\\R_1\end{smallmatrix}), \dotsc, (\begin{smallmatrix} X_n\\R_n\end{smallmatrix}) \right) $$ is exchangeable. (Then of course we need to assume first exist). Now calculate: (for some $j$ between 1 and $n$) \begin{align} \DeclareMathOperator{\E}{\mathbb{E}} & \sum_\pi \E X_{\pi j} R_{\pi j} \\ = {} & \E \sum_\pi X_{\pi j} R_{\pi j} \\ = {} & \E \sum_{r=1}^n \sum_{\pi\colon R_{\pi j=r}} X_{\pi j} R_{\pi j} \\ = {} & (n-1)! \sum_{r=1}^n \E X_{\pi j} r \\ = {} & (n-1)! \mu \frac{n (n+1)}{2} \end{align} where $\mu$ is the common expectation of the $X_i$. You should be able to conclude.
Correlation between an observation and its rank in a random sample I will give a hint. The key concept is exchangeability, meaning that the random vector $(X_1, \dotsc, X_n)$ has the same distribution as $(X_{\pi 1}, \dotsc, X_{\pi n})$ for all permutations $\pi$ of
42,298
Correlation between an observation and its rank in a random sample
We can find $\operatorname E\left[R_1X_1\right]$ using the conditional distribution of $X_1$ given $R_1$. The distribution of $X_1$ conditioned on $R_1=j$ is simply the distribution of $X_{(j)}$, since $R_1=j \implies X_1=X_{(j)}$ by definition for every $j=1,\ldots,n$. Hence, \begin{align} \operatorname E\left[R_1X_1\right]&=\sum_{j=1}^n \operatorname E\left[R_1X_1\mid R_1=j\right]\Pr(R_1=j) \\&=\frac1n\sum_{j=1}^n j\operatorname E\left[X_1\mid R_1=j\right] \\&=\frac1n\sum_{j=1}^n j\operatorname E\left[X_{(j)}\right] \end{align} Now $R_1$ has a uniform distribution on $\{1,2,\ldots,n\}$ with mean $\frac{n+1}2$ and variance $\frac{n^2-1}{12}$. So if $\sigma^2$ is the variance of $X_1$, then $$\operatorname{Corr}(X_1,R_1)=\left(\frac{12}{n^2-1}\right)^{1/2}\frac{\sum_{j=1}^n j\operatorname E\left[X_{(j)}\right]- (n(n+1)/2)\operatorname E[X_1]}{n\sigma}$$ Nonparametric Statistical Inference (5th ed.) by Gibbons and Chakraborti discusses this result on pages 191-192: The authors subsequently give an alternative expression for the correlation by deriving $$\sum_{j=1}^n j\operatorname E\left[X_{(j)}\right]=n(n-1)\operatorname E\left[X_1F(X_1)\right]+n\operatorname E[X_1]\,,$$ where $F$ is the common cdf of the $X_j$'s. And finally, $$\boxed{\operatorname{Corr}(X_1,R_1)=\left(\frac{12(n-1)}{n+1}\right)^{1/2}\frac1{\sigma}\left[\operatorname E\left[X_1F(X_1)\right]-\frac12 \operatorname E[X_1]\right]}$$
Correlation between an observation and its rank in a random sample
We can find $\operatorname E\left[R_1X_1\right]$ using the conditional distribution of $X_1$ given $R_1$. The distribution of $X_1$ conditioned on $R_1=j$ is simply the distribution of $X_{(j)}$, sinc
Correlation between an observation and its rank in a random sample We can find $\operatorname E\left[R_1X_1\right]$ using the conditional distribution of $X_1$ given $R_1$. The distribution of $X_1$ conditioned on $R_1=j$ is simply the distribution of $X_{(j)}$, since $R_1=j \implies X_1=X_{(j)}$ by definition for every $j=1,\ldots,n$. Hence, \begin{align} \operatorname E\left[R_1X_1\right]&=\sum_{j=1}^n \operatorname E\left[R_1X_1\mid R_1=j\right]\Pr(R_1=j) \\&=\frac1n\sum_{j=1}^n j\operatorname E\left[X_1\mid R_1=j\right] \\&=\frac1n\sum_{j=1}^n j\operatorname E\left[X_{(j)}\right] \end{align} Now $R_1$ has a uniform distribution on $\{1,2,\ldots,n\}$ with mean $\frac{n+1}2$ and variance $\frac{n^2-1}{12}$. So if $\sigma^2$ is the variance of $X_1$, then $$\operatorname{Corr}(X_1,R_1)=\left(\frac{12}{n^2-1}\right)^{1/2}\frac{\sum_{j=1}^n j\operatorname E\left[X_{(j)}\right]- (n(n+1)/2)\operatorname E[X_1]}{n\sigma}$$ Nonparametric Statistical Inference (5th ed.) by Gibbons and Chakraborti discusses this result on pages 191-192: The authors subsequently give an alternative expression for the correlation by deriving $$\sum_{j=1}^n j\operatorname E\left[X_{(j)}\right]=n(n-1)\operatorname E\left[X_1F(X_1)\right]+n\operatorname E[X_1]\,,$$ where $F$ is the common cdf of the $X_j$'s. And finally, $$\boxed{\operatorname{Corr}(X_1,R_1)=\left(\frac{12(n-1)}{n+1}\right)^{1/2}\frac1{\sigma}\left[\operatorname E\left[X_1F(X_1)\right]-\frac12 \operatorname E[X_1]\right]}$$
Correlation between an observation and its rank in a random sample We can find $\operatorname E\left[R_1X_1\right]$ using the conditional distribution of $X_1$ given $R_1$. The distribution of $X_1$ conditioned on $R_1=j$ is simply the distribution of $X_{(j)}$, sinc
42,299
How to Bayesian update on two events which occur with measure zero?
The paradox is one of measure theory and conditioning rather than one of Bayesian inference (and thus you should modify the title of the question). To quote Andrei Kolmogorov, "The concept of a conditional probability with regard to an isolated hypothesis whose probability equals 0 is inadmissible." When one defines the density $f$ of the random variable $X$, it can indeed be anything including the null function on any set $A\subset(-1,1)$ of measure zero. However, it seems to me that the easiest explanation is that one cannot choose the set $A$ a posteriori, that is once $X$ or $|X|$ is observed to be $x$, so that $x\in A$. Meaning that the actual observation $x$ (or more precisely the actual realisation $x$ of the random variable $X$) has probability zero to belong to $A$. When setting $$\mathbb{P}[X=0.5 \, |\, |X|=0.5]=\frac{\mathbb{P}[|X|=0.5 \,|\, X=0.5] \, f(0.5)}{f(0.5)+f(-0.5)}=\frac{ f(0.5)}{f(0.5)+f(-0.5)}$$ (a) the first equality is an incorrect application of Bayes' formula for sets, since the sets are of measure zero and (b) conditioning on the set of measure zero $\{\omega;|X(\omega)|=0.5\}$ is to be understood, rather than as a conditional probability, as setting the value of the function$$\mathbb{E}[\mathbb{I}_{X=|X|}||X|=x]$$ at $x=0.5$, which is not uniquely defined since the only constraint is the definition of conditional expectations as $$\mathbb{P}[X=|X|]=\mathbb{E}\{\mathbb{E}[\mathbb{I}_{X=|X|}||X|]\}$$
How to Bayesian update on two events which occur with measure zero?
The paradox is one of measure theory and conditioning rather than one of Bayesian inference (and thus you should modify the title of the question). To quote Andrei Kolmogorov, "The concept of a condi
How to Bayesian update on two events which occur with measure zero? The paradox is one of measure theory and conditioning rather than one of Bayesian inference (and thus you should modify the title of the question). To quote Andrei Kolmogorov, "The concept of a conditional probability with regard to an isolated hypothesis whose probability equals 0 is inadmissible." When one defines the density $f$ of the random variable $X$, it can indeed be anything including the null function on any set $A\subset(-1,1)$ of measure zero. However, it seems to me that the easiest explanation is that one cannot choose the set $A$ a posteriori, that is once $X$ or $|X|$ is observed to be $x$, so that $x\in A$. Meaning that the actual observation $x$ (or more precisely the actual realisation $x$ of the random variable $X$) has probability zero to belong to $A$. When setting $$\mathbb{P}[X=0.5 \, |\, |X|=0.5]=\frac{\mathbb{P}[|X|=0.5 \,|\, X=0.5] \, f(0.5)}{f(0.5)+f(-0.5)}=\frac{ f(0.5)}{f(0.5)+f(-0.5)}$$ (a) the first equality is an incorrect application of Bayes' formula for sets, since the sets are of measure zero and (b) conditioning on the set of measure zero $\{\omega;|X(\omega)|=0.5\}$ is to be understood, rather than as a conditional probability, as setting the value of the function$$\mathbb{E}[\mathbb{I}_{X=|X|}||X|=x]$$ at $x=0.5$, which is not uniquely defined since the only constraint is the definition of conditional expectations as $$\mathbb{P}[X=|X|]=\mathbb{E}\{\mathbb{E}[\mathbb{I}_{X=|X|}||X|]\}$$
How to Bayesian update on two events which occur with measure zero? The paradox is one of measure theory and conditioning rather than one of Bayesian inference (and thus you should modify the title of the question). To quote Andrei Kolmogorov, "The concept of a condi
42,300
When do we use an even size kernel in convolutional neural network and why?
To the best of my knowledge, there is no consistent answer to the first question. It's like asking "is it better to use (3,3) kernel size or (5,5) kernel size?". As far as I know, the reason behind choosing either an even or odd kernel comes from trial and error in practical implementations and can vary from one case to the other. For the second question, it is not counter-intuitive, the following picture shows it in a nice way: Begin with aligning the even kernel (here (4,4)) to the upper left part of the input feature map do element-wise multiplication between kernel and input feature and then take the sum, sum leads to the upper left position of the output feature map slide the kernel to the right (by arbitrary stride) do element-wise multiplication between kernel and input feature and then take the sum, sum leads to the value of the second position in output feature map repeat this scenario
When do we use an even size kernel in convolutional neural network and why?
To the best of my knowledge, there is no consistent answer to the first question. It's like asking "is it better to use (3,3) kernel size or (5,5) kernel size?". As far as I know, the reason behind ch
When do we use an even size kernel in convolutional neural network and why? To the best of my knowledge, there is no consistent answer to the first question. It's like asking "is it better to use (3,3) kernel size or (5,5) kernel size?". As far as I know, the reason behind choosing either an even or odd kernel comes from trial and error in practical implementations and can vary from one case to the other. For the second question, it is not counter-intuitive, the following picture shows it in a nice way: Begin with aligning the even kernel (here (4,4)) to the upper left part of the input feature map do element-wise multiplication between kernel and input feature and then take the sum, sum leads to the upper left position of the output feature map slide the kernel to the right (by arbitrary stride) do element-wise multiplication between kernel and input feature and then take the sum, sum leads to the value of the second position in output feature map repeat this scenario
When do we use an even size kernel in convolutional neural network and why? To the best of my knowledge, there is no consistent answer to the first question. It's like asking "is it better to use (3,3) kernel size or (5,5) kernel size?". As far as I know, the reason behind ch